const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LeadSiteHome-C0VWathR.js","assets/SearchAutocomplete-Ck3BOrgS.js","assets/CityPagesModule-avEZckoK.js","assets/imageOptimization-rphVJGSj.js","assets/LeadSiteLuxuryHome-Bd5v9Pba.js","assets/LeadSiteLandRanchHome-Bde4g3d5.js","assets/LeadSiteSearch-BKCm_uay.js","assets/SaveSearchButton-CknOMAzZ.js","assets/LeadSiteMap-Cew4srgs.js","assets/LeadSiteLuxurySearch-CCJuwrqP.js","assets/LeadSiteListingDetail-C4oQriBS.js","assets/ListingVideoTour-DgmnyMTl.js","assets/useListingVideos-D72rj6G9.js","assets/LeadSiteLuxuryListingDetail-CiPcqG2h.js","assets/LeadSiteCityPage-BK9xXwki.js","assets/PostcardManager-BNv4wQwN.js","assets/usePostcardZones-CQcDeixY.js","assets/DirectMail-DQVNdRZL.js","assets/jspdf.es.min-DUm09Sip.js","assets/LeadSiteEditor-lDqA65NA.js","assets/VideoUrlField-DTSIUHY3.js","assets/LeadSiteEditor-BzY4kI8E.css","assets/AdminLeadSiteThemes-Crc5wFHx.js","assets/MLSListingDetail-nDeNDdg1.js","assets/EmailCampaignComposer-C5bvFK8b.js","assets/EditorModeSelector-DT6rIoC9.js","assets/SharedCampaignTemplates-BJIh0UhF.js","assets/TemplateEditorDialog-CNjt8mng.js","assets/AgentTemplates-DpAX_5GW.js","assets/TheLocalMoveHome-TsZFqteb.js","assets/tlm-hero-bg-BbD3acLf.js","assets/TheLocalMoveGetStarted-acnGBlqC.js"])))=>i.map(i=>d[i]); var npt=Object.defineProperty;var jAe=t=>{throw TypeError(t)};var apt=(t,s,r)=>s in t?npt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var Cn=(t,s,r)=>apt(t,typeof s!="symbol"?s+"":s,r),gxe=(t,s,r)=>s.has(t)||jAe("Cannot "+r);var cs=(t,s,r)=>(gxe(t,s,"read from private field"),r?r.call(t):s.get(t)),Sa=(t,s,r)=>s.has(t)?jAe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),Dn=(t,s,r,n)=>(gxe(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Mi=(t,s,r)=>(gxe(t,s,"access private method"),r);var Y7=(t,s,r,n)=>({set _(a){Dn(t,s,a,r)},get _(){return cs(t,s,n)}});function ipt(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)}})();const opt="modulepreload",lpt=function(t){return"/"+t},NAe={},Ua=function(s,r,n){let a=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),i=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));a=Promise.allSettled(r.map(d=>{if(d=lpt(d),d in NAe)return;NAe[d]=!0;const u=d.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":opt,u||(f.as="script"),f.crossOrigin="",f.href=d,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 ${d}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return a.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return s().catch(o)})};var hd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ro(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function cpt(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 ABe={exports:{}},Lde={},EBe={exports:{}},Wi={};/** * @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 yR=Symbol.for("react.element"),dpt=Symbol.for("react.portal"),upt=Symbol.for("react.fragment"),hpt=Symbol.for("react.strict_mode"),mpt=Symbol.for("react.profiler"),ppt=Symbol.for("react.provider"),fpt=Symbol.for("react.context"),xpt=Symbol.for("react.forward_ref"),gpt=Symbol.for("react.suspense"),ypt=Symbol.for("react.memo"),vpt=Symbol.for("react.lazy"),kAe=Symbol.iterator;function _pt(t){return t===null||typeof t!="object"?null:(t=kAe&&t[kAe]||t["@@iterator"],typeof t=="function"?t:null)}var PBe={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},IBe=Object.assign,LBe={};function TA(t,s,r){this.props=t,this.context=s,this.refs=LBe,this.updater=r||PBe}TA.prototype.isReactComponent={};TA.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")};TA.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function DBe(){}DBe.prototype=TA.prototype;function c2e(t,s,r){this.props=t,this.context=s,this.refs=LBe,this.updater=r||PBe}var d2e=c2e.prototype=new DBe;d2e.constructor=c2e;IBe(d2e,TA.prototype);d2e.isPureReactComponent=!0;var SAe=Array.isArray,RBe=Object.prototype.hasOwnProperty,u2e={current:null},OBe={key:!0,ref:!0,__self:!0,__source:!0};function FBe(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)RBe.call(s,n)&&!OBe.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,we=le[he];if(0>>1;hea(Te,xe))Aea(ze,Te)?(le[he]=ze,le[Ae]=xe,he=Ae):(le[he]=Te,le[Ve]=xe,he=Ve);else if(Aea(ze,xe))le[he]=ze,le[Ae]=xe,he=Ae;else break e}}return fe}function a(le,fe){var xe=le.sortIndex-fe.sortIndex;return xe!==0?xe:le.id-fe.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,i=l.now();t.unstable_now=function(){return l.now()-i}}var d=[],u=[],p=1,f=null,y=3,_=!1,b=!1,N=!1,w=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(le){for(var fe=r(u);fe!==null;){if(fe.callback===null)n(u);else if(fe.startTime<=le)n(u),fe.sortIndex=fe.expirationTime,s(d,fe);else break;fe=r(u)}}function I(le){if(N=!1,A(le),!b)if(r(d)!==null)b=!0,ae(L);else{var fe=r(u);fe!==null&&ie(I,fe.startTime-le)}}function L(le,fe){b=!1,N&&(N=!1,S(q),q=-1),_=!0;var xe=y;try{for(A(fe),f=r(d);f!==null&&(!(f.expirationTime>fe)||le&&!ee());){var he=f.callback;if(typeof he=="function"){f.callback=null,y=f.priorityLevel;var we=he(f.expirationTime<=fe);fe=t.unstable_now(),typeof we=="function"?f.callback=we:f===r(d)&&n(d),A(fe)}else n(d);f=r(d)}if(f!==null)var Ne=!0;else{var Ve=r(u);Ve!==null&&ie(I,Ve.startTime-fe),Ne=!1}return Ne}finally{f=null,y=xe,_=!1}}var O=!1,U=null,q=-1,$=5,V=-1;function ee(){return!(t.unstable_now()-V<$)}function Z(){if(U!==null){var le=t.unstable_now();V=le;var fe=!0;try{fe=U(!0,le)}finally{fe?J():(O=!1,U=null)}}else O=!1}var J;if(typeof C=="function")J=function(){C(Z)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,ce=Y.port2;Y.port1.onmessage=Z,J=function(){ce.postMessage(null)}}else J=function(){w(Z,0)};function ae(le){U=le,O||(O=!0,J())}function ie(le,fe){q=w(function(){le(t.unstable_now())},fe)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(le){le.callback=null},t.unstable_continueExecution=function(){b||_||(b=!0,ae(L))},t.unstable_forceFrameRate=function(le){0>le||125he?(le.sortIndex=xe,s(u,le),r(d)===null&&le===r(u)&&(N?(S(q),q=-1):N=!0,ie(I,xe-he))):(le.sortIndex=we,s(d,le),b||_||(b=!0,ae(L))),le},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(le){var fe=y;return function(){var xe=y;y=fe;try{return le.apply(this,arguments)}finally{y=xe}}}})(UBe);qBe.exports=UBe;var Ept=qBe.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 Ppt=k,_f=Ept;function Hr(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"),P0e=Object.prototype.hasOwnProperty,Ipt=/^[: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]*$/,MAe={},TAe={};function Lpt(t){return P0e.call(TAe,t)?!0:P0e.call(MAe,t)?!1:Ipt.test(t)?TAe[t]=!0:(MAe[t]=!0,!1)}function Dpt(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 Rpt(t,s,r,n){if(s===null||typeof s>"u"||Dpt(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 Lm(t,s,r,n,a,o,l){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=n,this.attributeNamespace=a,this.mustUseProperty=r,this.propertyName=t,this.type=s,this.sanitizeURL=o,this.removeEmptyString=l}var ph={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){ph[t]=new Lm(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];ph[s]=new Lm(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){ph[t]=new Lm(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){ph[t]=new Lm(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){ph[t]=new Lm(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){ph[t]=new Lm(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){ph[t]=new Lm(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){ph[t]=new Lm(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){ph[t]=new Lm(t,5,!1,t.toLowerCase(),null,!1,!1)});var m2e=/[\-:]([a-z])/g;function p2e(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(m2e,p2e);ph[s]=new Lm(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(m2e,p2e);ph[s]=new Lm(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(m2e,p2e);ph[s]=new Lm(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){ph[t]=new Lm(t,1,!1,t.toLowerCase(),null,!1,!1)});ph.xlinkHref=new Lm("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){ph[t]=new Lm(t,1,!1,t.toLowerCase(),null,!0,!0)});function f2e(t,s,r,n){var a=ph.hasOwnProperty(s)?ph[s]:null;(a!==null?a.type!==0:n||!(2i||a[l]!==o[i]){var d=` `+a[l].replace(" at new "," at ");return t.displayName&&d.includes("")&&(d=d.replace("",t.displayName)),d}while(1<=l&&0<=i);break}}}finally{_xe=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?k6(t):""}function Opt(t){switch(t.tag){case 5:return k6(t.type);case 16:return k6("Lazy");case 13:return k6("Suspense");case 19:return k6("SuspenseList");case 0:case 2:case 15:return t=bxe(t.type,!1),t;case 11:return t=bxe(t.type.render,!1),t;case 1:return t=bxe(t.type,!0),t;default:return""}}function R0e(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 V5:return"Fragment";case U5:return"Portal";case I0e:return"Profiler";case x2e:return"StrictMode";case L0e:return"Suspense";case D0e:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case GBe:return(t.displayName||"Context")+".Consumer";case HBe:return(t._context.displayName||"Context")+".Provider";case g2e:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case y2e:return s=t.displayName||null,s!==null?s:R0e(t.type)||"Memo";case L_:s=t._payload,t=t._init;try{return R0e(t(s))}catch{}}return null}function Fpt(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 R0e(s);case 8:return s===x2e?"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 Zb(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function KBe(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function zpt(t){var s=KBe(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 J7(t){t._valueTracker||(t._valueTracker=zpt(t))}function ZBe(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=KBe(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function hoe(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 O0e(t,s){var r=s.checked;return $c({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function EAe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=Zb(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 YBe(t,s){s=s.checked,s!=null&&f2e(t,"checked",s,!1)}function F0e(t,s){YBe(t,s);var r=Zb(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")?z0e(t,s.type,r):s.hasOwnProperty("defaultValue")&&z0e(t,s.type,Zb(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function PAe(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 z0e(t,s,r){(s!=="number"||hoe(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var S6=Array.isArray;function pM(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=ez.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function P8(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var G6={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},Bpt=["Webkit","ms","Moz","O"];Object.keys(G6).forEach(function(t){Bpt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),G6[s]=G6[t]})});function e$e(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||G6.hasOwnProperty(t)&&G6[t]?(""+s).trim():s+"px"}function t$e(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=e$e(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var $pt=$c({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 q0e(t,s){if(s){if($pt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Hr(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Hr(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Hr(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Hr(62))}}function U0e(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 V0e=null;function v2e(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var H0e=null,fM=null,xM=null;function DAe(t){if(t=bR(t)){if(typeof H0e!="function")throw Error(Hr(280));var s=t.stateNode;s&&(s=Bde(s),H0e(t.stateNode,t.type,s))}}function s$e(t){fM?xM?xM.push(t):xM=[t]:fM=t}function r$e(){if(fM){var t=fM,s=xM;if(xM=fM=null,DAe(t),s)for(t=0;t>>=0,t===0?32:31-(Qpt(t)/Jpt|0)|0}var tz=64,sz=4194304;function C6(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 xoe(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=C6(i):(o&=l,o!==0&&(n=C6(o)))}else l=r&~a,l!==0?n=C6(l):o!==0&&(n=C6(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 vR(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Pg(s),t[s]=r}function rft(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=K6),VAe=" ",HAe=!1;function j$e(t,s){switch(t){case"keyup":return Eft.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function N$e(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var H5=!1;function Ift(t,s){switch(t){case"compositionend":return N$e(s);case"keypress":return s.which!==32?null:(HAe=!0,VAe);case"textInput":return t=s.data,t===VAe&&HAe?null:t;default:return null}}function Lft(t,s){if(H5)return t==="compositionend"||!C2e&&j$e(t,s)?(t=b$e(),z9=N2e=db=null,H5=!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=ZAe(r)}}function M$e(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?M$e(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function T$e(){for(var t=window,s=hoe();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=hoe(t.document)}return s}function M2e(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 Uft(t){var s=T$e(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&M$e(r.ownerDocument.documentElement,r)){if(n!==null&&M2e(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=YAe(r,o);var l=YAe(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,G5=null,X0e=null,Y6=null,Q0e=!1;function XAe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Q0e||G5==null||G5!==hoe(n)||(n=G5,"selectionStart"in n&&M2e(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}),Y6&&F8(Y6,n)||(Y6=n,n=voe(X0e,"onSelect"),0Z5||(t.current=nve[Z5],nve[Z5]=null,Z5--)}function Pl(t,s){Z5++,nve[Z5]=t.current,t.current=s}var Yb={},zh=uw(Yb),cp=uw(!1),BS=Yb;function bT(t,s){var r=t.type.contextTypes;if(!r)return Yb;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 dp(t){return t=t.childContextTypes,t!=null}function boe(){sc(cp),sc(zh)}function nEe(t,s,r){if(zh.current!==Yb)throw Error(Hr(168));Pl(zh,s),Pl(cp,r)}function F$e(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(Hr(108,Fpt(t)||"Unknown",a));return $c({},r,n)}function woe(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Yb,BS=zh.current,Pl(zh,t),Pl(cp,cp.current),!0}function aEe(t,s,r){var n=t.stateNode;if(!n)throw Error(Hr(169));r?(t=F$e(t,s,BS),n.__reactInternalMemoizedMergedChildContext=t,sc(cp),sc(zh),Pl(zh,t)):sc(cp),Pl(cp,r)}var kv=null,$de=!1,Dxe=!1;function z$e(t){kv===null?kv=[t]:kv.push(t)}function txt(t){$de=!0,z$e(t)}function hw(){if(!Dxe&&kv!==null){Dxe=!0;var t=0,s=Zo;try{var r=kv;for(Zo=1;t>=l,a-=l,Ov=1<<32-Pg(s)+a|r<q?($=U,U=null):$=U.sibling;var V=y(S,U,A[q],I);if(V===null){U===null&&(U=$);break}t&&U&&V.alternate===null&&s(S,U),C=o(V,C,q),O===null?L=V:O.sibling=V,O=V,U=$}if(q===A.length)return r(S,U),gc&&G2(S,q),L;if(U===null){for(;qq?($=U,U=null):$=U.sibling;var ee=y(S,U,V.value,I);if(ee===null){U===null&&(U=$);break}t&&U&&ee.alternate===null&&s(S,U),C=o(ee,C,q),O===null?L=ee:O.sibling=ee,O=ee,U=$}if(V.done)return r(S,U),gc&&G2(S,q),L;if(U===null){for(;!V.done;q++,V=A.next())V=f(S,V.value,I),V!==null&&(C=o(V,C,q),O===null?L=V:O.sibling=V,O=V);return gc&&G2(S,q),L}for(U=n(S,U);!V.done;q++,V=A.next())V=_(U,S,q,V.value,I),V!==null&&(t&&V.alternate!==null&&U.delete(V.key===null?q:V.key),C=o(V,C,q),O===null?L=V:O.sibling=V,O=V);return t&&U.forEach(function(Z){return s(S,Z)}),gc&&G2(S,q),L}function w(S,C,A,I){if(typeof A=="object"&&A!==null&&A.type===V5&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case Q7:e:{for(var L=A.key,O=C;O!==null;){if(O.key===L){if(L=A.type,L===V5){if(O.tag===7){r(S,O.sibling),C=a(O,A.props.children),C.return=S,S=C;break e}}else if(O.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===L_&&lEe(L)===O.type){r(S,O.sibling),C=a(O,A.props),C.ref=VI(S,O,A),C.return=S,S=C;break e}r(S,O);break}else s(S,O);O=O.sibling}A.type===V5?(C=H4(A.props.children,S.mode,I,A.key),C.return=S,S=C):(I=W9(A.type,A.key,A.props,null,S.mode,I),I.ref=VI(S,C,A),I.return=S,S=I)}return l(S);case U5:e:{for(O=A.key;C!==null;){if(C.key===O)if(C.tag===4&&C.stateNode.containerInfo===A.containerInfo&&C.stateNode.implementation===A.implementation){r(S,C.sibling),C=a(C,A.children||[]),C.return=S,S=C;break e}else{r(S,C);break}else s(S,C);C=C.sibling}C=Uxe(A,S.mode,I),C.return=S,S=C}return l(S);case L_:return O=A._init,w(S,C,O(A._payload),I)}if(S6(A))return b(S,C,A,I);if(zI(A))return N(S,C,A,I);cz(S,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,C!==null&&C.tag===6?(r(S,C.sibling),C=a(C,A),C.return=S,S=C):(r(S,C),C=qxe(A,S.mode,I),C.return=S,S=C),l(S)):r(S,C)}return w}var jT=U$e(!0),V$e=U$e(!1),koe=uw(null),Soe=null,Q5=null,P2e=null;function I2e(){P2e=Q5=Soe=null}function L2e(t){var s=koe.current;sc(koe),t._currentValue=s}function ove(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 yM(t,s){Soe=t,P2e=Q5=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(np=!0),t.firstContext=null)}function Mx(t){var s=t._currentValue;if(P2e!==t)if(t={context:t,memoizedValue:s,next:null},Q5===null){if(Soe===null)throw Error(Hr(308));Q5=t,Soe.dependencies={lanes:0,firstContext:t}}else Q5=Q5.next=t;return s}var f4=null;function D2e(t){f4===null?f4=[t]:f4.push(t)}function H$e(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,D2e(s)):(r.next=a.next,a.next=r),s.interleaved=r,u1(t,n)}function u1(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 D_=!1;function R2e(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function G$e(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 Hv(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function jb(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,xo&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,u1(t,r)}return a=n.interleaved,a===null?(s.next=s,D2e(n)):(s.next=a.next,a.next=s),n.interleaved=s,u1(t,r)}function $9(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,b2e(t,r)}}function cEe(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 Coe(t,s,r,n){var a=t.updateQueue;D_=!1;var o=a.firstBaseUpdate,l=a.lastBaseUpdate,i=a.shared.pending;if(i!==null){a.shared.pending=null;var d=i,u=d.next;d.next=null,l===null?o=u:l.next=u,l=d;var p=t.alternate;p!==null&&(p=p.updateQueue,i=p.lastBaseUpdate,i!==l&&(i===null?p.firstBaseUpdate=u:i.next=u,p.lastBaseUpdate=d))}if(o!==null){var f=a.baseState;l=0,p=u=d=null,i=o;do{var 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,N=i;switch(y=s,_=r,N.tag){case 1:if(b=N.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=N.payload,y=typeof b=="function"?b.call(_,f,y):b,y==null)break e;f=$c({},f,y);break e;case 2:D_=!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=_,d=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&&(d=f),a.baseState=d,a.firstBaseUpdate=u,a.lastBaseUpdate=p,s=a.shared.interleaved,s!==null){a=s;do l|=a.lane,a=a.next;while(a!==s)}else o===null&&(a.shared.lanes=0);US|=l,t.lanes=l,t.memoizedState=f}}function dEe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=Oxe.transition;Oxe.transition={};try{t(!1),s()}finally{Zo=r,Oxe.transition=n}}function cqe(){return Tx().memoizedState}function axt(t,s,r){var n=kb(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},dqe(t))uqe(s,r);else if(r=H$e(t,s,r,n),r!==null){var a=jm();Ig(r,t,n,a),hqe(r,s,n)}}function ixt(t,s,r){var n=kb(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(dqe(t))uqe(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,$g(i,l)){var d=s.interleaved;d===null?(a.next=a,D2e(s)):(a.next=d.next,d.next=a),s.interleaved=a;return}}catch{}finally{}r=H$e(t,s,a,n),r!==null&&(a=jm(),Ig(r,t,n,a),hqe(r,s,n))}}function dqe(t){var s=t.alternate;return t===zc||s!==null&&s===zc}function uqe(t,s){X6=Toe=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function hqe(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,b2e(t,r)}}var Aoe={readContext:Mx,useCallback:wh,useContext:wh,useEffect:wh,useImperativeHandle:wh,useInsertionEffect:wh,useLayoutEffect:wh,useMemo:wh,useReducer:wh,useRef:wh,useState:wh,useDebugValue:wh,useDeferredValue:wh,useTransition:wh,useMutableSource:wh,useSyncExternalStore:wh,useId:wh,unstable_isNewReconciler:!1},oxt={readContext:Mx,useCallback:function(t,s){return Cy().memoizedState=[t,s===void 0?null:s],t},useContext:Mx,useEffect:hEe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,U9(4194308,4,nqe.bind(null,s,t),r)},useLayoutEffect:function(t,s){return U9(4194308,4,t,s)},useInsertionEffect:function(t,s){return U9(4,2,t,s)},useMemo:function(t,s){var r=Cy();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=Cy();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=axt.bind(null,zc,t),[n.memoizedState,t]},useRef:function(t){var s=Cy();return t={current:t},s.memoizedState=t},useState:uEe,useDebugValue:V2e,useDeferredValue:function(t){return Cy().memoizedState=t},useTransition:function(){var t=uEe(!1),s=t[0];return t=nxt.bind(null,t[1]),Cy().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=zc,a=Cy();if(gc){if(r===void 0)throw Error(Hr(407));r=r()}else{if(r=s(),Du===null)throw Error(Hr(349));qS&30||Y$e(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,hEe(Q$e.bind(null,n,o,t),[t]),n.flags|=2048,G8(9,X$e.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=Cy(),s=Du.identifierPrefix;if(gc){var r=Fv,n=Ov;r=(n&~(1<<32-Pg(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=V8++,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[Fy]=s,t[$8]=n,wqe(t,s,!1,!1),s.stateNode=t;e:{switch(l=U0e(r,n),r){case"dialog":Wl("cancel",t),Wl("close",t),a=n;break;case"iframe":case"object":case"embed":Wl("load",t),a=n;break;case"video":case"audio":for(a=0;aST&&(s.flags|=128,n=!0,HI(o,!1),s.lanes=4194304)}else{if(!n)if(t=Moe(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),HI(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!gc)return jh(s),null}else 2*ud()-o.renderingStartTime>ST&&r!==1073741824&&(s.flags|=128,n=!0,HI(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=ud(),s.sibling=null,r=Dc.current,Pl(Dc,n?r&1|2:r&1),s):(jh(s),null);case 22:case 23:return Y2e(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?Wp&1073741824&&(jh(s),s.subtreeFlags&6&&(s.flags|=8192)):jh(s),null;case 24:return null;case 25:return null}throw Error(Hr(156,s.tag))}function fxt(t,s){switch(A2e(s),s.tag){case 1:return dp(s.type)&&boe(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return NT(),sc(cp),sc(zh),z2e(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return F2e(s),null;case 13:if(sc(Dc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Hr(340));wT()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return sc(Dc),null;case 4:return NT(),null;case 10:return L2e(s.type._context),null;case 22:case 23:return Y2e(),null;case 24:return null;default:return null}}var uz=!1,Th=!1,xxt=typeof WeakSet=="function"?WeakSet:Set,Yn=null;function J5(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){Kc(t,s,n)}else r.current=null}function xve(t,s,r){try{r()}catch(n){Kc(t,s,n)}}var jEe=!1;function gxt(t,s){if(J0e=goe,t=T$e(),M2e(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var a=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break e}var l=0,i=-1,d=-1,u=0,p=0,f=t,y=null;t:for(;;){for(var _;f!==r||a!==0&&f.nodeType!==3||(i=l+a),f!==o||n!==0&&f.nodeType!==3||(d=l+n),f.nodeType===3&&(l+=f.nodeValue.length),(_=f.firstChild)!==null;)y=f,f=_;for(;;){if(f===t)break t;if(y===r&&++u===a&&(i=l),y===o&&++p===n&&(d=l),(_=f.nextSibling)!==null)break;f=y,y=f.parentNode}f=_}r=i===-1||d===-1?null:{start:i,end:d}}else r=null}r=r||{start:0,end:0}}else r=null;for(eve={focusedElem:t,selectionRange:r},goe=!1,Yn=s;Yn!==null;)if(s=Yn,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,Yn=t;else for(;Yn!==null;){s=Yn;try{var b=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(b!==null){var N=b.memoizedProps,w=b.memoizedState,S=s.stateNode,C=S.getSnapshotBeforeUpdate(s.elementType===s.type?N:yg(s.type,N),w);S.__reactInternalSnapshotBeforeUpdate=C}break;case 3:var A=s.stateNode.containerInfo;A.nodeType===1?A.textContent="":A.nodeType===9&&A.documentElement&&A.removeChild(A.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Hr(163))}}catch(I){Kc(s,s.return,I)}if(t=s.sibling,t!==null){t.return=s.return,Yn=t;break}Yn=s.return}return b=jEe,jEe=!1,b}function Q6(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&&xve(s,r,o)}a=a.next}while(a!==n)}}function Vde(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 gve(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 kqe(t){var s=t.alternate;s!==null&&(t.alternate=null,kqe(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[Fy],delete s[$8],delete s[rve],delete s[Jft],delete s[ext])),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 Sqe(t){return t.tag===5||t.tag===3||t.tag===4}function NEe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Sqe(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 yve(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=_oe));else if(n!==4&&(t=t.child,t!==null))for(yve(t,s,r),t=t.sibling;t!==null;)yve(t,s,r),t=t.sibling}function vve(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(vve(t,s,r),t=t.sibling;t!==null;)vve(t,s,r),t=t.sibling}var Xu=null,_g=!1;function g_(t,s,r){for(r=r.child;r!==null;)Cqe(t,s,r),r=r.sibling}function Cqe(t,s,r){if(Gy&&typeof Gy.onCommitFiberUnmount=="function")try{Gy.onCommitFiberUnmount(Rde,r)}catch{}switch(r.tag){case 5:Th||J5(r,s);case 6:var n=Xu,a=_g;Xu=null,g_(t,s,r),Xu=n,_g=a,Xu!==null&&(_g?(t=Xu,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Xu.removeChild(r.stateNode));break;case 18:Xu!==null&&(_g?(t=Xu,r=r.stateNode,t.nodeType===8?Lxe(t.parentNode,r):t.nodeType===1&&Lxe(t,r),R8(t)):Lxe(Xu,r.stateNode));break;case 4:n=Xu,a=_g,Xu=r.stateNode.containerInfo,_g=!0,g_(t,s,r),Xu=n,_g=a;break;case 0:case 11:case 14:case 15:if(!Th&&(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)&&xve(r,s,l),a=a.next}while(a!==n)}g_(t,s,r);break;case 1:if(!Th&&(J5(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){Kc(r,s,i)}g_(t,s,r);break;case 21:g_(t,s,r);break;case 22:r.mode&1?(Th=(n=Th)||r.memoizedState!==null,g_(t,s,r),Th=n):g_(t,s,r);break;default:g_(t,s,r)}}function kEe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new xxt),s.forEach(function(n){var a=Sxt.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function dg(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=ud()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*vxt(n/1960))-n,10t?16:t,ub===null)var n=!1;else{if(t=ub,ub=null,Ioe=0,xo&6)throw Error(Hr(331));var a=xo;for(xo|=4,Yn=t.current;Yn!==null;){var o=Yn,l=o.child;if(Yn.flags&16){var i=o.deletions;if(i!==null){for(var d=0;dud()-K2e?V4(t,0):W2e|=r),up(t,s)}function Dqe(t,s){s===0&&(t.mode&1?(s=sz,sz<<=1,!(sz&130023424)&&(sz=4194304)):s=1);var r=jm();t=u1(t,s),t!==null&&(vR(t,s,r),up(t,r))}function kxt(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),Dqe(t,r)}function Sxt(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(Hr(314))}n!==null&&n.delete(s),Dqe(t,r)}var Rqe;Rqe=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||cp.current)np=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return np=!1,mxt(t,s,r);np=!!(t.flags&131072)}else np=!1,gc&&s.flags&1048576&&B$e(s,Noe,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;V9(t,s),t=s.pendingProps;var a=bT(s,zh.current);yM(s,r),a=$2e(null,s,n,t,a,r);var o=q2e();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,dp(n)?(o=!0,woe(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,R2e(s),a.updater=Ude,s.stateNode=a,a._reactInternals=s,cve(s,n,t,r),s=hve(null,s,n,!0,o,r)):(s.tag=0,gc&&o&&T2e(s),um(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(V9(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=Mxt(n),t=yg(n,t),a){case 0:s=uve(null,s,n,t,r);break e;case 1:s=_Ee(null,s,n,t,r);break e;case 11:s=yEe(null,s,n,t,r);break e;case 14:s=vEe(null,s,n,yg(n.type,t),r);break e}throw Error(Hr(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:yg(n,a),uve(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:yg(n,a),_Ee(t,s,n,a,r);case 3:e:{if(vqe(s),t===null)throw Error(Hr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,G$e(t,s),Coe(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=kT(Error(Hr(423)),s),s=bEe(t,s,n,r,a);break e}else if(n!==a){a=kT(Error(Hr(424)),s),s=bEe(t,s,n,r,a);break e}else for(rf=wb(s.stateNode.containerInfo.firstChild),af=s,gc=!0,kg=null,r=V$e(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(wT(),n===a){s=h1(t,s,r);break e}um(t,s,n,r)}s=s.child}return s;case 5:return W$e(s),t===null&&ive(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,tve(n,a)?l=null:o!==null&&tve(n,o)&&(s.flags|=32),yqe(t,s),um(t,s,l,r),s.child;case 6:return t===null&&ive(s),null;case 13:return _qe(t,s,r);case 4:return O2e(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=jT(s,null,n,r):um(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:yg(n,a),yEe(t,s,n,a,r);case 7:return um(t,s,s.pendingProps,r),s.child;case 8:return um(t,s,s.pendingProps.children,r),s.child;case 12:return um(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,Pl(koe,n._currentValue),n._currentValue=l,o!==null)if($g(o.value,l)){if(o.children===a.children&&!cp.current){s=h1(t,s,r);break e}}else for(o=s.child,o!==null&&(o.return=s);o!==null;){var i=o.dependencies;if(i!==null){l=o.child;for(var d=i.firstContext;d!==null;){if(d.context===n){if(o.tag===1){d=Hv(-1,r&-r),d.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?d.next=d:(d.next=p.next,p.next=d),u.pending=d}}o.lanes|=r,d=o.alternate,d!==null&&(d.lanes|=r),ove(o.return,r,s),i.lanes|=r;break}d=d.next}}else if(o.tag===10)l=o.type===s.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(Hr(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),ove(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}um(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,yM(s,r),a=Mx(a),n=n(a),s.flags|=1,um(t,s,n,r),s.child;case 14:return n=s.type,a=yg(n,s.pendingProps),a=yg(n.type,a),vEe(t,s,n,a,r);case 15:return xqe(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:yg(n,a),V9(t,s),s.tag=1,dp(n)?(t=!0,woe(s)):t=!1,yM(s,r),mqe(s,n,a),cve(s,n,a,r),hve(null,s,n,!0,t,r);case 19:return bqe(t,s,r);case 22:return gqe(t,s,r)}throw Error(Hr(156,s.tag))};function Oqe(t,s){return d$e(t,s)}function Cxt(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 fx(t,s,r,n){return new Cxt(t,s,r,n)}function Q2e(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Mxt(t){if(typeof t=="function")return Q2e(t)?1:0;if(t!=null){if(t=t.$$typeof,t===g2e)return 11;if(t===y2e)return 14}return 2}function Sb(t,s){var r=t.alternate;return r===null?(r=fx(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 W9(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")Q2e(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case V5:return H4(r.children,a,o,s);case x2e:l=8,a|=8;break;case I0e:return t=fx(12,r,s,a|2),t.elementType=I0e,t.lanes=o,t;case L0e:return t=fx(13,r,s,a),t.elementType=L0e,t.lanes=o,t;case D0e:return t=fx(19,r,s,a),t.elementType=D0e,t.lanes=o,t;case WBe:return Gde(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case HBe:l=10;break e;case GBe:l=9;break e;case g2e:l=11;break e;case y2e:l=14;break e;case L_:l=16,n=null;break e}throw Error(Hr(130,t==null?t:typeof t,""))}return s=fx(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function H4(t,s,r,n){return t=fx(7,t,n,s),t.lanes=r,t}function Gde(t,s,r,n){return t=fx(22,t,n,s),t.elementType=WBe,t.lanes=r,t.stateNode={isHidden:!1},t}function qxe(t,s,r){return t=fx(6,t,null,s),t.lanes=r,t}function Uxe(t,s,r){return s=fx(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function Txt(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=jxe(0),this.expirationTimes=jxe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=jxe(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function J2e(t,s,r,n,a,o,l,i,d){return t=new Txt(t,s,r,i,d),s===1?(s=1,o===!0&&(s|=8)):s=0,o=fx(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},R2e(o),t}function Axt(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE($qe)}catch(t){console.error(t)}}$qe(),$Be.exports=Sf;var ap=$Be.exports;const rje=ro(ap);var qqe,IEe=ap;qqe=IEe.createRoot,IEe.hydrateRoot;const Dxt=1,Rxt=1e6;let Vxe=0;function Oxt(){return Vxe=(Vxe+1)%Number.MAX_SAFE_INTEGER,Vxe.toString()}const Hxe=new Map,LEe=t=>{if(Hxe.has(t))return;const s=setTimeout(()=>{Hxe.delete(t),tL({type:"REMOVE_TOAST",toastId:t})},Rxt);Hxe.set(t,s)},Fxt=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,Dxt)};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?LEe(r):t.toasts.forEach(n=>{LEe(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)}}},K9=[];let Z9={toasts:[]};function tL(t){Z9=Fxt(Z9,t),K9.forEach(s=>{s(Z9)})}function cn({...t}){const s=Oxt(),r=a=>tL({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>tL({type:"DISMISS_TOAST",toastId:s});return tL({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function va(){const[t,s]=k.useState(Z9);return k.useEffect(()=>(K9.push(s),()=>{const r=K9.indexOf(s);r>-1&&K9.splice(r,1)}),[t]),{...t,toast:cn,dismiss:r=>tL({type:"DISMISS_TOAST",toastId:r})}}function Tr(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 DEe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function Mm(...t){return s=>{let r=!1;const n=t.map(a=>{const o=DEe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,d=k.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:d,children:l})};n.displayName=t+"Provider";function a(o){const l=k.useContext(r);if(l)return l;if(s!==void 0)return s;throw new Error(`\`${o}\` must be used within \`${t}\``)}return[n,a]}function bd(t,s=[]){let r=[];function n(o,l){const i=k.createContext(l),d=r.length;r=[...r,l];const u=f=>{var S;const{scope:y,children:_,...b}=f,N=((S=y==null?void 0:y[t])==null?void 0:S[d])||i,w=k.useMemo(()=>b,Object.values(b));return e.jsx(N.Provider,{value:w,children:_})};u.displayName=o+"Provider";function p(f,y){var N;const _=((N=y==null?void 0:y[t])==null?void 0:N[d])||i,b=k.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=>k.createContext(l));return function(i){const d=(i==null?void 0:i[t])||o;return k.useMemo(()=>({[`__scope${t}`]:{...i,[t]:d}}),[i,d])}};return a.scopeName=t,[n,Bxt(a,...s)]}function Bxt(...t){const s=t[0];if(t.length===1)return s;const r=()=>{const n=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const l=n.reduce((i,{useScope:d,scopeName:u})=>{const f=d(o)[`__scope${u}`];return{...i,...f}},{});return k.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function REe(t){const s=$xt(t),r=k.forwardRef((n,a)=>{const{children:o,...l}=n,i=k.Children.toArray(o),d=i.find(Uxt);if(d){const u=d.props.children,p=i.map(f=>f===d?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:k.isValidElement(u)?k.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}function $xt(t){const s=k.forwardRef((r,n)=>{const{children:a,...o}=r;if(k.isValidElement(a)){const l=Hxt(a),i=Vxt(o,a.props);return a.type!==k.Fragment&&(i.ref=n?Mm(n,l):l),k.cloneElement(a,i)}return k.Children.count(a)>1?k.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var qxt=Symbol("radix.slottable");function Uxt(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===qxt}function Vxt(t,s){const r={...s};for(const n in s){const a=t[n],o=s[n];/^on[A-Z]/.test(n)?a&&o?r[n]=(...i)=>{const d=o(...i);return a(...i),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function Hxt(t){var n,a;let s=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}function jR(t){const s=t+"CollectionProvider",[r,n]=bd(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=N=>{const{scope:w,children:S}=N,C=ht.useRef(null),A=ht.useRef(new Map).current;return e.jsx(a,{scope:w,itemMap:A,collectionRef:C,children:S})};l.displayName=s;const i=t+"CollectionSlot",d=REe(i),u=ht.forwardRef((N,w)=>{const{scope:S,children:C}=N,A=o(i,S),I=Ma(w,A.collectionRef);return e.jsx(d,{ref:I,children:C})});u.displayName=i;const p=t+"CollectionItemSlot",f="data-radix-collection-item",y=REe(p),_=ht.forwardRef((N,w)=>{const{scope:S,children:C,...A}=N,I=ht.useRef(null),L=Ma(w,I),O=o(p,S);return ht.useEffect(()=>(O.itemMap.set(I,{ref:I,...A}),()=>void O.itemMap.delete(I))),e.jsx(y,{[f]:"",ref:L,children:C})});_.displayName=p;function b(N){const w=o(t+"CollectionConsumer",N);return ht.useCallback(()=>{const C=w.collectionRef.current;if(!C)return[];const A=Array.from(C.querySelectorAll(`[${f}]`));return Array.from(w.itemMap.values()).sort((O,U)=>A.indexOf(O.ref.current)-A.indexOf(U.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:l,Slot:u,ItemSlot:_},b,n]}function Gxt(t){const s=Wxt(t),r=k.forwardRef((n,a)=>{const{children:o,...l}=n,i=k.Children.toArray(o),d=i.find(Zxt);if(d){const u=d.props.children,p=i.map(f=>f===d?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:k.isValidElement(u)?k.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}function Wxt(t){const s=k.forwardRef((r,n)=>{const{children:a,...o}=r;if(k.isValidElement(a)){const l=Xxt(a),i=Yxt(o,a.props);return a.type!==k.Fragment&&(i.ref=n?Mm(n,l):l),k.cloneElement(a,i)}return k.Children.count(a)>1?k.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var Kxt=Symbol("radix.slottable");function Zxt(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Kxt}function Yxt(t,s){const r={...s};for(const n in s){const a=t[n],o=s[n];/^on[A-Z]/.test(n)?a&&o?r[n]=(...i)=>{const d=o(...i);return a(...i),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function Xxt(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 Qxt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],dn=Qxt.reduce((t,s)=>{const r=Gxt(`Primitive.${s}`),n=k.forwardRef((a,o)=>{const{asChild:l,...i}=a,d=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{});function nje(t,s){t&&ap.flushSync(()=>t.dispatchEvent(s))}function ed(t){const s=k.useRef(t);return k.useEffect(()=>{s.current=t}),k.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function Jxt(t,s=globalThis==null?void 0:globalThis.document){const r=ed(t);k.useEffect(()=>{const n=a=>{a.key==="Escape"&&r(a)};return s.addEventListener("keydown",n,{capture:!0}),()=>s.removeEventListener("keydown",n,{capture:!0})},[r,s])}var egt="DismissableLayer",Nve="dismissableLayer.update",tgt="dismissableLayer.pointerDownOutside",sgt="dismissableLayer.focusOutside",OEe,Uqe=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),mw=k.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...d}=t,u=k.useContext(Uqe),[p,f]=k.useState(null),y=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,_]=k.useState({}),b=Ma(s,U=>f(U)),N=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),S=N.indexOf(w),C=p?N.indexOf(p):-1,A=u.layersWithOutsidePointerEventsDisabled.size>0,I=C>=S,L=ngt(U=>{const q=U.target,$=[...u.branches].some(V=>V.contains(q));!I||$||(a==null||a(U),l==null||l(U),U.defaultPrevented||i==null||i())},y),O=agt(U=>{const q=U.target;[...u.branches].some(V=>V.contains(q))||(o==null||o(U),l==null||l(U),U.defaultPrevented||i==null||i())},y);return Jxt(U=>{C===u.layers.size-1&&(n==null||n(U),!U.defaultPrevented&&i&&(U.preventDefault(),i()))},y),k.useEffect(()=>{if(p)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(OEe=y.body.style.pointerEvents,y.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),FEe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(y.body.style.pointerEvents=OEe)}},[p,y,r,u]),k.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),FEe())},[p,u]),k.useEffect(()=>{const U=()=>_({});return document.addEventListener(Nve,U),()=>document.removeEventListener(Nve,U)},[]),e.jsx(dn.div,{...d,ref:b,style:{pointerEvents:A?I?"auto":"none":void 0,...t.style},onFocusCapture:Tr(t.onFocusCapture,O.onFocusCapture),onBlurCapture:Tr(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:Tr(t.onPointerDownCapture,L.onPointerDownCapture)})});mw.displayName=egt;var rgt="DismissableLayerBranch",Vqe=k.forwardRef((t,s)=>{const r=k.useContext(Uqe),n=k.useRef(null),a=Ma(s,n);return k.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),e.jsx(dn.div,{...t,ref:a})});Vqe.displayName=rgt;function ngt(t,s=globalThis==null?void 0:globalThis.document){const r=ed(t),n=k.useRef(!1),a=k.useRef(()=>{});return k.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let d=function(){Hqe(tgt,r,u,{discrete:!0})};const u={originalEvent:i};i.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=d,s.addEventListener("click",a.current,{once:!0})):d()}else s.removeEventListener("click",a.current);n.current=!1},l=window.setTimeout(()=>{s.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(l),s.removeEventListener("pointerdown",o),s.removeEventListener("click",a.current)}},[s,r]),{onPointerDownCapture:()=>n.current=!0}}function agt(t,s=globalThis==null?void 0:globalThis.document){const r=ed(t),n=k.useRef(!1);return k.useEffect(()=>{const a=o=>{o.target&&!n.current&&Hqe(sgt,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 FEe(){const t=new CustomEvent(Nve);document.dispatchEvent(t)}function Hqe(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?nje(a,o):a.dispatchEvent(o)}var igt=mw,ogt=Vqe,rd=globalThis!=null&&globalThis.document?k.useLayoutEffect:()=>{},lgt="Portal",PA=k.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=k.useState(!1);rd(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?rje.createPortal(e.jsx(dn.div,{...n,ref:s}),l):null});PA.displayName=lgt;function cgt(t,s){return k.useReducer((r,n)=>s[r][n]??r,t)}var wd=t=>{const{present:s,children:r}=t,n=dgt(s),a=typeof r=="function"?r({present:n.isPresent}):k.Children.only(r),o=Ma(n.ref,ugt(a));return typeof r=="function"||n.isPresent?k.cloneElement(a,{ref:o}):null};wd.displayName="Presence";function dgt(t){const[s,r]=k.useState(),n=k.useRef(null),a=k.useRef(t),o=k.useRef("none"),l=t?"mounted":"unmounted",[i,d]=cgt(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const u=pz(n.current);o.current=i==="mounted"?u:"none"},[i]),rd(()=>{const u=n.current,p=a.current;if(p!==t){const y=o.current,_=pz(u);t?d("MOUNT"):_==="none"||(u==null?void 0:u.display)==="none"?d("UNMOUNT"):d(p&&y!==_?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,d]),rd(()=>{if(s){let u;const p=s.ownerDocument.defaultView??window,f=_=>{const N=pz(n.current).includes(CSS.escape(_.animationName));if(_.target===s&&N&&(d("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",u=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},y=_=>{_.target===s&&(o.current=pz(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 d("ANIMATION_END")},[s,d]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:k.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function pz(t){return(t==null?void 0:t.animationName)||"none"}function ugt(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 hgt=Dde[" useInsertionEffect ".trim().toString()]||rd;function Bu({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=mgt({defaultProp:s,onChange:r}),i=t!==void 0,d=i?t:a;{const p=k.useRef(t!==void 0);k.useEffect(()=>{const f=p.current;f!==i&&console.warn(`${n} is changing from ${f?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=i},[i,n])}const u=k.useCallback(p=>{var f;if(i){const y=pgt(p)?p(t):p;y!==t&&((f=l.current)==null||f.call(l,y))}else o(p)},[i,t,o,l]);return[d,u]}function mgt({defaultProp:t,onChange:s}){const[r,n]=k.useState(t),a=k.useRef(r),o=k.useRef(s);return hgt(()=>{o.current=s},[s]),k.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function pgt(t){return typeof t=="function"}var Gqe=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"}),fgt="VisuallyHidden",Xde=k.forwardRef((t,s)=>e.jsx(dn.span,{...t,ref:s,style:{...Gqe,...t.style}}));Xde.displayName=fgt;var xgt=Xde,aje="ToastProvider",[ije,ggt,ygt]=jR("Toast"),[Wqe]=bd("Toast",[ygt]),[vgt,Qde]=Wqe(aje),Kqe=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,d]=k.useState(null),[u,p]=k.useState(0),f=k.useRef(!1),y=k.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${aje}\`. Expected non-empty \`string\`.`),e.jsx(ije.Provider,{scope:s,children:e.jsx(vgt,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:d,onToastAdd:k.useCallback(()=>p(_=>_+1),[]),onToastRemove:k.useCallback(()=>p(_=>_-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:y,children:l})})};Kqe.displayName=aje;var Zqe="ToastViewport",_gt=["F8"],kve="toast.viewportPause",Sve="toast.viewportResume",Yqe=k.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=_gt,label:a="Notifications ({hotkey})",...o}=t,l=Qde(Zqe,r),i=ggt(r),d=k.useRef(null),u=k.useRef(null),p=k.useRef(null),f=k.useRef(null),y=Ma(s,f,l.onViewportChange),_=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=l.toastCount>0;k.useEffect(()=>{const w=S=>{var A;n.length!==0&&n.every(I=>S[I]||S.code===I)&&((A=f.current)==null||A.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[n]),k.useEffect(()=>{const w=d.current,S=f.current;if(b&&w&&S){const C=()=>{if(!l.isClosePausedRef.current){const O=new CustomEvent(kve);S.dispatchEvent(O),l.isClosePausedRef.current=!0}},A=()=>{if(l.isClosePausedRef.current){const O=new CustomEvent(Sve);S.dispatchEvent(O),l.isClosePausedRef.current=!1}},I=O=>{!w.contains(O.relatedTarget)&&A()},L=()=>{w.contains(document.activeElement)||A()};return w.addEventListener("focusin",C),w.addEventListener("focusout",I),w.addEventListener("pointermove",C),w.addEventListener("pointerleave",L),window.addEventListener("blur",C),window.addEventListener("focus",A),()=>{w.removeEventListener("focusin",C),w.removeEventListener("focusout",I),w.removeEventListener("pointermove",C),w.removeEventListener("pointerleave",L),window.removeEventListener("blur",C),window.removeEventListener("focus",A)}}},[b,l.isClosePausedRef]);const N=k.useCallback(({tabbingDirection:w})=>{const C=i().map(A=>{const I=A.ref.current,L=[I,...Igt(I)];return w==="forwards"?L:L.reverse()});return(w==="forwards"?C.reverse():C).flat()},[i]);return k.useEffect(()=>{const w=f.current;if(w){const S=C=>{var L,O,U;const A=C.altKey||C.ctrlKey||C.metaKey;if(C.key==="Tab"&&!A){const q=document.activeElement,$=C.shiftKey;if(C.target===w&&$){(L=u.current)==null||L.focus();return}const Z=N({tabbingDirection:$?"backwards":"forwards"}),J=Z.findIndex(Y=>Y===q);Gxe(Z.slice(J+1))?C.preventDefault():$?(O=u.current)==null||O.focus():(U=p.current)==null||U.focus()}};return w.addEventListener("keydown",S),()=>w.removeEventListener("keydown",S)}},[i,N]),e.jsxs(ogt,{ref:d,role:"region","aria-label":a.replace("{hotkey}",_),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&e.jsx(Cve,{ref:u,onFocusFromOutsideViewport:()=>{const w=N({tabbingDirection:"forwards"});Gxe(w)}}),e.jsx(ije.Slot,{scope:r,children:e.jsx(dn.ol,{tabIndex:-1,...o,ref:y})}),b&&e.jsx(Cve,{ref:p,onFocusFromOutsideViewport:()=>{const w=N({tabbingDirection:"backwards"});Gxe(w)}})]})});Yqe.displayName=Zqe;var Xqe="ToastFocusProxy",Cve=k.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=Qde(Xqe,r);return e.jsx(Xde,{tabIndex:0,...a,ref:s,style:{position:"fixed"},onFocus:l=>{var u;const i=l.relatedTarget;!((u=o.viewport)!=null&&u.contains(i))&&n()}})});Cve.displayName=Xqe;var NR="Toast",bgt="toast.swipeStart",wgt="toast.swipeMove",jgt="toast.swipeCancel",Ngt="toast.swipeEnd",Qqe=k.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,d]=Bu({prop:n,defaultProp:a??!0,onChange:o,caller:NR});return e.jsx(wd,{present:r||i,children:e.jsx(Cgt,{open:i,...l,ref:s,onClose:()=>d(!1),onPause:ed(t.onPause),onResume:ed(t.onResume),onSwipeStart:Tr(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Tr(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:Tr(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:Tr(t.onSwipeEnd,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),d(!1)})})})});Qqe.displayName=NR;var[kgt,Sgt]=Wqe(NR,{onClose(){}}),Cgt=k.forwardRef((t,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:d,onResume:u,onSwipeStart:p,onSwipeMove:f,onSwipeCancel:y,onSwipeEnd:_,...b}=t,N=Qde(NR,r),[w,S]=k.useState(null),C=Ma(s,Y=>S(Y)),A=k.useRef(null),I=k.useRef(null),L=a||N.duration,O=k.useRef(0),U=k.useRef(L),q=k.useRef(0),{onToastAdd:$,onToastRemove:V}=N,ee=ed(()=>{var ce;(w==null?void 0:w.contains(document.activeElement))&&((ce=N.viewport)==null||ce.focus()),l()}),Z=k.useCallback(Y=>{!Y||Y===1/0||(window.clearTimeout(q.current),O.current=new Date().getTime(),q.current=window.setTimeout(ee,Y))},[ee]);k.useEffect(()=>{const Y=N.viewport;if(Y){const ce=()=>{Z(U.current),u==null||u()},ae=()=>{const ie=new Date().getTime()-O.current;U.current=U.current-ie,window.clearTimeout(q.current),d==null||d()};return Y.addEventListener(kve,ae),Y.addEventListener(Sve,ce),()=>{Y.removeEventListener(kve,ae),Y.removeEventListener(Sve,ce)}}},[N.viewport,L,d,u,Z]),k.useEffect(()=>{o&&!N.isClosePausedRef.current&&Z(L)},[o,L,N.isClosePausedRef,Z]),k.useEffect(()=>($(),()=>V()),[$,V]);const J=k.useMemo(()=>w?aUe(w):null,[w]);return N.viewport?e.jsxs(e.Fragment,{children:[J&&e.jsx(Mgt,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite",children:J}),e.jsx(kgt,{scope:r,onClose:ee,children:ap.createPortal(e.jsx(ije.ItemSlot,{scope:r,children:e.jsx(igt,{asChild:!0,onEscapeKeyDown:Tr(i,()=>{N.isFocusedToastEscapeKeyDownRef.current||ee(),N.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(dn.li,{tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":N.swipeDirection,...b,ref:C,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Tr(t.onKeyDown,Y=>{Y.key==="Escape"&&(i==null||i(Y.nativeEvent),Y.nativeEvent.defaultPrevented||(N.isFocusedToastEscapeKeyDownRef.current=!0,ee()))}),onPointerDown:Tr(t.onPointerDown,Y=>{Y.button===0&&(A.current={x:Y.clientX,y:Y.clientY})}),onPointerMove:Tr(t.onPointerMove,Y=>{if(!A.current)return;const ce=Y.clientX-A.current.x,ae=Y.clientY-A.current.y,ie=!!I.current,le=["left","right"].includes(N.swipeDirection),fe=["left","up"].includes(N.swipeDirection)?Math.min:Math.max,xe=le?fe(0,ce):0,he=le?0:fe(0,ae),we=Y.pointerType==="touch"?10:2,Ne={x:xe,y:he},Ve={originalEvent:Y,delta:Ne};ie?(I.current=Ne,fz(wgt,f,Ve,{discrete:!1})):zEe(Ne,N.swipeDirection,we)?(I.current=Ne,fz(bgt,p,Ve,{discrete:!1}),Y.target.setPointerCapture(Y.pointerId)):(Math.abs(ce)>we||Math.abs(ae)>we)&&(A.current=null)}),onPointerUp:Tr(t.onPointerUp,Y=>{const ce=I.current,ae=Y.target;if(ae.hasPointerCapture(Y.pointerId)&&ae.releasePointerCapture(Y.pointerId),I.current=null,A.current=null,ce){const ie=Y.currentTarget,le={originalEvent:Y,delta:ce};zEe(ce,N.swipeDirection,N.swipeThreshold)?fz(Ngt,_,le,{discrete:!0}):fz(jgt,y,le,{discrete:!0}),ie.addEventListener("click",fe=>fe.preventDefault(),{once:!0})}})})})}),N.viewport)})]}):null}),Mgt=t=>{const{__scopeToast:s,children:r,...n}=t,a=Qde(NR,s),[o,l]=k.useState(!1),[i,d]=k.useState(!1);return Egt(()=>l(!0)),k.useEffect(()=>{const u=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(PA,{asChild:!0,children:e.jsx(Xde,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},Tgt="ToastTitle",Jqe=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(dn.div,{...n,ref:s})});Jqe.displayName=Tgt;var Agt="ToastDescription",eUe=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(dn.div,{...n,ref:s})});eUe.displayName=Agt;var tUe="ToastAction",sUe=k.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(nUe,{altText:r,asChild:!0,children:e.jsx(oje,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${tUe}\`. Expected non-empty \`string\`.`),null)});sUe.displayName=tUe;var rUe="ToastClose",oje=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=Sgt(rUe,r);return e.jsx(nUe,{asChild:!0,children:e.jsx(dn.button,{type:"button",...n,ref:s,onClick:Tr(t.onClick,a.onClose)})})});oje.displayName=rUe;var nUe=k.forwardRef((t,s)=>{const{__scopeToast:r,altText:n,...a}=t;return e.jsx(dn.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function aUe(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),Pgt(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(...aUe(n))}}),s}function fz(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?nje(a,o):a.dispatchEvent(o)}var zEe=(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 Egt(t=()=>{}){const s=ed(t);rd(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function Pgt(t){return t.nodeType===t.ELEMENT_NODE}function Igt(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 Gxe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var Lgt=Kqe,iUe=Yqe,oUe=Qqe,lUe=Jqe,cUe=eUe,dUe=sUe,uUe=oje;function hUe(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,$Ee=bi,wC=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return $Ee(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=BEe(p)||BEe(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},{}),d=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[N,w]=b;return Array.isArray(w)?w.includes({...o,...i}[N]):{...o,...i}[N]===w})?[...u,f,y]:u},[]);return $Ee(t,l,d,r==null?void 0:r.class,r==null?void 0:r.className)};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dgt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),mUe=(...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 Rgt={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 pUe=k.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},d)=>k.createElement("svg",{ref:d,...Rgt,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:mUe("lucide",a),...i},[...l.map(([u,p])=>k.createElement(u,p)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X=(t,s)=>{const r=k.forwardRef(({className:n,...a},o)=>k.createElement(pUe,{ref:o,iconNode:s,className:mUe(`lucide-${Dgt(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 Y9=X("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 X9=X("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 Q9=X("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 J9=X("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 ih=X("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 eB=X("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 tB=X("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 K2=X("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 Z2=X("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 sB=X("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 Y2=X("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 rB=X("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 nB=X("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 aB=X("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 iB=X("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 oB=X("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 G4=X("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 lB=X("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 cB=X("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 dB=X("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 uB=X("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 hB=X("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 mB=X("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 pB=X("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 fB=X("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 xB=X("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 gB=X("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 yB=X("AlignJustify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W4=X("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 K4=X("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 vB=X("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 _B=X("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 bB=X("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 wB=X("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 jB=X("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 NB=X("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 kB=X("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 SB=X("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 CB=X("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 MB=X("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 TB=X("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 AB=X("Ampersand",[["path",{d:"M17.5 12c0 4.4-3.6 8-8 8A4.5 4.5 0 0 1 5 15.5c0-6 8-4 8-8.5a3 3 0 1 0-6 0c0 3 2.5 8.5 12 13",key:"1o9ehi"}],["path",{d:"M16 12h3",key:"4uvgyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EB=X("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 PB=X("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 IB=X("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 LB=X("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 DB=X("Annoyed",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M14 9h2",key:"116p9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RB=X("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 OB=X("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 FB=X("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 zB=X("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 sL=X("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 BB=X("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 rL=X("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 $B=X("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 _M=X("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 qB=X("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 UB=X("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 VB=X("ArrowBigDown",[["path",{d:"M15 6v6h4l-7 7-7-7h4V6h6z",key:"1thax2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HB=X("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 GB=X("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 WB=X("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 KB=X("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 ZB=X("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 YB=X("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 XB=X("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 QB=X("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 X2=X("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 JB=X("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 e$=X("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 t$=X("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 nL=X("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 s$=X("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 r$=X("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 n$=X("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 Q2=X("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 J2=X("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 Ih=X("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 a$=X("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 i$=X("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 o$=X("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 Ra=X("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 l$=X("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=X("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 c$=X("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 ti=X("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 d$=X("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 u$=X("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 ej=X("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 td=X("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 h$=X("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 m$=X("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 p$=X("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 tj=X("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 aL=X("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 f$=X("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 x$=X("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 sj=X("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 cu=X("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 g$=X("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 y$=X("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 v$=X("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 _$=X("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 b$=X("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 w$=X("AudioWaveform",[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rc=X("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 j$=X("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 rj=X("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 N$=X("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 k$=X("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 S$=X("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 C$=X("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 nj=X("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 M$=X("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 T$=X("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 A$=X("BadgeHelp",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["line",{x1:"12",x2:"12.01",y1:"17",y2:"17",key:"io3f8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E$=X("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 P$=X("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 I$=X("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 L$=X("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 D$=X("BadgePercent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R$=X("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 O$=X("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 F$=X("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 z$=X("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$=X("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 $$=X("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 q$=X("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 iL=X("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 U$=X("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 V$=X("Bandage",[["path",{d:"M10 10.01h.01",key:"1e9xi7"}],["path",{d:"M10 14.01h.01",key:"ac23bv"}],["path",{d:"M14 10.01h.01",key:"2wfrvf"}],["path",{d:"M14 14.01h.01",key:"8tw8yn"}],["path",{d:"M18 6v11.5",key:"dkbidh"}],["path",{d:"M6 6v12",key:"vkc79e"}],["rect",{x:"2",y:"6",width:"20",height:"12",rx:"2",key:"1wpnh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H$=X("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 G$=X("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 W$=X("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 of=X("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 K$=X("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 Z$=X("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 Y$=X("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 X$=X("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 Q$=X("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 J$=X("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 eq=X("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 tq=X("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 sq=X("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 Z4=X("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 rq=X("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 Ky=X("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 nq=X("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 aq=X("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 iq=X("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 oq=X("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 lq=X("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 cq=X("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 Wv=X("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 dq=X("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 uq=X("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 Nm=X("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 aj=X("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 ij=X("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 hq=X("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 mq=X("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 pq=X("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 fq=X("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 xq=X("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 gq=X("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 yq=X("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 vq=X("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 _q=X("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 bq=X("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 wq=X("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 jq=X("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 Nq=X("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 kq=X("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 Sq=X("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 Cq=X("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 Y4=X("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 Mq=X("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 Tq=X("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 Aq=X("Bone",[["path",{d:"M17 10c.7-.7 1.69 0 2.5 0a2.5 2.5 0 1 0 0-5 .5.5 0 0 1-.5-.5 2.5 2.5 0 1 0-5 0c0 .81.7 1.8 0 2.5l-7 7c-.7.7-1.69 0-2.5 0a2.5 2.5 0 0 0 0 5c.28 0 .5.22.5.5a2.5 2.5 0 1 0 5 0c0-.81-.7-1.8 0-2.5Z",key:"w610uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eq=X("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 Pq=X("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 Iq=X("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 Lq=X("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 oj=X("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 Dq=X("BookDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3 3 3-3",key:"zt5b4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rq=X("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 Oq=X("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 Fq=X("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 zq=X("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 Bq=X("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=X("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 qq=X("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 Uq=X("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 Vq=X("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 oh=X("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hq=X("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 Gq=X("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 Wq=X("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 Kq=X("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 Zq=X("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 Yq=X("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 Xq=X("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 Qq=X("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 Jq=X("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 eU=X("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 oL=X("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 tU=X("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 _x=X("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 sU=X("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 rU=X("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 nU=X("BotOff",[["path",{d:"M13.67 8H18a2 2 0 0 1 2 2v4.33",key:"7az073"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}],["path",{d:"M8 8H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 1.414-.586",key:"s09a7a"}],["path",{d:"M9 13v2",key:"rq6x2g"}],["path",{d:"M9.67 4H12v2.33",key:"110xot"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bM=X("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 aU=X("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 iU=X("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 lj=X("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 oU=X("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 lU=X("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 cU=X("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 lL=X("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 dU=X("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 uU=X("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 hU=X("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 mU=X("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 Lh=X("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 pU=X("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 fU=X("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 xU=X("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 gU=X("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 yU=X("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 ma=X("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 X4=X("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 vU=X("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 _U=X("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 bU=X("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 wU=X("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 jU=X("CakeSlice",[["circle",{cx:"9",cy:"7",r:"2",key:"1305pl"}],["path",{d:"M7.2 7.9 3 11v9c0 .6.4 1 1 1h16c.6 0 1-.4 1-1v-9c0-2-3-6-7-8l-3.6 2.6",key:"xle13f"}],["path",{d:"M16 13H3",key:"1wpj08"}],["path",{d:"M16 17H3",key:"3lvfcd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lh=X("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 wM=X("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 NU=X("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 kU=X("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 SU=X("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 CU=X("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 cL=X("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 jM=X("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 MU=X("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 xd=X("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 TU=X("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 AU=X("CalendarHeart",[["path",{d:"M3 10h18V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7",key:"136lmk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21.29 14.7a2.43 2.43 0 0 0-2.65-.52c-.3.12-.57.3-.8.53l-.34.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L17.5 22l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1t7hil"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EU=X("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 PU=X("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 dL=X("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 IU=X("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 Cb=X("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 LU=X("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 DU=X("CalendarSearch",[["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 11.75V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.25",key:"1jrsq6"}],["path",{d:"m22 22-1.875-1.875",key:"13zax7"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RU=X("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 OU=X("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 FU=X("CalendarX",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m14 14-4 4",key:"rymu2i"}],["path",{d:"m10 14 4 4",key:"3sz06r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nn=X("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 zU=X("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 bx=X("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 BU=X("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 $U=X("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 qU=X("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 UU=X("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 VU=X("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 cj=X("Captions",[["rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2",key:"12ruh7"}],["path",{d:"M7 15h4M15 15h2M7 11h2M13 11h4",key:"1ueiar"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HU=X("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 GU=X("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 WU=X("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 KU=X("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 ZU=X("Carrot",[["path",{d:"M2.27 21.7s9.87-3.5 12.73-6.36a4.5 4.5 0 0 0-6.36-6.37C5.77 11.84 2.27 21.7 2.27 21.7zM8.64 14l-2.05-2.04M15.34 15l-2.46-2.46",key:"rfqxbe"}],["path",{d:"M22 9s-1.33-2-3.5-2C16.86 7 15 9 15 9s1.33 2 3.5 2S22 9 22 9z",key:"6b25w4"}],["path",{d:"M15 2s-2 1.33-2 3.5S15 9 15 9s2-1.84 2-3.5C17 3.33 15 2 15 2z",key:"fn65lo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YU=X("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 XU=X("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 QU=X("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 JU=X("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 eV=X("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 tV=X("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 sV=X("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 rV=X("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 dj=X("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 uj=X("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 nV=X("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 aV=X("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 iV=X("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 hj=X("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 mj=X("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 pj=X("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 oV=X("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 fj=X("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 lV=X("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 so=X("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 cV=X("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 xj=X("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 dV=X("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 uV=X("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 gj=X("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 yj=X("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 hV=X("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 vj=X("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 _j=X("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 bj=X("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 mV=X("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 uL=X("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 ea=X("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 pV=X("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 fV=X("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 Fi=X("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 xV=X("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 gV=X("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 wl=X("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 ja=X("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 lf=X("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 yV=X("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 vV=X("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 _V=X("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 bV=X("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 wV=X("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 jV=X("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 NV=X("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 wx=X("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 kV=X("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 SV=X("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 CV=X("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 MV=X("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 TV=X("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 co=X("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 wj=X("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 jj=X("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 Nj=X("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 kj=X("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 Sj=X("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 Cj=X("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 Mj=X("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 Tj=X("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 si=X("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 Hn=X("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 Aj=X("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 Ej=X("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 Pj=X("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 Ij=X("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 AV=X("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 Lj=X("CircleDivide",[["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EV=X("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 PV=X("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 IV=X("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 LV=X("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 DV=X("CircleEqual",[["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RV=X("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 OV=X("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 Dj=X("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 Sv=X("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 Rj=X("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 FV=X("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 Oj=X("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 Fj=X("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 zj=X("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 Bj=X("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 tp=X("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 $j=X("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 qj=X("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 Uj=X("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 zV=X("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 Vj=X("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 Hj=X("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 Gj=X("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 Ql=X("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 sd=X("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 BV=X("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 $V=X("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 qV=X("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 NM=X("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 UV=X("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 Mb=X("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 VV=X("ClipboardMinus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HV=X("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 Wj=X("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 Kj=X("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 GV=X("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 WV=X("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 KV=X("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 ZV=X("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 YV=X("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 XV=X("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 QV=X("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 JV=X("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 eH=X("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 tH=X("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 sH=X("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 rH=X("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 nH=X("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 aH=X("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 iH=X("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 oH=X("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 lH=X("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 cH=X("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 dH=X("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 rn=X("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 uH=X("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 hH=X("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=X("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 mH=X("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 pH=X("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 fH=X("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 xH=X("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 gH=X("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 yH=X("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 vH=X("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 _H=X("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 bH=X("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 wH=X("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 jH=X("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 NH=X("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 Yj=X("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 kH=X("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 SH=X("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 zv=X("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 CH=X("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 Xj=X("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 Q4=X("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 MH=X("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 TH=X("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 J4=X("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 AH=X("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 hL=X("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=X("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 Jj=X("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EH=X("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 PH=X("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 IH=X("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 kM=X("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 LH=X("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 DH=X("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 RH=X("ConciergeBell",[["path",{d:"M3 20a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1Z",key:"1pvr1r"}],["path",{d:"M20 16a8 8 0 1 0-16 0",key:"1pa543"}],["path",{d:"M12 4v4",key:"1bq03y"}],["path",{d:"M10 4h4",key:"1xpv9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OH=X("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 FH=X("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 eN=X("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 eS=X("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 zH=X("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 BH=X("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 $H=X("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 qH=X("CookingPot",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M20 12v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8",key:"u0tga0"}],["path",{d:"m4 8 16-4",key:"16g0ng"}],["path",{d:"m8.86 6.78-.45-1.81a2 2 0 0 1 1.45-2.43l1.94-.48a2 2 0 0 1 2.43 1.46l.45 1.8",key:"12cejc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UH=X("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 VH=X("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 HH=X("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 GH=X("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 WH=X("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 Ya=X("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 KH=X("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 ZH=X("Copyright",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M14.83 14.83a4 4 0 1 1 0-5.66",key:"1i56pz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YH=X("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 XH=X("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 QH=X("CornerLeftDown",[["polyline",{points:"14 15 9 20 4 15",key:"nkc4i"}],["path",{d:"M20 4h-7a4 4 0 0 0-4 4v12",key:"nbpdq2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JH=X("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 eG=X("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 tG=X("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 sG=X("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 rG=X("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 nG=X("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 aG=X("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 jx=X("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 iG=X("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 oG=X("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 lG=X("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 cG=X("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 km=X("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 dG=X("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 uG=X("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 hG=X("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 mG=X("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 pG=X("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 fG=X("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 xG=X("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 mL=X("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 gG=X("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 yG=X("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 vG=X("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 _G=X("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 tN=X("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 bG=X("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 wG=X("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 jG=X("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 NG=X("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 kG=X("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 SG=X("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 CG=X("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 MG=X("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 TG=X("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 AG=X("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 EG=X("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 PG=X("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 IG=X("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 LG=X("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 DG=X("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 RG=X("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 OG=X("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 FG=X("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 zG=X("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 _c=X("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 BG=X("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 $G=X("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 Kv=X("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 qG=X("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 Xa=X("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 UG=X("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 VG=X("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 HG=X("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 GG=X("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 WG=X("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 Lg=X("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 KG=X("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 ZG=X("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 YG=X("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 XG=X("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 QG=X("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 JG=X("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 sN=X("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 eW=X("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 tW=X("EggFried",[["circle",{cx:"11.5",cy:"12.5",r:"3.5",key:"1cl1mi"}],["path",{d:"M3 8c0-3.5 2.5-6 6.5-6 5 0 4.83 3 7.5 5s5 2 5 6c0 4.5-2.5 6.5-7 6.5-2.5 0-2.5 2.5-6 2.5s-7-2-7-5.5c0-3 1.5-3 1.5-5C3.5 10 3 9 3 8Z",key:"165ef9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sW=X("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 SM=X("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 cx=X("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 dx=X("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 rW=X("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 nW=X("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 aW=X("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 iW=X("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 oW=X("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 lW=X("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 cW=X("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 Kr=X("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 dW=X("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 hp=X("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 jn=X("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 du=X("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 uW=X("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 hW=X("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 mW=X("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 pW=X("Feather",[["path",{d:"M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z",key:"18jl4k"}],["path",{d:"M16 8 2 22",key:"vp34q"}],["path",{d:"M17.5 15H9",key:"1oz8nu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fW=X("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 xW=X("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 gW=X("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 yW=X("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 vW=X("FileAudio2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"3",cy:"17",r:"1",key:"vo6nti"}],["path",{d:"M2 17v-3a4 4 0 0 1 8 0v3",key:"1ggdre"}],["circle",{cx:"9",cy:"17",r:"1",key:"bc1fq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _W=X("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 rN=X("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 bW=X("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 wW=X("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 jW=X("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 nN=X("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 aN=X("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 iN=X("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 oN=X("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 NW=X("FileCheck2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kW=X("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 SW=X("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 CW=X("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 MW=X("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 lN=X("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 TW=X("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 AW=X("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 tS=X("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 EW=X("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 Tb=X("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 PW=X("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 IW=X("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 LW=X("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 DW=X("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 RW=X("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 OW=X("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 FW=X("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 zW=X("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 BW=X("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 $W=X("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 qW=X("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 cN=X("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 dN=X("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 UW=X("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 VW=X("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 HW=X("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 GW=X("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 WW=X("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 KW=X("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 ZW=X("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 Zv=X("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 pL=X("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 YW=X("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 XW=X("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 mn=X("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 QW=X("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 JW=X("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 eK=X("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 tK=X("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 sK=X("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 rK=X("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 nK=X("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 aK=X("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 iK=X("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 oK=X("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 lK=X("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 CM=X("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 cK=X("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 Ld=X("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 dK=X("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 Dg=X("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 uK=X("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 hK=X("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 mK=X("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 pK=X("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 fK=X("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 xK=X("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 gK=X("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 yK=X("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 Yv=X("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 vK=X("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 ch=X("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 _K=X("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 bK=X("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 wK=X("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 Ab=X("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 jK=X("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 NK=X("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 fL=X("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 kK=X("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 SK=X("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 Tg=X("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 CK=X("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 MK=X("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 TK=X("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 AK=X("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 EK=X("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 PK=X("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 IK=X("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 LK=X("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 DK=X("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 uN=X("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 RK=X("FolderDot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"1",key:"49l61u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OK=X("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 FK=X("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 zK=X("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 BK=X("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 $K=X("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 qK=X("FolderKanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UK=X("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 VK=X("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 HK=X("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 GK=X("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 Sm=X("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 WK=X("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 hN=X("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 KK=X("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 ZK=X("FolderRoot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M12 15v5",key:"11xva1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YK=X("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 XK=X("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 QK=X("FolderSymlink",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"x1c07l"}],["path",{d:"m8 16 3-3-3-3",key:"rlqrt1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JK=X("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 eZ=X("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 tZ=X("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 sZ=X("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 rZ=X("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 nZ=X("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 aZ=X("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 iZ=X("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 oZ=X("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 lZ=X("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 cZ=X("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 dZ=X("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 uZ=X("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 hZ=X("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 mZ=X("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 pZ=X("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 fZ=X("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 xZ=X("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 gZ=X("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 yZ=X("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 vZ=X("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 _Z=X("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 bZ=X("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 wZ=X("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 sS=X("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 Vi=X("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 jZ=X("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 NZ=X("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 mN=X("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 kZ=X("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 SZ=X("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 CZ=X("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 MZ=X("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 TZ=X("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 AZ=X("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 EZ=X("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 PZ=X("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 IZ=X("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 LZ=X("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 DZ=X("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 RZ=X("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OZ=X("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 FZ=X("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 zZ=X("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 BZ=X("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 $Z=X("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 gd=X("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 qZ=X("Goal",[["path",{d:"M12 13V2l8 4-8 4",key:"5wlwwj"}],["path",{d:"M20.561 10.222a9 9 0 1 1-12.55-5.29",key:"1c0wjv"}],["path",{d:"M8.002 9.997a5 5 0 1 0 8.9 2.02",key:"gb1g7m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UZ=X("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 Dh=X("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 VZ=X("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 HZ=X("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 pN=X("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 GZ=X("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 fN=X("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 tx=X("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 WZ=X("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 uu=X("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 KZ=X("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 ZZ=X("Group",[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YZ=X("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 XZ=X("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 QZ=X("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JZ=X("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 eY=X("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 xN=X("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 tY=X("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 sY=X("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 xL=X("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 gL=X("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 rY=X("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 nY=X("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 yL=X("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 aY=X("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 rS=X("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 iY=X("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 oY=X("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 MM=X("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 TM=X("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 vL=X("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 lY=X("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 cY=X("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 dY=X("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 uY=X("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 hY=X("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 mY=X("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 pY=X("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 fY=X("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 xY=X("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 gY=X("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 yY=X("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 Za=X("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 vY=X("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 _Y=X("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 bY=X("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 AM=X("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 wY=X("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 jY=X("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 NY=X("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 kY=X("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 SY=X("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 CY=X("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 MY=X("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 Mn=X("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 gN=X("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 yN=X("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 TY=X("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 AY=X("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 EY=X("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 PY=X("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 IY=X("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 Xv=X("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 LY=X("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 DY=X("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 Uo=X("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 RY=X("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OY=X("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 FY=X("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 vN=X("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 _N=X("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 zY=X("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 BY=X("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 nS=X("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 $Y=X("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 hu=X("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 aS=X("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 qY=X("IterationCcw",[["path",{d:"M20 10c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8h8",key:"4znkd0"}],["polyline",{points:"16 14 20 18 16 22",key:"11njsm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UY=X("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 VY=X("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 HY=X("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 Zy=X("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 iS=X("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 GY=X("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 mp=X("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 WY=X("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 KY=X("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 ZY=X("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YY=X("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 XY=X("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 QY=X("LampFloor",[["path",{d:"M9 2h6l3 7H6l3-7Z",key:"wcx6mj"}],["path",{d:"M12 9v13",key:"3n1su1"}],["path",{d:"M9 22h6",key:"1rlq3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JY=X("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 eX=X("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 tX=X("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 sX=X("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 rX=X("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 nX=X("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 aX=X("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 bN=X("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 iX=X("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 oX=X("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 lX=X("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 cX=X("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 dX=X("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 uX=X("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 hX=X("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 oS=X("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 pp=X("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 mX=X("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 pX=X("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 fX=X("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 lS=X("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 xX=X("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 gX=X("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 yX=X("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 vX=X("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 _X=X("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 cS=X("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 EM=X("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 bX=X("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 wX=X("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 Eb=X("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 jX=X("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 Do=X("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 go=X("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 fp=X("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 NX=X("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 kX=X("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 SX=X("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 CX=X("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 MX=X("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 TX=X("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 AX=X("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 Yy=X("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EX=X("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 PX=X("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 IX=X("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 LX=X("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 DX=X("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RX=X("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 OX=X("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 Rh=X("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 ps=X("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 FX=X("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 zX=X("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 BX=X("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 $X=X("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 PM=X("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 wN=X("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 qX=X("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 jN=X("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 yd=X("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 dS=X("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 IM=X("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UX=X("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 VX=X("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 HX=X("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 GX=X("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 WX=X("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 KX=X("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 ZX=X("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 _L=X("MailPlus",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YX=X("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 XX=X("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 QX=X("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 bL=X("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 tr=X("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JX=X("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 eQ=X("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 tQ=X("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 sQ=X("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 rQ=X("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 nQ=X("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 aQ=X("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 iQ=X("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 oQ=X("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 lQ=X("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 cQ=X("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 dQ=X("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 La=X("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 uQ=X("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 uS=X("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 hQ=X("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 mQ=X("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 wL=X("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 Qv=X("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 pQ=X("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 dh=X("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 fQ=X("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 xQ=X("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 hS=X("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 gQ=X("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 yQ=X("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 vQ=X("MessageCircleDashed",[["path",{d:"M13.5 3.1c-.5 0-1-.1-1.5-.1s-1 .1-1.5.1",key:"16ll65"}],["path",{d:"M19.3 6.8a10.45 10.45 0 0 0-2.1-2.1",key:"1nq77a"}],["path",{d:"M20.9 13.5c.1-.5.1-1 .1-1.5s-.1-1-.1-1.5",key:"1sf7wn"}],["path",{d:"M17.2 19.3a10.45 10.45 0 0 0 2.1-2.1",key:"x1hs5g"}],["path",{d:"M10.5 20.9c.5.1 1 .1 1.5.1s1-.1 1.5-.1",key:"19m18z"}],["path",{d:"M3.5 17.5 2 22l4.5-1.5",key:"1f36qi"}],["path",{d:"M3.1 10.5c0 .5-.1 1-.1 1.5s.1 1 .1 1.5",key:"1vz3ju"}],["path",{d:"M6.8 4.7a10.45 10.45 0 0 0-2.1 2.1",key:"19f9do"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LM=X("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 _Q=X("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 bQ=X("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 wQ=X("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 jL=X("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 jQ=X("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 NQ=X("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 kQ=X("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 bc=X("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 SQ=X("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 CQ=X("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 MQ=X("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 TQ=X("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 AQ=X("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 EQ=X("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 NL=X("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 PQ=X("MessageSquareOff",[["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M3.6 3.6c-.4.3-.6.8-.6 1.4v16l4-4h10",key:"pwpm4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DM=X("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 kL=X("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 IQ=X("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 LQ=X("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 DQ=X("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 RQ=X("MessageSquareWarning",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v2",key:"stiyo7"}],["path",{d:"M12 13h.01",key:"y0uutt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OQ=X("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 Si=X("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 FQ=X("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 zQ=X("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 NN=X("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 SL=X("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 BQ=X("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 $Q=X("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 qQ=X("Microwave",[["rect",{width:"20",height:"15",x:"2",y:"4",rx:"2",key:"2no95f"}],["rect",{width:"8",height:"7",x:"6",y:"8",rx:"1",key:"zh9wx"}],["path",{d:"M18 8v7",key:"o5zi4n"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 19v2",key:"1dawf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UQ=X("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 VQ=X("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 HQ=X("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 GQ=X("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 WQ=X("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 Xy=X("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 KQ=X("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 ZQ=X("MonitorCog",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m15.2 4.9-.9-.4",key:"12wd2u"}],["path",{d:"m15.2 7.1-.9.4",key:"1r2vl7"}],["path",{d:"m16.9 3.2-.4-.9",key:"3zbo91"}],["path",{d:"m16.9 8.8-.4.9",key:"1qr2dn"}],["path",{d:"m19.5 2.3-.4.9",key:"1rjrkq"}],["path",{d:"m19.5 9.7-.4-.9",key:"heryx5"}],["path",{d:"m21.7 4.5-.9.4",key:"17fqt1"}],["path",{d:"m21.7 7.5-.9-.4",key:"14zyni"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YQ=X("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 XQ=X("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 QQ=X("MonitorOff",[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JQ=X("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 eJ=X("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 tJ=X("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 sJ=X("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 rJ=X("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 mS=X("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 nJ=X("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 pS=X("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 aJ=X("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 iJ=X("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 oJ=X("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 lJ=X("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 cJ=X("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 dJ=X("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 uJ=X("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 Cm=X("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 sh=X("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 hJ=X("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 kN=X("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 mJ=X("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 pJ=X("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 fJ=X("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 xJ=X("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 gJ=X("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 yJ=X("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 vJ=X("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 _J=X("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 bJ=X("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 wJ=X("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 jJ=X("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 NJ=X("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 kJ=X("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 SJ=X("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 CJ=X("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 MJ=X("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 TJ=X("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 AJ=X("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 EJ=X("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 PJ=X("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 CL=X("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 IJ=X("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 Jv=X("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 LJ=X("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 DJ=X("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 RJ=X("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 OJ=X("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 FJ=X("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 zJ=X("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 BJ=X("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 $J=X("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 qJ=X("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 Cv=X("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 UJ=X("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 SN=X("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 CN=X("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 VJ=X("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 HJ=X("Omega",[["path",{d:"M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21",key:"1x94xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GJ=X("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 WJ=X("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 KJ=X("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 ZJ=X("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 YJ=X("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 XJ=X("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 QJ=X("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 JJ=X("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 eee=X("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 tee=X("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 al=X("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 see=X("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 ree=X("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 MN=X("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 nee=X("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 Rl=X("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 aee=X("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 TN=X("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 iee=X("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 oee=X("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 AN=X("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 EN=X("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 PN=X("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 IN=X("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 lee=X("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 LN=X("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 cee=X("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 dee=X("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 uee=X("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 DN=X("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 hee=X("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 mee=X("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 pee=X("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 fee=X("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 Mv=X("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 fS=X("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 xee=X("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 gee=X("ParkingMeter",[["path",{d:"M11 15h2",key:"199qp6"}],["path",{d:"M12 12v3",key:"158kv8"}],["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15.282 19a1 1 0 0 0 .948-.68l2.37-6.988a7 7 0 1 0-13.2 0l2.37 6.988a1 1 0 0 0 .948.68z",key:"1jofit"}],["path",{d:"M9 9a3 3 0 1 1 6 0",key:"jdoeu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bd=X("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 uh=X("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 yee=X("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 vee=X("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 Tv=X("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 _ee=X("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 Pb=X("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 Ry=X("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 bee=X("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 wee=X("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 jee=X("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 pa=X("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 Nee=X("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 RM=X("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 kee=X("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 See=X("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 Cee=X("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 Mee=X("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 Tee=X("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 Aee=X("PhoneMissed",[["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["line",{x1:"16",x2:"22",y1:"2",y2:"8",key:"13zxdn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eee=X("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 Pee=X("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 Tn=X("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 Iee=X("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 Lee=X("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 Dee=X("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 Ree=X("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 Oee=X("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 Fee=X("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 zee=X("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 Bee=X("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 $ee=X("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 qee=X("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 Uee=X("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 ML=X("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 Ib=X("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 Vee=X("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 Hee=X("Pizza",[["path",{d:"m12 14-1 1",key:"11onhr"}],["path",{d:"m13.75 18.25-1.25 1.42",key:"1yisr3"}],["path",{d:"M17.775 5.654a15.68 15.68 0 0 0-12.121 12.12",key:"1qtqk6"}],["path",{d:"M18.8 9.3a1 1 0 0 0 2.1 7.7",key:"fbbbr2"}],["path",{d:"M21.964 20.732a1 1 0 0 1-1.232 1.232l-18-5a1 1 0 0 1-.695-1.232A19.68 19.68 0 0 1 15.732 2.037a1 1 0 0 1 1.232.695z",key:"1hyfdd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gee=X("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 Wee=X("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 Kee=X("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 Co=X("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 Zee=X("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 RN=X("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 TL=X("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 Bs=X("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 Yee=X("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 Xee=X("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 Qee=X("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 Jee=X("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 ete=X("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 tte=X("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 ste=X("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 rte=X("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 nte=X("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 AL=X("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 Rg=X("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 ate=X("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 EL=X("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 ite=X("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 ote=X("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 lte=X("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 cte=X("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 Qy=X("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 xS=X("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 dte=X("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 ute=X("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 hte=X("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 mte=X("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 pte=X("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 fte=X("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 e1=X("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 xte=X("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 gte=X("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 yte=X("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 vte=X("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 _te=X("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 bte=X("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 wte=X("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 jte=X("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 Nte=X("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 kte=X("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 Ste=X("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 Cte=X("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 Mte=X("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 Tte=X("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 ON=X("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 Ate=X("RectangleHorizontal",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ete=X("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 Pte=X("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 Ite=X("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 Lte=X("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 gS=X("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 Dte=X("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 OM=X("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 Rte=X("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 to=X("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 Ote=X("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 Fte=X("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 zte=X("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 Bte=X("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 $te=X("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 PL=X("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 qte=X("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 Ute=X("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 Vte=X("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 IL=X("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 Hte=X("Rewind",[["polygon",{points:"11 19 2 12 11 5 11 19",key:"14yba5"}],["polygon",{points:"22 19 13 12 22 5 22 19",key:"1pi1cj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gte=X("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 Jy=X("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 Wte=X("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 Kte=X("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 FN=X("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 Zte=X("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 e0=X("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 Yte=X("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 LL=X("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 Xte=X("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 Qte=X("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 Jte=X("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 zN=X("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 BN=X("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 ese=X("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 tse=X("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 yS=X("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 sse=X("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 rse=X("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 nse=X("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 ase=X("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 ise=X("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 ose=X("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 lse=X("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 cse=X("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 wc=X("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 $N=X("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 DL=X("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 dse=X("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 use=X("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 hse=X("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 mse=X("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 pse=X("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 fse=X("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 xse=X("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 gse=X("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 yse=X("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 vse=X("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 _se=X("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 bse=X("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 wse=X("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 jse=X("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 Nse=X("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 kse=X("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 Sse=X("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 Cse=X("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 Mse=X("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 RL=X("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 tn=X("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 Tse=X("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 qN=X("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 Ase=X("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 Nn=X("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ese=X("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 Pse=X("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 Ise=X("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 Lse=X("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 Dse=X("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 Rse=X("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 OL=X("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 So=X("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 Ose=X("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 vd=X("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 FL=X("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 Fse=X("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 zse=X("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 Bse=X("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 $se=X("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 Lb=X("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 qse=X("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 Use=X("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 Vse=X("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 vS=X("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 Hse=X("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 Gse=X("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 UN=X("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 Ru=X("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 Wse=X("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 Kse=X("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 Zse=X("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 t0=X("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 Yse=X("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 ip=X("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 Xse=X("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 Qse=X("ShowerHead",[["path",{d:"m4 4 2.5 2.5",key:"uv2vmf"}],["path",{d:"M13.5 6.5a4.95 4.95 0 0 0-7 7",key:"frdkwv"}],["path",{d:"M15 5 5 15",key:"1ag8rq"}],["path",{d:"M14 17v.01",key:"eokfpp"}],["path",{d:"M10 16v.01",key:"14uyyl"}],["path",{d:"M13 13v.01",key:"1v1k97"}],["path",{d:"M16 10v.01",key:"5169yg"}],["path",{d:"M11 20v.01",key:"cj92p8"}],["path",{d:"M17 14v.01",key:"11cswd"}],["path",{d:"M20 11v.01",key:"19e0od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jse=X("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 ere=X("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 _S=X("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 tre=X("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 sre=X("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 rre=X("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 nre=X("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 are=X("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 ire=X("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 ore=X("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 lre=X("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 cre=X("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 dre=X("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 ure=X("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 hre=X("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 mre=X("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 pre=X("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 fre=X("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 xre=X("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 bS=X("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 VN=X("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 gre=X("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 yre=X("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 s0=X("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 vre=X("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 _re=X("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 bre=X("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 Bv=X("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 wre=X("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 jre=X("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 Nre=X("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 kre=X("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 Sre=X("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 qr=X("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 Cre=X("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 Mre=X("Speech",[["path",{d:"M8.8 20v-4.1l1.9.2a2.3 2.3 0 0 0 2.164-2.1V8.3A5.37 5.37 0 0 0 2 8.25c0 2.8.656 3.054 1 4.55a5.77 5.77 0 0 1 .029 2.758L2 20",key:"11atix"}],["path",{d:"M19.8 17.8a7.5 7.5 0 0 0 .003-10.603",key:"yol142"}],["path",{d:"M17 15a3.5 3.5 0 0 0-.025-4.975",key:"ssbmkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tre=X("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 Are=X("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 Ere=X("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 Pre=X("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 Ire=X("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 wS=X("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 HN=X("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 GN=X("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 WN=X("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 KN=X("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 ZN=X("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 YN=X("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 XN=X("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 QN=X("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 JN=X("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 ek=X("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 tk=X("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 sk=X("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 rk=X("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 nk=X("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 ak=X("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 ky=X("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 Av=X("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 ik=X("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 ok=X("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 lk=X("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 ck=X("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 dk=X("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 uk=X("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 Lre=X("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 Dre=X("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 hk=X("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 mk=X("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 pk=X("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 fk=X("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 xk=X("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 gk=X("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 yk=X("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 vk=X("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 _k=X("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 bk=X("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 wk=X("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 jk=X("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 Nk=X("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 kk=X("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 Sk=X("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 Gc=X("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 Ck=X("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 Mk=X("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 Tk=X("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 Ak=X("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 Ek=X("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 Pk=X("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 Rre=X("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 Ik=X("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 Lk=X("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 Dk=X("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 Rk=X("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 Ok=X("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 Ore=X("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 Fre=X("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 Fk=X("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 zk=X("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 Bk=X("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 $k=X("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 r0=X("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 zre=X("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 Bre=X("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 $re=X("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 qre=X("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 Ure=X("StarOff",[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",key:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gn=X("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 Vre=X("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 Hre=X("StepForward",[["line",{x1:"6",x2:"6",y1:"4",y2:"20",key:"fy8qot"}],["polygon",{points:"10,4 20,12 10,20",key:"1mc1pf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gre=X("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 Wre=X("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 Kre=X("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 Zre=X("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 Yre=X("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 Xre=X("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 zL=X("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 Qre=X("Subscript",[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jre=X("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 ene=X("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 tne=X("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 sne=X("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 t1=X("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 rne=X("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 nne=X("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 ane=X("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 ine=X("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 one=X("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 lne=X("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 cne=X("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 dne=X("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 une=X("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 FM=X("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 hne=X("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 mne=X("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 pne=X("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 fne=X("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 xne=X("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 gne=X("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 zM=X("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 yne=X("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 vne=X("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 _ne=X("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 hh=X("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 bne=X("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 wne=X("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 jne=X("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 Nne=X("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 kne=X("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 Sne=X("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 Cne=X("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 Oh=X("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 Mne=X("Telescope",[["path",{d:"m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44",key:"k4qptu"}],["path",{d:"m13.56 11.747 4.332-.924",key:"19l80z"}],["path",{d:"m16 21-3.105-6.21",key:"7oh9d"}],["path",{d:"M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z",key:"m7xp4m"}],["path",{d:"m6.158 8.633 1.114 4.456",key:"74o979"}],["path",{d:"m8 21 3.105-6.21",key:"1fvxut"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tne=X("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 Ane=X("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 Ene=X("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 qk=X("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 Pne=X("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 Ine=X("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 Lne=X("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 Dne=X("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 Rne=X("TextQuote",[["path",{d:"M17 6H3",key:"16j9eg"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 18H8",key:"1wfozv"}],["path",{d:"M3 12v6",key:"fv4c87"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const One=X("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 Uk=X("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 Fne=X("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 zne=X("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 Bne=X("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 $ne=X("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 qne=X("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 BL=X("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 Ou=X("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 Une=X("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 Vne=X("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 Hne=X("TicketPercent",[["path",{d:"M2 9a3 3 0 1 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 1 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"1l48ns"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gne=X("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 Wne=X("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 Kne=X("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 $L=X("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 Zne=X("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 Yne=X("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 Xne=X("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 Qne=X("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 Jne=X("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 eae=X("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 tae=X("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 sae=X("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 rae=X("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 nae=X("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 aae=X("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 iae=X("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 oae=X("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 lae=X("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 cae=X("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 dae=X("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 uae=X("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 hae=X("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 mae=X("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 Vk=X("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 yr=X("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 pae=X("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 fae=X("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 Hk=X("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 Db=X("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 xae=X("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 gae=X("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 jS=X("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 yae=X("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 Yo=X("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 Qc=X("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 vae=X("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 _ae=X("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 Hi=X("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 qL=X("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 bae=X("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 wae=X("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 Gk=X("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 jae=X("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 Nae=X("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 kae=X("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 Sae=X("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 Cae=X("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 Mae=X("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 Tae=X("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 UL=X("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 Aae=X("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eae=X("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 NS=X("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 Pae=X("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 Iae=X("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 Lae=X("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 Wk=X("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 Dae=X("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 kS=X("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 Rae=X("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 Da=X("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 Oae=X("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 Rb=X("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 VL=X("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 HL=X("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 Fae=X("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 il=X("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 Kk=X("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 Zk=X("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 Yk=X("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 zae=X("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 Xk=X("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 Bae=X("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 Qk=X("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 Jk=X("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 $ae=X("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 qae=X("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 Ei=X("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 e4=X("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 cr=X("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 t4=X("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 s4=X("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 Uae=X("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 BM=X("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 Vae=X("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 Hae=X("Vegan",[["path",{d:"M16 8q6 0 6-6-6 0-6 6",key:"qsyyc4"}],["path",{d:"M17.41 3.59a10 10 0 1 0 3 3",key:"41m9h7"}],["path",{d:"M2 2a26.6 26.6 0 0 1 10 20c.9-6.82 1.5-9.5 4-14",key:"qiv7li"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gae=X("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 Wae=X("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 Kae=X("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 Zae=X("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 hn=X("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 Yae=X("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 Xae=X("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 Qae=X("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 Jae=X("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 eie=X("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 tie=X("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 sie=X("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 rie=X("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 nie=X("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 aie=X("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 iie=X("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 r4=X("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 GL=X("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 oie=X("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 Ev=X("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 lie=X("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 cie=X("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 die=X("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 uie=X("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 hie=X("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 mie=X("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 pie=X("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 fie=X("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 xie=X("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 gie=X("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 yie=X("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 vie=X("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 _ie=X("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 bie=X("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 wie=X("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 jie=X("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 Nie=X("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 kie=X("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 Sie=X("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 Cie=X("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 Mie=X("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 Tie=X("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 Aie=X("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 Eie=X("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 Pie=X("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 Og=X("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 Sr=X("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 Iie=X("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 Lie=X("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 Fh=X("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 Ob=X("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 $M=X("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 Ogt=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:Y9,AArrowUp:X9,ALargeSmall:Q9,Accessibility:J9,Activity:ih,AirVent:eB,Airplay:tB,AlarmClock:rB,AlarmClockCheck:K2,AlarmClockMinus:Z2,AlarmClockOff:sB,AlarmClockPlus:Y2,AlarmSmoke:nB,Album:aB,AlignCenter:G4,AlignCenterHorizontal:iB,AlignCenterVertical:oB,AlignEndHorizontal:lB,AlignEndVertical:cB,AlignHorizontalDistributeCenter:dB,AlignHorizontalDistributeEnd:uB,AlignHorizontalDistributeStart:hB,AlignHorizontalJustifyCenter:mB,AlignHorizontalJustifyEnd:pB,AlignHorizontalJustifyStart:fB,AlignHorizontalSpaceAround:xB,AlignHorizontalSpaceBetween:gB,AlignJustify:yB,AlignLeft:W4,AlignRight:K4,AlignStartHorizontal:vB,AlignStartVertical:_B,AlignVerticalDistributeCenter:bB,AlignVerticalDistributeEnd:wB,AlignVerticalDistributeStart:jB,AlignVerticalJustifyCenter:NB,AlignVerticalJustifyEnd:kB,AlignVerticalJustifyStart:SB,AlignVerticalSpaceAround:CB,AlignVerticalSpaceBetween:MB,Ambulance:TB,Ampersand:AB,Ampersands:EB,Amphora:PB,Anchor:IB,Angry:LB,Annoyed:DB,Antenna:RB,Anvil:OB,Aperture:FB,AppWindow:sL,AppWindowMac:zB,Apple:BB,Archive:_M,ArchiveRestore:rL,ArchiveX:$B,Armchair:qB,ArrowBigDown:VB,ArrowBigDownDash:UB,ArrowBigLeft:GB,ArrowBigLeftDash:HB,ArrowBigRight:KB,ArrowBigRightDash:WB,ArrowBigUp:YB,ArrowBigUpDash:ZB,ArrowDown:Ih,ArrowDown01:XB,ArrowDown10:QB,ArrowDownAZ:X2,ArrowDownFromLine:JB,ArrowDownLeft:e$,ArrowDownNarrowWide:t$,ArrowDownRight:nL,ArrowDownToDot:s$,ArrowDownToLine:r$,ArrowDownUp:n$,ArrowDownWideNarrow:Q2,ArrowDownZA:J2,ArrowLeft:Ra,ArrowLeftFromLine:a$,ArrowLeftRight:i$,ArrowLeftToLine:o$,ArrowRight:ti,ArrowRightFromLine:l$,ArrowRightLeft:Gv,ArrowRightToLine:c$,ArrowUp:cu,ArrowUp01:d$,ArrowUp10:u$,ArrowUpAZ:ej,ArrowUpDown:td,ArrowUpFromDot:h$,ArrowUpFromLine:m$,ArrowUpLeft:p$,ArrowUpNarrowWide:tj,ArrowUpRight:aL,ArrowUpToLine:f$,ArrowUpWideNarrow:x$,ArrowUpZA:sj,ArrowsUpFromLine:g$,Asterisk:y$,AtSign:v$,Atom:_$,AudioLines:b$,AudioWaveform:w$,Award:rc,Axe:j$,Axis3d:rj,Baby:N$,Backpack:k$,Badge:$$,BadgeAlert:S$,BadgeCent:C$,BadgeCheck:nj,BadgeDollarSign:M$,BadgeEuro:T$,BadgeHelp:A$,BadgeIndianRupee:E$,BadgeInfo:P$,BadgeJapaneseYen:I$,BadgeMinus:L$,BadgePercent:D$,BadgePlus:R$,BadgePoundSterling:O$,BadgeRussianRuble:F$,BadgeSwissFranc:z$,BadgeX:B$,BaggageClaim:q$,Ban:iL,Banana:U$,Bandage:V$,Banknote:H$,Barcode:G$,Baseline:W$,Bath:of,Battery:J$,BatteryCharging:K$,BatteryFull:Z$,BatteryLow:Y$,BatteryMedium:X$,BatteryWarning:Q$,Beaker:eq,Bean:sq,BeanOff:tq,Bed:Ky,BedDouble:Z4,BedSingle:rq,Beef:nq,Beer:iq,BeerOff:aq,Bell:Nm,BellDot:oq,BellElectric:lq,BellMinus:cq,BellOff:Wv,BellPlus:dq,BellRing:uq,BetweenHorizontalEnd:aj,BetweenHorizontalStart:ij,BetweenVerticalEnd:hq,BetweenVerticalStart:mq,BicepsFlexed:pq,Bike:fq,Binary:xq,Binoculars:gq,Biohazard:yq,Bird:vq,Bitcoin:_q,Blend:bq,Blinds:wq,Blocks:jq,Bluetooth:Cq,BluetoothConnected:Nq,BluetoothOff:kq,BluetoothSearching:Sq,Bold:Y4,Bolt:Mq,Bomb:Tq,Bone:Aq,Book:Qq,BookA:Eq,BookAudio:Pq,BookCheck:Iq,BookCopy:Lq,BookDashed:oj,BookDown:Dq,BookHeadphones:Rq,BookHeart:Oq,BookImage:Fq,BookKey:zq,BookLock:Bq,BookMarked:$q,BookMinus:qq,BookOpen:oh,BookOpenCheck:Uq,BookOpenText:Vq,BookPlus:Hq,BookText:Gq,BookType:Wq,BookUp:Zq,BookUp2:Kq,BookUser:Yq,BookX:Xq,Bookmark:_x,BookmarkCheck:Jq,BookmarkMinus:eU,BookmarkPlus:oL,BookmarkX:tU,BoomBox:sU,Bot:bM,BotMessageSquare:rU,BotOff:nU,Box:aU,Boxes:iU,Braces:lj,Brackets:oU,Brain:lL,BrainCircuit:lU,BrainCog:cU,BrickWall:dU,Briefcase:Lh,BriefcaseBusiness:uU,BriefcaseConveyorBelt:hU,BriefcaseMedical:mU,BringToFront:pU,Brush:fU,Bug:yU,BugOff:xU,BugPlay:gU,Building:X4,Building2:ma,Bus:_U,BusFront:vU,Cable:wU,CableCar:bU,Cake:lh,CakeSlice:jU,Calculator:wM,Calendar:nn,Calendar1:NU,CalendarArrowDown:kU,CalendarArrowUp:SU,CalendarCheck:cL,CalendarCheck2:CU,CalendarClock:jM,CalendarCog:MU,CalendarDays:xd,CalendarFold:TU,CalendarHeart:AU,CalendarMinus:PU,CalendarMinus2:EU,CalendarOff:dL,CalendarPlus:Cb,CalendarPlus2:IU,CalendarRange:LU,CalendarSearch:DU,CalendarSync:RU,CalendarX:FU,CalendarX2:OU,Camera:bx,CameraOff:zU,Candy:qU,CandyCane:BU,CandyOff:$U,Cannabis:UU,Captions:cj,CaptionsOff:VU,Car:WU,CarFront:HU,CarTaxiFront:GU,Caravan:KU,Carrot:ZU,CaseLower:YU,CaseSensitive:XU,CaseUpper:QU,CassetteTape:JU,Cast:eV,Castle:tV,Cat:sV,Cctv:rV,ChartArea:dj,ChartBar:hj,ChartBarBig:uj,ChartBarDecreasing:nV,ChartBarIncreasing:aV,ChartBarStacked:iV,ChartCandlestick:mj,ChartColumn:so,ChartColumnBig:pj,ChartColumnDecreasing:oV,ChartColumnIncreasing:fj,ChartColumnStacked:lV,ChartGantt:cV,ChartLine:xj,ChartNetwork:dV,ChartNoAxesColumn:yj,ChartNoAxesColumnDecreasing:uV,ChartNoAxesColumnIncreasing:gj,ChartNoAxesCombined:hV,ChartNoAxesGantt:vj,ChartPie:_j,ChartScatter:bj,ChartSpline:mV,Check:ea,CheckCheck:uL,ChefHat:pV,Cherry:fV,ChevronDown:Fi,ChevronFirst:xV,ChevronLast:gV,ChevronLeft:wl,ChevronRight:ja,ChevronUp:lf,ChevronsDown:vV,ChevronsDownUp:yV,ChevronsLeft:wV,ChevronsLeftRight:bV,ChevronsLeftRightEllipsis:_V,ChevronsRight:NV,ChevronsRightLeft:jV,ChevronsUp:kV,ChevronsUpDown:wx,Chrome:SV,Church:CV,Cigarette:TV,CigaretteOff:MV,Circle:sd,CircleAlert:co,CircleArrowDown:wj,CircleArrowLeft:jj,CircleArrowOutDownLeft:Nj,CircleArrowOutDownRight:kj,CircleArrowOutUpLeft:Sj,CircleArrowOutUpRight:Cj,CircleArrowRight:Mj,CircleArrowUp:Tj,CircleCheck:Hn,CircleCheckBig:si,CircleChevronDown:Aj,CircleChevronLeft:Ej,CircleChevronRight:Pj,CircleChevronUp:Ij,CircleDashed:AV,CircleDivide:Lj,CircleDollarSign:EV,CircleDot:IV,CircleDotDashed:PV,CircleEllipsis:LV,CircleEqual:DV,CircleFadingArrowUp:RV,CircleFadingPlus:OV,CircleGauge:Dj,CircleHelp:Sv,CircleMinus:Rj,CircleOff:FV,CircleParking:Fj,CircleParkingOff:Oj,CirclePause:zj,CirclePercent:Bj,CirclePlay:tp,CirclePlus:$j,CirclePower:qj,CircleSlash:zV,CircleSlash2:Uj,CircleStop:Vj,CircleUser:Gj,CircleUserRound:Hj,CircleX:Ql,CircuitBoard:BV,Citrus:$V,Clapperboard:qV,Clipboard:ZV,ClipboardCheck:NM,ClipboardCopy:UV,ClipboardList:Mb,ClipboardMinus:VV,ClipboardPaste:HV,ClipboardPen:Kj,ClipboardPenLine:Wj,ClipboardPlus:GV,ClipboardType:WV,ClipboardX:KV,Clock:rn,Clock1:YV,Clock10:XV,Clock11:QV,Clock12:JV,Clock2:eH,Clock3:tH,Clock4:sH,Clock5:rH,Clock6:nH,Clock7:aH,Clock8:iH,Clock9:oH,ClockAlert:lH,ClockArrowDown:cH,ClockArrowUp:dH,Cloud:kH,CloudAlert:uH,CloudCog:hH,CloudDownload:Zj,CloudDrizzle:mH,CloudFog:pH,CloudHail:fH,CloudLightning:xH,CloudMoon:yH,CloudMoonRain:gH,CloudOff:vH,CloudRain:bH,CloudRainWind:_H,CloudSnow:wH,CloudSun:NH,CloudSunRain:jH,CloudUpload:Yj,Cloudy:SH,Clover:zv,Club:CH,Code:Q4,CodeXml:Xj,Codepen:MH,Codesandbox:TH,Coffee:J4,Cog:AH,Coins:hL,Columns2:Qj,Columns3:Jj,Columns4:EH,Combine:PH,Command:IH,Compass:kM,Component:LH,Computer:DH,ConciergeBell:RH,Cone:OH,Construction:FH,Contact:eS,ContactRound:eN,Container:zH,Contrast:BH,Cookie:$H,CookingPot:qH,Copy:Ya,CopyCheck:UH,CopyMinus:VH,CopyPlus:HH,CopySlash:GH,CopyX:WH,Copyleft:KH,Copyright:ZH,CornerDownLeft:YH,CornerDownRight:XH,CornerLeftDown:QH,CornerLeftUp:JH,CornerRightDown:eG,CornerRightUp:tG,CornerUpLeft:sG,CornerUpRight:rG,Cpu:nG,CreativeCommons:aG,CreditCard:jx,Croissant:iG,Crop:oG,Cross:lG,Crosshair:cG,Crown:km,Cuboid:dG,CupSoda:uG,Currency:hG,Cylinder:mG,Dam:pG,Database:mL,DatabaseBackup:fG,DatabaseZap:xG,Delete:gG,Dessert:yG,Diameter:vG,Diamond:wG,DiamondMinus:_G,DiamondPercent:tN,DiamondPlus:bG,Dice1:jG,Dice2:NG,Dice3:kG,Dice4:SG,Dice5:CG,Dice6:MG,Dices:TG,Diff:AG,Disc:LG,Disc2:EG,Disc3:PG,DiscAlbum:IG,Divide:DG,Dna:OG,DnaOff:RG,Dock:FG,Dog:zG,DollarSign:_c,Donut:BG,DoorClosed:$G,DoorOpen:Kv,Dot:qG,Download:Xa,DraftingCompass:UG,Drama:VG,Dribbble:HG,Drill:GG,Droplet:WG,Droplets:Lg,Drum:KG,Drumstick:ZG,Dumbbell:YG,Ear:QG,EarOff:XG,Earth:sN,EarthLock:JG,Eclipse:eW,Egg:SM,EggFried:tW,EggOff:sW,Ellipsis:dx,EllipsisVertical:cx,Equal:aW,EqualApproximately:rW,EqualNot:nW,Eraser:iW,EthernetPort:oW,Euro:lW,Expand:cW,ExternalLink:Kr,Eye:jn,EyeClosed:dW,EyeOff:hp,Facebook:du,Factory:uW,Fan:hW,FastForward:mW,Feather:pW,Fence:fW,FerrisWheel:xW,Figma:gW,File:CM,FileArchive:yW,FileAudio:_W,FileAudio2:vW,FileAxis3d:rN,FileBadge:wW,FileBadge2:bW,FileBox:jW,FileChartColumn:aN,FileChartColumnIncreasing:nN,FileChartLine:iN,FileChartPie:oN,FileCheck:kW,FileCheck2:NW,FileClock:SW,FileCode:MW,FileCode2:CW,FileCog:lN,FileDiff:TW,FileDigit:AW,FileDown:tS,FileHeart:EW,FileImage:Tb,FileInput:PW,FileJson:LW,FileJson2:IW,FileKey:RW,FileKey2:DW,FileLock:FW,FileLock2:OW,FileMinus:BW,FileMinus2:zW,FileMusic:$W,FileOutput:qW,FilePen:dN,FilePenLine:cN,FilePlus:VW,FilePlus2:UW,FileQuestion:HW,FileScan:GW,FileSearch:KW,FileSearch2:WW,FileSliders:ZW,FileSpreadsheet:Zv,FileStack:pL,FileSymlink:YW,FileTerminal:XW,FileText:mn,FileType:JW,FileType2:QW,FileUp:eK,FileUser:tK,FileVideo:rK,FileVideo2:sK,FileVolume:aK,FileVolume2:nK,FileWarning:iK,FileX:lK,FileX2:oK,Files:cK,Film:Ld,Filter:Dg,FilterX:dK,Fingerprint:uK,FireExtinguisher:hK,Fish:fK,FishOff:mK,FishSymbol:pK,Flag:Yv,FlagOff:xK,FlagTriangleLeft:gK,FlagTriangleRight:yK,Flame:ch,FlameKindling:vK,Flashlight:bK,FlashlightOff:_K,FlaskConical:Ab,FlaskConicalOff:wK,FlaskRound:jK,FlipHorizontal:fL,FlipHorizontal2:NK,FlipVertical:SK,FlipVertical2:kK,Flower:CK,Flower2:Tg,Focus:MK,FoldHorizontal:TK,FoldVertical:AK,Folder:rZ,FolderArchive:EK,FolderCheck:PK,FolderClock:IK,FolderClosed:LK,FolderCode:DK,FolderCog:uN,FolderDot:RK,FolderDown:OK,FolderGit:zK,FolderGit2:FK,FolderHeart:BK,FolderInput:$K,FolderKanban:qK,FolderKey:UK,FolderLock:VK,FolderMinus:HK,FolderOpen:Sm,FolderOpenDot:GK,FolderOutput:WK,FolderPen:hN,FolderPlus:KK,FolderRoot:ZK,FolderSearch:XK,FolderSearch2:YK,FolderSymlink:QK,FolderSync:JK,FolderTree:eZ,FolderUp:tZ,FolderX:sZ,Folders:nZ,Footprints:aZ,Forklift:iZ,Forward:oZ,Frame:lZ,Framer:cZ,Frown:dZ,Fuel:uZ,Fullscreen:hZ,GalleryHorizontal:pZ,GalleryHorizontalEnd:mZ,GalleryThumbnails:fZ,GalleryVertical:gZ,GalleryVerticalEnd:xZ,Gamepad:vZ,Gamepad2:yZ,Gauge:_Z,Gavel:bZ,Gem:wZ,Ghost:sS,Gift:Vi,GitBranch:NZ,GitBranchPlus:jZ,GitCommitHorizontal:mN,GitCommitVertical:kZ,GitCompare:CZ,GitCompareArrows:SZ,GitFork:MZ,GitGraph:TZ,GitMerge:AZ,GitPullRequest:RZ,GitPullRequestArrow:EZ,GitPullRequestClosed:PZ,GitPullRequestCreate:LZ,GitPullRequestCreateArrow:IZ,GitPullRequestDraft:DZ,Github:OZ,Gitlab:FZ,GlassWater:zZ,Glasses:BZ,Globe:gd,GlobeLock:$Z,Goal:qZ,Grab:UZ,GraduationCap:Dh,Grape:VZ,Grid2x2:fN,Grid2x2Check:HZ,Grid2x2Plus:pN,Grid2x2X:GZ,Grid3x3:tx,Grip:KZ,GripHorizontal:WZ,GripVertical:uu,Group:ZZ,Guitar:YZ,Ham:XZ,Hammer:QZ,Hand:xL,HandCoins:JZ,HandHeart:eY,HandHelping:xN,HandMetal:tY,HandPlatter:sY,Handshake:gL,HardDrive:yL,HardDriveDownload:rY,HardDriveUpload:nY,HardHat:aY,Hash:rS,Haze:iY,HdmiPort:oY,Heading:uY,Heading1:MM,Heading2:TM,Heading3:vL,Heading4:lY,Heading5:cY,Heading6:dY,HeadphoneOff:hY,Headphones:mY,Headset:pY,Heart:Za,HeartCrack:fY,HeartHandshake:xY,HeartOff:gY,HeartPulse:yY,Heater:vY,Hexagon:_Y,Highlighter:bY,History:AM,Hop:jY,HopOff:wY,Hospital:NY,Hotel:kY,Hourglass:SY,House:Mn,HousePlug:CY,HousePlus:MY,IceCreamBowl:gN,IceCreamCone:yN,IdCard:TY,Image:Uo,ImageDown:AY,ImageMinus:EY,ImageOff:PY,ImagePlay:IY,ImagePlus:Xv,ImageUp:LY,ImageUpscale:DY,Images:RY,Import:OY,Inbox:FY,IndentDecrease:vN,IndentIncrease:_N,IndianRupee:zY,Infinity:BY,Info:nS,InspectionPanel:$Y,Instagram:hu,Italic:aS,IterationCcw:qY,IterationCw:UY,JapaneseYen:VY,Joystick:HY,Kanban:Zy,Key:mp,KeyRound:iS,KeySquare:GY,Keyboard:ZY,KeyboardMusic:WY,KeyboardOff:KY,Lamp:tX,LampCeiling:YY,LampDesk:XY,LampFloor:QY,LampWallDown:JY,LampWallUp:eX,LandPlot:sX,Landmark:rX,Languages:nX,Laptop:iX,LaptopMinimal:bN,LaptopMinimalCheck:aX,Lasso:lX,LassoSelect:oX,Laugh:cX,Layers:hX,Layers2:dX,Layers3:uX,LayoutDashboard:oS,LayoutGrid:pp,LayoutList:mX,LayoutPanelLeft:pX,LayoutPanelTop:fX,LayoutTemplate:lS,Leaf:xX,LeafyGreen:gX,Lectern:yX,LetterText:vX,Library:cS,LibraryBig:_X,LifeBuoy:EM,Ligature:bX,Lightbulb:Eb,LightbulbOff:wX,Link:go,Link2:Do,Link2Off:jX,Linkedin:fp,List:Rh,ListCheck:NX,ListChecks:kX,ListCollapse:SX,ListEnd:CX,ListFilter:MX,ListMinus:TX,ListMusic:AX,ListOrdered:Yy,ListPlus:EX,ListRestart:PX,ListStart:IX,ListTodo:LX,ListTree:DX,ListVideo:RX,ListX:OX,Loader:zX,LoaderCircle:ps,LoaderPinwheel:FX,Locate:PM,LocateFixed:BX,LocateOff:$X,Lock:yd,LockKeyhole:qX,LockKeyholeOpen:wN,LockOpen:jN,LogIn:dS,LogOut:IM,Logs:UX,Lollipop:VX,Luggage:HX,Magnet:GX,Mail:tr,MailCheck:WX,MailMinus:KX,MailOpen:ZX,MailPlus:_L,MailQuestion:YX,MailSearch:XX,MailWarning:QX,MailX:bL,Mailbox:JX,Mails:eQ,Map:uS,MapPin:La,MapPinCheck:sQ,MapPinCheckInside:tQ,MapPinHouse:rQ,MapPinMinus:aQ,MapPinMinusInside:nQ,MapPinOff:iQ,MapPinPlus:lQ,MapPinPlusInside:oQ,MapPinX:dQ,MapPinXInside:cQ,MapPinned:uQ,Martini:hQ,Maximize:wL,Maximize2:mQ,Medal:Qv,Megaphone:dh,MegaphoneOff:pQ,Meh:fQ,MemoryStick:xQ,Menu:hS,Merge:gQ,MessageCircle:bc,MessageCircleCode:yQ,MessageCircleDashed:vQ,MessageCircleHeart:LM,MessageCircleMore:_Q,MessageCircleOff:bQ,MessageCirclePlus:wQ,MessageCircleQuestion:jL,MessageCircleReply:jQ,MessageCircleWarning:NQ,MessageCircleX:kQ,MessageSquare:Si,MessageSquareCode:SQ,MessageSquareDashed:CQ,MessageSquareDiff:MQ,MessageSquareDot:TQ,MessageSquareHeart:AQ,MessageSquareLock:EQ,MessageSquareMore:NL,MessageSquareOff:PQ,MessageSquarePlus:DM,MessageSquareQuote:kL,MessageSquareReply:IQ,MessageSquareShare:LQ,MessageSquareText:DQ,MessageSquareWarning:RQ,MessageSquareX:OQ,MessagesSquare:FQ,Mic:SL,MicOff:zQ,MicVocal:NN,Microchip:BQ,Microscope:$Q,Microwave:qQ,Milestone:UQ,Milk:HQ,MilkOff:VQ,Minimize:WQ,Minimize2:GQ,Minus:Xy,Monitor:pS,MonitorCheck:KQ,MonitorCog:ZQ,MonitorDot:YQ,MonitorDown:XQ,MonitorOff:QQ,MonitorPause:JQ,MonitorPlay:eJ,MonitorSmartphone:tJ,MonitorSpeaker:sJ,MonitorStop:rJ,MonitorUp:mS,MonitorX:nJ,Moon:iJ,MoonStar:aJ,Mountain:lJ,MountainSnow:oJ,Mouse:hJ,MouseOff:cJ,MousePointer:sh,MousePointer2:dJ,MousePointerBan:uJ,MousePointerClick:Cm,Move:kJ,Move3d:kN,MoveDiagonal:pJ,MoveDiagonal2:mJ,MoveDown:gJ,MoveDownLeft:fJ,MoveDownRight:xJ,MoveHorizontal:yJ,MoveLeft:vJ,MoveRight:_J,MoveUp:jJ,MoveUpLeft:bJ,MoveUpRight:wJ,MoveVertical:NJ,Music:TJ,Music2:SJ,Music3:CJ,Music4:MJ,Navigation:CL,Navigation2:EJ,Navigation2Off:AJ,NavigationOff:PJ,Network:IJ,Newspaper:Jv,Nfc:LJ,Notebook:FJ,NotebookPen:DJ,NotebookTabs:RJ,NotebookText:OJ,NotepadText:BJ,NotepadTextDashed:zJ,Nut:qJ,NutOff:$J,Octagon:VJ,OctagonAlert:Cv,OctagonMinus:UJ,OctagonPause:SN,OctagonX:CN,Omega:HJ,Option:GJ,Orbit:WJ,Origami:KJ,Package:al,Package2:ZJ,PackageCheck:YJ,PackageMinus:XJ,PackageOpen:QJ,PackagePlus:JJ,PackageSearch:eee,PackageX:tee,PaintBucket:see,PaintRoller:ree,Paintbrush:nee,PaintbrushVertical:MN,Palette:Rl,PanelBottom:oee,PanelBottomClose:aee,PanelBottomDashed:TN,PanelBottomOpen:iee,PanelLeft:IN,PanelLeftClose:AN,PanelLeftDashed:EN,PanelLeftOpen:PN,PanelRight:dee,PanelRightClose:lee,PanelRightDashed:LN,PanelRightOpen:cee,PanelTop:mee,PanelTopClose:uee,PanelTopDashed:DN,PanelTopOpen:hee,PanelsLeftBottom:pee,PanelsRightBottom:fee,PanelsTopLeft:Mv,Paperclip:fS,Parentheses:xee,ParkingMeter:gee,PartyPopper:Bd,Pause:uh,PawPrint:yee,PcCase:vee,Pen:Ry,PenLine:Tv,PenOff:_ee,PenTool:Pb,Pencil:pa,PencilLine:bee,PencilOff:wee,PencilRuler:jee,Pentagon:Nee,Percent:RM,PersonStanding:kee,PhilippinePeso:See,Phone:Tn,PhoneCall:Cee,PhoneForwarded:Mee,PhoneIncoming:Tee,PhoneMissed:Aee,PhoneOff:Eee,PhoneOutgoing:Pee,Pi:Iee,Piano:Lee,Pickaxe:Dee,PictureInPicture:Oee,PictureInPicture2:Ree,PiggyBank:Fee,Pilcrow:$ee,PilcrowLeft:zee,PilcrowRight:Bee,Pill:Uee,PillBottle:qee,Pin:Ib,PinOff:ML,Pipette:Vee,Pizza:Hee,Plane:Kee,PlaneLanding:Gee,PlaneTakeoff:Wee,Play:Co,Plug:TL,Plug2:Zee,PlugZap:RN,Plus:Bs,Pocket:Xee,PocketKnife:Yee,Podcast:Qee,Pointer:ete,PointerOff:Jee,Popcorn:tte,Popsicle:ste,PoundSterling:rte,Power:AL,PowerOff:nte,Presentation:Rg,Printer:EL,PrinterCheck:ate,Projector:ite,Proportions:ote,Puzzle:lte,Pyramid:cte,QrCode:Qy,Quote:xS,Rabbit:dte,Radar:ute,Radiation:hte,Radical:mte,Radio:e1,RadioReceiver:pte,RadioTower:fte,Radius:xte,RailSymbol:gte,Rainbow:yte,Rat:vte,Ratio:_te,Receipt:Tte,ReceiptCent:bte,ReceiptEuro:wte,ReceiptIndianRupee:jte,ReceiptJapaneseYen:Nte,ReceiptPoundSterling:kte,ReceiptRussianRuble:Ste,ReceiptSwissFranc:Cte,ReceiptText:Mte,RectangleEllipsis:ON,RectangleHorizontal:Ate,RectangleVertical:Ete,Recycle:Pte,Redo:gS,Redo2:Ite,RedoDot:Lte,RefreshCcw:OM,RefreshCcwDot:Dte,RefreshCw:to,RefreshCwOff:Rte,Refrigerator:Ote,Regex:Fte,RemoveFormatting:zte,Repeat:PL,Repeat1:Bte,Repeat2:$te,Replace:Ute,ReplaceAll:qte,Reply:IL,ReplyAll:Vte,Rewind:Hte,Ribbon:Gte,Rocket:Jy,RockingChair:Wte,RollerCoaster:Kte,Rotate3d:FN,RotateCcw:e0,RotateCcwSquare:Zte,RotateCw:LL,RotateCwSquare:Yte,Route:Qte,RouteOff:Xte,Router:Jte,Rows2:zN,Rows3:BN,Rows4:ese,Rss:tse,Ruler:yS,RussianRuble:sse,Sailboat:rse,Salad:nse,Sandwich:ase,Satellite:ose,SatelliteDish:ise,Save:wc,SaveAll:lse,SaveOff:cse,Scale:DL,Scale3d:$N,Scaling:dse,Scan:yse,ScanBarcode:use,ScanEye:hse,ScanFace:mse,ScanLine:pse,ScanQrCode:fse,ScanSearch:xse,ScanText:gse,School:vse,Scissors:bse,ScissorsLineDashed:_se,ScreenShare:jse,ScreenShareOff:wse,Scroll:kse,ScrollText:Nse,Search:tn,SearchCheck:Sse,SearchCode:Cse,SearchSlash:Mse,SearchX:RL,Section:Tse,Send:Nn,SendHorizontal:qN,SendToBack:Ase,SeparatorHorizontal:Ese,SeparatorVertical:Pse,Server:Rse,ServerCog:Ise,ServerCrash:Lse,ServerOff:Dse,Settings:So,Settings2:OL,Shapes:Ose,Share:FL,Share2:vd,Sheet:Fse,Shell:zse,Shield:Ru,ShieldAlert:Bse,ShieldBan:$se,ShieldCheck:Lb,ShieldEllipsis:qse,ShieldHalf:Use,ShieldMinus:Vse,ShieldOff:vS,ShieldPlus:Hse,ShieldQuestion:Gse,ShieldX:UN,Ship:Kse,ShipWheel:Wse,Shirt:Zse,ShoppingBag:t0,ShoppingBasket:Yse,ShoppingCart:ip,Shovel:Xse,ShowerHead:Qse,Shrink:Jse,Shrub:ere,Shuffle:_S,Sigma:tre,Signal:ire,SignalHigh:sre,SignalLow:rre,SignalMedium:nre,SignalZero:are,Signature:ore,Signpost:cre,SignpostBig:lre,Siren:dre,SkipBack:ure,SkipForward:hre,Skull:mre,Slack:pre,Slash:fre,Slice:xre,SlidersHorizontal:bS,SlidersVertical:VN,Smartphone:s0,SmartphoneCharging:gre,SmartphoneNfc:yre,Smile:_re,SmilePlus:vre,Snail:bre,Snowflake:Bv,Sofa:wre,Soup:jre,Space:Nre,Spade:kre,Sparkle:Sre,Sparkles:qr,Speaker:Cre,Speech:Mre,SpellCheck:Are,SpellCheck2:Tre,Spline:Ere,Split:Pre,SprayCan:Ire,Sprout:wS,Square:r0,SquareActivity:HN,SquareArrowDown:KN,SquareArrowDownLeft:GN,SquareArrowDownRight:WN,SquareArrowLeft:ZN,SquareArrowOutDownLeft:YN,SquareArrowOutDownRight:XN,SquareArrowOutUpLeft:QN,SquareArrowOutUpRight:JN,SquareArrowRight:ek,SquareArrowUp:rk,SquareArrowUpLeft:tk,SquareArrowUpRight:sk,SquareAsterisk:nk,SquareBottomDashedScissors:ak,SquareChartGantt:ky,SquareCheck:ik,SquareCheckBig:Av,SquareChevronDown:ok,SquareChevronLeft:lk,SquareChevronRight:ck,SquareChevronUp:dk,SquareCode:uk,SquareDashed:pk,SquareDashedBottom:Dre,SquareDashedBottomCode:Lre,SquareDashedKanban:hk,SquareDashedMousePointer:mk,SquareDivide:fk,SquareDot:xk,SquareEqual:gk,SquareFunction:yk,SquareKanban:vk,SquareLibrary:_k,SquareM:bk,SquareMenu:wk,SquareMinus:jk,SquareMousePointer:Nk,SquareParking:Sk,SquareParkingOff:kk,SquarePen:Gc,SquarePercent:Ck,SquarePi:Mk,SquarePilcrow:Tk,SquarePlay:Ak,SquarePlus:Ek,SquarePower:Pk,SquareRadical:Rre,SquareScissors:Ik,SquareSigma:Lk,SquareSlash:Dk,SquareSplitHorizontal:Rk,SquareSplitVertical:Ok,SquareSquare:Ore,SquareStack:Fre,SquareTerminal:Fk,SquareUser:Bk,SquareUserRound:zk,SquareX:$k,Squircle:zre,Squirrel:Bre,Stamp:$re,Star:Gn,StarHalf:qre,StarOff:Ure,StepBack:Vre,StepForward:Hre,Stethoscope:Gre,Sticker:Wre,StickyNote:Kre,Store:Zre,StretchHorizontal:Yre,StretchVertical:Xre,Strikethrough:zL,Subscript:Qre,Sun:t1,SunDim:Jre,SunMedium:ene,SunMoon:tne,SunSnow:sne,Sunrise:rne,Sunset:nne,Superscript:ane,SwatchBook:ine,SwissFranc:one,SwitchCamera:lne,Sword:cne,Swords:dne,Syringe:une,Table:zM,Table2:FM,TableCellsMerge:hne,TableCellsSplit:mne,TableColumnsSplit:pne,TableOfContents:fne,TableProperties:xne,TableRowsSplit:gne,Tablet:vne,TabletSmartphone:yne,Tablets:_ne,Tag:hh,Tags:bne,Tally1:wne,Tally2:jne,Tally3:Nne,Tally4:kne,Tally5:Sne,Tangent:Cne,Target:Oh,Telescope:Mne,Tent:Ane,TentTree:Tne,Terminal:Ene,TestTube:Pne,TestTubeDiagonal:qk,TestTubes:Ine,Text:Fne,TextCursor:Dne,TextCursorInput:Lne,TextQuote:Rne,TextSearch:One,TextSelect:Uk,Theater:zne,Thermometer:qne,ThermometerSnowflake:Bne,ThermometerSun:$ne,ThumbsDown:BL,ThumbsUp:Ou,Ticket:$L,TicketCheck:Une,TicketMinus:Vne,TicketPercent:Hne,TicketPlus:Gne,TicketSlash:Wne,TicketX:Kne,Tickets:Yne,TicketsPlane:Zne,Timer:Jne,TimerOff:Xne,TimerReset:Qne,ToggleLeft:eae,ToggleRight:tae,Toilet:sae,Tornado:rae,Torus:nae,Touchpad:iae,TouchpadOff:aae,TowerControl:oae,ToyBrick:lae,Tractor:cae,TrafficCone:dae,TrainFront:hae,TrainFrontTunnel:uae,TrainTrack:mae,TramFront:Vk,Trash:pae,Trash2:yr,TreeDeciduous:fae,TreePalm:Hk,TreePine:Db,Trees:xae,Trello:gae,TrendingDown:jS,TrendingUp:Yo,TrendingUpDown:yae,Triangle:_ae,TriangleAlert:Qc,TriangleRight:vae,Trophy:Hi,Truck:qL,Turtle:bae,Tv:jae,TvMinimal:Gk,TvMinimalPlay:wae,Twitch:Nae,Twitter:kae,Type:Cae,TypeOutline:Sae,Umbrella:Tae,UmbrellaOff:Mae,Underline:UL,Undo:NS,Undo2:Aae,UndoDot:Eae,UnfoldHorizontal:Pae,UnfoldVertical:Iae,Ungroup:Lae,University:Wk,Unlink:kS,Unlink2:Dae,Unplug:Rae,Upload:Da,Usb:Oae,User:Ei,UserCheck:Rb,UserCog:VL,UserMinus:HL,UserPen:Fae,UserPlus:il,UserRound:Jk,UserRoundCheck:Kk,UserRoundCog:Zk,UserRoundMinus:Yk,UserRoundPen:zae,UserRoundPlus:Xk,UserRoundSearch:Bae,UserRoundX:Qk,UserSearch:$ae,UserX:qae,Users:cr,UsersRound:e4,Utensils:s4,UtensilsCrossed:t4,UtilityPole:Uae,Variable:BM,Vault:Vae,Vegan:Hae,VenetianMask:Gae,Vibrate:Kae,VibrateOff:Wae,Video:hn,VideoOff:Zae,Videotape:Yae,View:Xae,Voicemail:Qae,Volleyball:Jae,Volume:nie,Volume1:eie,Volume2:tie,VolumeOff:sie,VolumeX:rie,Vote:aie,Wallet:GL,WalletCards:iie,WalletMinimal:r4,Wallpaper:oie,Wand:lie,WandSparkles:Ev,Warehouse:cie,WashingMachine:die,Watch:uie,Waves:hie,Waypoints:mie,Webcam:pie,Webhook:xie,WebhookOff:fie,Weight:gie,Wheat:vie,WheatOff:yie,WholeWord:_ie,Wifi:kie,WifiHigh:bie,WifiLow:wie,WifiOff:jie,WifiZero:Nie,Wind:Cie,WindArrowDown:Sie,Wine:Tie,WineOff:Mie,Workflow:Aie,Worm:Eie,WrapText:Pie,Wrench:Og,X:Sr,Youtube:Iie,Zap:Fh,ZapOff:Lie,ZoomIn:Ob,ZoomOut:$M},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 lje=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:Y9,AArrowDownIcon:Y9,AArrowUp:X9,AArrowUpIcon:X9,ALargeSmall:Q9,ALargeSmallIcon:Q9,Accessibility:J9,AccessibilityIcon:J9,Activity:ih,ActivityIcon:ih,ActivitySquare:HN,ActivitySquareIcon:HN,AirVent:eB,AirVentIcon:eB,Airplay:tB,AirplayIcon:tB,AlarmCheck:K2,AlarmCheckIcon:K2,AlarmClock:rB,AlarmClockCheck:K2,AlarmClockCheckIcon:K2,AlarmClockIcon:rB,AlarmClockMinus:Z2,AlarmClockMinusIcon:Z2,AlarmClockOff:sB,AlarmClockOffIcon:sB,AlarmClockPlus:Y2,AlarmClockPlusIcon:Y2,AlarmMinus:Z2,AlarmMinusIcon:Z2,AlarmPlus:Y2,AlarmPlusIcon:Y2,AlarmSmoke:nB,AlarmSmokeIcon:nB,Album:aB,AlbumIcon:aB,AlertCircle:co,AlertCircleIcon:co,AlertOctagon:Cv,AlertOctagonIcon:Cv,AlertTriangle:Qc,AlertTriangleIcon:Qc,AlignCenter:G4,AlignCenterHorizontal:iB,AlignCenterHorizontalIcon:iB,AlignCenterIcon:G4,AlignCenterVertical:oB,AlignCenterVerticalIcon:oB,AlignEndHorizontal:lB,AlignEndHorizontalIcon:lB,AlignEndVertical:cB,AlignEndVerticalIcon:cB,AlignHorizontalDistributeCenter:dB,AlignHorizontalDistributeCenterIcon:dB,AlignHorizontalDistributeEnd:uB,AlignHorizontalDistributeEndIcon:uB,AlignHorizontalDistributeStart:hB,AlignHorizontalDistributeStartIcon:hB,AlignHorizontalJustifyCenter:mB,AlignHorizontalJustifyCenterIcon:mB,AlignHorizontalJustifyEnd:pB,AlignHorizontalJustifyEndIcon:pB,AlignHorizontalJustifyStart:fB,AlignHorizontalJustifyStartIcon:fB,AlignHorizontalSpaceAround:xB,AlignHorizontalSpaceAroundIcon:xB,AlignHorizontalSpaceBetween:gB,AlignHorizontalSpaceBetweenIcon:gB,AlignJustify:yB,AlignJustifyIcon:yB,AlignLeft:W4,AlignLeftIcon:W4,AlignRight:K4,AlignRightIcon:K4,AlignStartHorizontal:vB,AlignStartHorizontalIcon:vB,AlignStartVertical:_B,AlignStartVerticalIcon:_B,AlignVerticalDistributeCenter:bB,AlignVerticalDistributeCenterIcon:bB,AlignVerticalDistributeEnd:wB,AlignVerticalDistributeEndIcon:wB,AlignVerticalDistributeStart:jB,AlignVerticalDistributeStartIcon:jB,AlignVerticalJustifyCenter:NB,AlignVerticalJustifyCenterIcon:NB,AlignVerticalJustifyEnd:kB,AlignVerticalJustifyEndIcon:kB,AlignVerticalJustifyStart:SB,AlignVerticalJustifyStartIcon:SB,AlignVerticalSpaceAround:CB,AlignVerticalSpaceAroundIcon:CB,AlignVerticalSpaceBetween:MB,AlignVerticalSpaceBetweenIcon:MB,Ambulance:TB,AmbulanceIcon:TB,Ampersand:AB,AmpersandIcon:AB,Ampersands:EB,AmpersandsIcon:EB,Amphora:PB,AmphoraIcon:PB,Anchor:IB,AnchorIcon:IB,Angry:LB,AngryIcon:LB,Annoyed:DB,AnnoyedIcon:DB,Antenna:RB,AntennaIcon:RB,Anvil:OB,AnvilIcon:OB,Aperture:FB,ApertureIcon:FB,AppWindow:sL,AppWindowIcon:sL,AppWindowMac:zB,AppWindowMacIcon:zB,Apple:BB,AppleIcon:BB,Archive:_M,ArchiveIcon:_M,ArchiveRestore:rL,ArchiveRestoreIcon:rL,ArchiveX:$B,ArchiveXIcon:$B,AreaChart:dj,AreaChartIcon:dj,Armchair:qB,ArmchairIcon:qB,ArrowBigDown:VB,ArrowBigDownDash:UB,ArrowBigDownDashIcon:UB,ArrowBigDownIcon:VB,ArrowBigLeft:GB,ArrowBigLeftDash:HB,ArrowBigLeftDashIcon:HB,ArrowBigLeftIcon:GB,ArrowBigRight:KB,ArrowBigRightDash:WB,ArrowBigRightDashIcon:WB,ArrowBigRightIcon:KB,ArrowBigUp:YB,ArrowBigUpDash:ZB,ArrowBigUpDashIcon:ZB,ArrowBigUpIcon:YB,ArrowDown:Ih,ArrowDown01:XB,ArrowDown01Icon:XB,ArrowDown10:QB,ArrowDown10Icon:QB,ArrowDownAZ:X2,ArrowDownAZIcon:X2,ArrowDownAz:X2,ArrowDownAzIcon:X2,ArrowDownCircle:wj,ArrowDownCircleIcon:wj,ArrowDownFromLine:JB,ArrowDownFromLineIcon:JB,ArrowDownIcon:Ih,ArrowDownLeft:e$,ArrowDownLeftFromCircle:Nj,ArrowDownLeftFromCircleIcon:Nj,ArrowDownLeftFromSquare:YN,ArrowDownLeftFromSquareIcon:YN,ArrowDownLeftIcon:e$,ArrowDownLeftSquare:GN,ArrowDownLeftSquareIcon:GN,ArrowDownNarrowWide:t$,ArrowDownNarrowWideIcon:t$,ArrowDownRight:nL,ArrowDownRightFromCircle:kj,ArrowDownRightFromCircleIcon:kj,ArrowDownRightFromSquare:XN,ArrowDownRightFromSquareIcon:XN,ArrowDownRightIcon:nL,ArrowDownRightSquare:WN,ArrowDownRightSquareIcon:WN,ArrowDownSquare:KN,ArrowDownSquareIcon:KN,ArrowDownToDot:s$,ArrowDownToDotIcon:s$,ArrowDownToLine:r$,ArrowDownToLineIcon:r$,ArrowDownUp:n$,ArrowDownUpIcon:n$,ArrowDownWideNarrow:Q2,ArrowDownWideNarrowIcon:Q2,ArrowDownZA:J2,ArrowDownZAIcon:J2,ArrowDownZa:J2,ArrowDownZaIcon:J2,ArrowLeft:Ra,ArrowLeftCircle:jj,ArrowLeftCircleIcon:jj,ArrowLeftFromLine:a$,ArrowLeftFromLineIcon:a$,ArrowLeftIcon:Ra,ArrowLeftRight:i$,ArrowLeftRightIcon:i$,ArrowLeftSquare:ZN,ArrowLeftSquareIcon:ZN,ArrowLeftToLine:o$,ArrowLeftToLineIcon:o$,ArrowRight:ti,ArrowRightCircle:Mj,ArrowRightCircleIcon:Mj,ArrowRightFromLine:l$,ArrowRightFromLineIcon:l$,ArrowRightIcon:ti,ArrowRightLeft:Gv,ArrowRightLeftIcon:Gv,ArrowRightSquare:ek,ArrowRightSquareIcon:ek,ArrowRightToLine:c$,ArrowRightToLineIcon:c$,ArrowUp:cu,ArrowUp01:d$,ArrowUp01Icon:d$,ArrowUp10:u$,ArrowUp10Icon:u$,ArrowUpAZ:ej,ArrowUpAZIcon:ej,ArrowUpAz:ej,ArrowUpAzIcon:ej,ArrowUpCircle:Tj,ArrowUpCircleIcon:Tj,ArrowUpDown:td,ArrowUpDownIcon:td,ArrowUpFromDot:h$,ArrowUpFromDotIcon:h$,ArrowUpFromLine:m$,ArrowUpFromLineIcon:m$,ArrowUpIcon:cu,ArrowUpLeft:p$,ArrowUpLeftFromCircle:Sj,ArrowUpLeftFromCircleIcon:Sj,ArrowUpLeftFromSquare:QN,ArrowUpLeftFromSquareIcon:QN,ArrowUpLeftIcon:p$,ArrowUpLeftSquare:tk,ArrowUpLeftSquareIcon:tk,ArrowUpNarrowWide:tj,ArrowUpNarrowWideIcon:tj,ArrowUpRight:aL,ArrowUpRightFromCircle:Cj,ArrowUpRightFromCircleIcon:Cj,ArrowUpRightFromSquare:JN,ArrowUpRightFromSquareIcon:JN,ArrowUpRightIcon:aL,ArrowUpRightSquare:sk,ArrowUpRightSquareIcon:sk,ArrowUpSquare:rk,ArrowUpSquareIcon:rk,ArrowUpToLine:f$,ArrowUpToLineIcon:f$,ArrowUpWideNarrow:x$,ArrowUpWideNarrowIcon:x$,ArrowUpZA:sj,ArrowUpZAIcon:sj,ArrowUpZa:sj,ArrowUpZaIcon:sj,ArrowsUpFromLine:g$,ArrowsUpFromLineIcon:g$,Asterisk:y$,AsteriskIcon:y$,AsteriskSquare:nk,AsteriskSquareIcon:nk,AtSign:v$,AtSignIcon:v$,Atom:_$,AtomIcon:_$,AudioLines:b$,AudioLinesIcon:b$,AudioWaveform:w$,AudioWaveformIcon:w$,Award:rc,AwardIcon:rc,Axe:j$,AxeIcon:j$,Axis3D:rj,Axis3DIcon:rj,Axis3d:rj,Axis3dIcon:rj,Baby:N$,BabyIcon:N$,Backpack:k$,BackpackIcon:k$,Badge:$$,BadgeAlert:S$,BadgeAlertIcon:S$,BadgeCent:C$,BadgeCentIcon:C$,BadgeCheck:nj,BadgeCheckIcon:nj,BadgeDollarSign:M$,BadgeDollarSignIcon:M$,BadgeEuro:T$,BadgeEuroIcon:T$,BadgeHelp:A$,BadgeHelpIcon:A$,BadgeIcon:$$,BadgeIndianRupee:E$,BadgeIndianRupeeIcon:E$,BadgeInfo:P$,BadgeInfoIcon:P$,BadgeJapaneseYen:I$,BadgeJapaneseYenIcon:I$,BadgeMinus:L$,BadgeMinusIcon:L$,BadgePercent:D$,BadgePercentIcon:D$,BadgePlus:R$,BadgePlusIcon:R$,BadgePoundSterling:O$,BadgePoundSterlingIcon:O$,BadgeRussianRuble:F$,BadgeRussianRubleIcon:F$,BadgeSwissFranc:z$,BadgeSwissFrancIcon:z$,BadgeX:B$,BadgeXIcon:B$,BaggageClaim:q$,BaggageClaimIcon:q$,Ban:iL,BanIcon:iL,Banana:U$,BananaIcon:U$,Bandage:V$,BandageIcon:V$,Banknote:H$,BanknoteIcon:H$,BarChart:gj,BarChart2:yj,BarChart2Icon:yj,BarChart3:so,BarChart3Icon:so,BarChart4:fj,BarChart4Icon:fj,BarChartBig:pj,BarChartBigIcon:pj,BarChartHorizontal:hj,BarChartHorizontalBig:uj,BarChartHorizontalBigIcon:uj,BarChartHorizontalIcon:hj,BarChartIcon:gj,Barcode:G$,BarcodeIcon:G$,Baseline:W$,BaselineIcon:W$,Bath:of,BathIcon:of,Battery:J$,BatteryCharging:K$,BatteryChargingIcon:K$,BatteryFull:Z$,BatteryFullIcon:Z$,BatteryIcon:J$,BatteryLow:Y$,BatteryLowIcon:Y$,BatteryMedium:X$,BatteryMediumIcon:X$,BatteryWarning:Q$,BatteryWarningIcon:Q$,Beaker:eq,BeakerIcon:eq,Bean:sq,BeanIcon:sq,BeanOff:tq,BeanOffIcon:tq,Bed:Ky,BedDouble:Z4,BedDoubleIcon:Z4,BedIcon:Ky,BedSingle:rq,BedSingleIcon:rq,Beef:nq,BeefIcon:nq,Beer:iq,BeerIcon:iq,BeerOff:aq,BeerOffIcon:aq,Bell:Nm,BellDot:oq,BellDotIcon:oq,BellElectric:lq,BellElectricIcon:lq,BellIcon:Nm,BellMinus:cq,BellMinusIcon:cq,BellOff:Wv,BellOffIcon:Wv,BellPlus:dq,BellPlusIcon:dq,BellRing:uq,BellRingIcon:uq,BetweenHorizonalEnd:aj,BetweenHorizonalEndIcon:aj,BetweenHorizonalStart:ij,BetweenHorizonalStartIcon:ij,BetweenHorizontalEnd:aj,BetweenHorizontalEndIcon:aj,BetweenHorizontalStart:ij,BetweenHorizontalStartIcon:ij,BetweenVerticalEnd:hq,BetweenVerticalEndIcon:hq,BetweenVerticalStart:mq,BetweenVerticalStartIcon:mq,BicepsFlexed:pq,BicepsFlexedIcon:pq,Bike:fq,BikeIcon:fq,Binary:xq,BinaryIcon:xq,Binoculars:gq,BinocularsIcon:gq,Biohazard:yq,BiohazardIcon:yq,Bird:vq,BirdIcon:vq,Bitcoin:_q,BitcoinIcon:_q,Blend:bq,BlendIcon:bq,Blinds:wq,BlindsIcon:wq,Blocks:jq,BlocksIcon:jq,Bluetooth:Cq,BluetoothConnected:Nq,BluetoothConnectedIcon:Nq,BluetoothIcon:Cq,BluetoothOff:kq,BluetoothOffIcon:kq,BluetoothSearching:Sq,BluetoothSearchingIcon:Sq,Bold:Y4,BoldIcon:Y4,Bolt:Mq,BoltIcon:Mq,Bomb:Tq,BombIcon:Tq,Bone:Aq,BoneIcon:Aq,Book:Qq,BookA:Eq,BookAIcon:Eq,BookAudio:Pq,BookAudioIcon:Pq,BookCheck:Iq,BookCheckIcon:Iq,BookCopy:Lq,BookCopyIcon:Lq,BookDashed:oj,BookDashedIcon:oj,BookDown:Dq,BookDownIcon:Dq,BookHeadphones:Rq,BookHeadphonesIcon:Rq,BookHeart:Oq,BookHeartIcon:Oq,BookIcon:Qq,BookImage:Fq,BookImageIcon:Fq,BookKey:zq,BookKeyIcon:zq,BookLock:Bq,BookLockIcon:Bq,BookMarked:$q,BookMarkedIcon:$q,BookMinus:qq,BookMinusIcon:qq,BookOpen:oh,BookOpenCheck:Uq,BookOpenCheckIcon:Uq,BookOpenIcon:oh,BookOpenText:Vq,BookOpenTextIcon:Vq,BookPlus:Hq,BookPlusIcon:Hq,BookTemplate:oj,BookTemplateIcon:oj,BookText:Gq,BookTextIcon:Gq,BookType:Wq,BookTypeIcon:Wq,BookUp:Zq,BookUp2:Kq,BookUp2Icon:Kq,BookUpIcon:Zq,BookUser:Yq,BookUserIcon:Yq,BookX:Xq,BookXIcon:Xq,Bookmark:_x,BookmarkCheck:Jq,BookmarkCheckIcon:Jq,BookmarkIcon:_x,BookmarkMinus:eU,BookmarkMinusIcon:eU,BookmarkPlus:oL,BookmarkPlusIcon:oL,BookmarkX:tU,BookmarkXIcon:tU,BoomBox:sU,BoomBoxIcon:sU,Bot:bM,BotIcon:bM,BotMessageSquare:rU,BotMessageSquareIcon:rU,BotOff:nU,BotOffIcon:nU,Box:aU,BoxIcon:aU,BoxSelect:pk,BoxSelectIcon:pk,Boxes:iU,BoxesIcon:iU,Braces:lj,BracesIcon:lj,Brackets:oU,BracketsIcon:oU,Brain:lL,BrainCircuit:lU,BrainCircuitIcon:lU,BrainCog:cU,BrainCogIcon:cU,BrainIcon:lL,BrickWall:dU,BrickWallIcon:dU,Briefcase:Lh,BriefcaseBusiness:uU,BriefcaseBusinessIcon:uU,BriefcaseConveyorBelt:hU,BriefcaseConveyorBeltIcon:hU,BriefcaseIcon:Lh,BriefcaseMedical:mU,BriefcaseMedicalIcon:mU,BringToFront:pU,BringToFrontIcon:pU,Brush:fU,BrushIcon:fU,Bug:yU,BugIcon:yU,BugOff:xU,BugOffIcon:xU,BugPlay:gU,BugPlayIcon:gU,Building:X4,Building2:ma,Building2Icon:ma,BuildingIcon:X4,Bus:_U,BusFront:vU,BusFrontIcon:vU,BusIcon:_U,Cable:wU,CableCar:bU,CableCarIcon:bU,CableIcon:wU,Cake:lh,CakeIcon:lh,CakeSlice:jU,CakeSliceIcon:jU,Calculator:wM,CalculatorIcon:wM,Calendar:nn,Calendar1:NU,Calendar1Icon:NU,CalendarArrowDown:kU,CalendarArrowDownIcon:kU,CalendarArrowUp:SU,CalendarArrowUpIcon:SU,CalendarCheck:cL,CalendarCheck2:CU,CalendarCheck2Icon:CU,CalendarCheckIcon:cL,CalendarClock:jM,CalendarClockIcon:jM,CalendarCog:MU,CalendarCogIcon:MU,CalendarDays:xd,CalendarDaysIcon:xd,CalendarFold:TU,CalendarFoldIcon:TU,CalendarHeart:AU,CalendarHeartIcon:AU,CalendarIcon:nn,CalendarMinus:PU,CalendarMinus2:EU,CalendarMinus2Icon:EU,CalendarMinusIcon:PU,CalendarOff:dL,CalendarOffIcon:dL,CalendarPlus:Cb,CalendarPlus2:IU,CalendarPlus2Icon:IU,CalendarPlusIcon:Cb,CalendarRange:LU,CalendarRangeIcon:LU,CalendarSearch:DU,CalendarSearchIcon:DU,CalendarSync:RU,CalendarSyncIcon:RU,CalendarX:FU,CalendarX2:OU,CalendarX2Icon:OU,CalendarXIcon:FU,Camera:bx,CameraIcon:bx,CameraOff:zU,CameraOffIcon:zU,CandlestickChart:mj,CandlestickChartIcon:mj,Candy:qU,CandyCane:BU,CandyCaneIcon:BU,CandyIcon:qU,CandyOff:$U,CandyOffIcon:$U,Cannabis:UU,CannabisIcon:UU,Captions:cj,CaptionsIcon:cj,CaptionsOff:VU,CaptionsOffIcon:VU,Car:WU,CarFront:HU,CarFrontIcon:HU,CarIcon:WU,CarTaxiFront:GU,CarTaxiFrontIcon:GU,Caravan:KU,CaravanIcon:KU,Carrot:ZU,CarrotIcon:ZU,CaseLower:YU,CaseLowerIcon:YU,CaseSensitive:XU,CaseSensitiveIcon:XU,CaseUpper:QU,CaseUpperIcon:QU,CassetteTape:JU,CassetteTapeIcon:JU,Cast:eV,CastIcon:eV,Castle:tV,CastleIcon:tV,Cat:sV,CatIcon:sV,Cctv:rV,CctvIcon:rV,ChartArea:dj,ChartAreaIcon:dj,ChartBar:hj,ChartBarBig:uj,ChartBarBigIcon:uj,ChartBarDecreasing:nV,ChartBarDecreasingIcon:nV,ChartBarIcon:hj,ChartBarIncreasing:aV,ChartBarIncreasingIcon:aV,ChartBarStacked:iV,ChartBarStackedIcon:iV,ChartCandlestick:mj,ChartCandlestickIcon:mj,ChartColumn:so,ChartColumnBig:pj,ChartColumnBigIcon:pj,ChartColumnDecreasing:oV,ChartColumnDecreasingIcon:oV,ChartColumnIcon:so,ChartColumnIncreasing:fj,ChartColumnIncreasingIcon:fj,ChartColumnStacked:lV,ChartColumnStackedIcon:lV,ChartGantt:cV,ChartGanttIcon:cV,ChartLine:xj,ChartLineIcon:xj,ChartNetwork:dV,ChartNetworkIcon:dV,ChartNoAxesColumn:yj,ChartNoAxesColumnDecreasing:uV,ChartNoAxesColumnDecreasingIcon:uV,ChartNoAxesColumnIcon:yj,ChartNoAxesColumnIncreasing:gj,ChartNoAxesColumnIncreasingIcon:gj,ChartNoAxesCombined:hV,ChartNoAxesCombinedIcon:hV,ChartNoAxesGantt:vj,ChartNoAxesGanttIcon:vj,ChartPie:_j,ChartPieIcon:_j,ChartScatter:bj,ChartScatterIcon:bj,ChartSpline:mV,ChartSplineIcon:mV,Check:ea,CheckCheck:uL,CheckCheckIcon:uL,CheckCircle:si,CheckCircle2:Hn,CheckCircle2Icon:Hn,CheckCircleIcon:si,CheckIcon:ea,CheckSquare:Av,CheckSquare2:ik,CheckSquare2Icon:ik,CheckSquareIcon:Av,ChefHat:pV,ChefHatIcon:pV,Cherry:fV,CherryIcon:fV,ChevronDown:Fi,ChevronDownCircle:Aj,ChevronDownCircleIcon:Aj,ChevronDownIcon:Fi,ChevronDownSquare:ok,ChevronDownSquareIcon:ok,ChevronFirst:xV,ChevronFirstIcon:xV,ChevronLast:gV,ChevronLastIcon:gV,ChevronLeft:wl,ChevronLeftCircle:Ej,ChevronLeftCircleIcon:Ej,ChevronLeftIcon:wl,ChevronLeftSquare:lk,ChevronLeftSquareIcon:lk,ChevronRight:ja,ChevronRightCircle:Pj,ChevronRightCircleIcon:Pj,ChevronRightIcon:ja,ChevronRightSquare:ck,ChevronRightSquareIcon:ck,ChevronUp:lf,ChevronUpCircle:Ij,ChevronUpCircleIcon:Ij,ChevronUpIcon:lf,ChevronUpSquare:dk,ChevronUpSquareIcon:dk,ChevronsDown:vV,ChevronsDownIcon:vV,ChevronsDownUp:yV,ChevronsDownUpIcon:yV,ChevronsLeft:wV,ChevronsLeftIcon:wV,ChevronsLeftRight:bV,ChevronsLeftRightEllipsis:_V,ChevronsLeftRightEllipsisIcon:_V,ChevronsLeftRightIcon:bV,ChevronsRight:NV,ChevronsRightIcon:NV,ChevronsRightLeft:jV,ChevronsRightLeftIcon:jV,ChevronsUp:kV,ChevronsUpDown:wx,ChevronsUpDownIcon:wx,ChevronsUpIcon:kV,Chrome:SV,ChromeIcon:SV,Church:CV,ChurchIcon:CV,Cigarette:TV,CigaretteIcon:TV,CigaretteOff:MV,CigaretteOffIcon:MV,Circle:sd,CircleAlert:co,CircleAlertIcon:co,CircleArrowDown:wj,CircleArrowDownIcon:wj,CircleArrowLeft:jj,CircleArrowLeftIcon:jj,CircleArrowOutDownLeft:Nj,CircleArrowOutDownLeftIcon:Nj,CircleArrowOutDownRight:kj,CircleArrowOutDownRightIcon:kj,CircleArrowOutUpLeft:Sj,CircleArrowOutUpLeftIcon:Sj,CircleArrowOutUpRight:Cj,CircleArrowOutUpRightIcon:Cj,CircleArrowRight:Mj,CircleArrowRightIcon:Mj,CircleArrowUp:Tj,CircleArrowUpIcon:Tj,CircleCheck:Hn,CircleCheckBig:si,CircleCheckBigIcon:si,CircleCheckIcon:Hn,CircleChevronDown:Aj,CircleChevronDownIcon:Aj,CircleChevronLeft:Ej,CircleChevronLeftIcon:Ej,CircleChevronRight:Pj,CircleChevronRightIcon:Pj,CircleChevronUp:Ij,CircleChevronUpIcon:Ij,CircleDashed:AV,CircleDashedIcon:AV,CircleDivide:Lj,CircleDivideIcon:Lj,CircleDollarSign:EV,CircleDollarSignIcon:EV,CircleDot:IV,CircleDotDashed:PV,CircleDotDashedIcon:PV,CircleDotIcon:IV,CircleEllipsis:LV,CircleEllipsisIcon:LV,CircleEqual:DV,CircleEqualIcon:DV,CircleFadingArrowUp:RV,CircleFadingArrowUpIcon:RV,CircleFadingPlus:OV,CircleFadingPlusIcon:OV,CircleGauge:Dj,CircleGaugeIcon:Dj,CircleHelp:Sv,CircleHelpIcon:Sv,CircleIcon:sd,CircleMinus:Rj,CircleMinusIcon:Rj,CircleOff:FV,CircleOffIcon:FV,CircleParking:Fj,CircleParkingIcon:Fj,CircleParkingOff:Oj,CircleParkingOffIcon:Oj,CirclePause:zj,CirclePauseIcon:zj,CirclePercent:Bj,CirclePercentIcon:Bj,CirclePlay:tp,CirclePlayIcon:tp,CirclePlus:$j,CirclePlusIcon:$j,CirclePower:qj,CirclePowerIcon:qj,CircleSlash:zV,CircleSlash2:Uj,CircleSlash2Icon:Uj,CircleSlashIcon:zV,CircleSlashed:Uj,CircleSlashedIcon:Uj,CircleStop:Vj,CircleStopIcon:Vj,CircleUser:Gj,CircleUserIcon:Gj,CircleUserRound:Hj,CircleUserRoundIcon:Hj,CircleX:Ql,CircleXIcon:Ql,CircuitBoard:BV,CircuitBoardIcon:BV,Citrus:$V,CitrusIcon:$V,Clapperboard:qV,ClapperboardIcon:qV,Clipboard:ZV,ClipboardCheck:NM,ClipboardCheckIcon:NM,ClipboardCopy:UV,ClipboardCopyIcon:UV,ClipboardEdit:Kj,ClipboardEditIcon:Kj,ClipboardIcon:ZV,ClipboardList:Mb,ClipboardListIcon:Mb,ClipboardMinus:VV,ClipboardMinusIcon:VV,ClipboardPaste:HV,ClipboardPasteIcon:HV,ClipboardPen:Kj,ClipboardPenIcon:Kj,ClipboardPenLine:Wj,ClipboardPenLineIcon:Wj,ClipboardPlus:GV,ClipboardPlusIcon:GV,ClipboardSignature:Wj,ClipboardSignatureIcon:Wj,ClipboardType:WV,ClipboardTypeIcon:WV,ClipboardX:KV,ClipboardXIcon:KV,Clock:rn,Clock1:YV,Clock10:XV,Clock10Icon:XV,Clock11:QV,Clock11Icon:QV,Clock12:JV,Clock12Icon:JV,Clock1Icon:YV,Clock2:eH,Clock2Icon:eH,Clock3:tH,Clock3Icon:tH,Clock4:sH,Clock4Icon:sH,Clock5:rH,Clock5Icon:rH,Clock6:nH,Clock6Icon:nH,Clock7:aH,Clock7Icon:aH,Clock8:iH,Clock8Icon:iH,Clock9:oH,Clock9Icon:oH,ClockAlert:lH,ClockAlertIcon:lH,ClockArrowDown:cH,ClockArrowDownIcon:cH,ClockArrowUp:dH,ClockArrowUpIcon:dH,ClockIcon:rn,Cloud:kH,CloudAlert:uH,CloudAlertIcon:uH,CloudCog:hH,CloudCogIcon:hH,CloudDownload:Zj,CloudDownloadIcon:Zj,CloudDrizzle:mH,CloudDrizzleIcon:mH,CloudFog:pH,CloudFogIcon:pH,CloudHail:fH,CloudHailIcon:fH,CloudIcon:kH,CloudLightning:xH,CloudLightningIcon:xH,CloudMoon:yH,CloudMoonIcon:yH,CloudMoonRain:gH,CloudMoonRainIcon:gH,CloudOff:vH,CloudOffIcon:vH,CloudRain:bH,CloudRainIcon:bH,CloudRainWind:_H,CloudRainWindIcon:_H,CloudSnow:wH,CloudSnowIcon:wH,CloudSun:NH,CloudSunIcon:NH,CloudSunRain:jH,CloudSunRainIcon:jH,CloudUpload:Yj,CloudUploadIcon:Yj,Cloudy:SH,CloudyIcon:SH,Clover:zv,CloverIcon:zv,Club:CH,ClubIcon:CH,Code:Q4,Code2:Xj,Code2Icon:Xj,CodeIcon:Q4,CodeSquare:uk,CodeSquareIcon:uk,CodeXml:Xj,CodeXmlIcon:Xj,Codepen:MH,CodepenIcon:MH,Codesandbox:TH,CodesandboxIcon:TH,Coffee:J4,CoffeeIcon:J4,Cog:AH,CogIcon:AH,Coins:hL,CoinsIcon:hL,Columns:Qj,Columns2:Qj,Columns2Icon:Qj,Columns3:Jj,Columns3Icon:Jj,Columns4:EH,Columns4Icon:EH,ColumnsIcon:Qj,Combine:PH,CombineIcon:PH,Command:IH,CommandIcon:IH,Compass:kM,CompassIcon:kM,Component:LH,ComponentIcon:LH,Computer:DH,ComputerIcon:DH,ConciergeBell:RH,ConciergeBellIcon:RH,Cone:OH,ConeIcon:OH,Construction:FH,ConstructionIcon:FH,Contact:eS,Contact2:eN,Contact2Icon:eN,ContactIcon:eS,ContactRound:eN,ContactRoundIcon:eN,Container:zH,ContainerIcon:zH,Contrast:BH,ContrastIcon:BH,Cookie:$H,CookieIcon:$H,CookingPot:qH,CookingPotIcon:qH,Copy:Ya,CopyCheck:UH,CopyCheckIcon:UH,CopyIcon:Ya,CopyMinus:VH,CopyMinusIcon:VH,CopyPlus:HH,CopyPlusIcon:HH,CopySlash:GH,CopySlashIcon:GH,CopyX:WH,CopyXIcon:WH,Copyleft:KH,CopyleftIcon:KH,Copyright:ZH,CopyrightIcon:ZH,CornerDownLeft:YH,CornerDownLeftIcon:YH,CornerDownRight:XH,CornerDownRightIcon:XH,CornerLeftDown:QH,CornerLeftDownIcon:QH,CornerLeftUp:JH,CornerLeftUpIcon:JH,CornerRightDown:eG,CornerRightDownIcon:eG,CornerRightUp:tG,CornerRightUpIcon:tG,CornerUpLeft:sG,CornerUpLeftIcon:sG,CornerUpRight:rG,CornerUpRightIcon:rG,Cpu:nG,CpuIcon:nG,CreativeCommons:aG,CreativeCommonsIcon:aG,CreditCard:jx,CreditCardIcon:jx,Croissant:iG,CroissantIcon:iG,Crop:oG,CropIcon:oG,Cross:lG,CrossIcon:lG,Crosshair:cG,CrosshairIcon:cG,Crown:km,CrownIcon:km,Cuboid:dG,CuboidIcon:dG,CupSoda:uG,CupSodaIcon:uG,CurlyBraces:lj,CurlyBracesIcon:lj,Currency:hG,CurrencyIcon:hG,Cylinder:mG,CylinderIcon:mG,Dam:pG,DamIcon:pG,Database:mL,DatabaseBackup:fG,DatabaseBackupIcon:fG,DatabaseIcon:mL,DatabaseZap:xG,DatabaseZapIcon:xG,Delete:gG,DeleteIcon:gG,Dessert:yG,DessertIcon:yG,Diameter:vG,DiameterIcon:vG,Diamond:wG,DiamondIcon:wG,DiamondMinus:_G,DiamondMinusIcon:_G,DiamondPercent:tN,DiamondPercentIcon:tN,DiamondPlus:bG,DiamondPlusIcon:bG,Dice1:jG,Dice1Icon:jG,Dice2:NG,Dice2Icon:NG,Dice3:kG,Dice3Icon:kG,Dice4:SG,Dice4Icon:SG,Dice5:CG,Dice5Icon:CG,Dice6:MG,Dice6Icon:MG,Dices:TG,DicesIcon:TG,Diff:AG,DiffIcon:AG,Disc:LG,Disc2:EG,Disc2Icon:EG,Disc3:PG,Disc3Icon:PG,DiscAlbum:IG,DiscAlbumIcon:IG,DiscIcon:LG,Divide:DG,DivideCircle:Lj,DivideCircleIcon:Lj,DivideIcon:DG,DivideSquare:fk,DivideSquareIcon:fk,Dna:OG,DnaIcon:OG,DnaOff:RG,DnaOffIcon:RG,Dock:FG,DockIcon:FG,Dog:zG,DogIcon:zG,DollarSign:_c,DollarSignIcon:_c,Donut:BG,DonutIcon:BG,DoorClosed:$G,DoorClosedIcon:$G,DoorOpen:Kv,DoorOpenIcon:Kv,Dot:qG,DotIcon:qG,DotSquare:xk,DotSquareIcon:xk,Download:Xa,DownloadCloud:Zj,DownloadCloudIcon:Zj,DownloadIcon:Xa,DraftingCompass:UG,DraftingCompassIcon:UG,Drama:VG,DramaIcon:VG,Dribbble:HG,DribbbleIcon:HG,Drill:GG,DrillIcon:GG,Droplet:WG,DropletIcon:WG,Droplets:Lg,DropletsIcon:Lg,Drum:KG,DrumIcon:KG,Drumstick:ZG,DrumstickIcon:ZG,Dumbbell:YG,DumbbellIcon:YG,Ear:QG,EarIcon:QG,EarOff:XG,EarOffIcon:XG,Earth:sN,EarthIcon:sN,EarthLock:JG,EarthLockIcon:JG,Eclipse:eW,EclipseIcon:eW,Edit:Gc,Edit2:Ry,Edit2Icon:Ry,Edit3:Tv,Edit3Icon:Tv,EditIcon:Gc,Egg:SM,EggFried:tW,EggFriedIcon:tW,EggIcon:SM,EggOff:sW,EggOffIcon:sW,Ellipsis:dx,EllipsisIcon:dx,EllipsisVertical:cx,EllipsisVerticalIcon:cx,Equal:aW,EqualApproximately:rW,EqualApproximatelyIcon:rW,EqualIcon:aW,EqualNot:nW,EqualNotIcon:nW,EqualSquare:gk,EqualSquareIcon:gk,Eraser:iW,EraserIcon:iW,EthernetPort:oW,EthernetPortIcon:oW,Euro:lW,EuroIcon:lW,Expand:cW,ExpandIcon:cW,ExternalLink:Kr,ExternalLinkIcon:Kr,Eye:jn,EyeClosed:dW,EyeClosedIcon:dW,EyeIcon:jn,EyeOff:hp,EyeOffIcon:hp,Facebook:du,FacebookIcon:du,Factory:uW,FactoryIcon:uW,Fan:hW,FanIcon:hW,FastForward:mW,FastForwardIcon:mW,Feather:pW,FeatherIcon:pW,Fence:fW,FenceIcon:fW,FerrisWheel:xW,FerrisWheelIcon:xW,Figma:gW,FigmaIcon:gW,File:CM,FileArchive:yW,FileArchiveIcon:yW,FileAudio:_W,FileAudio2:vW,FileAudio2Icon:vW,FileAudioIcon:_W,FileAxis3D:rN,FileAxis3DIcon:rN,FileAxis3d:rN,FileAxis3dIcon:rN,FileBadge:wW,FileBadge2:bW,FileBadge2Icon:bW,FileBadgeIcon:wW,FileBarChart:nN,FileBarChart2:aN,FileBarChart2Icon:aN,FileBarChartIcon:nN,FileBox:jW,FileBoxIcon:jW,FileChartColumn:aN,FileChartColumnIcon:aN,FileChartColumnIncreasing:nN,FileChartColumnIncreasingIcon:nN,FileChartLine:iN,FileChartLineIcon:iN,FileChartPie:oN,FileChartPieIcon:oN,FileCheck:kW,FileCheck2:NW,FileCheck2Icon:NW,FileCheckIcon:kW,FileClock:SW,FileClockIcon:SW,FileCode:MW,FileCode2:CW,FileCode2Icon:CW,FileCodeIcon:MW,FileCog:lN,FileCog2:lN,FileCog2Icon:lN,FileCogIcon:lN,FileDiff:TW,FileDiffIcon:TW,FileDigit:AW,FileDigitIcon:AW,FileDown:tS,FileDownIcon:tS,FileEdit:dN,FileEditIcon:dN,FileHeart:EW,FileHeartIcon:EW,FileIcon:CM,FileImage:Tb,FileImageIcon:Tb,FileInput:PW,FileInputIcon:PW,FileJson:LW,FileJson2:IW,FileJson2Icon:IW,FileJsonIcon:LW,FileKey:RW,FileKey2:DW,FileKey2Icon:DW,FileKeyIcon:RW,FileLineChart:iN,FileLineChartIcon:iN,FileLock:FW,FileLock2:OW,FileLock2Icon:OW,FileLockIcon:FW,FileMinus:BW,FileMinus2:zW,FileMinus2Icon:zW,FileMinusIcon:BW,FileMusic:$W,FileMusicIcon:$W,FileOutput:qW,FileOutputIcon:qW,FilePen:dN,FilePenIcon:dN,FilePenLine:cN,FilePenLineIcon:cN,FilePieChart:oN,FilePieChartIcon:oN,FilePlus:VW,FilePlus2:UW,FilePlus2Icon:UW,FilePlusIcon:VW,FileQuestion:HW,FileQuestionIcon:HW,FileScan:GW,FileScanIcon:GW,FileSearch:KW,FileSearch2:WW,FileSearch2Icon:WW,FileSearchIcon:KW,FileSignature:cN,FileSignatureIcon:cN,FileSliders:ZW,FileSlidersIcon:ZW,FileSpreadsheet:Zv,FileSpreadsheetIcon:Zv,FileStack:pL,FileStackIcon:pL,FileSymlink:YW,FileSymlinkIcon:YW,FileTerminal:XW,FileTerminalIcon:XW,FileText:mn,FileTextIcon:mn,FileType:JW,FileType2:QW,FileType2Icon:QW,FileTypeIcon:JW,FileUp:eK,FileUpIcon:eK,FileUser:tK,FileUserIcon:tK,FileVideo:rK,FileVideo2:sK,FileVideo2Icon:sK,FileVideoIcon:rK,FileVolume:aK,FileVolume2:nK,FileVolume2Icon:nK,FileVolumeIcon:aK,FileWarning:iK,FileWarningIcon:iK,FileX:lK,FileX2:oK,FileX2Icon:oK,FileXIcon:lK,Files:cK,FilesIcon:cK,Film:Ld,FilmIcon:Ld,Filter:Dg,FilterIcon:Dg,FilterX:dK,FilterXIcon:dK,Fingerprint:uK,FingerprintIcon:uK,FireExtinguisher:hK,FireExtinguisherIcon:hK,Fish:fK,FishIcon:fK,FishOff:mK,FishOffIcon:mK,FishSymbol:pK,FishSymbolIcon:pK,Flag:Yv,FlagIcon:Yv,FlagOff:xK,FlagOffIcon:xK,FlagTriangleLeft:gK,FlagTriangleLeftIcon:gK,FlagTriangleRight:yK,FlagTriangleRightIcon:yK,Flame:ch,FlameIcon:ch,FlameKindling:vK,FlameKindlingIcon:vK,Flashlight:bK,FlashlightIcon:bK,FlashlightOff:_K,FlashlightOffIcon:_K,FlaskConical:Ab,FlaskConicalIcon:Ab,FlaskConicalOff:wK,FlaskConicalOffIcon:wK,FlaskRound:jK,FlaskRoundIcon:jK,FlipHorizontal:fL,FlipHorizontal2:NK,FlipHorizontal2Icon:NK,FlipHorizontalIcon:fL,FlipVertical:SK,FlipVertical2:kK,FlipVertical2Icon:kK,FlipVerticalIcon:SK,Flower:CK,Flower2:Tg,Flower2Icon:Tg,FlowerIcon:CK,Focus:MK,FocusIcon:MK,FoldHorizontal:TK,FoldHorizontalIcon:TK,FoldVertical:AK,FoldVerticalIcon:AK,Folder:rZ,FolderArchive:EK,FolderArchiveIcon:EK,FolderCheck:PK,FolderCheckIcon:PK,FolderClock:IK,FolderClockIcon:IK,FolderClosed:LK,FolderClosedIcon:LK,FolderCode:DK,FolderCodeIcon:DK,FolderCog:uN,FolderCog2:uN,FolderCog2Icon:uN,FolderCogIcon:uN,FolderDot:RK,FolderDotIcon:RK,FolderDown:OK,FolderDownIcon:OK,FolderEdit:hN,FolderEditIcon:hN,FolderGit:zK,FolderGit2:FK,FolderGit2Icon:FK,FolderGitIcon:zK,FolderHeart:BK,FolderHeartIcon:BK,FolderIcon:rZ,FolderInput:$K,FolderInputIcon:$K,FolderKanban:qK,FolderKanbanIcon:qK,FolderKey:UK,FolderKeyIcon:UK,FolderLock:VK,FolderLockIcon:VK,FolderMinus:HK,FolderMinusIcon:HK,FolderOpen:Sm,FolderOpenDot:GK,FolderOpenDotIcon:GK,FolderOpenIcon:Sm,FolderOutput:WK,FolderOutputIcon:WK,FolderPen:hN,FolderPenIcon:hN,FolderPlus:KK,FolderPlusIcon:KK,FolderRoot:ZK,FolderRootIcon:ZK,FolderSearch:XK,FolderSearch2:YK,FolderSearch2Icon:YK,FolderSearchIcon:XK,FolderSymlink:QK,FolderSymlinkIcon:QK,FolderSync:JK,FolderSyncIcon:JK,FolderTree:eZ,FolderTreeIcon:eZ,FolderUp:tZ,FolderUpIcon:tZ,FolderX:sZ,FolderXIcon:sZ,Folders:nZ,FoldersIcon:nZ,Footprints:aZ,FootprintsIcon:aZ,ForkKnife:s4,ForkKnifeCrossed:t4,ForkKnifeCrossedIcon:t4,ForkKnifeIcon:s4,Forklift:iZ,ForkliftIcon:iZ,FormInput:ON,FormInputIcon:ON,Forward:oZ,ForwardIcon:oZ,Frame:lZ,FrameIcon:lZ,Framer:cZ,FramerIcon:cZ,Frown:dZ,FrownIcon:dZ,Fuel:uZ,FuelIcon:uZ,Fullscreen:hZ,FullscreenIcon:hZ,FunctionSquare:yk,FunctionSquareIcon:yk,GalleryHorizontal:pZ,GalleryHorizontalEnd:mZ,GalleryHorizontalEndIcon:mZ,GalleryHorizontalIcon:pZ,GalleryThumbnails:fZ,GalleryThumbnailsIcon:fZ,GalleryVertical:gZ,GalleryVerticalEnd:xZ,GalleryVerticalEndIcon:xZ,GalleryVerticalIcon:gZ,Gamepad:vZ,Gamepad2:yZ,Gamepad2Icon:yZ,GamepadIcon:vZ,GanttChart:vj,GanttChartIcon:vj,GanttChartSquare:ky,GanttChartSquareIcon:ky,Gauge:_Z,GaugeCircle:Dj,GaugeCircleIcon:Dj,GaugeIcon:_Z,Gavel:bZ,GavelIcon:bZ,Gem:wZ,GemIcon:wZ,Ghost:sS,GhostIcon:sS,Gift:Vi,GiftIcon:Vi,GitBranch:NZ,GitBranchIcon:NZ,GitBranchPlus:jZ,GitBranchPlusIcon:jZ,GitCommit:mN,GitCommitHorizontal:mN,GitCommitHorizontalIcon:mN,GitCommitIcon:mN,GitCommitVertical:kZ,GitCommitVerticalIcon:kZ,GitCompare:CZ,GitCompareArrows:SZ,GitCompareArrowsIcon:SZ,GitCompareIcon:CZ,GitFork:MZ,GitForkIcon:MZ,GitGraph:TZ,GitGraphIcon:TZ,GitMerge:AZ,GitMergeIcon:AZ,GitPullRequest:RZ,GitPullRequestArrow:EZ,GitPullRequestArrowIcon:EZ,GitPullRequestClosed:PZ,GitPullRequestClosedIcon:PZ,GitPullRequestCreate:LZ,GitPullRequestCreateArrow:IZ,GitPullRequestCreateArrowIcon:IZ,GitPullRequestCreateIcon:LZ,GitPullRequestDraft:DZ,GitPullRequestDraftIcon:DZ,GitPullRequestIcon:RZ,Github:OZ,GithubIcon:OZ,Gitlab:FZ,GitlabIcon:FZ,GlassWater:zZ,GlassWaterIcon:zZ,Glasses:BZ,GlassesIcon:BZ,Globe:gd,Globe2:sN,Globe2Icon:sN,GlobeIcon:gd,GlobeLock:$Z,GlobeLockIcon:$Z,Goal:qZ,GoalIcon:qZ,Grab:UZ,GrabIcon:UZ,GraduationCap:Dh,GraduationCapIcon:Dh,Grape:VZ,GrapeIcon:VZ,Grid:tx,Grid2X2:fN,Grid2X2Icon:fN,Grid2X2Plus:pN,Grid2X2PlusIcon:pN,Grid2x2:fN,Grid2x2Check:HZ,Grid2x2CheckIcon:HZ,Grid2x2Icon:fN,Grid2x2Plus:pN,Grid2x2PlusIcon:pN,Grid2x2X:GZ,Grid2x2XIcon:GZ,Grid3X3:tx,Grid3X3Icon:tx,Grid3x3:tx,Grid3x3Icon:tx,GridIcon:tx,Grip:KZ,GripHorizontal:WZ,GripHorizontalIcon:WZ,GripIcon:KZ,GripVertical:uu,GripVerticalIcon:uu,Group:ZZ,GroupIcon:ZZ,Guitar:YZ,GuitarIcon:YZ,Ham:XZ,HamIcon:XZ,Hammer:QZ,HammerIcon:QZ,Hand:xL,HandCoins:JZ,HandCoinsIcon:JZ,HandHeart:eY,HandHeartIcon:eY,HandHelping:xN,HandHelpingIcon:xN,HandIcon:xL,HandMetal:tY,HandMetalIcon:tY,HandPlatter:sY,HandPlatterIcon:sY,Handshake:gL,HandshakeIcon:gL,HardDrive:yL,HardDriveDownload:rY,HardDriveDownloadIcon:rY,HardDriveIcon:yL,HardDriveUpload:nY,HardDriveUploadIcon:nY,HardHat:aY,HardHatIcon:aY,Hash:rS,HashIcon:rS,Haze:iY,HazeIcon:iY,HdmiPort:oY,HdmiPortIcon:oY,Heading:uY,Heading1:MM,Heading1Icon:MM,Heading2:TM,Heading2Icon:TM,Heading3:vL,Heading3Icon:vL,Heading4:lY,Heading4Icon:lY,Heading5:cY,Heading5Icon:cY,Heading6:dY,Heading6Icon:dY,HeadingIcon:uY,HeadphoneOff:hY,HeadphoneOffIcon:hY,Headphones:mY,HeadphonesIcon:mY,Headset:pY,HeadsetIcon:pY,Heart:Za,HeartCrack:fY,HeartCrackIcon:fY,HeartHandshake:xY,HeartHandshakeIcon:xY,HeartIcon:Za,HeartOff:gY,HeartOffIcon:gY,HeartPulse:yY,HeartPulseIcon:yY,Heater:vY,HeaterIcon:vY,HelpCircle:Sv,HelpCircleIcon:Sv,HelpingHand:xN,HelpingHandIcon:xN,Hexagon:_Y,HexagonIcon:_Y,Highlighter:bY,HighlighterIcon:bY,History:AM,HistoryIcon:AM,Home:Mn,HomeIcon:Mn,Hop:jY,HopIcon:jY,HopOff:wY,HopOffIcon:wY,Hospital:NY,HospitalIcon:NY,Hotel:kY,HotelIcon:kY,Hourglass:SY,HourglassIcon:SY,House:Mn,HouseIcon:Mn,HousePlug:CY,HousePlugIcon:CY,HousePlus:MY,HousePlusIcon:MY,IceCream:yN,IceCream2:gN,IceCream2Icon:gN,IceCreamBowl:gN,IceCreamBowlIcon:gN,IceCreamCone:yN,IceCreamConeIcon:yN,IceCreamIcon:yN,Icon:pUe,IdCard:TY,IdCardIcon:TY,Image:Uo,ImageDown:AY,ImageDownIcon:AY,ImageIcon:Uo,ImageMinus:EY,ImageMinusIcon:EY,ImageOff:PY,ImageOffIcon:PY,ImagePlay:IY,ImagePlayIcon:IY,ImagePlus:Xv,ImagePlusIcon:Xv,ImageUp:LY,ImageUpIcon:LY,ImageUpscale:DY,ImageUpscaleIcon:DY,Images:RY,ImagesIcon:RY,Import:OY,ImportIcon:OY,Inbox:FY,InboxIcon:FY,Indent:_N,IndentDecrease:vN,IndentDecreaseIcon:vN,IndentIcon:_N,IndentIncrease:_N,IndentIncreaseIcon:_N,IndianRupee:zY,IndianRupeeIcon:zY,Infinity:BY,InfinityIcon:BY,Info:nS,InfoIcon:nS,Inspect:Nk,InspectIcon:Nk,InspectionPanel:$Y,InspectionPanelIcon:$Y,Instagram:hu,InstagramIcon:hu,Italic:aS,ItalicIcon:aS,IterationCcw:qY,IterationCcwIcon:qY,IterationCw:UY,IterationCwIcon:UY,JapaneseYen:VY,JapaneseYenIcon:VY,Joystick:HY,JoystickIcon:HY,Kanban:Zy,KanbanIcon:Zy,KanbanSquare:vk,KanbanSquareDashed:hk,KanbanSquareDashedIcon:hk,KanbanSquareIcon:vk,Key:mp,KeyIcon:mp,KeyRound:iS,KeyRoundIcon:iS,KeySquare:GY,KeySquareIcon:GY,Keyboard:ZY,KeyboardIcon:ZY,KeyboardMusic:WY,KeyboardMusicIcon:WY,KeyboardOff:KY,KeyboardOffIcon:KY,Lamp:tX,LampCeiling:YY,LampCeilingIcon:YY,LampDesk:XY,LampDeskIcon:XY,LampFloor:QY,LampFloorIcon:QY,LampIcon:tX,LampWallDown:JY,LampWallDownIcon:JY,LampWallUp:eX,LampWallUpIcon:eX,LandPlot:sX,LandPlotIcon:sX,Landmark:rX,LandmarkIcon:rX,Languages:nX,LanguagesIcon:nX,Laptop:iX,Laptop2:bN,Laptop2Icon:bN,LaptopIcon:iX,LaptopMinimal:bN,LaptopMinimalCheck:aX,LaptopMinimalCheckIcon:aX,LaptopMinimalIcon:bN,Lasso:lX,LassoIcon:lX,LassoSelect:oX,LassoSelectIcon:oX,Laugh:cX,LaughIcon:cX,Layers:hX,Layers2:dX,Layers2Icon:dX,Layers3:uX,Layers3Icon:uX,LayersIcon:hX,Layout:Mv,LayoutDashboard:oS,LayoutDashboardIcon:oS,LayoutGrid:pp,LayoutGridIcon:pp,LayoutIcon:Mv,LayoutList:mX,LayoutListIcon:mX,LayoutPanelLeft:pX,LayoutPanelLeftIcon:pX,LayoutPanelTop:fX,LayoutPanelTopIcon:fX,LayoutTemplate:lS,LayoutTemplateIcon:lS,Leaf:xX,LeafIcon:xX,LeafyGreen:gX,LeafyGreenIcon:gX,Lectern:yX,LecternIcon:yX,LetterText:vX,LetterTextIcon:vX,Library:cS,LibraryBig:_X,LibraryBigIcon:_X,LibraryIcon:cS,LibrarySquare:_k,LibrarySquareIcon:_k,LifeBuoy:EM,LifeBuoyIcon:EM,Ligature:bX,LigatureIcon:bX,Lightbulb:Eb,LightbulbIcon:Eb,LightbulbOff:wX,LightbulbOffIcon:wX,LineChart:xj,LineChartIcon:xj,Link:go,Link2:Do,Link2Icon:Do,Link2Off:jX,Link2OffIcon:jX,LinkIcon:go,Linkedin:fp,LinkedinIcon:fp,List:Rh,ListCheck:NX,ListCheckIcon:NX,ListChecks:kX,ListChecksIcon:kX,ListCollapse:SX,ListCollapseIcon:SX,ListEnd:CX,ListEndIcon:CX,ListFilter:MX,ListFilterIcon:MX,ListIcon:Rh,ListMinus:TX,ListMinusIcon:TX,ListMusic:AX,ListMusicIcon:AX,ListOrdered:Yy,ListOrderedIcon:Yy,ListPlus:EX,ListPlusIcon:EX,ListRestart:PX,ListRestartIcon:PX,ListStart:IX,ListStartIcon:IX,ListTodo:LX,ListTodoIcon:LX,ListTree:DX,ListTreeIcon:DX,ListVideo:RX,ListVideoIcon:RX,ListX:OX,ListXIcon:OX,Loader:zX,Loader2:ps,Loader2Icon:ps,LoaderCircle:ps,LoaderCircleIcon:ps,LoaderIcon:zX,LoaderPinwheel:FX,LoaderPinwheelIcon:FX,Locate:PM,LocateFixed:BX,LocateFixedIcon:BX,LocateIcon:PM,LocateOff:$X,LocateOffIcon:$X,Lock:yd,LockIcon:yd,LockKeyhole:qX,LockKeyholeIcon:qX,LockKeyholeOpen:wN,LockKeyholeOpenIcon:wN,LockOpen:jN,LockOpenIcon:jN,LogIn:dS,LogInIcon:dS,LogOut:IM,LogOutIcon:IM,Logs:UX,LogsIcon:UX,Lollipop:VX,LollipopIcon:VX,LucideAArrowDown:Y9,LucideAArrowUp:X9,LucideALargeSmall:Q9,LucideAccessibility:J9,LucideActivity:ih,LucideActivitySquare:HN,LucideAirVent:eB,LucideAirplay:tB,LucideAlarmCheck:K2,LucideAlarmClock:rB,LucideAlarmClockCheck:K2,LucideAlarmClockMinus:Z2,LucideAlarmClockOff:sB,LucideAlarmClockPlus:Y2,LucideAlarmMinus:Z2,LucideAlarmPlus:Y2,LucideAlarmSmoke:nB,LucideAlbum:aB,LucideAlertCircle:co,LucideAlertOctagon:Cv,LucideAlertTriangle:Qc,LucideAlignCenter:G4,LucideAlignCenterHorizontal:iB,LucideAlignCenterVertical:oB,LucideAlignEndHorizontal:lB,LucideAlignEndVertical:cB,LucideAlignHorizontalDistributeCenter:dB,LucideAlignHorizontalDistributeEnd:uB,LucideAlignHorizontalDistributeStart:hB,LucideAlignHorizontalJustifyCenter:mB,LucideAlignHorizontalJustifyEnd:pB,LucideAlignHorizontalJustifyStart:fB,LucideAlignHorizontalSpaceAround:xB,LucideAlignHorizontalSpaceBetween:gB,LucideAlignJustify:yB,LucideAlignLeft:W4,LucideAlignRight:K4,LucideAlignStartHorizontal:vB,LucideAlignStartVertical:_B,LucideAlignVerticalDistributeCenter:bB,LucideAlignVerticalDistributeEnd:wB,LucideAlignVerticalDistributeStart:jB,LucideAlignVerticalJustifyCenter:NB,LucideAlignVerticalJustifyEnd:kB,LucideAlignVerticalJustifyStart:SB,LucideAlignVerticalSpaceAround:CB,LucideAlignVerticalSpaceBetween:MB,LucideAmbulance:TB,LucideAmpersand:AB,LucideAmpersands:EB,LucideAmphora:PB,LucideAnchor:IB,LucideAngry:LB,LucideAnnoyed:DB,LucideAntenna:RB,LucideAnvil:OB,LucideAperture:FB,LucideAppWindow:sL,LucideAppWindowMac:zB,LucideApple:BB,LucideArchive:_M,LucideArchiveRestore:rL,LucideArchiveX:$B,LucideAreaChart:dj,LucideArmchair:qB,LucideArrowBigDown:VB,LucideArrowBigDownDash:UB,LucideArrowBigLeft:GB,LucideArrowBigLeftDash:HB,LucideArrowBigRight:KB,LucideArrowBigRightDash:WB,LucideArrowBigUp:YB,LucideArrowBigUpDash:ZB,LucideArrowDown:Ih,LucideArrowDown01:XB,LucideArrowDown10:QB,LucideArrowDownAZ:X2,LucideArrowDownAz:X2,LucideArrowDownCircle:wj,LucideArrowDownFromLine:JB,LucideArrowDownLeft:e$,LucideArrowDownLeftFromCircle:Nj,LucideArrowDownLeftFromSquare:YN,LucideArrowDownLeftSquare:GN,LucideArrowDownNarrowWide:t$,LucideArrowDownRight:nL,LucideArrowDownRightFromCircle:kj,LucideArrowDownRightFromSquare:XN,LucideArrowDownRightSquare:WN,LucideArrowDownSquare:KN,LucideArrowDownToDot:s$,LucideArrowDownToLine:r$,LucideArrowDownUp:n$,LucideArrowDownWideNarrow:Q2,LucideArrowDownZA:J2,LucideArrowDownZa:J2,LucideArrowLeft:Ra,LucideArrowLeftCircle:jj,LucideArrowLeftFromLine:a$,LucideArrowLeftRight:i$,LucideArrowLeftSquare:ZN,LucideArrowLeftToLine:o$,LucideArrowRight:ti,LucideArrowRightCircle:Mj,LucideArrowRightFromLine:l$,LucideArrowRightLeft:Gv,LucideArrowRightSquare:ek,LucideArrowRightToLine:c$,LucideArrowUp:cu,LucideArrowUp01:d$,LucideArrowUp10:u$,LucideArrowUpAZ:ej,LucideArrowUpAz:ej,LucideArrowUpCircle:Tj,LucideArrowUpDown:td,LucideArrowUpFromDot:h$,LucideArrowUpFromLine:m$,LucideArrowUpLeft:p$,LucideArrowUpLeftFromCircle:Sj,LucideArrowUpLeftFromSquare:QN,LucideArrowUpLeftSquare:tk,LucideArrowUpNarrowWide:tj,LucideArrowUpRight:aL,LucideArrowUpRightFromCircle:Cj,LucideArrowUpRightFromSquare:JN,LucideArrowUpRightSquare:sk,LucideArrowUpSquare:rk,LucideArrowUpToLine:f$,LucideArrowUpWideNarrow:x$,LucideArrowUpZA:sj,LucideArrowUpZa:sj,LucideArrowsUpFromLine:g$,LucideAsterisk:y$,LucideAsteriskSquare:nk,LucideAtSign:v$,LucideAtom:_$,LucideAudioLines:b$,LucideAudioWaveform:w$,LucideAward:rc,LucideAxe:j$,LucideAxis3D:rj,LucideAxis3d:rj,LucideBaby:N$,LucideBackpack:k$,LucideBadge:$$,LucideBadgeAlert:S$,LucideBadgeCent:C$,LucideBadgeCheck:nj,LucideBadgeDollarSign:M$,LucideBadgeEuro:T$,LucideBadgeHelp:A$,LucideBadgeIndianRupee:E$,LucideBadgeInfo:P$,LucideBadgeJapaneseYen:I$,LucideBadgeMinus:L$,LucideBadgePercent:D$,LucideBadgePlus:R$,LucideBadgePoundSterling:O$,LucideBadgeRussianRuble:F$,LucideBadgeSwissFranc:z$,LucideBadgeX:B$,LucideBaggageClaim:q$,LucideBan:iL,LucideBanana:U$,LucideBandage:V$,LucideBanknote:H$,LucideBarChart:gj,LucideBarChart2:yj,LucideBarChart3:so,LucideBarChart4:fj,LucideBarChartBig:pj,LucideBarChartHorizontal:hj,LucideBarChartHorizontalBig:uj,LucideBarcode:G$,LucideBaseline:W$,LucideBath:of,LucideBattery:J$,LucideBatteryCharging:K$,LucideBatteryFull:Z$,LucideBatteryLow:Y$,LucideBatteryMedium:X$,LucideBatteryWarning:Q$,LucideBeaker:eq,LucideBean:sq,LucideBeanOff:tq,LucideBed:Ky,LucideBedDouble:Z4,LucideBedSingle:rq,LucideBeef:nq,LucideBeer:iq,LucideBeerOff:aq,LucideBell:Nm,LucideBellDot:oq,LucideBellElectric:lq,LucideBellMinus:cq,LucideBellOff:Wv,LucideBellPlus:dq,LucideBellRing:uq,LucideBetweenHorizonalEnd:aj,LucideBetweenHorizonalStart:ij,LucideBetweenHorizontalEnd:aj,LucideBetweenHorizontalStart:ij,LucideBetweenVerticalEnd:hq,LucideBetweenVerticalStart:mq,LucideBicepsFlexed:pq,LucideBike:fq,LucideBinary:xq,LucideBinoculars:gq,LucideBiohazard:yq,LucideBird:vq,LucideBitcoin:_q,LucideBlend:bq,LucideBlinds:wq,LucideBlocks:jq,LucideBluetooth:Cq,LucideBluetoothConnected:Nq,LucideBluetoothOff:kq,LucideBluetoothSearching:Sq,LucideBold:Y4,LucideBolt:Mq,LucideBomb:Tq,LucideBone:Aq,LucideBook:Qq,LucideBookA:Eq,LucideBookAudio:Pq,LucideBookCheck:Iq,LucideBookCopy:Lq,LucideBookDashed:oj,LucideBookDown:Dq,LucideBookHeadphones:Rq,LucideBookHeart:Oq,LucideBookImage:Fq,LucideBookKey:zq,LucideBookLock:Bq,LucideBookMarked:$q,LucideBookMinus:qq,LucideBookOpen:oh,LucideBookOpenCheck:Uq,LucideBookOpenText:Vq,LucideBookPlus:Hq,LucideBookTemplate:oj,LucideBookText:Gq,LucideBookType:Wq,LucideBookUp:Zq,LucideBookUp2:Kq,LucideBookUser:Yq,LucideBookX:Xq,LucideBookmark:_x,LucideBookmarkCheck:Jq,LucideBookmarkMinus:eU,LucideBookmarkPlus:oL,LucideBookmarkX:tU,LucideBoomBox:sU,LucideBot:bM,LucideBotMessageSquare:rU,LucideBotOff:nU,LucideBox:aU,LucideBoxSelect:pk,LucideBoxes:iU,LucideBraces:lj,LucideBrackets:oU,LucideBrain:lL,LucideBrainCircuit:lU,LucideBrainCog:cU,LucideBrickWall:dU,LucideBriefcase:Lh,LucideBriefcaseBusiness:uU,LucideBriefcaseConveyorBelt:hU,LucideBriefcaseMedical:mU,LucideBringToFront:pU,LucideBrush:fU,LucideBug:yU,LucideBugOff:xU,LucideBugPlay:gU,LucideBuilding:X4,LucideBuilding2:ma,LucideBus:_U,LucideBusFront:vU,LucideCable:wU,LucideCableCar:bU,LucideCake:lh,LucideCakeSlice:jU,LucideCalculator:wM,LucideCalendar:nn,LucideCalendar1:NU,LucideCalendarArrowDown:kU,LucideCalendarArrowUp:SU,LucideCalendarCheck:cL,LucideCalendarCheck2:CU,LucideCalendarClock:jM,LucideCalendarCog:MU,LucideCalendarDays:xd,LucideCalendarFold:TU,LucideCalendarHeart:AU,LucideCalendarMinus:PU,LucideCalendarMinus2:EU,LucideCalendarOff:dL,LucideCalendarPlus:Cb,LucideCalendarPlus2:IU,LucideCalendarRange:LU,LucideCalendarSearch:DU,LucideCalendarSync:RU,LucideCalendarX:FU,LucideCalendarX2:OU,LucideCamera:bx,LucideCameraOff:zU,LucideCandlestickChart:mj,LucideCandy:qU,LucideCandyCane:BU,LucideCandyOff:$U,LucideCannabis:UU,LucideCaptions:cj,LucideCaptionsOff:VU,LucideCar:WU,LucideCarFront:HU,LucideCarTaxiFront:GU,LucideCaravan:KU,LucideCarrot:ZU,LucideCaseLower:YU,LucideCaseSensitive:XU,LucideCaseUpper:QU,LucideCassetteTape:JU,LucideCast:eV,LucideCastle:tV,LucideCat:sV,LucideCctv:rV,LucideChartArea:dj,LucideChartBar:hj,LucideChartBarBig:uj,LucideChartBarDecreasing:nV,LucideChartBarIncreasing:aV,LucideChartBarStacked:iV,LucideChartCandlestick:mj,LucideChartColumn:so,LucideChartColumnBig:pj,LucideChartColumnDecreasing:oV,LucideChartColumnIncreasing:fj,LucideChartColumnStacked:lV,LucideChartGantt:cV,LucideChartLine:xj,LucideChartNetwork:dV,LucideChartNoAxesColumn:yj,LucideChartNoAxesColumnDecreasing:uV,LucideChartNoAxesColumnIncreasing:gj,LucideChartNoAxesCombined:hV,LucideChartNoAxesGantt:vj,LucideChartPie:_j,LucideChartScatter:bj,LucideChartSpline:mV,LucideCheck:ea,LucideCheckCheck:uL,LucideCheckCircle:si,LucideCheckCircle2:Hn,LucideCheckSquare:Av,LucideCheckSquare2:ik,LucideChefHat:pV,LucideCherry:fV,LucideChevronDown:Fi,LucideChevronDownCircle:Aj,LucideChevronDownSquare:ok,LucideChevronFirst:xV,LucideChevronLast:gV,LucideChevronLeft:wl,LucideChevronLeftCircle:Ej,LucideChevronLeftSquare:lk,LucideChevronRight:ja,LucideChevronRightCircle:Pj,LucideChevronRightSquare:ck,LucideChevronUp:lf,LucideChevronUpCircle:Ij,LucideChevronUpSquare:dk,LucideChevronsDown:vV,LucideChevronsDownUp:yV,LucideChevronsLeft:wV,LucideChevronsLeftRight:bV,LucideChevronsLeftRightEllipsis:_V,LucideChevronsRight:NV,LucideChevronsRightLeft:jV,LucideChevronsUp:kV,LucideChevronsUpDown:wx,LucideChrome:SV,LucideChurch:CV,LucideCigarette:TV,LucideCigaretteOff:MV,LucideCircle:sd,LucideCircleAlert:co,LucideCircleArrowDown:wj,LucideCircleArrowLeft:jj,LucideCircleArrowOutDownLeft:Nj,LucideCircleArrowOutDownRight:kj,LucideCircleArrowOutUpLeft:Sj,LucideCircleArrowOutUpRight:Cj,LucideCircleArrowRight:Mj,LucideCircleArrowUp:Tj,LucideCircleCheck:Hn,LucideCircleCheckBig:si,LucideCircleChevronDown:Aj,LucideCircleChevronLeft:Ej,LucideCircleChevronRight:Pj,LucideCircleChevronUp:Ij,LucideCircleDashed:AV,LucideCircleDivide:Lj,LucideCircleDollarSign:EV,LucideCircleDot:IV,LucideCircleDotDashed:PV,LucideCircleEllipsis:LV,LucideCircleEqual:DV,LucideCircleFadingArrowUp:RV,LucideCircleFadingPlus:OV,LucideCircleGauge:Dj,LucideCircleHelp:Sv,LucideCircleMinus:Rj,LucideCircleOff:FV,LucideCircleParking:Fj,LucideCircleParkingOff:Oj,LucideCirclePause:zj,LucideCirclePercent:Bj,LucideCirclePlay:tp,LucideCirclePlus:$j,LucideCirclePower:qj,LucideCircleSlash:zV,LucideCircleSlash2:Uj,LucideCircleSlashed:Uj,LucideCircleStop:Vj,LucideCircleUser:Gj,LucideCircleUserRound:Hj,LucideCircleX:Ql,LucideCircuitBoard:BV,LucideCitrus:$V,LucideClapperboard:qV,LucideClipboard:ZV,LucideClipboardCheck:NM,LucideClipboardCopy:UV,LucideClipboardEdit:Kj,LucideClipboardList:Mb,LucideClipboardMinus:VV,LucideClipboardPaste:HV,LucideClipboardPen:Kj,LucideClipboardPenLine:Wj,LucideClipboardPlus:GV,LucideClipboardSignature:Wj,LucideClipboardType:WV,LucideClipboardX:KV,LucideClock:rn,LucideClock1:YV,LucideClock10:XV,LucideClock11:QV,LucideClock12:JV,LucideClock2:eH,LucideClock3:tH,LucideClock4:sH,LucideClock5:rH,LucideClock6:nH,LucideClock7:aH,LucideClock8:iH,LucideClock9:oH,LucideClockAlert:lH,LucideClockArrowDown:cH,LucideClockArrowUp:dH,LucideCloud:kH,LucideCloudAlert:uH,LucideCloudCog:hH,LucideCloudDownload:Zj,LucideCloudDrizzle:mH,LucideCloudFog:pH,LucideCloudHail:fH,LucideCloudLightning:xH,LucideCloudMoon:yH,LucideCloudMoonRain:gH,LucideCloudOff:vH,LucideCloudRain:bH,LucideCloudRainWind:_H,LucideCloudSnow:wH,LucideCloudSun:NH,LucideCloudSunRain:jH,LucideCloudUpload:Yj,LucideCloudy:SH,LucideClover:zv,LucideClub:CH,LucideCode:Q4,LucideCode2:Xj,LucideCodeSquare:uk,LucideCodeXml:Xj,LucideCodepen:MH,LucideCodesandbox:TH,LucideCoffee:J4,LucideCog:AH,LucideCoins:hL,LucideColumns:Qj,LucideColumns2:Qj,LucideColumns3:Jj,LucideColumns4:EH,LucideCombine:PH,LucideCommand:IH,LucideCompass:kM,LucideComponent:LH,LucideComputer:DH,LucideConciergeBell:RH,LucideCone:OH,LucideConstruction:FH,LucideContact:eS,LucideContact2:eN,LucideContactRound:eN,LucideContainer:zH,LucideContrast:BH,LucideCookie:$H,LucideCookingPot:qH,LucideCopy:Ya,LucideCopyCheck:UH,LucideCopyMinus:VH,LucideCopyPlus:HH,LucideCopySlash:GH,LucideCopyX:WH,LucideCopyleft:KH,LucideCopyright:ZH,LucideCornerDownLeft:YH,LucideCornerDownRight:XH,LucideCornerLeftDown:QH,LucideCornerLeftUp:JH,LucideCornerRightDown:eG,LucideCornerRightUp:tG,LucideCornerUpLeft:sG,LucideCornerUpRight:rG,LucideCpu:nG,LucideCreativeCommons:aG,LucideCreditCard:jx,LucideCroissant:iG,LucideCrop:oG,LucideCross:lG,LucideCrosshair:cG,LucideCrown:km,LucideCuboid:dG,LucideCupSoda:uG,LucideCurlyBraces:lj,LucideCurrency:hG,LucideCylinder:mG,LucideDam:pG,LucideDatabase:mL,LucideDatabaseBackup:fG,LucideDatabaseZap:xG,LucideDelete:gG,LucideDessert:yG,LucideDiameter:vG,LucideDiamond:wG,LucideDiamondMinus:_G,LucideDiamondPercent:tN,LucideDiamondPlus:bG,LucideDice1:jG,LucideDice2:NG,LucideDice3:kG,LucideDice4:SG,LucideDice5:CG,LucideDice6:MG,LucideDices:TG,LucideDiff:AG,LucideDisc:LG,LucideDisc2:EG,LucideDisc3:PG,LucideDiscAlbum:IG,LucideDivide:DG,LucideDivideCircle:Lj,LucideDivideSquare:fk,LucideDna:OG,LucideDnaOff:RG,LucideDock:FG,LucideDog:zG,LucideDollarSign:_c,LucideDonut:BG,LucideDoorClosed:$G,LucideDoorOpen:Kv,LucideDot:qG,LucideDotSquare:xk,LucideDownload:Xa,LucideDownloadCloud:Zj,LucideDraftingCompass:UG,LucideDrama:VG,LucideDribbble:HG,LucideDrill:GG,LucideDroplet:WG,LucideDroplets:Lg,LucideDrum:KG,LucideDrumstick:ZG,LucideDumbbell:YG,LucideEar:QG,LucideEarOff:XG,LucideEarth:sN,LucideEarthLock:JG,LucideEclipse:eW,LucideEdit:Gc,LucideEdit2:Ry,LucideEdit3:Tv,LucideEgg:SM,LucideEggFried:tW,LucideEggOff:sW,LucideEllipsis:dx,LucideEllipsisVertical:cx,LucideEqual:aW,LucideEqualApproximately:rW,LucideEqualNot:nW,LucideEqualSquare:gk,LucideEraser:iW,LucideEthernetPort:oW,LucideEuro:lW,LucideExpand:cW,LucideExternalLink:Kr,LucideEye:jn,LucideEyeClosed:dW,LucideEyeOff:hp,LucideFacebook:du,LucideFactory:uW,LucideFan:hW,LucideFastForward:mW,LucideFeather:pW,LucideFence:fW,LucideFerrisWheel:xW,LucideFigma:gW,LucideFile:CM,LucideFileArchive:yW,LucideFileAudio:_W,LucideFileAudio2:vW,LucideFileAxis3D:rN,LucideFileAxis3d:rN,LucideFileBadge:wW,LucideFileBadge2:bW,LucideFileBarChart:nN,LucideFileBarChart2:aN,LucideFileBox:jW,LucideFileChartColumn:aN,LucideFileChartColumnIncreasing:nN,LucideFileChartLine:iN,LucideFileChartPie:oN,LucideFileCheck:kW,LucideFileCheck2:NW,LucideFileClock:SW,LucideFileCode:MW,LucideFileCode2:CW,LucideFileCog:lN,LucideFileCog2:lN,LucideFileDiff:TW,LucideFileDigit:AW,LucideFileDown:tS,LucideFileEdit:dN,LucideFileHeart:EW,LucideFileImage:Tb,LucideFileInput:PW,LucideFileJson:LW,LucideFileJson2:IW,LucideFileKey:RW,LucideFileKey2:DW,LucideFileLineChart:iN,LucideFileLock:FW,LucideFileLock2:OW,LucideFileMinus:BW,LucideFileMinus2:zW,LucideFileMusic:$W,LucideFileOutput:qW,LucideFilePen:dN,LucideFilePenLine:cN,LucideFilePieChart:oN,LucideFilePlus:VW,LucideFilePlus2:UW,LucideFileQuestion:HW,LucideFileScan:GW,LucideFileSearch:KW,LucideFileSearch2:WW,LucideFileSignature:cN,LucideFileSliders:ZW,LucideFileSpreadsheet:Zv,LucideFileStack:pL,LucideFileSymlink:YW,LucideFileTerminal:XW,LucideFileText:mn,LucideFileType:JW,LucideFileType2:QW,LucideFileUp:eK,LucideFileUser:tK,LucideFileVideo:rK,LucideFileVideo2:sK,LucideFileVolume:aK,LucideFileVolume2:nK,LucideFileWarning:iK,LucideFileX:lK,LucideFileX2:oK,LucideFiles:cK,LucideFilm:Ld,LucideFilter:Dg,LucideFilterX:dK,LucideFingerprint:uK,LucideFireExtinguisher:hK,LucideFish:fK,LucideFishOff:mK,LucideFishSymbol:pK,LucideFlag:Yv,LucideFlagOff:xK,LucideFlagTriangleLeft:gK,LucideFlagTriangleRight:yK,LucideFlame:ch,LucideFlameKindling:vK,LucideFlashlight:bK,LucideFlashlightOff:_K,LucideFlaskConical:Ab,LucideFlaskConicalOff:wK,LucideFlaskRound:jK,LucideFlipHorizontal:fL,LucideFlipHorizontal2:NK,LucideFlipVertical:SK,LucideFlipVertical2:kK,LucideFlower:CK,LucideFlower2:Tg,LucideFocus:MK,LucideFoldHorizontal:TK,LucideFoldVertical:AK,LucideFolder:rZ,LucideFolderArchive:EK,LucideFolderCheck:PK,LucideFolderClock:IK,LucideFolderClosed:LK,LucideFolderCode:DK,LucideFolderCog:uN,LucideFolderCog2:uN,LucideFolderDot:RK,LucideFolderDown:OK,LucideFolderEdit:hN,LucideFolderGit:zK,LucideFolderGit2:FK,LucideFolderHeart:BK,LucideFolderInput:$K,LucideFolderKanban:qK,LucideFolderKey:UK,LucideFolderLock:VK,LucideFolderMinus:HK,LucideFolderOpen:Sm,LucideFolderOpenDot:GK,LucideFolderOutput:WK,LucideFolderPen:hN,LucideFolderPlus:KK,LucideFolderRoot:ZK,LucideFolderSearch:XK,LucideFolderSearch2:YK,LucideFolderSymlink:QK,LucideFolderSync:JK,LucideFolderTree:eZ,LucideFolderUp:tZ,LucideFolderX:sZ,LucideFolders:nZ,LucideFootprints:aZ,LucideForkKnife:s4,LucideForkKnifeCrossed:t4,LucideForklift:iZ,LucideFormInput:ON,LucideForward:oZ,LucideFrame:lZ,LucideFramer:cZ,LucideFrown:dZ,LucideFuel:uZ,LucideFullscreen:hZ,LucideFunctionSquare:yk,LucideGalleryHorizontal:pZ,LucideGalleryHorizontalEnd:mZ,LucideGalleryThumbnails:fZ,LucideGalleryVertical:gZ,LucideGalleryVerticalEnd:xZ,LucideGamepad:vZ,LucideGamepad2:yZ,LucideGanttChart:vj,LucideGanttChartSquare:ky,LucideGauge:_Z,LucideGaugeCircle:Dj,LucideGavel:bZ,LucideGem:wZ,LucideGhost:sS,LucideGift:Vi,LucideGitBranch:NZ,LucideGitBranchPlus:jZ,LucideGitCommit:mN,LucideGitCommitHorizontal:mN,LucideGitCommitVertical:kZ,LucideGitCompare:CZ,LucideGitCompareArrows:SZ,LucideGitFork:MZ,LucideGitGraph:TZ,LucideGitMerge:AZ,LucideGitPullRequest:RZ,LucideGitPullRequestArrow:EZ,LucideGitPullRequestClosed:PZ,LucideGitPullRequestCreate:LZ,LucideGitPullRequestCreateArrow:IZ,LucideGitPullRequestDraft:DZ,LucideGithub:OZ,LucideGitlab:FZ,LucideGlassWater:zZ,LucideGlasses:BZ,LucideGlobe:gd,LucideGlobe2:sN,LucideGlobeLock:$Z,LucideGoal:qZ,LucideGrab:UZ,LucideGraduationCap:Dh,LucideGrape:VZ,LucideGrid:tx,LucideGrid2X2:fN,LucideGrid2X2Plus:pN,LucideGrid2x2:fN,LucideGrid2x2Check:HZ,LucideGrid2x2Plus:pN,LucideGrid2x2X:GZ,LucideGrid3X3:tx,LucideGrid3x3:tx,LucideGrip:KZ,LucideGripHorizontal:WZ,LucideGripVertical:uu,LucideGroup:ZZ,LucideGuitar:YZ,LucideHam:XZ,LucideHammer:QZ,LucideHand:xL,LucideHandCoins:JZ,LucideHandHeart:eY,LucideHandHelping:xN,LucideHandMetal:tY,LucideHandPlatter:sY,LucideHandshake:gL,LucideHardDrive:yL,LucideHardDriveDownload:rY,LucideHardDriveUpload:nY,LucideHardHat:aY,LucideHash:rS,LucideHaze:iY,LucideHdmiPort:oY,LucideHeading:uY,LucideHeading1:MM,LucideHeading2:TM,LucideHeading3:vL,LucideHeading4:lY,LucideHeading5:cY,LucideHeading6:dY,LucideHeadphoneOff:hY,LucideHeadphones:mY,LucideHeadset:pY,LucideHeart:Za,LucideHeartCrack:fY,LucideHeartHandshake:xY,LucideHeartOff:gY,LucideHeartPulse:yY,LucideHeater:vY,LucideHelpCircle:Sv,LucideHelpingHand:xN,LucideHexagon:_Y,LucideHighlighter:bY,LucideHistory:AM,LucideHome:Mn,LucideHop:jY,LucideHopOff:wY,LucideHospital:NY,LucideHotel:kY,LucideHourglass:SY,LucideHouse:Mn,LucideHousePlug:CY,LucideHousePlus:MY,LucideIceCream:yN,LucideIceCream2:gN,LucideIceCreamBowl:gN,LucideIceCreamCone:yN,LucideIdCard:TY,LucideImage:Uo,LucideImageDown:AY,LucideImageMinus:EY,LucideImageOff:PY,LucideImagePlay:IY,LucideImagePlus:Xv,LucideImageUp:LY,LucideImageUpscale:DY,LucideImages:RY,LucideImport:OY,LucideInbox:FY,LucideIndent:_N,LucideIndentDecrease:vN,LucideIndentIncrease:_N,LucideIndianRupee:zY,LucideInfinity:BY,LucideInfo:nS,LucideInspect:Nk,LucideInspectionPanel:$Y,LucideInstagram:hu,LucideItalic:aS,LucideIterationCcw:qY,LucideIterationCw:UY,LucideJapaneseYen:VY,LucideJoystick:HY,LucideKanban:Zy,LucideKanbanSquare:vk,LucideKanbanSquareDashed:hk,LucideKey:mp,LucideKeyRound:iS,LucideKeySquare:GY,LucideKeyboard:ZY,LucideKeyboardMusic:WY,LucideKeyboardOff:KY,LucideLamp:tX,LucideLampCeiling:YY,LucideLampDesk:XY,LucideLampFloor:QY,LucideLampWallDown:JY,LucideLampWallUp:eX,LucideLandPlot:sX,LucideLandmark:rX,LucideLanguages:nX,LucideLaptop:iX,LucideLaptop2:bN,LucideLaptopMinimal:bN,LucideLaptopMinimalCheck:aX,LucideLasso:lX,LucideLassoSelect:oX,LucideLaugh:cX,LucideLayers:hX,LucideLayers2:dX,LucideLayers3:uX,LucideLayout:Mv,LucideLayoutDashboard:oS,LucideLayoutGrid:pp,LucideLayoutList:mX,LucideLayoutPanelLeft:pX,LucideLayoutPanelTop:fX,LucideLayoutTemplate:lS,LucideLeaf:xX,LucideLeafyGreen:gX,LucideLectern:yX,LucideLetterText:vX,LucideLibrary:cS,LucideLibraryBig:_X,LucideLibrarySquare:_k,LucideLifeBuoy:EM,LucideLigature:bX,LucideLightbulb:Eb,LucideLightbulbOff:wX,LucideLineChart:xj,LucideLink:go,LucideLink2:Do,LucideLink2Off:jX,LucideLinkedin:fp,LucideList:Rh,LucideListCheck:NX,LucideListChecks:kX,LucideListCollapse:SX,LucideListEnd:CX,LucideListFilter:MX,LucideListMinus:TX,LucideListMusic:AX,LucideListOrdered:Yy,LucideListPlus:EX,LucideListRestart:PX,LucideListStart:IX,LucideListTodo:LX,LucideListTree:DX,LucideListVideo:RX,LucideListX:OX,LucideLoader:zX,LucideLoader2:ps,LucideLoaderCircle:ps,LucideLoaderPinwheel:FX,LucideLocate:PM,LucideLocateFixed:BX,LucideLocateOff:$X,LucideLock:yd,LucideLockKeyhole:qX,LucideLockKeyholeOpen:wN,LucideLockOpen:jN,LucideLogIn:dS,LucideLogOut:IM,LucideLogs:UX,LucideLollipop:VX,LucideLuggage:HX,LucideMSquare:bk,LucideMagnet:GX,LucideMail:tr,LucideMailCheck:WX,LucideMailMinus:KX,LucideMailOpen:ZX,LucideMailPlus:_L,LucideMailQuestion:YX,LucideMailSearch:XX,LucideMailWarning:QX,LucideMailX:bL,LucideMailbox:JX,LucideMails:eQ,LucideMap:uS,LucideMapPin:La,LucideMapPinCheck:sQ,LucideMapPinCheckInside:tQ,LucideMapPinHouse:rQ,LucideMapPinMinus:aQ,LucideMapPinMinusInside:nQ,LucideMapPinOff:iQ,LucideMapPinPlus:lQ,LucideMapPinPlusInside:oQ,LucideMapPinX:dQ,LucideMapPinXInside:cQ,LucideMapPinned:uQ,LucideMartini:hQ,LucideMaximize:wL,LucideMaximize2:mQ,LucideMedal:Qv,LucideMegaphone:dh,LucideMegaphoneOff:pQ,LucideMeh:fQ,LucideMemoryStick:xQ,LucideMenu:hS,LucideMenuSquare:wk,LucideMerge:gQ,LucideMessageCircle:bc,LucideMessageCircleCode:yQ,LucideMessageCircleDashed:vQ,LucideMessageCircleHeart:LM,LucideMessageCircleMore:_Q,LucideMessageCircleOff:bQ,LucideMessageCirclePlus:wQ,LucideMessageCircleQuestion:jL,LucideMessageCircleReply:jQ,LucideMessageCircleWarning:NQ,LucideMessageCircleX:kQ,LucideMessageSquare:Si,LucideMessageSquareCode:SQ,LucideMessageSquareDashed:CQ,LucideMessageSquareDiff:MQ,LucideMessageSquareDot:TQ,LucideMessageSquareHeart:AQ,LucideMessageSquareLock:EQ,LucideMessageSquareMore:NL,LucideMessageSquareOff:PQ,LucideMessageSquarePlus:DM,LucideMessageSquareQuote:kL,LucideMessageSquareReply:IQ,LucideMessageSquareShare:LQ,LucideMessageSquareText:DQ,LucideMessageSquareWarning:RQ,LucideMessageSquareX:OQ,LucideMessagesSquare:FQ,LucideMic:SL,LucideMic2:NN,LucideMicOff:zQ,LucideMicVocal:NN,LucideMicrochip:BQ,LucideMicroscope:$Q,LucideMicrowave:qQ,LucideMilestone:UQ,LucideMilk:HQ,LucideMilkOff:VQ,LucideMinimize:WQ,LucideMinimize2:GQ,LucideMinus:Xy,LucideMinusCircle:Rj,LucideMinusSquare:jk,LucideMonitor:pS,LucideMonitorCheck:KQ,LucideMonitorCog:ZQ,LucideMonitorDot:YQ,LucideMonitorDown:XQ,LucideMonitorOff:QQ,LucideMonitorPause:JQ,LucideMonitorPlay:eJ,LucideMonitorSmartphone:tJ,LucideMonitorSpeaker:sJ,LucideMonitorStop:rJ,LucideMonitorUp:mS,LucideMonitorX:nJ,LucideMoon:iJ,LucideMoonStar:aJ,LucideMoreHorizontal:dx,LucideMoreVertical:cx,LucideMountain:lJ,LucideMountainSnow:oJ,LucideMouse:hJ,LucideMouseOff:cJ,LucideMousePointer:sh,LucideMousePointer2:dJ,LucideMousePointerBan:uJ,LucideMousePointerClick:Cm,LucideMousePointerSquareDashed:mk,LucideMove:kJ,LucideMove3D:kN,LucideMove3d:kN,LucideMoveDiagonal:pJ,LucideMoveDiagonal2:mJ,LucideMoveDown:gJ,LucideMoveDownLeft:fJ,LucideMoveDownRight:xJ,LucideMoveHorizontal:yJ,LucideMoveLeft:vJ,LucideMoveRight:_J,LucideMoveUp:jJ,LucideMoveUpLeft:bJ,LucideMoveUpRight:wJ,LucideMoveVertical:NJ,LucideMusic:TJ,LucideMusic2:SJ,LucideMusic3:CJ,LucideMusic4:MJ,LucideNavigation:CL,LucideNavigation2:EJ,LucideNavigation2Off:AJ,LucideNavigationOff:PJ,LucideNetwork:IJ,LucideNewspaper:Jv,LucideNfc:LJ,LucideNotebook:FJ,LucideNotebookPen:DJ,LucideNotebookTabs:RJ,LucideNotebookText:OJ,LucideNotepadText:BJ,LucideNotepadTextDashed:zJ,LucideNut:qJ,LucideNutOff:$J,LucideOctagon:VJ,LucideOctagonAlert:Cv,LucideOctagonMinus:UJ,LucideOctagonPause:SN,LucideOctagonX:CN,LucideOmega:HJ,LucideOption:GJ,LucideOrbit:WJ,LucideOrigami:KJ,LucideOutdent:vN,LucidePackage:al,LucidePackage2:ZJ,LucidePackageCheck:YJ,LucidePackageMinus:XJ,LucidePackageOpen:QJ,LucidePackagePlus:JJ,LucidePackageSearch:eee,LucidePackageX:tee,LucidePaintBucket:see,LucidePaintRoller:ree,LucidePaintbrush:nee,LucidePaintbrush2:MN,LucidePaintbrushVertical:MN,LucidePalette:Rl,LucidePalmtree:Hk,LucidePanelBottom:oee,LucidePanelBottomClose:aee,LucidePanelBottomDashed:TN,LucidePanelBottomInactive:TN,LucidePanelBottomOpen:iee,LucidePanelLeft:IN,LucidePanelLeftClose:AN,LucidePanelLeftDashed:EN,LucidePanelLeftInactive:EN,LucidePanelLeftOpen:PN,LucidePanelRight:dee,LucidePanelRightClose:lee,LucidePanelRightDashed:LN,LucidePanelRightInactive:LN,LucidePanelRightOpen:cee,LucidePanelTop:mee,LucidePanelTopClose:uee,LucidePanelTopDashed:DN,LucidePanelTopInactive:DN,LucidePanelTopOpen:hee,LucidePanelsLeftBottom:pee,LucidePanelsLeftRight:Jj,LucidePanelsRightBottom:fee,LucidePanelsTopBottom:BN,LucidePanelsTopLeft:Mv,LucidePaperclip:fS,LucideParentheses:xee,LucideParkingCircle:Fj,LucideParkingCircleOff:Oj,LucideParkingMeter:gee,LucideParkingSquare:Sk,LucideParkingSquareOff:kk,LucidePartyPopper:Bd,LucidePause:uh,LucidePauseCircle:zj,LucidePauseOctagon:SN,LucidePawPrint:yee,LucidePcCase:vee,LucidePen:Ry,LucidePenBox:Gc,LucidePenLine:Tv,LucidePenOff:_ee,LucidePenSquare:Gc,LucidePenTool:Pb,LucidePencil:pa,LucidePencilLine:bee,LucidePencilOff:wee,LucidePencilRuler:jee,LucidePentagon:Nee,LucidePercent:RM,LucidePercentCircle:Bj,LucidePercentDiamond:tN,LucidePercentSquare:Ck,LucidePersonStanding:kee,LucidePhilippinePeso:See,LucidePhone:Tn,LucidePhoneCall:Cee,LucidePhoneForwarded:Mee,LucidePhoneIncoming:Tee,LucidePhoneMissed:Aee,LucidePhoneOff:Eee,LucidePhoneOutgoing:Pee,LucidePi:Iee,LucidePiSquare:Mk,LucidePiano:Lee,LucidePickaxe:Dee,LucidePictureInPicture:Oee,LucidePictureInPicture2:Ree,LucidePieChart:_j,LucidePiggyBank:Fee,LucidePilcrow:$ee,LucidePilcrowLeft:zee,LucidePilcrowRight:Bee,LucidePilcrowSquare:Tk,LucidePill:Uee,LucidePillBottle:qee,LucidePin:Ib,LucidePinOff:ML,LucidePipette:Vee,LucidePizza:Hee,LucidePlane:Kee,LucidePlaneLanding:Gee,LucidePlaneTakeoff:Wee,LucidePlay:Co,LucidePlayCircle:tp,LucidePlaySquare:Ak,LucidePlug:TL,LucidePlug2:Zee,LucidePlugZap:RN,LucidePlugZap2:RN,LucidePlus:Bs,LucidePlusCircle:$j,LucidePlusSquare:Ek,LucidePocket:Xee,LucidePocketKnife:Yee,LucidePodcast:Qee,LucidePointer:ete,LucidePointerOff:Jee,LucidePopcorn:tte,LucidePopsicle:ste,LucidePoundSterling:rte,LucidePower:AL,LucidePowerCircle:qj,LucidePowerOff:nte,LucidePowerSquare:Pk,LucidePresentation:Rg,LucidePrinter:EL,LucidePrinterCheck:ate,LucideProjector:ite,LucideProportions:ote,LucidePuzzle:lte,LucidePyramid:cte,LucideQrCode:Qy,LucideQuote:xS,LucideRabbit:dte,LucideRadar:ute,LucideRadiation:hte,LucideRadical:mte,LucideRadio:e1,LucideRadioReceiver:pte,LucideRadioTower:fte,LucideRadius:xte,LucideRailSymbol:gte,LucideRainbow:yte,LucideRat:vte,LucideRatio:_te,LucideReceipt:Tte,LucideReceiptCent:bte,LucideReceiptEuro:wte,LucideReceiptIndianRupee:jte,LucideReceiptJapaneseYen:Nte,LucideReceiptPoundSterling:kte,LucideReceiptRussianRuble:Ste,LucideReceiptSwissFranc:Cte,LucideReceiptText:Mte,LucideRectangleEllipsis:ON,LucideRectangleHorizontal:Ate,LucideRectangleVertical:Ete,LucideRecycle:Pte,LucideRedo:gS,LucideRedo2:Ite,LucideRedoDot:Lte,LucideRefreshCcw:OM,LucideRefreshCcwDot:Dte,LucideRefreshCw:to,LucideRefreshCwOff:Rte,LucideRefrigerator:Ote,LucideRegex:Fte,LucideRemoveFormatting:zte,LucideRepeat:PL,LucideRepeat1:Bte,LucideRepeat2:$te,LucideReplace:Ute,LucideReplaceAll:qte,LucideReply:IL,LucideReplyAll:Vte,LucideRewind:Hte,LucideRibbon:Gte,LucideRocket:Jy,LucideRockingChair:Wte,LucideRollerCoaster:Kte,LucideRotate3D:FN,LucideRotate3d:FN,LucideRotateCcw:e0,LucideRotateCcwSquare:Zte,LucideRotateCw:LL,LucideRotateCwSquare:Yte,LucideRoute:Qte,LucideRouteOff:Xte,LucideRouter:Jte,LucideRows:zN,LucideRows2:zN,LucideRows3:BN,LucideRows4:ese,LucideRss:tse,LucideRuler:yS,LucideRussianRuble:sse,LucideSailboat:rse,LucideSalad:nse,LucideSandwich:ase,LucideSatellite:ose,LucideSatelliteDish:ise,LucideSave:wc,LucideSaveAll:lse,LucideSaveOff:cse,LucideScale:DL,LucideScale3D:$N,LucideScale3d:$N,LucideScaling:dse,LucideScan:yse,LucideScanBarcode:use,LucideScanEye:hse,LucideScanFace:mse,LucideScanLine:pse,LucideScanQrCode:fse,LucideScanSearch:xse,LucideScanText:gse,LucideScatterChart:bj,LucideSchool:vse,LucideSchool2:Wk,LucideScissors:bse,LucideScissorsLineDashed:_se,LucideScissorsSquare:Ik,LucideScissorsSquareDashedBottom:ak,LucideScreenShare:jse,LucideScreenShareOff:wse,LucideScroll:kse,LucideScrollText:Nse,LucideSearch:tn,LucideSearchCheck:Sse,LucideSearchCode:Cse,LucideSearchSlash:Mse,LucideSearchX:RL,LucideSection:Tse,LucideSend:Nn,LucideSendHorizonal:qN,LucideSendHorizontal:qN,LucideSendToBack:Ase,LucideSeparatorHorizontal:Ese,LucideSeparatorVertical:Pse,LucideServer:Rse,LucideServerCog:Ise,LucideServerCrash:Lse,LucideServerOff:Dse,LucideSettings:So,LucideSettings2:OL,LucideShapes:Ose,LucideShare:FL,LucideShare2:vd,LucideSheet:Fse,LucideShell:zse,LucideShield:Ru,LucideShieldAlert:Bse,LucideShieldBan:$se,LucideShieldCheck:Lb,LucideShieldClose:UN,LucideShieldEllipsis:qse,LucideShieldHalf:Use,LucideShieldMinus:Vse,LucideShieldOff:vS,LucideShieldPlus:Hse,LucideShieldQuestion:Gse,LucideShieldX:UN,LucideShip:Kse,LucideShipWheel:Wse,LucideShirt:Zse,LucideShoppingBag:t0,LucideShoppingBasket:Yse,LucideShoppingCart:ip,LucideShovel:Xse,LucideShowerHead:Qse,LucideShrink:Jse,LucideShrub:ere,LucideShuffle:_S,LucideSidebar:IN,LucideSidebarClose:AN,LucideSidebarOpen:PN,LucideSigma:tre,LucideSigmaSquare:Lk,LucideSignal:ire,LucideSignalHigh:sre,LucideSignalLow:rre,LucideSignalMedium:nre,LucideSignalZero:are,LucideSignature:ore,LucideSignpost:cre,LucideSignpostBig:lre,LucideSiren:dre,LucideSkipBack:ure,LucideSkipForward:hre,LucideSkull:mre,LucideSlack:pre,LucideSlash:fre,LucideSlashSquare:Dk,LucideSlice:xre,LucideSliders:VN,LucideSlidersHorizontal:bS,LucideSlidersVertical:VN,LucideSmartphone:s0,LucideSmartphoneCharging:gre,LucideSmartphoneNfc:yre,LucideSmile:_re,LucideSmilePlus:vre,LucideSnail:bre,LucideSnowflake:Bv,LucideSofa:wre,LucideSortAsc:tj,LucideSortDesc:Q2,LucideSoup:jre,LucideSpace:Nre,LucideSpade:kre,LucideSparkle:Sre,LucideSparkles:qr,LucideSpeaker:Cre,LucideSpeech:Mre,LucideSpellCheck:Are,LucideSpellCheck2:Tre,LucideSpline:Ere,LucideSplit:Pre,LucideSplitSquareHorizontal:Rk,LucideSplitSquareVertical:Ok,LucideSprayCan:Ire,LucideSprout:wS,LucideSquare:r0,LucideSquareActivity:HN,LucideSquareArrowDown:KN,LucideSquareArrowDownLeft:GN,LucideSquareArrowDownRight:WN,LucideSquareArrowLeft:ZN,LucideSquareArrowOutDownLeft:YN,LucideSquareArrowOutDownRight:XN,LucideSquareArrowOutUpLeft:QN,LucideSquareArrowOutUpRight:JN,LucideSquareArrowRight:ek,LucideSquareArrowUp:rk,LucideSquareArrowUpLeft:tk,LucideSquareArrowUpRight:sk,LucideSquareAsterisk:nk,LucideSquareBottomDashedScissors:ak,LucideSquareChartGantt:ky,LucideSquareCheck:ik,LucideSquareCheckBig:Av,LucideSquareChevronDown:ok,LucideSquareChevronLeft:lk,LucideSquareChevronRight:ck,LucideSquareChevronUp:dk,LucideSquareCode:uk,LucideSquareDashed:pk,LucideSquareDashedBottom:Dre,LucideSquareDashedBottomCode:Lre,LucideSquareDashedKanban:hk,LucideSquareDashedMousePointer:mk,LucideSquareDivide:fk,LucideSquareDot:xk,LucideSquareEqual:gk,LucideSquareFunction:yk,LucideSquareGanttChart:ky,LucideSquareKanban:vk,LucideSquareLibrary:_k,LucideSquareM:bk,LucideSquareMenu:wk,LucideSquareMinus:jk,LucideSquareMousePointer:Nk,LucideSquareParking:Sk,LucideSquareParkingOff:kk,LucideSquarePen:Gc,LucideSquarePercent:Ck,LucideSquarePi:Mk,LucideSquarePilcrow:Tk,LucideSquarePlay:Ak,LucideSquarePlus:Ek,LucideSquarePower:Pk,LucideSquareRadical:Rre,LucideSquareScissors:Ik,LucideSquareSigma:Lk,LucideSquareSlash:Dk,LucideSquareSplitHorizontal:Rk,LucideSquareSplitVertical:Ok,LucideSquareSquare:Ore,LucideSquareStack:Fre,LucideSquareTerminal:Fk,LucideSquareUser:Bk,LucideSquareUserRound:zk,LucideSquareX:$k,LucideSquircle:zre,LucideSquirrel:Bre,LucideStamp:$re,LucideStar:Gn,LucideStarHalf:qre,LucideStarOff:Ure,LucideStars:qr,LucideStepBack:Vre,LucideStepForward:Hre,LucideStethoscope:Gre,LucideSticker:Wre,LucideStickyNote:Kre,LucideStopCircle:Vj,LucideStore:Zre,LucideStretchHorizontal:Yre,LucideStretchVertical:Xre,LucideStrikethrough:zL,LucideSubscript:Qre,LucideSubtitles:cj,LucideSun:t1,LucideSunDim:Jre,LucideSunMedium:ene,LucideSunMoon:tne,LucideSunSnow:sne,LucideSunrise:rne,LucideSunset:nne,LucideSuperscript:ane,LucideSwatchBook:ine,LucideSwissFranc:one,LucideSwitchCamera:lne,LucideSword:cne,LucideSwords:dne,LucideSyringe:une,LucideTable:zM,LucideTable2:FM,LucideTableCellsMerge:hne,LucideTableCellsSplit:mne,LucideTableColumnsSplit:pne,LucideTableOfContents:fne,LucideTableProperties:xne,LucideTableRowsSplit:gne,LucideTablet:vne,LucideTabletSmartphone:yne,LucideTablets:_ne,LucideTag:hh,LucideTags:bne,LucideTally1:wne,LucideTally2:jne,LucideTally3:Nne,LucideTally4:kne,LucideTally5:Sne,LucideTangent:Cne,LucideTarget:Oh,LucideTelescope:Mne,LucideTent:Ane,LucideTentTree:Tne,LucideTerminal:Ene,LucideTerminalSquare:Fk,LucideTestTube:Pne,LucideTestTube2:qk,LucideTestTubeDiagonal:qk,LucideTestTubes:Ine,LucideText:Fne,LucideTextCursor:Dne,LucideTextCursorInput:Lne,LucideTextQuote:Rne,LucideTextSearch:One,LucideTextSelect:Uk,LucideTextSelection:Uk,LucideTheater:zne,LucideThermometer:qne,LucideThermometerSnowflake:Bne,LucideThermometerSun:$ne,LucideThumbsDown:BL,LucideThumbsUp:Ou,LucideTicket:$L,LucideTicketCheck:Une,LucideTicketMinus:Vne,LucideTicketPercent:Hne,LucideTicketPlus:Gne,LucideTicketSlash:Wne,LucideTicketX:Kne,LucideTickets:Yne,LucideTicketsPlane:Zne,LucideTimer:Jne,LucideTimerOff:Xne,LucideTimerReset:Qne,LucideToggleLeft:eae,LucideToggleRight:tae,LucideToilet:sae,LucideTornado:rae,LucideTorus:nae,LucideTouchpad:iae,LucideTouchpadOff:aae,LucideTowerControl:oae,LucideToyBrick:lae,LucideTractor:cae,LucideTrafficCone:dae,LucideTrain:Vk,LucideTrainFront:hae,LucideTrainFrontTunnel:uae,LucideTrainTrack:mae,LucideTramFront:Vk,LucideTrash:pae,LucideTrash2:yr,LucideTreeDeciduous:fae,LucideTreePalm:Hk,LucideTreePine:Db,LucideTrees:xae,LucideTrello:gae,LucideTrendingDown:jS,LucideTrendingUp:Yo,LucideTrendingUpDown:yae,LucideTriangle:_ae,LucideTriangleAlert:Qc,LucideTriangleRight:vae,LucideTrophy:Hi,LucideTruck:qL,LucideTurtle:bae,LucideTv:jae,LucideTv2:Gk,LucideTvMinimal:Gk,LucideTvMinimalPlay:wae,LucideTwitch:Nae,LucideTwitter:kae,LucideType:Cae,LucideTypeOutline:Sae,LucideUmbrella:Tae,LucideUmbrellaOff:Mae,LucideUnderline:UL,LucideUndo:NS,LucideUndo2:Aae,LucideUndoDot:Eae,LucideUnfoldHorizontal:Pae,LucideUnfoldVertical:Iae,LucideUngroup:Lae,LucideUniversity:Wk,LucideUnlink:kS,LucideUnlink2:Dae,LucideUnlock:jN,LucideUnlockKeyhole:wN,LucideUnplug:Rae,LucideUpload:Da,LucideUploadCloud:Yj,LucideUsb:Oae,LucideUser:Ei,LucideUser2:Jk,LucideUserCheck:Rb,LucideUserCheck2:Kk,LucideUserCircle:Gj,LucideUserCircle2:Hj,LucideUserCog:VL,LucideUserCog2:Zk,LucideUserMinus:HL,LucideUserMinus2:Yk,LucideUserPen:Fae,LucideUserPlus:il,LucideUserPlus2:Xk,LucideUserRound:Jk,LucideUserRoundCheck:Kk,LucideUserRoundCog:Zk,LucideUserRoundMinus:Yk,LucideUserRoundPen:zae,LucideUserRoundPlus:Xk,LucideUserRoundSearch:Bae,LucideUserRoundX:Qk,LucideUserSearch:$ae,LucideUserSquare:Bk,LucideUserSquare2:zk,LucideUserX:qae,LucideUserX2:Qk,LucideUsers:cr,LucideUsers2:e4,LucideUsersRound:e4,LucideUtensils:s4,LucideUtensilsCrossed:t4,LucideUtilityPole:Uae,LucideVariable:BM,LucideVault:Vae,LucideVegan:Hae,LucideVenetianMask:Gae,LucideVerified:nj,LucideVibrate:Kae,LucideVibrateOff:Wae,LucideVideo:hn,LucideVideoOff:Zae,LucideVideotape:Yae,LucideView:Xae,LucideVoicemail:Qae,LucideVolleyball:Jae,LucideVolume:nie,LucideVolume1:eie,LucideVolume2:tie,LucideVolumeOff:sie,LucideVolumeX:rie,LucideVote:aie,LucideWallet:GL,LucideWallet2:r4,LucideWalletCards:iie,LucideWalletMinimal:r4,LucideWallpaper:oie,LucideWand:lie,LucideWand2:Ev,LucideWandSparkles:Ev,LucideWarehouse:cie,LucideWashingMachine:die,LucideWatch:uie,LucideWaves:hie,LucideWaypoints:mie,LucideWebcam:pie,LucideWebhook:xie,LucideWebhookOff:fie,LucideWeight:gie,LucideWheat:vie,LucideWheatOff:yie,LucideWholeWord:_ie,LucideWifi:kie,LucideWifiHigh:bie,LucideWifiLow:wie,LucideWifiOff:jie,LucideWifiZero:Nie,LucideWind:Cie,LucideWindArrowDown:Sie,LucideWine:Tie,LucideWineOff:Mie,LucideWorkflow:Aie,LucideWorm:Eie,LucideWrapText:Pie,LucideWrench:Og,LucideX:Sr,LucideXCircle:Ql,LucideXOctagon:CN,LucideXSquare:$k,LucideYoutube:Iie,LucideZap:Fh,LucideZapOff:Lie,LucideZoomIn:Ob,LucideZoomOut:$M,Luggage:HX,LuggageIcon:HX,MSquare:bk,MSquareIcon:bk,Magnet:GX,MagnetIcon:GX,Mail:tr,MailCheck:WX,MailCheckIcon:WX,MailIcon:tr,MailMinus:KX,MailMinusIcon:KX,MailOpen:ZX,MailOpenIcon:ZX,MailPlus:_L,MailPlusIcon:_L,MailQuestion:YX,MailQuestionIcon:YX,MailSearch:XX,MailSearchIcon:XX,MailWarning:QX,MailWarningIcon:QX,MailX:bL,MailXIcon:bL,Mailbox:JX,MailboxIcon:JX,Mails:eQ,MailsIcon:eQ,Map:uS,MapIcon:uS,MapPin:La,MapPinCheck:sQ,MapPinCheckIcon:sQ,MapPinCheckInside:tQ,MapPinCheckInsideIcon:tQ,MapPinHouse:rQ,MapPinHouseIcon:rQ,MapPinIcon:La,MapPinMinus:aQ,MapPinMinusIcon:aQ,MapPinMinusInside:nQ,MapPinMinusInsideIcon:nQ,MapPinOff:iQ,MapPinOffIcon:iQ,MapPinPlus:lQ,MapPinPlusIcon:lQ,MapPinPlusInside:oQ,MapPinPlusInsideIcon:oQ,MapPinX:dQ,MapPinXIcon:dQ,MapPinXInside:cQ,MapPinXInsideIcon:cQ,MapPinned:uQ,MapPinnedIcon:uQ,Martini:hQ,MartiniIcon:hQ,Maximize:wL,Maximize2:mQ,Maximize2Icon:mQ,MaximizeIcon:wL,Medal:Qv,MedalIcon:Qv,Megaphone:dh,MegaphoneIcon:dh,MegaphoneOff:pQ,MegaphoneOffIcon:pQ,Meh:fQ,MehIcon:fQ,MemoryStick:xQ,MemoryStickIcon:xQ,Menu:hS,MenuIcon:hS,MenuSquare:wk,MenuSquareIcon:wk,Merge:gQ,MergeIcon:gQ,MessageCircle:bc,MessageCircleCode:yQ,MessageCircleCodeIcon:yQ,MessageCircleDashed:vQ,MessageCircleDashedIcon:vQ,MessageCircleHeart:LM,MessageCircleHeartIcon:LM,MessageCircleIcon:bc,MessageCircleMore:_Q,MessageCircleMoreIcon:_Q,MessageCircleOff:bQ,MessageCircleOffIcon:bQ,MessageCirclePlus:wQ,MessageCirclePlusIcon:wQ,MessageCircleQuestion:jL,MessageCircleQuestionIcon:jL,MessageCircleReply:jQ,MessageCircleReplyIcon:jQ,MessageCircleWarning:NQ,MessageCircleWarningIcon:NQ,MessageCircleX:kQ,MessageCircleXIcon:kQ,MessageSquare:Si,MessageSquareCode:SQ,MessageSquareCodeIcon:SQ,MessageSquareDashed:CQ,MessageSquareDashedIcon:CQ,MessageSquareDiff:MQ,MessageSquareDiffIcon:MQ,MessageSquareDot:TQ,MessageSquareDotIcon:TQ,MessageSquareHeart:AQ,MessageSquareHeartIcon:AQ,MessageSquareIcon:Si,MessageSquareLock:EQ,MessageSquareLockIcon:EQ,MessageSquareMore:NL,MessageSquareMoreIcon:NL,MessageSquareOff:PQ,MessageSquareOffIcon:PQ,MessageSquarePlus:DM,MessageSquarePlusIcon:DM,MessageSquareQuote:kL,MessageSquareQuoteIcon:kL,MessageSquareReply:IQ,MessageSquareReplyIcon:IQ,MessageSquareShare:LQ,MessageSquareShareIcon:LQ,MessageSquareText:DQ,MessageSquareTextIcon:DQ,MessageSquareWarning:RQ,MessageSquareWarningIcon:RQ,MessageSquareX:OQ,MessageSquareXIcon:OQ,MessagesSquare:FQ,MessagesSquareIcon:FQ,Mic:SL,Mic2:NN,Mic2Icon:NN,MicIcon:SL,MicOff:zQ,MicOffIcon:zQ,MicVocal:NN,MicVocalIcon:NN,Microchip:BQ,MicrochipIcon:BQ,Microscope:$Q,MicroscopeIcon:$Q,Microwave:qQ,MicrowaveIcon:qQ,Milestone:UQ,MilestoneIcon:UQ,Milk:HQ,MilkIcon:HQ,MilkOff:VQ,MilkOffIcon:VQ,Minimize:WQ,Minimize2:GQ,Minimize2Icon:GQ,MinimizeIcon:WQ,Minus:Xy,MinusCircle:Rj,MinusCircleIcon:Rj,MinusIcon:Xy,MinusSquare:jk,MinusSquareIcon:jk,Monitor:pS,MonitorCheck:KQ,MonitorCheckIcon:KQ,MonitorCog:ZQ,MonitorCogIcon:ZQ,MonitorDot:YQ,MonitorDotIcon:YQ,MonitorDown:XQ,MonitorDownIcon:XQ,MonitorIcon:pS,MonitorOff:QQ,MonitorOffIcon:QQ,MonitorPause:JQ,MonitorPauseIcon:JQ,MonitorPlay:eJ,MonitorPlayIcon:eJ,MonitorSmartphone:tJ,MonitorSmartphoneIcon:tJ,MonitorSpeaker:sJ,MonitorSpeakerIcon:sJ,MonitorStop:rJ,MonitorStopIcon:rJ,MonitorUp:mS,MonitorUpIcon:mS,MonitorX:nJ,MonitorXIcon:nJ,Moon:iJ,MoonIcon:iJ,MoonStar:aJ,MoonStarIcon:aJ,MoreHorizontal:dx,MoreHorizontalIcon:dx,MoreVertical:cx,MoreVerticalIcon:cx,Mountain:lJ,MountainIcon:lJ,MountainSnow:oJ,MountainSnowIcon:oJ,Mouse:hJ,MouseIcon:hJ,MouseOff:cJ,MouseOffIcon:cJ,MousePointer:sh,MousePointer2:dJ,MousePointer2Icon:dJ,MousePointerBan:uJ,MousePointerBanIcon:uJ,MousePointerClick:Cm,MousePointerClickIcon:Cm,MousePointerIcon:sh,MousePointerSquareDashed:mk,MousePointerSquareDashedIcon:mk,Move:kJ,Move3D:kN,Move3DIcon:kN,Move3d:kN,Move3dIcon:kN,MoveDiagonal:pJ,MoveDiagonal2:mJ,MoveDiagonal2Icon:mJ,MoveDiagonalIcon:pJ,MoveDown:gJ,MoveDownIcon:gJ,MoveDownLeft:fJ,MoveDownLeftIcon:fJ,MoveDownRight:xJ,MoveDownRightIcon:xJ,MoveHorizontal:yJ,MoveHorizontalIcon:yJ,MoveIcon:kJ,MoveLeft:vJ,MoveLeftIcon:vJ,MoveRight:_J,MoveRightIcon:_J,MoveUp:jJ,MoveUpIcon:jJ,MoveUpLeft:bJ,MoveUpLeftIcon:bJ,MoveUpRight:wJ,MoveUpRightIcon:wJ,MoveVertical:NJ,MoveVerticalIcon:NJ,Music:TJ,Music2:SJ,Music2Icon:SJ,Music3:CJ,Music3Icon:CJ,Music4:MJ,Music4Icon:MJ,MusicIcon:TJ,Navigation:CL,Navigation2:EJ,Navigation2Icon:EJ,Navigation2Off:AJ,Navigation2OffIcon:AJ,NavigationIcon:CL,NavigationOff:PJ,NavigationOffIcon:PJ,Network:IJ,NetworkIcon:IJ,Newspaper:Jv,NewspaperIcon:Jv,Nfc:LJ,NfcIcon:LJ,Notebook:FJ,NotebookIcon:FJ,NotebookPen:DJ,NotebookPenIcon:DJ,NotebookTabs:RJ,NotebookTabsIcon:RJ,NotebookText:OJ,NotebookTextIcon:OJ,NotepadText:BJ,NotepadTextDashed:zJ,NotepadTextDashedIcon:zJ,NotepadTextIcon:BJ,Nut:qJ,NutIcon:qJ,NutOff:$J,NutOffIcon:$J,Octagon:VJ,OctagonAlert:Cv,OctagonAlertIcon:Cv,OctagonIcon:VJ,OctagonMinus:UJ,OctagonMinusIcon:UJ,OctagonPause:SN,OctagonPauseIcon:SN,OctagonX:CN,OctagonXIcon:CN,Omega:HJ,OmegaIcon:HJ,Option:GJ,OptionIcon:GJ,Orbit:WJ,OrbitIcon:WJ,Origami:KJ,OrigamiIcon:KJ,Outdent:vN,OutdentIcon:vN,Package:al,Package2:ZJ,Package2Icon:ZJ,PackageCheck:YJ,PackageCheckIcon:YJ,PackageIcon:al,PackageMinus:XJ,PackageMinusIcon:XJ,PackageOpen:QJ,PackageOpenIcon:QJ,PackagePlus:JJ,PackagePlusIcon:JJ,PackageSearch:eee,PackageSearchIcon:eee,PackageX:tee,PackageXIcon:tee,PaintBucket:see,PaintBucketIcon:see,PaintRoller:ree,PaintRollerIcon:ree,Paintbrush:nee,Paintbrush2:MN,Paintbrush2Icon:MN,PaintbrushIcon:nee,PaintbrushVertical:MN,PaintbrushVerticalIcon:MN,Palette:Rl,PaletteIcon:Rl,Palmtree:Hk,PalmtreeIcon:Hk,PanelBottom:oee,PanelBottomClose:aee,PanelBottomCloseIcon:aee,PanelBottomDashed:TN,PanelBottomDashedIcon:TN,PanelBottomIcon:oee,PanelBottomInactive:TN,PanelBottomInactiveIcon:TN,PanelBottomOpen:iee,PanelBottomOpenIcon:iee,PanelLeft:IN,PanelLeftClose:AN,PanelLeftCloseIcon:AN,PanelLeftDashed:EN,PanelLeftDashedIcon:EN,PanelLeftIcon:IN,PanelLeftInactive:EN,PanelLeftInactiveIcon:EN,PanelLeftOpen:PN,PanelLeftOpenIcon:PN,PanelRight:dee,PanelRightClose:lee,PanelRightCloseIcon:lee,PanelRightDashed:LN,PanelRightDashedIcon:LN,PanelRightIcon:dee,PanelRightInactive:LN,PanelRightInactiveIcon:LN,PanelRightOpen:cee,PanelRightOpenIcon:cee,PanelTop:mee,PanelTopClose:uee,PanelTopCloseIcon:uee,PanelTopDashed:DN,PanelTopDashedIcon:DN,PanelTopIcon:mee,PanelTopInactive:DN,PanelTopInactiveIcon:DN,PanelTopOpen:hee,PanelTopOpenIcon:hee,PanelsLeftBottom:pee,PanelsLeftBottomIcon:pee,PanelsLeftRight:Jj,PanelsLeftRightIcon:Jj,PanelsRightBottom:fee,PanelsRightBottomIcon:fee,PanelsTopBottom:BN,PanelsTopBottomIcon:BN,PanelsTopLeft:Mv,PanelsTopLeftIcon:Mv,Paperclip:fS,PaperclipIcon:fS,Parentheses:xee,ParenthesesIcon:xee,ParkingCircle:Fj,ParkingCircleIcon:Fj,ParkingCircleOff:Oj,ParkingCircleOffIcon:Oj,ParkingMeter:gee,ParkingMeterIcon:gee,ParkingSquare:Sk,ParkingSquareIcon:Sk,ParkingSquareOff:kk,ParkingSquareOffIcon:kk,PartyPopper:Bd,PartyPopperIcon:Bd,Pause:uh,PauseCircle:zj,PauseCircleIcon:zj,PauseIcon:uh,PauseOctagon:SN,PauseOctagonIcon:SN,PawPrint:yee,PawPrintIcon:yee,PcCase:vee,PcCaseIcon:vee,Pen:Ry,PenBox:Gc,PenBoxIcon:Gc,PenIcon:Ry,PenLine:Tv,PenLineIcon:Tv,PenOff:_ee,PenOffIcon:_ee,PenSquare:Gc,PenSquareIcon:Gc,PenTool:Pb,PenToolIcon:Pb,Pencil:pa,PencilIcon:pa,PencilLine:bee,PencilLineIcon:bee,PencilOff:wee,PencilOffIcon:wee,PencilRuler:jee,PencilRulerIcon:jee,Pentagon:Nee,PentagonIcon:Nee,Percent:RM,PercentCircle:Bj,PercentCircleIcon:Bj,PercentDiamond:tN,PercentDiamondIcon:tN,PercentIcon:RM,PercentSquare:Ck,PercentSquareIcon:Ck,PersonStanding:kee,PersonStandingIcon:kee,PhilippinePeso:See,PhilippinePesoIcon:See,Phone:Tn,PhoneCall:Cee,PhoneCallIcon:Cee,PhoneForwarded:Mee,PhoneForwardedIcon:Mee,PhoneIcon:Tn,PhoneIncoming:Tee,PhoneIncomingIcon:Tee,PhoneMissed:Aee,PhoneMissedIcon:Aee,PhoneOff:Eee,PhoneOffIcon:Eee,PhoneOutgoing:Pee,PhoneOutgoingIcon:Pee,Pi:Iee,PiIcon:Iee,PiSquare:Mk,PiSquareIcon:Mk,Piano:Lee,PianoIcon:Lee,Pickaxe:Dee,PickaxeIcon:Dee,PictureInPicture:Oee,PictureInPicture2:Ree,PictureInPicture2Icon:Ree,PictureInPictureIcon:Oee,PieChart:_j,PieChartIcon:_j,PiggyBank:Fee,PiggyBankIcon:Fee,Pilcrow:$ee,PilcrowIcon:$ee,PilcrowLeft:zee,PilcrowLeftIcon:zee,PilcrowRight:Bee,PilcrowRightIcon:Bee,PilcrowSquare:Tk,PilcrowSquareIcon:Tk,Pill:Uee,PillBottle:qee,PillBottleIcon:qee,PillIcon:Uee,Pin:Ib,PinIcon:Ib,PinOff:ML,PinOffIcon:ML,Pipette:Vee,PipetteIcon:Vee,Pizza:Hee,PizzaIcon:Hee,Plane:Kee,PlaneIcon:Kee,PlaneLanding:Gee,PlaneLandingIcon:Gee,PlaneTakeoff:Wee,PlaneTakeoffIcon:Wee,Play:Co,PlayCircle:tp,PlayCircleIcon:tp,PlayIcon:Co,PlaySquare:Ak,PlaySquareIcon:Ak,Plug:TL,Plug2:Zee,Plug2Icon:Zee,PlugIcon:TL,PlugZap:RN,PlugZap2:RN,PlugZap2Icon:RN,PlugZapIcon:RN,Plus:Bs,PlusCircle:$j,PlusCircleIcon:$j,PlusIcon:Bs,PlusSquare:Ek,PlusSquareIcon:Ek,Pocket:Xee,PocketIcon:Xee,PocketKnife:Yee,PocketKnifeIcon:Yee,Podcast:Qee,PodcastIcon:Qee,Pointer:ete,PointerIcon:ete,PointerOff:Jee,PointerOffIcon:Jee,Popcorn:tte,PopcornIcon:tte,Popsicle:ste,PopsicleIcon:ste,PoundSterling:rte,PoundSterlingIcon:rte,Power:AL,PowerCircle:qj,PowerCircleIcon:qj,PowerIcon:AL,PowerOff:nte,PowerOffIcon:nte,PowerSquare:Pk,PowerSquareIcon:Pk,Presentation:Rg,PresentationIcon:Rg,Printer:EL,PrinterCheck:ate,PrinterCheckIcon:ate,PrinterIcon:EL,Projector:ite,ProjectorIcon:ite,Proportions:ote,ProportionsIcon:ote,Puzzle:lte,PuzzleIcon:lte,Pyramid:cte,PyramidIcon:cte,QrCode:Qy,QrCodeIcon:Qy,Quote:xS,QuoteIcon:xS,Rabbit:dte,RabbitIcon:dte,Radar:ute,RadarIcon:ute,Radiation:hte,RadiationIcon:hte,Radical:mte,RadicalIcon:mte,Radio:e1,RadioIcon:e1,RadioReceiver:pte,RadioReceiverIcon:pte,RadioTower:fte,RadioTowerIcon:fte,Radius:xte,RadiusIcon:xte,RailSymbol:gte,RailSymbolIcon:gte,Rainbow:yte,RainbowIcon:yte,Rat:vte,RatIcon:vte,Ratio:_te,RatioIcon:_te,Receipt:Tte,ReceiptCent:bte,ReceiptCentIcon:bte,ReceiptEuro:wte,ReceiptEuroIcon:wte,ReceiptIcon:Tte,ReceiptIndianRupee:jte,ReceiptIndianRupeeIcon:jte,ReceiptJapaneseYen:Nte,ReceiptJapaneseYenIcon:Nte,ReceiptPoundSterling:kte,ReceiptPoundSterlingIcon:kte,ReceiptRussianRuble:Ste,ReceiptRussianRubleIcon:Ste,ReceiptSwissFranc:Cte,ReceiptSwissFrancIcon:Cte,ReceiptText:Mte,ReceiptTextIcon:Mte,RectangleEllipsis:ON,RectangleEllipsisIcon:ON,RectangleHorizontal:Ate,RectangleHorizontalIcon:Ate,RectangleVertical:Ete,RectangleVerticalIcon:Ete,Recycle:Pte,RecycleIcon:Pte,Redo:gS,Redo2:Ite,Redo2Icon:Ite,RedoDot:Lte,RedoDotIcon:Lte,RedoIcon:gS,RefreshCcw:OM,RefreshCcwDot:Dte,RefreshCcwDotIcon:Dte,RefreshCcwIcon:OM,RefreshCw:to,RefreshCwIcon:to,RefreshCwOff:Rte,RefreshCwOffIcon:Rte,Refrigerator:Ote,RefrigeratorIcon:Ote,Regex:Fte,RegexIcon:Fte,RemoveFormatting:zte,RemoveFormattingIcon:zte,Repeat:PL,Repeat1:Bte,Repeat1Icon:Bte,Repeat2:$te,Repeat2Icon:$te,RepeatIcon:PL,Replace:Ute,ReplaceAll:qte,ReplaceAllIcon:qte,ReplaceIcon:Ute,Reply:IL,ReplyAll:Vte,ReplyAllIcon:Vte,ReplyIcon:IL,Rewind:Hte,RewindIcon:Hte,Ribbon:Gte,RibbonIcon:Gte,Rocket:Jy,RocketIcon:Jy,RockingChair:Wte,RockingChairIcon:Wte,RollerCoaster:Kte,RollerCoasterIcon:Kte,Rotate3D:FN,Rotate3DIcon:FN,Rotate3d:FN,Rotate3dIcon:FN,RotateCcw:e0,RotateCcwIcon:e0,RotateCcwSquare:Zte,RotateCcwSquareIcon:Zte,RotateCw:LL,RotateCwIcon:LL,RotateCwSquare:Yte,RotateCwSquareIcon:Yte,Route:Qte,RouteIcon:Qte,RouteOff:Xte,RouteOffIcon:Xte,Router:Jte,RouterIcon:Jte,Rows:zN,Rows2:zN,Rows2Icon:zN,Rows3:BN,Rows3Icon:BN,Rows4:ese,Rows4Icon:ese,RowsIcon:zN,Rss:tse,RssIcon:tse,Ruler:yS,RulerIcon:yS,RussianRuble:sse,RussianRubleIcon:sse,Sailboat:rse,SailboatIcon:rse,Salad:nse,SaladIcon:nse,Sandwich:ase,SandwichIcon:ase,Satellite:ose,SatelliteDish:ise,SatelliteDishIcon:ise,SatelliteIcon:ose,Save:wc,SaveAll:lse,SaveAllIcon:lse,SaveIcon:wc,SaveOff:cse,SaveOffIcon:cse,Scale:DL,Scale3D:$N,Scale3DIcon:$N,Scale3d:$N,Scale3dIcon:$N,ScaleIcon:DL,Scaling:dse,ScalingIcon:dse,Scan:yse,ScanBarcode:use,ScanBarcodeIcon:use,ScanEye:hse,ScanEyeIcon:hse,ScanFace:mse,ScanFaceIcon:mse,ScanIcon:yse,ScanLine:pse,ScanLineIcon:pse,ScanQrCode:fse,ScanQrCodeIcon:fse,ScanSearch:xse,ScanSearchIcon:xse,ScanText:gse,ScanTextIcon:gse,ScatterChart:bj,ScatterChartIcon:bj,School:vse,School2:Wk,School2Icon:Wk,SchoolIcon:vse,Scissors:bse,ScissorsIcon:bse,ScissorsLineDashed:_se,ScissorsLineDashedIcon:_se,ScissorsSquare:Ik,ScissorsSquareDashedBottom:ak,ScissorsSquareDashedBottomIcon:ak,ScissorsSquareIcon:Ik,ScreenShare:jse,ScreenShareIcon:jse,ScreenShareOff:wse,ScreenShareOffIcon:wse,Scroll:kse,ScrollIcon:kse,ScrollText:Nse,ScrollTextIcon:Nse,Search:tn,SearchCheck:Sse,SearchCheckIcon:Sse,SearchCode:Cse,SearchCodeIcon:Cse,SearchIcon:tn,SearchSlash:Mse,SearchSlashIcon:Mse,SearchX:RL,SearchXIcon:RL,Section:Tse,SectionIcon:Tse,Send:Nn,SendHorizonal:qN,SendHorizonalIcon:qN,SendHorizontal:qN,SendHorizontalIcon:qN,SendIcon:Nn,SendToBack:Ase,SendToBackIcon:Ase,SeparatorHorizontal:Ese,SeparatorHorizontalIcon:Ese,SeparatorVertical:Pse,SeparatorVerticalIcon:Pse,Server:Rse,ServerCog:Ise,ServerCogIcon:Ise,ServerCrash:Lse,ServerCrashIcon:Lse,ServerIcon:Rse,ServerOff:Dse,ServerOffIcon:Dse,Settings:So,Settings2:OL,Settings2Icon:OL,SettingsIcon:So,Shapes:Ose,ShapesIcon:Ose,Share:FL,Share2:vd,Share2Icon:vd,ShareIcon:FL,Sheet:Fse,SheetIcon:Fse,Shell:zse,ShellIcon:zse,Shield:Ru,ShieldAlert:Bse,ShieldAlertIcon:Bse,ShieldBan:$se,ShieldBanIcon:$se,ShieldCheck:Lb,ShieldCheckIcon:Lb,ShieldClose:UN,ShieldCloseIcon:UN,ShieldEllipsis:qse,ShieldEllipsisIcon:qse,ShieldHalf:Use,ShieldHalfIcon:Use,ShieldIcon:Ru,ShieldMinus:Vse,ShieldMinusIcon:Vse,ShieldOff:vS,ShieldOffIcon:vS,ShieldPlus:Hse,ShieldPlusIcon:Hse,ShieldQuestion:Gse,ShieldQuestionIcon:Gse,ShieldX:UN,ShieldXIcon:UN,Ship:Kse,ShipIcon:Kse,ShipWheel:Wse,ShipWheelIcon:Wse,Shirt:Zse,ShirtIcon:Zse,ShoppingBag:t0,ShoppingBagIcon:t0,ShoppingBasket:Yse,ShoppingBasketIcon:Yse,ShoppingCart:ip,ShoppingCartIcon:ip,Shovel:Xse,ShovelIcon:Xse,ShowerHead:Qse,ShowerHeadIcon:Qse,Shrink:Jse,ShrinkIcon:Jse,Shrub:ere,ShrubIcon:ere,Shuffle:_S,ShuffleIcon:_S,Sidebar:IN,SidebarClose:AN,SidebarCloseIcon:AN,SidebarIcon:IN,SidebarOpen:PN,SidebarOpenIcon:PN,Sigma:tre,SigmaIcon:tre,SigmaSquare:Lk,SigmaSquareIcon:Lk,Signal:ire,SignalHigh:sre,SignalHighIcon:sre,SignalIcon:ire,SignalLow:rre,SignalLowIcon:rre,SignalMedium:nre,SignalMediumIcon:nre,SignalZero:are,SignalZeroIcon:are,Signature:ore,SignatureIcon:ore,Signpost:cre,SignpostBig:lre,SignpostBigIcon:lre,SignpostIcon:cre,Siren:dre,SirenIcon:dre,SkipBack:ure,SkipBackIcon:ure,SkipForward:hre,SkipForwardIcon:hre,Skull:mre,SkullIcon:mre,Slack:pre,SlackIcon:pre,Slash:fre,SlashIcon:fre,SlashSquare:Dk,SlashSquareIcon:Dk,Slice:xre,SliceIcon:xre,Sliders:VN,SlidersHorizontal:bS,SlidersHorizontalIcon:bS,SlidersIcon:VN,SlidersVertical:VN,SlidersVerticalIcon:VN,Smartphone:s0,SmartphoneCharging:gre,SmartphoneChargingIcon:gre,SmartphoneIcon:s0,SmartphoneNfc:yre,SmartphoneNfcIcon:yre,Smile:_re,SmileIcon:_re,SmilePlus:vre,SmilePlusIcon:vre,Snail:bre,SnailIcon:bre,Snowflake:Bv,SnowflakeIcon:Bv,Sofa:wre,SofaIcon:wre,SortAsc:tj,SortAscIcon:tj,SortDesc:Q2,SortDescIcon:Q2,Soup:jre,SoupIcon:jre,Space:Nre,SpaceIcon:Nre,Spade:kre,SpadeIcon:kre,Sparkle:Sre,SparkleIcon:Sre,Sparkles:qr,SparklesIcon:qr,Speaker:Cre,SpeakerIcon:Cre,Speech:Mre,SpeechIcon:Mre,SpellCheck:Are,SpellCheck2:Tre,SpellCheck2Icon:Tre,SpellCheckIcon:Are,Spline:Ere,SplineIcon:Ere,Split:Pre,SplitIcon:Pre,SplitSquareHorizontal:Rk,SplitSquareHorizontalIcon:Rk,SplitSquareVertical:Ok,SplitSquareVerticalIcon:Ok,SprayCan:Ire,SprayCanIcon:Ire,Sprout:wS,SproutIcon:wS,Square:r0,SquareActivity:HN,SquareActivityIcon:HN,SquareArrowDown:KN,SquareArrowDownIcon:KN,SquareArrowDownLeft:GN,SquareArrowDownLeftIcon:GN,SquareArrowDownRight:WN,SquareArrowDownRightIcon:WN,SquareArrowLeft:ZN,SquareArrowLeftIcon:ZN,SquareArrowOutDownLeft:YN,SquareArrowOutDownLeftIcon:YN,SquareArrowOutDownRight:XN,SquareArrowOutDownRightIcon:XN,SquareArrowOutUpLeft:QN,SquareArrowOutUpLeftIcon:QN,SquareArrowOutUpRight:JN,SquareArrowOutUpRightIcon:JN,SquareArrowRight:ek,SquareArrowRightIcon:ek,SquareArrowUp:rk,SquareArrowUpIcon:rk,SquareArrowUpLeft:tk,SquareArrowUpLeftIcon:tk,SquareArrowUpRight:sk,SquareArrowUpRightIcon:sk,SquareAsterisk:nk,SquareAsteriskIcon:nk,SquareBottomDashedScissors:ak,SquareBottomDashedScissorsIcon:ak,SquareChartGantt:ky,SquareChartGanttIcon:ky,SquareCheck:ik,SquareCheckBig:Av,SquareCheckBigIcon:Av,SquareCheckIcon:ik,SquareChevronDown:ok,SquareChevronDownIcon:ok,SquareChevronLeft:lk,SquareChevronLeftIcon:lk,SquareChevronRight:ck,SquareChevronRightIcon:ck,SquareChevronUp:dk,SquareChevronUpIcon:dk,SquareCode:uk,SquareCodeIcon:uk,SquareDashed:pk,SquareDashedBottom:Dre,SquareDashedBottomCode:Lre,SquareDashedBottomCodeIcon:Lre,SquareDashedBottomIcon:Dre,SquareDashedIcon:pk,SquareDashedKanban:hk,SquareDashedKanbanIcon:hk,SquareDashedMousePointer:mk,SquareDashedMousePointerIcon:mk,SquareDivide:fk,SquareDivideIcon:fk,SquareDot:xk,SquareDotIcon:xk,SquareEqual:gk,SquareEqualIcon:gk,SquareFunction:yk,SquareFunctionIcon:yk,SquareGanttChart:ky,SquareGanttChartIcon:ky,SquareIcon:r0,SquareKanban:vk,SquareKanbanIcon:vk,SquareLibrary:_k,SquareLibraryIcon:_k,SquareM:bk,SquareMIcon:bk,SquareMenu:wk,SquareMenuIcon:wk,SquareMinus:jk,SquareMinusIcon:jk,SquareMousePointer:Nk,SquareMousePointerIcon:Nk,SquareParking:Sk,SquareParkingIcon:Sk,SquareParkingOff:kk,SquareParkingOffIcon:kk,SquarePen:Gc,SquarePenIcon:Gc,SquarePercent:Ck,SquarePercentIcon:Ck,SquarePi:Mk,SquarePiIcon:Mk,SquarePilcrow:Tk,SquarePilcrowIcon:Tk,SquarePlay:Ak,SquarePlayIcon:Ak,SquarePlus:Ek,SquarePlusIcon:Ek,SquarePower:Pk,SquarePowerIcon:Pk,SquareRadical:Rre,SquareRadicalIcon:Rre,SquareScissors:Ik,SquareScissorsIcon:Ik,SquareSigma:Lk,SquareSigmaIcon:Lk,SquareSlash:Dk,SquareSlashIcon:Dk,SquareSplitHorizontal:Rk,SquareSplitHorizontalIcon:Rk,SquareSplitVertical:Ok,SquareSplitVerticalIcon:Ok,SquareSquare:Ore,SquareSquareIcon:Ore,SquareStack:Fre,SquareStackIcon:Fre,SquareTerminal:Fk,SquareTerminalIcon:Fk,SquareUser:Bk,SquareUserIcon:Bk,SquareUserRound:zk,SquareUserRoundIcon:zk,SquareX:$k,SquareXIcon:$k,Squircle:zre,SquircleIcon:zre,Squirrel:Bre,SquirrelIcon:Bre,Stamp:$re,StampIcon:$re,Star:Gn,StarHalf:qre,StarHalfIcon:qre,StarIcon:Gn,StarOff:Ure,StarOffIcon:Ure,Stars:qr,StarsIcon:qr,StepBack:Vre,StepBackIcon:Vre,StepForward:Hre,StepForwardIcon:Hre,Stethoscope:Gre,StethoscopeIcon:Gre,Sticker:Wre,StickerIcon:Wre,StickyNote:Kre,StickyNoteIcon:Kre,StopCircle:Vj,StopCircleIcon:Vj,Store:Zre,StoreIcon:Zre,StretchHorizontal:Yre,StretchHorizontalIcon:Yre,StretchVertical:Xre,StretchVerticalIcon:Xre,Strikethrough:zL,StrikethroughIcon:zL,Subscript:Qre,SubscriptIcon:Qre,Subtitles:cj,SubtitlesIcon:cj,Sun:t1,SunDim:Jre,SunDimIcon:Jre,SunIcon:t1,SunMedium:ene,SunMediumIcon:ene,SunMoon:tne,SunMoonIcon:tne,SunSnow:sne,SunSnowIcon:sne,Sunrise:rne,SunriseIcon:rne,Sunset:nne,SunsetIcon:nne,Superscript:ane,SuperscriptIcon:ane,SwatchBook:ine,SwatchBookIcon:ine,SwissFranc:one,SwissFrancIcon:one,SwitchCamera:lne,SwitchCameraIcon:lne,Sword:cne,SwordIcon:cne,Swords:dne,SwordsIcon:dne,Syringe:une,SyringeIcon:une,Table:zM,Table2:FM,Table2Icon:FM,TableCellsMerge:hne,TableCellsMergeIcon:hne,TableCellsSplit:mne,TableCellsSplitIcon:mne,TableColumnsSplit:pne,TableColumnsSplitIcon:pne,TableIcon:zM,TableOfContents:fne,TableOfContentsIcon:fne,TableProperties:xne,TablePropertiesIcon:xne,TableRowsSplit:gne,TableRowsSplitIcon:gne,Tablet:vne,TabletIcon:vne,TabletSmartphone:yne,TabletSmartphoneIcon:yne,Tablets:_ne,TabletsIcon:_ne,Tag:hh,TagIcon:hh,Tags:bne,TagsIcon:bne,Tally1:wne,Tally1Icon:wne,Tally2:jne,Tally2Icon:jne,Tally3:Nne,Tally3Icon:Nne,Tally4:kne,Tally4Icon:kne,Tally5:Sne,Tally5Icon:Sne,Tangent:Cne,TangentIcon:Cne,Target:Oh,TargetIcon:Oh,Telescope:Mne,TelescopeIcon:Mne,Tent:Ane,TentIcon:Ane,TentTree:Tne,TentTreeIcon:Tne,Terminal:Ene,TerminalIcon:Ene,TerminalSquare:Fk,TerminalSquareIcon:Fk,TestTube:Pne,TestTube2:qk,TestTube2Icon:qk,TestTubeDiagonal:qk,TestTubeDiagonalIcon:qk,TestTubeIcon:Pne,TestTubes:Ine,TestTubesIcon:Ine,Text:Fne,TextCursor:Dne,TextCursorIcon:Dne,TextCursorInput:Lne,TextCursorInputIcon:Lne,TextIcon:Fne,TextQuote:Rne,TextQuoteIcon:Rne,TextSearch:One,TextSearchIcon:One,TextSelect:Uk,TextSelectIcon:Uk,TextSelection:Uk,TextSelectionIcon:Uk,Theater:zne,TheaterIcon:zne,Thermometer:qne,ThermometerIcon:qne,ThermometerSnowflake:Bne,ThermometerSnowflakeIcon:Bne,ThermometerSun:$ne,ThermometerSunIcon:$ne,ThumbsDown:BL,ThumbsDownIcon:BL,ThumbsUp:Ou,ThumbsUpIcon:Ou,Ticket:$L,TicketCheck:Une,TicketCheckIcon:Une,TicketIcon:$L,TicketMinus:Vne,TicketMinusIcon:Vne,TicketPercent:Hne,TicketPercentIcon:Hne,TicketPlus:Gne,TicketPlusIcon:Gne,TicketSlash:Wne,TicketSlashIcon:Wne,TicketX:Kne,TicketXIcon:Kne,Tickets:Yne,TicketsIcon:Yne,TicketsPlane:Zne,TicketsPlaneIcon:Zne,Timer:Jne,TimerIcon:Jne,TimerOff:Xne,TimerOffIcon:Xne,TimerReset:Qne,TimerResetIcon:Qne,ToggleLeft:eae,ToggleLeftIcon:eae,ToggleRight:tae,ToggleRightIcon:tae,Toilet:sae,ToiletIcon:sae,Tornado:rae,TornadoIcon:rae,Torus:nae,TorusIcon:nae,Touchpad:iae,TouchpadIcon:iae,TouchpadOff:aae,TouchpadOffIcon:aae,TowerControl:oae,TowerControlIcon:oae,ToyBrick:lae,ToyBrickIcon:lae,Tractor:cae,TractorIcon:cae,TrafficCone:dae,TrafficConeIcon:dae,Train:Vk,TrainFront:hae,TrainFrontIcon:hae,TrainFrontTunnel:uae,TrainFrontTunnelIcon:uae,TrainIcon:Vk,TrainTrack:mae,TrainTrackIcon:mae,TramFront:Vk,TramFrontIcon:Vk,Trash:pae,Trash2:yr,Trash2Icon:yr,TrashIcon:pae,TreeDeciduous:fae,TreeDeciduousIcon:fae,TreePalm:Hk,TreePalmIcon:Hk,TreePine:Db,TreePineIcon:Db,Trees:xae,TreesIcon:xae,Trello:gae,TrelloIcon:gae,TrendingDown:jS,TrendingDownIcon:jS,TrendingUp:Yo,TrendingUpDown:yae,TrendingUpDownIcon:yae,TrendingUpIcon:Yo,Triangle:_ae,TriangleAlert:Qc,TriangleAlertIcon:Qc,TriangleIcon:_ae,TriangleRight:vae,TriangleRightIcon:vae,Trophy:Hi,TrophyIcon:Hi,Truck:qL,TruckIcon:qL,Turtle:bae,TurtleIcon:bae,Tv:jae,Tv2:Gk,Tv2Icon:Gk,TvIcon:jae,TvMinimal:Gk,TvMinimalIcon:Gk,TvMinimalPlay:wae,TvMinimalPlayIcon:wae,Twitch:Nae,TwitchIcon:Nae,Twitter:kae,TwitterIcon:kae,Type:Cae,TypeIcon:Cae,TypeOutline:Sae,TypeOutlineIcon:Sae,Umbrella:Tae,UmbrellaIcon:Tae,UmbrellaOff:Mae,UmbrellaOffIcon:Mae,Underline:UL,UnderlineIcon:UL,Undo:NS,Undo2:Aae,Undo2Icon:Aae,UndoDot:Eae,UndoDotIcon:Eae,UndoIcon:NS,UnfoldHorizontal:Pae,UnfoldHorizontalIcon:Pae,UnfoldVertical:Iae,UnfoldVerticalIcon:Iae,Ungroup:Lae,UngroupIcon:Lae,University:Wk,UniversityIcon:Wk,Unlink:kS,Unlink2:Dae,Unlink2Icon:Dae,UnlinkIcon:kS,Unlock:jN,UnlockIcon:jN,UnlockKeyhole:wN,UnlockKeyholeIcon:wN,Unplug:Rae,UnplugIcon:Rae,Upload:Da,UploadCloud:Yj,UploadCloudIcon:Yj,UploadIcon:Da,Usb:Oae,UsbIcon:Oae,User:Ei,User2:Jk,User2Icon:Jk,UserCheck:Rb,UserCheck2:Kk,UserCheck2Icon:Kk,UserCheckIcon:Rb,UserCircle:Gj,UserCircle2:Hj,UserCircle2Icon:Hj,UserCircleIcon:Gj,UserCog:VL,UserCog2:Zk,UserCog2Icon:Zk,UserCogIcon:VL,UserIcon:Ei,UserMinus:HL,UserMinus2:Yk,UserMinus2Icon:Yk,UserMinusIcon:HL,UserPen:Fae,UserPenIcon:Fae,UserPlus:il,UserPlus2:Xk,UserPlus2Icon:Xk,UserPlusIcon:il,UserRound:Jk,UserRoundCheck:Kk,UserRoundCheckIcon:Kk,UserRoundCog:Zk,UserRoundCogIcon:Zk,UserRoundIcon:Jk,UserRoundMinus:Yk,UserRoundMinusIcon:Yk,UserRoundPen:zae,UserRoundPenIcon:zae,UserRoundPlus:Xk,UserRoundPlusIcon:Xk,UserRoundSearch:Bae,UserRoundSearchIcon:Bae,UserRoundX:Qk,UserRoundXIcon:Qk,UserSearch:$ae,UserSearchIcon:$ae,UserSquare:Bk,UserSquare2:zk,UserSquare2Icon:zk,UserSquareIcon:Bk,UserX:qae,UserX2:Qk,UserX2Icon:Qk,UserXIcon:qae,Users:cr,Users2:e4,Users2Icon:e4,UsersIcon:cr,UsersRound:e4,UsersRoundIcon:e4,Utensils:s4,UtensilsCrossed:t4,UtensilsCrossedIcon:t4,UtensilsIcon:s4,UtilityPole:Uae,UtilityPoleIcon:Uae,Variable:BM,VariableIcon:BM,Vault:Vae,VaultIcon:Vae,Vegan:Hae,VeganIcon:Hae,VenetianMask:Gae,VenetianMaskIcon:Gae,Verified:nj,VerifiedIcon:nj,Vibrate:Kae,VibrateIcon:Kae,VibrateOff:Wae,VibrateOffIcon:Wae,Video:hn,VideoIcon:hn,VideoOff:Zae,VideoOffIcon:Zae,Videotape:Yae,VideotapeIcon:Yae,View:Xae,ViewIcon:Xae,Voicemail:Qae,VoicemailIcon:Qae,Volleyball:Jae,VolleyballIcon:Jae,Volume:nie,Volume1:eie,Volume1Icon:eie,Volume2:tie,Volume2Icon:tie,VolumeIcon:nie,VolumeOff:sie,VolumeOffIcon:sie,VolumeX:rie,VolumeXIcon:rie,Vote:aie,VoteIcon:aie,Wallet:GL,Wallet2:r4,Wallet2Icon:r4,WalletCards:iie,WalletCardsIcon:iie,WalletIcon:GL,WalletMinimal:r4,WalletMinimalIcon:r4,Wallpaper:oie,WallpaperIcon:oie,Wand:lie,Wand2:Ev,Wand2Icon:Ev,WandIcon:lie,WandSparkles:Ev,WandSparklesIcon:Ev,Warehouse:cie,WarehouseIcon:cie,WashingMachine:die,WashingMachineIcon:die,Watch:uie,WatchIcon:uie,Waves:hie,WavesIcon:hie,Waypoints:mie,WaypointsIcon:mie,Webcam:pie,WebcamIcon:pie,Webhook:xie,WebhookIcon:xie,WebhookOff:fie,WebhookOffIcon:fie,Weight:gie,WeightIcon:gie,Wheat:vie,WheatIcon:vie,WheatOff:yie,WheatOffIcon:yie,WholeWord:_ie,WholeWordIcon:_ie,Wifi:kie,WifiHigh:bie,WifiHighIcon:bie,WifiIcon:kie,WifiLow:wie,WifiLowIcon:wie,WifiOff:jie,WifiOffIcon:jie,WifiZero:Nie,WifiZeroIcon:Nie,Wind:Cie,WindArrowDown:Sie,WindArrowDownIcon:Sie,WindIcon:Cie,Wine:Tie,WineIcon:Tie,WineOff:Mie,WineOffIcon:Mie,Workflow:Aie,WorkflowIcon:Aie,Worm:Eie,WormIcon:Eie,WrapText:Pie,WrapTextIcon:Pie,Wrench:Og,WrenchIcon:Og,X:Sr,XCircle:Ql,XCircleIcon:Ql,XIcon:Sr,XOctagon:CN,XOctagonIcon:CN,XSquare:$k,XSquareIcon:$k,Youtube:Iie,YoutubeIcon:Iie,Zap:Fh,ZapIcon:Fh,ZapOff:Lie,ZapOffIcon:Lie,ZoomIn:Ob,ZoomInIcon:Ob,ZoomOut:$M,ZoomOutIcon:$M,createLucideIcon:X,icons:Ogt},Symbol.toStringTag,{value:"Module"})),cje="-",Fgt=t=>{const s=Bgt(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(cje);return i[0]===""&&i.length!==1&&i.shift(),fUe(i,s)||zgt(l)},getConflictingClassGroupIds:(l,i)=>{const d=r[l]||[];return i&&n[l]?[...d,...n[l]]:d}}},fUe=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?fUe(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(cje);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},qEe=/^\[(.+)\]$/,zgt=t=>{if(qEe.test(t)){const s=qEe.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},Bgt=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return qgt(Object.entries(t.classGroups),r).forEach(([o,l])=>{Mve(l,n,o,s)}),n},Mve=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:UEe(s,a);o.classGroupId=r;return}if(typeof a=="function"){if($gt(a)){Mve(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{Mve(l,UEe(s,o),r,n)})})},UEe=(t,s)=>{let r=t;return s.split(cje).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},$gt=t=>t.isThemeGetter,qgt=(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,Ugt=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)}}},xUe="!",Vgt=t=>{const{separator:s,experimentalParseClassName:r}=t,n=s.length===1,a=s[0],o=s.length,l=i=>{const d=[];let u=0,p=0,f;for(let w=0;wp?f-p:void 0;return{modifiers:d,hasImportantModifier:_,baseClassName:b,maybePostfixModifierPosition:N}};return r?i=>r({className:i,parseClassName:l}):l},Hgt=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},Ggt=t=>({cache:Ugt(t.cacheSize),parseClassName:Vgt(t),...Fgt(t)}),Wgt=/\s+/,Kgt=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(Wgt);let i="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{modifiers:p,hasImportantModifier:f,baseClassName:y,maybePostfixModifierPosition:_}=r(u);let b=!!_,N=n(b?y.substring(0,_):y);if(!N){if(!b){i=u+(i.length>0?" "+i:i);continue}if(N=n(y),!N){i=u+(i.length>0?" "+i:i);continue}b=!1}const w=Hgt(p).join(":"),S=f?w+xUe:w,C=S+N;if(o.includes(C))continue;o.push(C);const A=a(N,b);for(let I=0;I0?" "+i:i)}return i};function Zgt(){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=Ggt(u),n=r.cache.get,a=r.cache.set,o=i,i(d)}function i(d){const u=n(d);if(u)return u;const p=Kgt(d,r);return a(d,p),p}return function(){return o(Zgt.apply(null,arguments))}}const Hl=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},yUe=/^\[(?:([a-z-]+):)?(.+)\]$/i,Xgt=/^\d+\/\d+$/,Qgt=new Set(["px","full","screen"]),Jgt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,eyt=/\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$/,tyt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,syt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ryt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,uv=t=>qM(t)||Qgt.has(t)||Xgt.test(t),y_=t=>IA(t,"length",uyt),qM=t=>!!t&&!Number.isNaN(Number(t)),Wxe=t=>IA(t,"number",qM),WI=t=>!!t&&Number.isInteger(Number(t)),nyt=t=>t.endsWith("%")&&qM(t.slice(0,-1)),Ti=t=>yUe.test(t),v_=t=>Jgt.test(t),ayt=new Set(["length","size","percentage"]),iyt=t=>IA(t,ayt,vUe),oyt=t=>IA(t,"position",vUe),lyt=new Set(["image","url"]),cyt=t=>IA(t,lyt,myt),dyt=t=>IA(t,"",hyt),KI=()=>!0,IA=(t,s,r)=>{const n=yUe.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},uyt=t=>eyt.test(t)&&!tyt.test(t),vUe=()=>!1,hyt=t=>syt.test(t),myt=t=>ryt.test(t),pyt=()=>{const t=Hl("colors"),s=Hl("spacing"),r=Hl("blur"),n=Hl("brightness"),a=Hl("borderColor"),o=Hl("borderRadius"),l=Hl("borderSpacing"),i=Hl("borderWidth"),d=Hl("contrast"),u=Hl("grayscale"),p=Hl("hueRotate"),f=Hl("invert"),y=Hl("gap"),_=Hl("gradientColorStops"),b=Hl("gradientColorStopPositions"),N=Hl("inset"),w=Hl("margin"),S=Hl("opacity"),C=Hl("padding"),A=Hl("saturate"),I=Hl("scale"),L=Hl("sepia"),O=Hl("skew"),U=Hl("space"),q=Hl("translate"),$=()=>["auto","contain","none"],V=()=>["auto","hidden","clip","visible","scroll"],ee=()=>["auto",Ti,s],Z=()=>[Ti,s],J=()=>["",uv,y_],Y=()=>["auto",qM,Ti],ce=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ae=()=>["solid","dashed","dotted","double","none"],ie=()=>["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"],fe=()=>["","0",Ti],xe=()=>["auto","avoid","all","avoid-page","page","left","right","column"],he=()=>[qM,Ti];return{cacheSize:500,separator:":",theme:{colors:[KI],spacing:[uv,y_],blur:["none","",v_,Ti],brightness:he(),borderColor:[t],borderRadius:["none","","full",v_,Ti],borderSpacing:Z(),borderWidth:J(),contrast:he(),grayscale:fe(),hueRotate:he(),invert:fe(),gap:Z(),gradientColorStops:[t],gradientColorStopPositions:[nyt,y_],inset:ee(),margin:ee(),opacity:he(),padding:Z(),saturate:he(),scale:he(),sepia:fe(),skew:he(),space:Z(),translate:Z()},classGroups:{aspect:[{aspect:["auto","square","video",Ti]}],container:["container"],columns:[{columns:[v_]}],"break-after":[{"break-after":xe()}],"break-before":[{"break-before":xe()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...ce(),Ti]}],overflow:[{overflow:V()}],"overflow-x":[{"overflow-x":V()}],"overflow-y":[{"overflow-y":V()}],overscroll:[{overscroll:$()}],"overscroll-x":[{"overscroll-x":$()}],"overscroll-y":[{"overscroll-y":$()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[N]}],"inset-x":[{"inset-x":[N]}],"inset-y":[{"inset-y":[N]}],start:[{start:[N]}],end:[{end:[N]}],top:[{top:[N]}],right:[{right:[N]}],bottom:[{bottom:[N]}],left:[{left:[N]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",WI,Ti]}],basis:[{basis:ee()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Ti]}],grow:[{grow:fe()}],shrink:[{shrink:fe()}],order:[{order:["first","last","none",WI,Ti]}],"grid-cols":[{"grid-cols":[KI]}],"col-start-end":[{col:["auto",{span:["full",WI,Ti]},Ti]}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":[KI]}],"row-start-end":[{row:["auto",{span:[WI,Ti]},Ti]}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Ti]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Ti]}],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:[C]}],px:[{px:[C]}],py:[{py:[C]}],ps:[{ps:[C]}],pe:[{pe:[C]}],pt:[{pt:[C]}],pr:[{pr:[C]}],pb:[{pb:[C]}],pl:[{pl:[C]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[U]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[U]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Ti,s]}],"min-w":[{"min-w":[Ti,s,"min","max","fit"]}],"max-w":[{"max-w":[Ti,s,"none","full","min","max","fit","prose",{screen:[v_]},v_]}],h:[{h:[Ti,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Ti,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Ti,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Ti,s,"auto","min","max","fit"]}],"font-size":[{text:["base",v_,y_]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Wxe]}],"font-family":[{font:[KI]}],"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",Ti]}],"line-clamp":[{"line-clamp":["none",qM,Wxe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",uv,Ti]}],"list-image":[{"list-image":["none",Ti]}],"list-style-type":[{list:["none","disc","decimal",Ti]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[S]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[S]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ae(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",uv,y_]}],"underline-offset":[{"underline-offset":["auto",uv,Ti]}],"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:Z()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ti]}],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",Ti]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[S]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ce(),oyt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",iyt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},cyt]}],"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":[S]}],"border-style":[{border:[...ae(),"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":[S]}],"divide-style":[{divide:ae()}],"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:["",...ae()]}],"outline-offset":[{"outline-offset":[uv,Ti]}],"outline-w":[{outline:[uv,y_]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[S]}],"ring-offset-w":[{"ring-offset":[uv,y_]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",v_,dyt]}],"shadow-color":[{shadow:[KI]}],opacity:[{opacity:[S]}],"mix-blend":[{"mix-blend":[...ie(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ie()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",v_,Ti]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[f]}],saturate:[{saturate:[A]}],sepia:[{sepia:[L]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[d]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[S]}],"backdrop-saturate":[{"backdrop-saturate":[A]}],"backdrop-sepia":[{"backdrop-sepia":[L]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[l]}],"border-spacing-x":[{"border-spacing-x":[l]}],"border-spacing-y":[{"border-spacing-y":[l]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Ti]}],duration:[{duration:he()}],ease:[{ease:["linear","in","out","in-out",Ti]}],delay:[{delay:he()}],animate:[{animate:["none","spin","ping","pulse","bounce",Ti]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[I]}],"scale-x":[{"scale-x":[I]}],"scale-y":[{"scale-y":[I]}],rotate:[{rotate:[WI,Ti]}],"translate-x":[{"translate-x":[q]}],"translate-y":[{"translate-y":[q]}],"skew-x":[{"skew-x":[O]}],"skew-y":[{"skew-y":[O]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Ti]}],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",Ti]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Z()}],"scroll-mx":[{"scroll-mx":Z()}],"scroll-my":[{"scroll-my":Z()}],"scroll-ms":[{"scroll-ms":Z()}],"scroll-me":[{"scroll-me":Z()}],"scroll-mt":[{"scroll-mt":Z()}],"scroll-mr":[{"scroll-mr":Z()}],"scroll-mb":[{"scroll-mb":Z()}],"scroll-ml":[{"scroll-ml":Z()}],"scroll-p":[{"scroll-p":Z()}],"scroll-px":[{"scroll-px":Z()}],"scroll-py":[{"scroll-py":Z()}],"scroll-ps":[{"scroll-ps":Z()}],"scroll-pe":[{"scroll-pe":Z()}],"scroll-pt":[{"scroll-pt":Z()}],"scroll-pr":[{"scroll-pr":Z()}],"scroll-pb":[{"scroll-pb":Z()}],"scroll-pl":[{"scroll-pl":Z()}],"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",Ti]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[uv,y_,Wxe]}],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"]}}},fyt=Ygt(pyt);function Rt(...t){return fyt(bi(t))}function El(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 VEe(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function Jde(t){return t?t.replace(/<[^>]*>/g,""):""}const xyt=Lgt,_Ue=k.forwardRef(({className:t,...s},r)=>e.jsx(iUe,{ref:r,className:Rt("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}));_Ue.displayName=iUe.displayName;const gyt=wC("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"}}),bUe=k.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(oUe,{ref:n,className:Rt(gyt({variant:s}),t),...r}));bUe.displayName=oUe.displayName;const yyt=k.forwardRef(({className:t,...s},r)=>e.jsx(dUe,{ref:r,className:Rt("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}));yyt.displayName=dUe.displayName;const wUe=k.forwardRef(({className:t,...s},r)=>e.jsx(uUe,{ref:r,className:Rt("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(Sr,{className:"h-4 w-4"})}));wUe.displayName=uUe.displayName;const jUe=k.forwardRef(({className:t,...s},r)=>e.jsx(lUe,{ref:r,className:Rt("text-sm font-semibold",t),...s}));jUe.displayName=lUe.displayName;const NUe=k.forwardRef(({className:t,...s},r)=>e.jsx(cUe,{ref:r,className:Rt("text-sm opacity-90",t),...s}));NUe.displayName=cUe.displayName;function vyt(){const{toasts:t}=va();return e.jsxs(xyt,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(bUe,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(jUe,{children:r}),n&&e.jsx(NUe,{children:n})]}),a,e.jsx(wUe,{})]},s)}),e.jsx(_Ue,{})]})}var HEe=["light","dark"],_yt="(prefers-color-scheme: dark)",byt=k.createContext(void 0),wyt={setTheme:t=>{},themes:[]},jyt=()=>{var t;return(t=k.useContext(byt))!=null?t:wyt};k.memo(({forcedTheme:t,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:l,attrs:i,nonce:d})=>{let u=o==="system",p=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(b=>`'${b}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,f=a?HEe.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,N=!1,w=!0)=>{let S=l?l[b]:b,C=N?b+"|| ''":`'${S}'`,A="";return a&&w&&!N&&HEe.includes(b)&&(A+=`d.style.colorScheme = '${b}';`),r==="class"?N||S?A+=`c.add(${C})`:A+="null":S&&(A+=`d[s](n,${C})`),A},_=t?`!function(){${p}${y(t)}}()`:n?`!function(){try{${p}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${_yt}',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 k.createElement("script",{nonce:d,dangerouslySetInnerHTML:{__html:_}})});var Nyt=t=>{switch(t){case"success":return Cyt;case"info":return Tyt;case"warning":return Myt;case"error":return Ayt;default:return null}},kyt=Array(12).fill(0),Syt=({visible:t,className:s})=>ht.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},ht.createElement("div",{className:"sonner-spinner"},kyt.map((r,n)=>ht.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),Cyt=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"})),Myt=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"})),Tyt=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"})),Ayt=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"})),Eyt=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"})),Pyt=()=>{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},Tve=1,Iyt=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:Tve++,l=this.toasts.find(d=>d.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(d=>d.id===o?(this.publish({...d,...s,id:o,title:n}),{...d,...s,id:o,dismissible:i,title:n}):d):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(Dyt(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)}),d=()=>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:d}:Object.assign(n,{unwrap:d})},this.custom=(s,r)=>{let n=(r==null?void 0:r.id)||Tve++;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}},Xm=new Iyt,Lyt=(t,s)=>{let r=(s==null?void 0:s.id)||Tve++;return Xm.addToast({title:t,...s,id:r}),r},Dyt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",Ryt=Lyt,Oyt=()=>Xm.toasts,Fyt=()=>Xm.getActiveToasts(),me=Object.assign(Ryt,{success:Xm.success,info:Xm.info,warning:Xm.warning,error:Xm.error,custom:Xm.custom,message:Xm.message,promise:Xm.promise,dismiss:Xm.dismiss,loading:Xm.loading},{getHistory:Oyt,getToasts:Fyt});function zyt(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))}zyt(`: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 xz(t){return t.label!==void 0}var Byt=3,$yt="32px",qyt="16px",GEe=4e3,Uyt=356,Vyt=14,Hyt=20,Gyt=200;function ug(...t){return t.filter(Boolean).join(" ")}function Wyt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var Kyt=t=>{var s,r,n,a,o,l,i,d,u,p,f;let{invert:y,toast:_,unstyled:b,interacting:N,setHeights:w,visibleToasts:S,heights:C,index:A,toasts:I,expanded:L,removeToast:O,defaultRichColors:U,closeButton:q,style:$,cancelButtonStyle:V,actionButtonStyle:ee,className:Z="",descriptionClassName:J="",duration:Y,position:ce,gap:ae,loadingIcon:ie,expandByDefault:le,classNames:fe,icons:xe,closeButtonAriaLabel:he="Close toast",pauseWhenPageIsHidden:we}=t,[Ne,Ve]=ht.useState(null),[Te,Ae]=ht.useState(null),[ze,Ee]=ht.useState(!1),[ve,Re]=ht.useState(!1),[Ue,ye]=ht.useState(!1),[ct,pe]=ht.useState(!1),[Ge,tt]=ht.useState(!1),[st,Ce]=ht.useState(0),[et,Ct]=ht.useState(0),Ot=ht.useRef(_.duration||Y||GEe),ut=ht.useRef(null),Oe=ht.useRef(null),Xe=A===0,at=A+1<=S,Ke=_.type,He=_.dismissible!==!1,gt=_.className||"",Mt=_.descriptionClassName||"",Wt=ht.useMemo(()=>C.findIndex(hr=>hr.toastId===_.id)||0,[C,_.id]),xs=ht.useMemo(()=>{var hr;return(hr=_.closeButton)!=null?hr:q},[_.closeButton,q]),Cs=ht.useMemo(()=>_.duration||Y||GEe,[_.duration,Y]),Us=ht.useRef(0),Ar=ht.useRef(0),Bt=ht.useRef(0),Xs=ht.useRef(null),[Nr,Vs]=ce.split("-"),ar=ht.useMemo(()=>C.reduce((hr,an,Gr)=>Gr>=Wt?hr:hr+an.height,0),[C,Wt]),Or=Pyt(),Rn=_.invert||y,bn=Ke==="loading";Ar.current=ht.useMemo(()=>Wt*ae+ar,[Wt,ar]),ht.useEffect(()=>{Ot.current=Cs},[Cs]),ht.useEffect(()=>{Ee(!0)},[]),ht.useEffect(()=>{let hr=Oe.current;if(hr){let an=hr.getBoundingClientRect().height;return Ct(an),w(Gr=>[{toastId:_.id,height:an,position:_.position},...Gr]),()=>w(Gr=>Gr.filter(Va=>Va.toastId!==_.id))}},[w,_.id]),ht.useLayoutEffect(()=>{if(!ze)return;let hr=Oe.current,an=hr.style.height;hr.style.height="auto";let Gr=hr.getBoundingClientRect().height;hr.style.height=an,Ct(Gr),w(Va=>Va.find($a=>$a.toastId===_.id)?Va.map($a=>$a.toastId===_.id?{...$a,height:Gr}:$a):[{toastId:_.id,height:Gr,position:_.position},...Va])},[ze,_.title,_.description,w,_.id]);let ir=ht.useCallback(()=>{Re(!0),Ce(Ar.current),w(hr=>hr.filter(an=>an.toastId!==_.id)),setTimeout(()=>{O(_)},Gyt)},[_,O,w,Ar]);ht.useEffect(()=>{if(_.promise&&Ke==="loading"||_.duration===1/0||_.type==="loading")return;let hr;return L||N||we&&Or?(()=>{if(Bt.current{var an;(an=_.onAutoClose)==null||an.call(_,_),ir()},Ot.current)),()=>clearTimeout(hr)},[L,N,_,Ke,we,Or,ir]),ht.useEffect(()=>{_.delete&&ir()},[ir,_.delete]);function or(){var hr,an,Gr;return xe!=null&&xe.loading?ht.createElement("div",{className:ug(fe==null?void 0:fe.loader,(hr=_==null?void 0:_.classNames)==null?void 0:hr.loader,"sonner-loader"),"data-visible":Ke==="loading"},xe.loading):ie?ht.createElement("div",{className:ug(fe==null?void 0:fe.loader,(an=_==null?void 0:_.classNames)==null?void 0:an.loader,"sonner-loader"),"data-visible":Ke==="loading"},ie):ht.createElement(Syt,{className:ug(fe==null?void 0:fe.loader,(Gr=_==null?void 0:_.classNames)==null?void 0:Gr.loader),visible:Ke==="loading"})}return ht.createElement("li",{tabIndex:0,ref:Oe,className:ug(Z,gt,fe==null?void 0:fe.toast,(s=_==null?void 0:_.classNames)==null?void 0:s.toast,fe==null?void 0:fe.default,fe==null?void 0:fe[Ke],(r=_==null?void 0:_.classNames)==null?void 0:r[Ke]),"data-sonner-toast":"","data-rich-colors":(n=_.richColors)!=null?n:U,"data-styled":!(_.jsx||_.unstyled||b),"data-mounted":ze,"data-promise":!!_.promise,"data-swiped":Ge,"data-removed":ve,"data-visible":at,"data-y-position":Nr,"data-x-position":Vs,"data-index":A,"data-front":Xe,"data-swiping":Ue,"data-dismissible":He,"data-type":Ke,"data-invert":Rn,"data-swipe-out":ct,"data-swipe-direction":Te,"data-expanded":!!(L||le&&ze),style:{"--index":A,"--toasts-before":A,"--z-index":I.length-A,"--offset":`${ve?st:Ar.current}px`,"--initial-height":le?"auto":`${et}px`,...$,..._.style},onDragEnd:()=>{ye(!1),Ve(null),Xs.current=null},onPointerDown:hr=>{bn||!He||(ut.current=new Date,Ce(Ar.current),hr.target.setPointerCapture(hr.pointerId),hr.target.tagName!=="BUTTON"&&(ye(!0),Xs.current={x:hr.clientX,y:hr.clientY}))},onPointerUp:()=>{var hr,an,Gr,Va;if(ct||!He)return;Xs.current=null;let $a=Number(((hr=Oe.current)==null?void 0:hr.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Xt=Number(((an=Oe.current)==null?void 0:an.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Qa=new Date().getTime()-((Gr=ut.current)==null?void 0:Gr.getTime()),Cr=Ne==="x"?$a:Xt,Fn=Math.abs(Cr)/Qa;if(Math.abs(Cr)>=Hyt||Fn>.11){Ce(Ar.current),(Va=_.onDismiss)==null||Va.call(_,_),Ae(Ne==="x"?$a>0?"right":"left":Xt>0?"down":"up"),ir(),pe(!0),tt(!1);return}ye(!1),Ve(null)},onPointerMove:hr=>{var an,Gr,Va,$a;if(!Xs.current||!He||((an=window.getSelection())==null?void 0:an.toString().length)>0)return;let Xt=hr.clientY-Xs.current.y,Qa=hr.clientX-Xs.current.x,Cr=(Gr=t.swipeDirections)!=null?Gr:Wyt(ce);!Ne&&(Math.abs(Qa)>1||Math.abs(Xt)>1)&&Ve(Math.abs(Qa)>Math.abs(Xt)?"x":"y");let Fn={x:0,y:0};Ne==="y"?(Cr.includes("top")||Cr.includes("bottom"))&&(Cr.includes("top")&&Xt<0||Cr.includes("bottom")&&Xt>0)&&(Fn.y=Xt):Ne==="x"&&(Cr.includes("left")||Cr.includes("right"))&&(Cr.includes("left")&&Qa<0||Cr.includes("right")&&Qa>0)&&(Fn.x=Qa),(Math.abs(Fn.x)>0||Math.abs(Fn.y)>0)&&tt(!0),(Va=Oe.current)==null||Va.style.setProperty("--swipe-amount-x",`${Fn.x}px`),($a=Oe.current)==null||$a.style.setProperty("--swipe-amount-y",`${Fn.y}px`)}},xs&&!_.jsx?ht.createElement("button",{"aria-label":he,"data-disabled":bn,"data-close-button":!0,onClick:bn||!He?()=>{}:()=>{var hr;ir(),(hr=_.onDismiss)==null||hr.call(_,_)},className:ug(fe==null?void 0:fe.closeButton,(a=_==null?void 0:_.classNames)==null?void 0:a.closeButton)},(o=xe==null?void 0:xe.close)!=null?o:Eyt):null,_.jsx||k.isValidElement(_.title)?_.jsx?_.jsx:typeof _.title=="function"?_.title():_.title:ht.createElement(ht.Fragment,null,Ke||_.icon||_.promise?ht.createElement("div",{"data-icon":"",className:ug(fe==null?void 0:fe.icon,(l=_==null?void 0:_.classNames)==null?void 0:l.icon)},_.promise||_.type==="loading"&&!_.icon?_.icon||or():null,_.type!=="loading"?_.icon||(xe==null?void 0:xe[Ke])||Nyt(Ke):null):null,ht.createElement("div",{"data-content":"",className:ug(fe==null?void 0:fe.content,(i=_==null?void 0:_.classNames)==null?void 0:i.content)},ht.createElement("div",{"data-title":"",className:ug(fe==null?void 0:fe.title,(d=_==null?void 0:_.classNames)==null?void 0:d.title)},typeof _.title=="function"?_.title():_.title),_.description?ht.createElement("div",{"data-description":"",className:ug(J,Mt,fe==null?void 0:fe.description,(u=_==null?void 0:_.classNames)==null?void 0:u.description)},typeof _.description=="function"?_.description():_.description):null),k.isValidElement(_.cancel)?_.cancel:_.cancel&&xz(_.cancel)?ht.createElement("button",{"data-button":!0,"data-cancel":!0,style:_.cancelButtonStyle||V,onClick:hr=>{var an,Gr;xz(_.cancel)&&He&&((Gr=(an=_.cancel).onClick)==null||Gr.call(an,hr),ir())},className:ug(fe==null?void 0:fe.cancelButton,(p=_==null?void 0:_.classNames)==null?void 0:p.cancelButton)},_.cancel.label):null,k.isValidElement(_.action)?_.action:_.action&&xz(_.action)?ht.createElement("button",{"data-button":!0,"data-action":!0,style:_.actionButtonStyle||ee,onClick:hr=>{var an,Gr;xz(_.action)&&((Gr=(an=_.action).onClick)==null||Gr.call(an,hr),!hr.defaultPrevented&&ir())},className:ug(fe==null?void 0:fe.actionButton,(f=_==null?void 0:_.classNames)==null?void 0:f.actionButton)},_.action.label):null))};function WEe(){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 Zyt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?qyt:$yt;function d(u){["top","right","bottom","left"].forEach(p=>{r[`${l}-${p}`]=typeof u=="number"?`${u}px`:u})}typeof n=="number"||typeof n=="string"?d(n):typeof n=="object"?["top","right","bottom","left"].forEach(u=>{n[u]===void 0?r[`${l}-${u}`]=i:r[`${l}-${u}`]=typeof n[u]=="number"?`${n[u]}px`:n[u]}):d(i)}),r}var Yyt=k.forwardRef(function(t,s){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:l,className:i,offset:d,mobileOffset:u,theme:p="light",richColors:f,duration:y,style:_,visibleToasts:b=Byt,toastOptions:N,dir:w=WEe(),gap:S=Vyt,loadingIcon:C,icons:A,containerAriaLabel:I="Notifications",pauseWhenPageIsHidden:L}=t,[O,U]=ht.useState([]),q=ht.useMemo(()=>Array.from(new Set([n].concat(O.filter(we=>we.position).map(we=>we.position)))),[O,n]),[$,V]=ht.useState([]),[ee,Z]=ht.useState(!1),[J,Y]=ht.useState(!1),[ce,ae]=ht.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),ie=ht.useRef(null),le=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),fe=ht.useRef(null),xe=ht.useRef(!1),he=ht.useCallback(we=>{U(Ne=>{var Ve;return(Ve=Ne.find(Te=>Te.id===we.id))!=null&&Ve.delete||Xm.dismiss(we.id),Ne.filter(({id:Te})=>Te!==we.id)})},[]);return ht.useEffect(()=>Xm.subscribe(we=>{if(we.dismiss){U(Ne=>Ne.map(Ve=>Ve.id===we.id?{...Ve,delete:!0}:Ve));return}setTimeout(()=>{rje.flushSync(()=>{U(Ne=>{let Ve=Ne.findIndex(Te=>Te.id===we.id);return Ve!==-1?[...Ne.slice(0,Ve),{...Ne[Ve],...we},...Ne.slice(Ve+1)]:[we,...Ne]})})})}),[]),ht.useEffect(()=>{if(p!=="system"){ae(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ae("dark"):ae("light")),typeof window>"u")return;let we=window.matchMedia("(prefers-color-scheme: dark)");try{we.addEventListener("change",({matches:Ne})=>{ae(Ne?"dark":"light")})}catch{we.addListener(({matches:Ve})=>{try{ae(Ve?"dark":"light")}catch(Te){console.error(Te)}})}},[p]),ht.useEffect(()=>{O.length<=1&&Z(!1)},[O]),ht.useEffect(()=>{let we=Ne=>{var Ve,Te;a.every(Ae=>Ne[Ae]||Ne.code===Ae)&&(Z(!0),(Ve=ie.current)==null||Ve.focus()),Ne.code==="Escape"&&(document.activeElement===ie.current||(Te=ie.current)!=null&&Te.contains(document.activeElement))&&Z(!1)};return document.addEventListener("keydown",we),()=>document.removeEventListener("keydown",we)},[a]),ht.useEffect(()=>{if(ie.current)return()=>{fe.current&&(fe.current.focus({preventScroll:!0}),fe.current=null,xe.current=!1)}},[ie.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((we,Ne)=>{var Ve;let[Te,Ae]=we.split("-");return O.length?ht.createElement("ol",{key:we,dir:w==="auto"?WEe():w,tabIndex:-1,ref:ie,className:i,"data-sonner-toaster":!0,"data-theme":ce,"data-y-position":Te,"data-lifted":ee&&O.length>1&&!o,"data-x-position":Ae,style:{"--front-toast-height":`${((Ve=$[0])==null?void 0:Ve.height)||0}px`,"--width":`${Uyt}px`,"--gap":`${S}px`,..._,...Zyt(d,u)},onBlur:ze=>{xe.current&&!ze.currentTarget.contains(ze.relatedTarget)&&(xe.current=!1,fe.current&&(fe.current.focus({preventScroll:!0}),fe.current=null))},onFocus:ze=>{ze.target instanceof HTMLElement&&ze.target.dataset.dismissible==="false"||xe.current||(xe.current=!0,fe.current=ze.relatedTarget)},onMouseEnter:()=>Z(!0),onMouseMove:()=>Z(!0),onMouseLeave:()=>{J||Z(!1)},onDragEnd:()=>Z(!1),onPointerDown:ze=>{ze.target instanceof HTMLElement&&ze.target.dataset.dismissible==="false"||Y(!0)},onPointerUp:()=>Y(!1)},O.filter(ze=>!ze.position&&Ne===0||ze.position===we).map((ze,Ee)=>{var ve,Re;return ht.createElement(Kyt,{key:ze.id,icons:A,index:Ee,toast:ze,defaultRichColors:f,duration:(ve=N==null?void 0:N.duration)!=null?ve:y,className:N==null?void 0:N.className,descriptionClassName:N==null?void 0:N.descriptionClassName,invert:r,visibleToasts:b,closeButton:(Re=N==null?void 0:N.closeButton)!=null?Re:l,interacting:J,position:we,style:N==null?void 0:N.style,unstyled:N==null?void 0:N.unstyled,classNames:N==null?void 0:N.classNames,cancelButtonStyle:N==null?void 0:N.cancelButtonStyle,actionButtonStyle:N==null?void 0:N.actionButtonStyle,removeToast:he,toasts:O.filter(Ue=>Ue.position==ze.position),heights:$.filter(Ue=>Ue.position==ze.position),setHeights:V,expandByDefault:o,gap:S,loadingIcon:C,expanded:ee,pauseWhenPageIsHidden:L,swipeDirections:t.swipeDirections})})):null}))});const Xyt=({...t})=>{const{theme:s="system"}=jyt();return e.jsx(Yyt,{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 Qyt=Dde[" useId ".trim().toString()]||(()=>{}),Jyt=0;function mu(t){const[s,r]=k.useState(Qyt());return rd(()=>{r(n=>n??String(Jyt++))},[t]),s?`radix-${s}`:""}const e0t=["top","right","bottom","left"],Xb=Math.min,Qp=Math.max,Roe=Math.round,gz=Math.floor,n0=t=>({x:t,y:t}),t0t={left:"right",right:"left",bottom:"top",top:"bottom"};function Ave(t,s,r){return Qp(t,Xb(s,r))}function m1(t,s){return typeof t=="function"?t(s):t}function p1(t){return t.split("-")[0]}function LA(t){return t.split("-")[1]}function dje(t){return t==="x"?"y":"x"}function uje(t){return t==="y"?"height":"width"}function qy(t){const s=t[0];return s==="t"||s==="b"?"y":"x"}function hje(t){return dje(qy(t))}function s0t(t,s,r){r===void 0&&(r=!1);const n=LA(t),a=hje(t),o=uje(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=Ooe(l)),[l,Ooe(l)]}function r0t(t){const s=Ooe(t);return[Eve(t),s,Eve(s)]}function Eve(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const KEe=["left","right"],ZEe=["right","left"],n0t=["top","bottom"],a0t=["bottom","top"];function i0t(t,s,r){switch(t){case"top":case"bottom":return r?s?ZEe:KEe:s?KEe:ZEe;case"left":case"right":return s?n0t:a0t;default:return[]}}function o0t(t,s,r,n){const a=LA(t);let o=i0t(p1(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(Eve)))),o}function Ooe(t){const s=p1(t);return t0t[s]+t.slice(s.length)}function l0t(t){return{top:0,right:0,bottom:0,left:0,...t}}function kUe(t){return typeof t!="number"?l0t(t):{top:t,right:t,bottom:t,left:t}}function Foe(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 YEe(t,s,r){let{reference:n,floating:a}=t;const o=qy(s),l=hje(s),i=uje(l),d=p1(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(d){case"top":_={x:p,y:n.y-a.height};break;case"bottom":_={x:p,y:n.y+n.height};break;case"right":_={x:n.x+n.width,y:f};break;case"left":_={x:n.x-a.width,y:f};break;default:_={x:n.x,y:n.y}}switch(LA(s)){case"start":_[l]-=y*(r&&u?-1:1);break;case"end":_[l]+=y*(r&&u?-1:1);break}return _}async function c0t(t,s){var r;s===void 0&&(s={});const{x:n,y:a,platform:o,rects:l,elements:i,strategy:d}=t,{boundary:u="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:y=!1,padding:_=0}=m1(s,t),b=kUe(_),w=i[y?f==="floating"?"reference":"floating":f],S=Foe(await o.getClippingRect({element:(r=await(o.isElement==null?void 0:o.isElement(w)))==null||r?w:w.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(i.floating)),boundary:u,rootBoundary:p,strategy:d})),C=f==="floating"?{x:n,y:a,width:l.floating.width,height:l.floating.height}:l.reference,A=await(o.getOffsetParent==null?void 0:o.getOffsetParent(i.floating)),I=await(o.isElement==null?void 0:o.isElement(A))?await(o.getScale==null?void 0:o.getScale(A))||{x:1,y:1}:{x:1,y:1},L=Foe(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:C,offsetParent:A,strategy:d}):C);return{top:(S.top-L.top+b.top)/I.y,bottom:(L.bottom-S.bottom+b.bottom)/I.y,left:(S.left-L.left+b.left)/I.x,right:(L.right-S.right+b.right)/I.x}}const d0t=50,u0t=async(t,s,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:o=[],platform:l}=r,i=l.detectOverflow?l:{...l,detectOverflow:c0t},d=await(l.isRTL==null?void 0:l.isRTL(s));let u=await l.getElementRects({reference:t,floating:s,strategy:a}),{x:p,y:f}=YEe(u,n,d),y=n,_=0;const b={};for(let N=0;N({name:"arrow",options:t,async fn(s){const{x:r,y:n,placement:a,rects:o,platform:l,elements:i,middlewareData:d}=s,{element:u,padding:p=0}=m1(t,s)||{};if(u==null)return{};const f=kUe(p),y={x:r,y:n},_=hje(a),b=uje(_),N=await l.getDimensions(u),w=_==="y",S=w?"top":"left",C=w?"bottom":"right",A=w?"clientHeight":"clientWidth",I=o.reference[b]+o.reference[_]-y[_]-o.floating[b],L=y[_]-o.reference[_],O=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let U=O?O[A]:0;(!U||!await(l.isElement==null?void 0:l.isElement(O)))&&(U=i.floating[A]||o.floating[b]);const q=I/2-L/2,$=U/2-N[b]/2-1,V=Xb(f[S],$),ee=Xb(f[C],$),Z=V,J=U-N[b]-ee,Y=U/2-N[b]/2+q,ce=Ave(Z,Y,J),ae=!d.arrow&&LA(a)!=null&&Y!==ce&&o.reference[b]/2-(YY<=0)){var ee,Z;const Y=(((ee=o.flip)==null?void 0:ee.index)||0)+1,ce=U[Y];if(ce&&(!(f==="alignment"?C!==qy(ce):!1)||V.every(le=>qy(le.placement)===C?le.overflows[0]>0:!0)))return{data:{index:Y,overflows:V},reset:{placement:ce}};let ae=(Z=V.filter(ie=>ie.overflows[0]<=0).sort((ie,le)=>ie.overflows[1]-le.overflows[1])[0])==null?void 0:Z.placement;if(!ae)switch(_){case"bestFit":{var J;const ie=(J=V.filter(le=>{if(O){const fe=qy(le.placement);return fe===C||fe==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(fe=>fe>0).reduce((fe,xe)=>fe+xe,0)]).sort((le,fe)=>le[1]-fe[1])[0])==null?void 0:J[0];ie&&(ae=ie);break}case"initialPlacement":ae=i;break}if(a!==ae)return{reset:{placement:ae}}}return{}}}};function XEe(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function QEe(t){return e0t.some(s=>t[s]>=0)}const p0t=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r,platform:n}=s,{strategy:a="referenceHidden",...o}=m1(t,s);switch(a){case"referenceHidden":{const l=await n.detectOverflow(s,{...o,elementContext:"reference"}),i=XEe(l,r.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:QEe(i)}}}case"escaped":{const l=await n.detectOverflow(s,{...o,altBoundary:!0}),i=XEe(l,r.floating);return{data:{escapedOffsets:i,escaped:QEe(i)}}}default:return{}}}}},SUe=new Set(["left","top"]);async function f0t(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=p1(r),i=LA(r),d=qy(r)==="y",u=SUe.has(l)?-1:1,p=o&&d?-1:1,f=m1(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),d?{x:_*p,y:y*u}:{x:y*u,y:_*p}}const x0t=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var r,n;const{x:a,y:o,placement:l,middlewareData:i}=s,d=await f0t(s,t);return l===((r=i.offset)==null?void 0:r.placement)&&(n=i.arrow)!=null&&n.alignmentOffset?{}:{x:a+d.x,y:o+d.y,data:{...d,placement:l}}}}},g0t=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:r,y:n,placement:a,platform:o}=s,{mainAxis:l=!0,crossAxis:i=!1,limiter:d={fn:S=>{let{x:C,y:A}=S;return{x:C,y:A}}},...u}=m1(t,s),p={x:r,y:n},f=await o.detectOverflow(s,u),y=qy(p1(a)),_=dje(y);let b=p[_],N=p[y];if(l){const S=_==="y"?"top":"left",C=_==="y"?"bottom":"right",A=b+f[S],I=b-f[C];b=Ave(A,b,I)}if(i){const S=y==="y"?"top":"left",C=y==="y"?"bottom":"right",A=N+f[S],I=N-f[C];N=Ave(A,N,I)}const w=d.fn({...s,[_]:b,[y]:N});return{...w,data:{x:w.x-r,y:w.y-n,enabled:{[_]:l,[y]:i}}}}}},y0t=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:r,y:n,placement:a,rects:o,middlewareData:l}=s,{offset:i=0,mainAxis:d=!0,crossAxis:u=!0}=m1(t,s),p={x:r,y:n},f=qy(a),y=dje(f);let _=p[y],b=p[f];const N=m1(i,s),w=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:0,crossAxis:0,...N};if(d){const A=y==="y"?"height":"width",I=o.reference[y]-o.floating[A]+w.mainAxis,L=o.reference[y]+o.reference[A]-w.mainAxis;_L&&(_=L)}if(u){var S,C;const A=y==="y"?"width":"height",I=SUe.has(p1(a)),L=o.reference[f]-o.floating[A]+(I&&((S=l.offset)==null?void 0:S[f])||0)+(I?0:w.crossAxis),O=o.reference[f]+o.reference[A]+(I?0:((C=l.offset)==null?void 0:C[f])||0)-(I?w.crossAxis:0);bO&&(b=O)}return{[y]:_,[f]:b}}}},v0t=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var r,n;const{placement:a,rects:o,platform:l,elements:i}=s,{apply:d=()=>{},...u}=m1(t,s),p=await l.detectOverflow(s,u),f=p1(a),y=LA(a),_=qy(a)==="y",{width:b,height:N}=o.floating;let w,S;f==="top"||f==="bottom"?(w=f,S=y===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(S=f,w=y==="end"?"top":"bottom");const C=N-p.top-p.bottom,A=b-p.left-p.right,I=Xb(N-p[w],C),L=Xb(b-p[S],A),O=!s.middlewareData.shift;let U=I,q=L;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(q=A),(n=s.middlewareData.shift)!=null&&n.enabled.y&&(U=C),O&&!y){const V=Qp(p.left,0),ee=Qp(p.right,0),Z=Qp(p.top,0),J=Qp(p.bottom,0);_?q=b-2*(V!==0||ee!==0?V+ee:Qp(p.left,p.right)):U=N-2*(Z!==0||J!==0?Z+J:Qp(p.top,p.bottom))}await d({...s,availableWidth:q,availableHeight:U});const $=await l.getDimensions(i.floating);return b!==$.width||N!==$.height?{reset:{rects:!0}}:{}}}};function eue(){return typeof window<"u"}function DA(t){return CUe(t)?(t.nodeName||"").toLowerCase():"#document"}function cf(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function v0(t){var s;return(s=(CUe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function CUe(t){return eue()?t instanceof Node||t instanceof cf(t).Node:!1}function qg(t){return eue()?t instanceof Element||t instanceof cf(t).Element:!1}function k1(t){return eue()?t instanceof HTMLElement||t instanceof cf(t).HTMLElement:!1}function JEe(t){return!eue()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof cf(t).ShadowRoot}function kR(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=Ug(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&a!=="inline"&&a!=="contents"}function _0t(t){return/^(table|td|th)$/.test(DA(t))}function tue(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const b0t=/transform|translate|scale|rotate|perspective|filter/,w0t=/paint|layout|strict|content/,O2=t=>!!t&&t!=="none";let Kxe;function mje(t){const s=qg(t)?Ug(t):t;return O2(s.transform)||O2(s.translate)||O2(s.scale)||O2(s.rotate)||O2(s.perspective)||!pje()&&(O2(s.backdropFilter)||O2(s.filter))||b0t.test(s.willChange||"")||w0t.test(s.contain||"")}function j0t(t){let s=Qb(t);for(;k1(s)&&!CT(s);){if(mje(s))return s;if(tue(s))return null;s=Qb(s)}return null}function pje(){return Kxe==null&&(Kxe=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Kxe}function CT(t){return/^(html|body|#document)$/.test(DA(t))}function Ug(t){return cf(t).getComputedStyle(t)}function sue(t){return qg(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Qb(t){if(DA(t)==="html")return t;const s=t.assignedSlot||t.parentNode||JEe(t)&&t.host||v0(t);return JEe(s)?s.host:s}function MUe(t){const s=Qb(t);return CT(s)?t.ownerDocument?t.ownerDocument.body:t.body:k1(s)&&kR(s)?s:MUe(s)}function K8(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=MUe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=cf(a);if(o){const i=Pve(l);return s.concat(l,l.visualViewport||[],kR(a)?a:[],i&&r?K8(i):[])}else return s.concat(a,K8(a,[],r))}function Pve(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function TUe(t){const s=Ug(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=k1(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=Roe(r)!==o||Roe(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function fje(t){return qg(t)?t:t.contextElement}function UM(t){const s=fje(t);if(!k1(s))return n0(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=TUe(s);let l=(o?Roe(r.width):r.width)/n,i=(o?Roe(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const N0t=n0(0);function AUe(t){const s=cf(t);return!pje()||!s.visualViewport?N0t:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function k0t(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==cf(t)?!1:s}function HS(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=fje(t);let l=n0(1);s&&(n?qg(n)&&(l=UM(n)):l=UM(t));const i=k0t(o,r,n)?AUe(o):n0(0);let d=(a.left+i.x)/l.x,u=(a.top+i.y)/l.y,p=a.width/l.x,f=a.height/l.y;if(o){const y=cf(o),_=n&&qg(n)?cf(n):n;let b=y,N=Pve(b);for(;N&&n&&_!==b;){const w=UM(N),S=N.getBoundingClientRect(),C=Ug(N),A=S.left+(N.clientLeft+parseFloat(C.paddingLeft))*w.x,I=S.top+(N.clientTop+parseFloat(C.paddingTop))*w.y;d*=w.x,u*=w.y,p*=w.x,f*=w.y,d+=A,u+=I,b=cf(N),N=Pve(b)}}return Foe({width:p,height:f,x:d,y:u})}function rue(t,s){const r=sue(t).scrollLeft;return s?s.left+r:HS(v0(t)).left+r}function EUe(t,s){const r=t.getBoundingClientRect(),n=r.left+s.scrollLeft-rue(t,r),a=r.top+s.scrollTop;return{x:n,y:a}}function S0t(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=v0(n),i=s?tue(s.floating):!1;if(n===l||i&&o)return r;let d={scrollLeft:0,scrollTop:0},u=n0(1);const p=n0(0),f=k1(n);if((f||!f&&!o)&&((DA(n)!=="body"||kR(l))&&(d=sue(n)),f)){const _=HS(n);u=UM(n),p.x=_.x+n.clientLeft,p.y=_.y+n.clientTop}const y=l&&!f&&!o?EUe(l,d):n0(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-d.scrollLeft*u.x+p.x+y.x,y:r.y*u.y-d.scrollTop*u.y+p.y+y.y}}function C0t(t){return Array.from(t.getClientRects())}function M0t(t){const s=v0(t),r=sue(t),n=t.ownerDocument.body,a=Qp(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=Qp(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+rue(t);const i=-r.scrollTop;return Ug(n).direction==="rtl"&&(l+=Qp(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}const ePe=25;function T0t(t,s){const r=cf(t),n=v0(t),a=r.visualViewport;let o=n.clientWidth,l=n.clientHeight,i=0,d=0;if(a){o=a.width,l=a.height;const p=pje();(!p||p&&s==="fixed")&&(i=a.offsetLeft,d=a.offsetTop)}const u=rue(n);if(u<=0){const p=n.ownerDocument,f=p.body,y=getComputedStyle(f),_=p.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,b=Math.abs(n.clientWidth-f.clientWidth-_);b<=ePe&&(o-=b)}else u<=ePe&&(o+=u);return{width:o,height:l,x:i,y:d}}function A0t(t,s){const r=HS(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=k1(t)?UM(t):n0(1),l=t.clientWidth*o.x,i=t.clientHeight*o.y,d=a*o.x,u=n*o.y;return{width:l,height:i,x:d,y:u}}function tPe(t,s,r){let n;if(s==="viewport")n=T0t(t,r);else if(s==="document")n=M0t(v0(t));else if(qg(s))n=A0t(s,r);else{const a=AUe(t);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return Foe(n)}function PUe(t,s){const r=Qb(t);return r===s||!qg(r)||CT(r)?!1:Ug(r).position==="fixed"||PUe(r,s)}function E0t(t,s){const r=s.get(t);if(r)return r;let n=K8(t,[],!1).filter(i=>qg(i)&&DA(i)!=="body"),a=null;const o=Ug(t).position==="fixed";let l=o?Qb(t):t;for(;qg(l)&&!CT(l);){const i=Ug(l),d=mje(l);!d&&i.position==="fixed"&&(a=null),(o?!d&&!a:!d&&i.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||kR(l)&&!d&&PUe(t,l))?n=n.filter(p=>p!==l):a=i,l=Qb(l)}return s.set(t,n),n}function P0t(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?tue(s)?[]:E0t(s,this._c):[].concat(r),n],i=tPe(s,l[0],a);let d=i.top,u=i.right,p=i.bottom,f=i.left;for(let y=1;y{l(!1,1e-7)},1e3)}U===1&&!LUe(u,t.getBoundingClientRect())&&l(),I=!1}try{r=new IntersectionObserver(L,{...A,root:a.ownerDocument})}catch{r=new IntersectionObserver(L,A)}r.observe(t)}return l(!0),o}function z0t(t,s,r,n){n===void 0&&(n={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:d=!1}=n,u=fje(t),p=a||o?[...u?K8(u):[],...s?K8(s):[]]:[];p.forEach(S=>{a&&S.addEventListener("scroll",r,{passive:!0}),o&&S.addEventListener("resize",r)});const f=u&&i?F0t(u,r):null;let y=-1,_=null;l&&(_=new ResizeObserver(S=>{let[C]=S;C&&C.target===u&&_&&s&&(_.unobserve(s),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var A;(A=_)==null||A.observe(s)})),r()}),u&&!d&&_.observe(u),s&&_.observe(s));let b,N=d?HS(t):null;d&&w();function w(){const S=HS(t);N&&!LUe(N,S)&&r(),N=S,b=requestAnimationFrame(w)}return r(),()=>{var S;p.forEach(C=>{a&&C.removeEventListener("scroll",r),o&&C.removeEventListener("resize",r)}),f==null||f(),(S=_)==null||S.disconnect(),_=null,d&&cancelAnimationFrame(b)}}const B0t=x0t,$0t=g0t,q0t=m0t,U0t=v0t,V0t=p0t,rPe=h0t,H0t=y0t,G0t=(t,s,r)=>{const n=new Map,a={platform:O0t,...r},o={...a.platform,_c:n};return u0t(t,s,{...a,platform:o})};var W0t=typeof document<"u",K0t=function(){},Die=W0t?k.useLayoutEffect:K0t;function zoe(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(!zoe(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)&&!zoe(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function DUe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function nPe(t,s){const r=DUe(t);return Math.round(s*r)/r}function Yxe(t){const s=k.useRef(t);return Die(()=>{s.current=t}),s}function Z0t(t){t===void 0&&(t={});const{placement:s="bottom",strategy:r="absolute",middleware:n=[],platform:a,elements:{reference:o,floating:l}={},transform:i=!0,whileElementsMounted:d,open:u}=t,[p,f]=k.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[y,_]=k.useState(n);zoe(y,n)||_(n);const[b,N]=k.useState(null),[w,S]=k.useState(null),C=k.useCallback(le=>{le!==O.current&&(O.current=le,N(le))},[]),A=k.useCallback(le=>{le!==U.current&&(U.current=le,S(le))},[]),I=o||b,L=l||w,O=k.useRef(null),U=k.useRef(null),q=k.useRef(p),$=d!=null,V=Yxe(d),ee=Yxe(a),Z=Yxe(u),J=k.useCallback(()=>{if(!O.current||!U.current)return;const le={placement:s,strategy:r,middleware:y};ee.current&&(le.platform=ee.current),G0t(O.current,U.current,le).then(fe=>{const xe={...fe,isPositioned:Z.current!==!1};Y.current&&!zoe(q.current,xe)&&(q.current=xe,ap.flushSync(()=>{f(xe)}))})},[y,s,r,ee,Z]);Die(()=>{u===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,f(le=>({...le,isPositioned:!1})))},[u]);const Y=k.useRef(!1);Die(()=>(Y.current=!0,()=>{Y.current=!1}),[]),Die(()=>{if(I&&(O.current=I),L&&(U.current=L),I&&L){if(V.current)return V.current(I,L,J);J()}},[I,L,J,V,$]);const ce=k.useMemo(()=>({reference:O,floating:U,setReference:C,setFloating:A}),[C,A]),ae=k.useMemo(()=>({reference:I,floating:L}),[I,L]),ie=k.useMemo(()=>{const le={position:r,left:0,top:0};if(!ae.floating)return le;const fe=nPe(ae.floating,p.x),xe=nPe(ae.floating,p.y);return i?{...le,transform:"translate("+fe+"px, "+xe+"px)",...DUe(ae.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:fe,top:xe}},[r,i,ae.floating,p.x,p.y]);return k.useMemo(()=>({...p,update:J,refs:ce,elements:ae,floatingStyles:ie}),[p,J,ce,ae,ie])}const Y0t=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?rPe({element:n.current,padding:a}).fn(r):{}:n?rPe({element:n,padding:a}).fn(r):{}}}},X0t=(t,s)=>{const r=B0t(t);return{name:r.name,fn:r.fn,options:[t,s]}},Q0t=(t,s)=>{const r=$0t(t);return{name:r.name,fn:r.fn,options:[t,s]}},J0t=(t,s)=>({fn:H0t(t).fn,options:[t,s]}),evt=(t,s)=>{const r=q0t(t);return{name:r.name,fn:r.fn,options:[t,s]}},tvt=(t,s)=>{const r=U0t(t);return{name:r.name,fn:r.fn,options:[t,s]}},svt=(t,s)=>{const r=V0t(t);return{name:r.name,fn:r.fn,options:[t,s]}},rvt=(t,s)=>{const r=Y0t(t);return{name:r.name,fn:r.fn,options:[t,s]}};var nvt="Arrow",RUe=k.forwardRef((t,s)=>{const{children:r,width:n=10,height:a=5,...o}=t;return e.jsx(dn.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"})})});RUe.displayName=nvt;var avt=RUe;function SR(t){const[s,r]=k.useState(void 0);return rd(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const n=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let l,i;if("borderBoxSize"in o){const d=o.borderBoxSize,u=Array.isArray(d)?d[0]:d;l=u.inlineSize,i=u.blockSize}else l=t.offsetWidth,i=t.offsetHeight;r({width:l,height:i})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),s}var xje="Popper",[OUe,_0]=bd(xje),[ivt,FUe]=OUe(xje),zUe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=k.useState(null);return e.jsx(ivt,{scope:s,anchor:n,onAnchorChange:a,children:r})};zUe.displayName=xje;var BUe="PopperAnchor",$Ue=k.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=FUe(BUe,r),l=k.useRef(null),i=Ma(s,l),d=k.useRef(null);return k.useEffect(()=>{const u=d.current;d.current=(n==null?void 0:n.current)||l.current,u!==d.current&&o.onAnchorChange(d.current)}),n?null:e.jsx(dn.div,{...a,ref:i})});$Ue.displayName=BUe;var gje="PopperContent",[ovt,lvt]=OUe(gje),qUe=k.forwardRef((t,s)=>{var ze,Ee,ve,Re,Ue,ye;const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:i=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:y=!1,updatePositionStrategy:_="optimized",onPlaced:b,...N}=t,w=FUe(gje,r),[S,C]=k.useState(null),A=Ma(s,ct=>C(ct)),[I,L]=k.useState(null),O=SR(I),U=(O==null?void 0:O.width)??0,q=(O==null?void 0:O.height)??0,$=n+(o!=="center"?"-"+o:""),V=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},ee=Array.isArray(u)?u:[u],Z=ee.length>0,J={padding:V,boundary:ee.filter(dvt),altBoundary:Z},{refs:Y,floatingStyles:ce,placement:ae,isPositioned:ie,middlewareData:le}=Z0t({strategy:"fixed",placement:$,whileElementsMounted:(...ct)=>z0t(...ct,{animationFrame:_==="always"}),elements:{reference:w.anchor},middleware:[X0t({mainAxis:a+q,alignmentAxis:l}),d&&Q0t({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?J0t():void 0,...J}),d&&evt({...J}),tvt({...J,apply:({elements:ct,rects:pe,availableWidth:Ge,availableHeight:tt})=>{const{width:st,height:Ce}=pe.reference,et=ct.floating.style;et.setProperty("--radix-popper-available-width",`${Ge}px`),et.setProperty("--radix-popper-available-height",`${tt}px`),et.setProperty("--radix-popper-anchor-width",`${st}px`),et.setProperty("--radix-popper-anchor-height",`${Ce}px`)}}),I&&rvt({element:I,padding:i}),uvt({arrowWidth:U,arrowHeight:q}),y&&svt({strategy:"referenceHidden",...J})]}),[fe,xe]=HUe(ae),he=ed(b);rd(()=>{ie&&(he==null||he())},[ie,he]);const we=(ze=le.arrow)==null?void 0:ze.x,Ne=(Ee=le.arrow)==null?void 0:Ee.y,Ve=((ve=le.arrow)==null?void 0:ve.centerOffset)!==0,[Te,Ae]=k.useState();return rd(()=>{S&&Ae(window.getComputedStyle(S).zIndex)},[S]),e.jsx("div",{ref:Y.setFloating,"data-radix-popper-content-wrapper":"",style:{...ce,transform:ie?ce.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Te,"--radix-popper-transform-origin":[(Re=le.transformOrigin)==null?void 0:Re.x,(Ue=le.transformOrigin)==null?void 0:Ue.y].join(" "),...((ye=le.hide)==null?void 0:ye.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(ovt,{scope:r,placedSide:fe,onArrowChange:L,arrowX:we,arrowY:Ne,shouldHideArrow:Ve,children:e.jsx(dn.div,{"data-side":fe,"data-align":xe,...N,ref:A,style:{...N.style,animation:ie?void 0:"none"}})})})});qUe.displayName=gje;var UUe="PopperArrow",cvt={top:"bottom",right:"left",bottom:"top",left:"right"},VUe=k.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=lvt(UUe,n),l=cvt[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(avt,{...a,ref:r,style:{...a.style,display:"block"}})})});VUe.displayName=UUe;function dvt(t){return t!==null}var uvt=t=>({name:"transformOrigin",options:t,fn(s){var w,S,C;const{placement:r,rects:n,middlewareData:a}=s,l=((w=a.arrow)==null?void 0:w.centerOffset)!==0,i=l?0:t.arrowWidth,d=l?0:t.arrowHeight,[u,p]=HUe(r),f={start:"0%",center:"50%",end:"100%"}[p],y=(((S=a.arrow)==null?void 0:S.x)??0)+i/2,_=(((C=a.arrow)==null?void 0:C.y)??0)+d/2;let b="",N="";return u==="bottom"?(b=l?f:`${y}px`,N=`${-d}px`):u==="top"?(b=l?f:`${y}px`,N=`${n.floating.height+d}px`):u==="right"?(b=`${-d}px`,N=l?f:`${_}px`):u==="left"&&(b=`${n.floating.width+d}px`,N=l?f:`${_}px`),{data:{x:b,y:N}}}});function HUe(t){const[s,r="center"]=t.split("-");return[s,r]}var CR=zUe,RA=$Ue,MR=qUe,TR=VUe,hvt=Symbol("radix.slottable");function mvt(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=hvt,s}var[nue]=bd("Tooltip",[_0]),aue=_0(),GUe="TooltipProvider",pvt=700,Ive="tooltip.open",[fvt,yje]=nue(GUe),WUe=t=>{const{__scopeTooltip:s,delayDuration:r=pvt,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=k.useRef(!0),i=k.useRef(!1),d=k.useRef(0);return k.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),e.jsx(fvt,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:k.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:k.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:k.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};WUe.displayName=GUe;var Z8="Tooltip",[xvt,iue]=nue(Z8),KUe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,d=yje(Z8,t.__scopeTooltip),u=aue(s),[p,f]=k.useState(null),y=mu(),_=k.useRef(0),b=l??d.disableHoverableContent,N=i??d.delayDuration,w=k.useRef(!1),[S,C]=Bu({prop:n,defaultProp:a??!1,onChange:U=>{U?(d.onOpen(),document.dispatchEvent(new CustomEvent(Ive))):d.onClose(),o==null||o(U)},caller:Z8}),A=k.useMemo(()=>S?w.current?"delayed-open":"instant-open":"closed",[S]),I=k.useCallback(()=>{window.clearTimeout(_.current),_.current=0,w.current=!1,C(!0)},[C]),L=k.useCallback(()=>{window.clearTimeout(_.current),_.current=0,C(!1)},[C]),O=k.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{w.current=!0,C(!0),_.current=0},N)},[N,C]);return k.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),e.jsx(CR,{...u,children:e.jsx(xvt,{scope:s,contentId:y,open:S,stateAttribute:A,trigger:p,onTriggerChange:f,onTriggerEnter:k.useCallback(()=>{d.isOpenDelayedRef.current?O():I()},[d.isOpenDelayedRef,O,I]),onTriggerLeave:k.useCallback(()=>{b?L():(window.clearTimeout(_.current),_.current=0)},[L,b]),onOpen:I,onClose:L,disableHoverableContent:b,children:r})})};KUe.displayName=Z8;var Lve="TooltipTrigger",ZUe=k.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=iue(Lve,r),o=yje(Lve,r),l=aue(r),i=k.useRef(null),d=Ma(s,i,a.onTriggerChange),u=k.useRef(!1),p=k.useRef(!1),f=k.useCallback(()=>u.current=!1,[]);return k.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),e.jsx(RA,{asChild:!0,...l,children:e.jsx(dn.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:d,onPointerMove:Tr(t.onPointerMove,y=>{y.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Tr(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Tr(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Tr(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Tr(t.onBlur,a.onClose),onClick:Tr(t.onClick,a.onClose)})})});ZUe.displayName=Lve;var gvt="TooltipPortal",[JAs,yvt]=nue(gvt,{forceMount:void 0}),MT="TooltipContent",YUe=k.forwardRef((t,s)=>{const r=yvt(MT,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=iue(MT,t.__scopeTooltip);return e.jsx(wd,{present:n||l.open,children:l.disableHoverableContent?e.jsx(XUe,{side:a,...o,ref:s}):e.jsx(vvt,{side:a,...o,ref:s})})}),vvt=k.forwardRef((t,s)=>{const r=iue(MT,t.__scopeTooltip),n=yje(MT,t.__scopeTooltip),a=k.useRef(null),o=Ma(s,a),[l,i]=k.useState(null),{trigger:d,onClose:u}=r,p=a.current,{onPointerInTransitChange:f}=n,y=k.useCallback(()=>{i(null),f(!1)},[f]),_=k.useCallback((b,N)=>{const w=b.currentTarget,S={x:b.clientX,y:b.clientY},C=Nvt(S,w.getBoundingClientRect()),A=kvt(S,C),I=Svt(N.getBoundingClientRect()),L=Mvt([...A,...I]);i(L),f(!0)},[f]);return k.useEffect(()=>()=>y(),[y]),k.useEffect(()=>{if(d&&p){const b=w=>_(w,p),N=w=>_(w,d);return d.addEventListener("pointerleave",b),p.addEventListener("pointerleave",N),()=>{d.removeEventListener("pointerleave",b),p.removeEventListener("pointerleave",N)}}},[d,p,_,y]),k.useEffect(()=>{if(l){const b=N=>{const w=N.target,S={x:N.clientX,y:N.clientY},C=(d==null?void 0:d.contains(w))||(p==null?void 0:p.contains(w)),A=!Cvt(S,l);C?y():A&&(y(),u())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[d,p,l,u,y]),e.jsx(XUe,{...t,ref:o})}),[_vt,bvt]=nue(Z8,{isInside:!1}),wvt=mvt("TooltipContent"),XUe=k.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,d=iue(MT,r),u=aue(r),{onClose:p}=d;return k.useEffect(()=>(document.addEventListener(Ive,p),()=>document.removeEventListener(Ive,p)),[p]),k.useEffect(()=>{if(d.trigger){const f=y=>{const _=y.target;_!=null&&_.contains(d.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[d.trigger,p]),e.jsx(mw,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:e.jsxs(MR,{"data-state":d.stateAttribute,...u,...i,ref:s,style:{...i.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(wvt,{children:n}),e.jsx(_vt,{scope:r,isInside:!0,children:e.jsx(xgt,{id:d.contentId,role:"tooltip",children:a||n})})]})})});YUe.displayName=MT;var QUe="TooltipArrow",jvt=k.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=aue(r);return bvt(QUe,r).isInside?null:e.jsx(TR,{...a,...n,ref:s})});jvt.displayName=QUe;function Nvt(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 kvt(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 Svt(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 Cvt(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 Mvt(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),Tvt(s)}function Tvt(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 Avt=WUe,Evt=KUe,Pvt=ZUe,JUe=YUe;const S1=Avt,Jl=Evt,ec=Pvt,Il=k.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(JUe,{ref:n,sideOffset:s,className:Rt("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}));Il.displayName=JUe.displayName;var OA=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(){}},L4,tb,lT,yBe,Ivt=(yBe=class extends OA{constructor(){super();Sa(this,L4);Sa(this,tb);Sa(this,lT);Dn(this,lT,s=>{if(typeof window<"u"&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){cs(this,tb)||this.setEventListener(cs(this,lT))}onUnsubscribe(){var s;this.hasListeners()||((s=cs(this,tb))==null||s.call(this),Dn(this,tb,void 0))}setEventListener(s){var r;Dn(this,lT,s),(r=cs(this,tb))==null||r.call(this),Dn(this,tb,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){cs(this,L4)!==s&&(Dn(this,L4,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof cs(this,L4)=="boolean"?cs(this,L4):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},L4=new WeakMap,tb=new WeakMap,lT=new WeakMap,yBe),vje=new Ivt,Lvt={setTimeout:(t,s)=>setTimeout(t,s),clearTimeout:t=>clearTimeout(t),setInterval:(t,s)=>setInterval(t,s),clearInterval:t=>clearInterval(t)},sb,l2e,vBe,Dvt=(vBe=class{constructor(){Sa(this,sb,Lvt);Sa(this,l2e,!1)}setTimeoutProvider(t){Dn(this,sb,t)}setTimeout(t,s){return cs(this,sb).setTimeout(t,s)}clearTimeout(t){cs(this,sb).clearTimeout(t)}setInterval(t,s){return cs(this,sb).setInterval(t,s)}clearInterval(t){cs(this,sb).clearInterval(t)}},sb=new WeakMap,l2e=new WeakMap,vBe),g4=new Dvt;function Rvt(t){setTimeout(t,0)}var Ovt=typeof window>"u"||"Deno"in globalThis;function hm(){}function Fvt(t,s){return typeof t=="function"?t(s):t}function Dve(t){return typeof t=="number"&&t>=0&&t!==1/0}function eVe(t,s){return Math.max(t+(s||0)-Date.now(),0)}function Fb(t,s){return typeof t=="function"?t(s):t}function Yp(t,s){return typeof t=="function"?t(s):t}function aPe(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==_je(l,s.options))return!1}else if(!Y8(s.queryKey,l))return!1}if(r!=="all"){const d=s.isActive();if(r==="active"&&!d||r==="inactive"&&d)return!1}return!(typeof i=="boolean"&&s.isStale()!==i||a&&a!==s.state.fetchStatus||o&&!o(s))}function iPe(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(GS(s.options.mutationKey)!==GS(o))return!1}else if(!Y8(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function _je(t,s){return((s==null?void 0:s.queryKeyHashFn)||GS)(t)}function GS(t){return JSON.stringify(t,(s,r)=>Rve(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function Y8(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>Y8(t[r],s[r])):!1}var zvt=Object.prototype.hasOwnProperty;function tVe(t,s,r=0){if(t===s)return t;if(r>500)return s;const n=oPe(t)&&oPe(s);if(!n&&!(Rve(t)&&Rve(s)))return s;const o=(n?t:Object.keys(t)).length,l=n?s:Object.keys(s),i=l.length,d=n?new Array(i):{};let u=0;for(let p=0;p{g4.setTimeout(s,t)})}function Ove(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?tVe(t,s):s}function $vt(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function qvt(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var bje=Symbol();function sVe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===bje?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function wje(t,s){return typeof t=="function"?t(...s):!!t}function Uvt(t,s,r){let n=!1,a;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(a??(a=s()),n||(n=!0,a.aborted?r():a.addEventListener("abort",r,{once:!0})),a)}),t}var X8=(()=>{let t=()=>Ovt;return{isServer(){return t()},setIsServer(s){t=s}}})();function Fve(){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}var Vvt=Rvt;function Hvt(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=Vvt;const o=i=>{s?t.push(i):a(()=>{r(i)})},l=()=>{const i=t;t=[],i.length&&a(()=>{n(()=>{i.forEach(d=>{r(d)})})})};return{batch:i=>{let d;s++;try{d=i()}finally{s--,s||l()}return d},batchCalls:i=>(...d)=>{o(()=>{i(...d)})},schedule:o,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{a=i}}}var ru=Hvt(),cT,rb,dT,_Be,Gvt=(_Be=class extends OA{constructor(){super();Sa(this,cT,!0);Sa(this,rb);Sa(this,dT);Dn(this,dT,s=>{if(typeof window<"u"&&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,rb)||this.setEventListener(cs(this,dT))}onUnsubscribe(){var s;this.hasListeners()||((s=cs(this,rb))==null||s.call(this),Dn(this,rb,void 0))}setEventListener(s){var r;Dn(this,dT,s),(r=cs(this,rb))==null||r.call(this),Dn(this,rb,s(this.setOnline.bind(this)))}setOnline(s){cs(this,cT)!==s&&(Dn(this,cT,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return cs(this,cT)}},cT=new WeakMap,rb=new WeakMap,dT=new WeakMap,_Be),$oe=new Gvt;function Wvt(t){return Math.min(1e3*2**t,3e4)}function rVe(t){return(t??"online")==="online"?$oe.isOnline():!0}var zve=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function nVe(t){let s=!1,r=0,n;const a=Fve(),o=()=>a.status!=="pending",l=N=>{var w;if(!o()){const S=new zve(N);y(S),(w=t.onCancel)==null||w.call(t,S)}},i=()=>{s=!0},d=()=>{s=!1},u=()=>vje.isFocused()&&(t.networkMode==="always"||$oe.isOnline())&&t.canRun(),p=()=>rVe(t.networkMode)&&t.canRun(),f=N=>{o()||(n==null||n(),a.resolve(N))},y=N=>{o()||(n==null||n(),a.reject(N))},_=()=>new Promise(N=>{var w;n=S=>{(o()||u())&&N(S)},(w=t.onPause)==null||w.call(t)}).then(()=>{var N;n=void 0,o()||(N=t.onContinue)==null||N.call(t)}),b=()=>{if(o())return;let N;const w=r===0?t.initialPromise:void 0;try{N=w??t.fn()}catch(S){N=Promise.reject(S)}Promise.resolve(N).then(f).catch(S=>{var O;if(o())return;const C=t.retry??(X8.isServer()?0:3),A=t.retryDelay??Wvt,I=typeof A=="function"?A(r,S):A,L=C===!0||typeof C=="number"&&ru()?void 0:_()).then(()=>{s?y(S):b()})})};return{promise:a,status:()=>a.status,cancel:l,continue:()=>(n==null||n(),a),cancelRetry:i,continueRetry:d,canStart:p,start:()=>(p()?b():_().then(b),a)}}var D4,bBe,aVe=(bBe=class{constructor(){Sa(this,D4)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Dve(this.gcTime)&&Dn(this,D4,g4.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(X8.isServer()?1/0:5*60*1e3))}clearGcTimeout(){cs(this,D4)!==void 0&&(g4.clearTimeout(cs(this,D4)),Dn(this,D4,void 0))}},D4=new WeakMap,bBe),R4,uT,rx,O4,Mu,mR,F4,Zp,iVe,yv,wBe,Kvt=(wBe=class extends aVe{constructor(s){super();Sa(this,Zp);Sa(this,R4);Sa(this,uT);Sa(this,rx);Sa(this,O4);Sa(this,Mu);Sa(this,mR);Sa(this,F4);Dn(this,F4,!1),Dn(this,mR,s.defaultOptions),this.setOptions(s.options),this.observers=[],Dn(this,O4,s.client),Dn(this,rx,cs(this,O4).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,Dn(this,R4,dPe(this.options)),this.state=s.state??cs(this,R4),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=cs(this,Mu))==null?void 0:s.promise}setOptions(s){if(this.options={...cs(this,mR),...s},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=dPe(this.options);r.data!==void 0&&(this.setState(cPe(r.data,r.dataUpdatedAt)),Dn(this,R4,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&cs(this,rx).remove(this)}setData(s,r){const n=Ove(this.state.data,s,this.options);return Mi(this,Zp,yv).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){Mi(this,Zp,yv).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=cs(this,Mu))==null?void 0:n.promise;return(a=cs(this,Mu))==null||a.cancel(s),r?r.then(hm).catch(hm):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return cs(this,R4)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(s=>Yp(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===bje||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>Fb(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:!eVe(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=cs(this,Mu))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=cs(this,Mu))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),cs(this,rx).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,Mu)&&(cs(this,F4)||Mi(this,Zp,iVe).call(this)?cs(this,Mu).cancel({revert:!0}):cs(this,Mu).cancelRetry()),this.scheduleGc()),cs(this,rx).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Mi(this,Zp,yv).call(this,{type:"invalidate"})}async fetch(s,r){var d,u,p,f,y,_,b,N,w,S,C,A;if(this.state.fetchStatus!=="idle"&&((d=cs(this,Mu))==null?void 0:d.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(cs(this,Mu))return cs(this,Mu).continueRetry(),cs(this,Mu).promise}if(s&&this.setOptions(s),!this.options.queryFn){const I=this.observers.find(L=>L.options.queryFn);I&&this.setOptions(I.options)}const n=new AbortController,a=I=>{Object.defineProperty(I,"signal",{enumerable:!0,get:()=>(Dn(this,F4,!0),n.signal)})},o=()=>{const I=sVe(this.options,r),O=(()=>{const U={client:cs(this,O4),queryKey:this.queryKey,meta:this.meta};return a(U),U})();return Dn(this,F4,!1),this.options.persister?this.options.persister(I,O,this):I(O)},i=(()=>{const I={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:cs(this,O4),state:this.state,fetchFn:o};return a(I),I})();(u=this.options.behavior)==null||u.onFetch(i,this),Dn(this,uT,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=i.fetchOptions)==null?void 0:p.meta))&&Mi(this,Zp,yv).call(this,{type:"fetch",meta:(f=i.fetchOptions)==null?void 0:f.meta}),Dn(this,Mu,nVe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,onCancel:I=>{I instanceof zve&&I.revert&&this.setState({...cs(this,uT),fetchStatus:"idle"}),n.abort()},onFail:(I,L)=>{Mi(this,Zp,yv).call(this,{type:"failed",failureCount:I,error:L})},onPause:()=>{Mi(this,Zp,yv).call(this,{type:"pause"})},onContinue:()=>{Mi(this,Zp,yv).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}));try{const I=await cs(this,Mu).start();if(I===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(I),(_=(y=cs(this,rx).config).onSuccess)==null||_.call(y,I,this),(N=(b=cs(this,rx).config).onSettled)==null||N.call(b,I,this.state.error,this),I}catch(I){if(I instanceof zve){if(I.silent)return cs(this,Mu).promise;if(I.revert){if(this.state.data===void 0)throw I;return this.state.data}}throw Mi(this,Zp,yv).call(this,{type:"error",error:I}),(S=(w=cs(this,rx).config).onError)==null||S.call(w,I,this),(A=(C=cs(this,rx).config).onSettled)==null||A.call(C,this.state.data,I,this),I}finally{this.scheduleGc()}}},R4=new WeakMap,uT=new WeakMap,rx=new WeakMap,O4=new WeakMap,Mu=new WeakMap,mR=new WeakMap,F4=new WeakMap,Zp=new WeakSet,iVe=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},yv=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,...oVe(n.data,this.options),fetchMeta:s.meta??null};case"success":const a={...n,...cPe(s.data,s.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!s.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return Dn(this,uT,s.manual?a:void 0),a;case"error":const o=s.error;return{...n,error:o,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...s.state}}};this.state=r(this.state),ru.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),cs(this,rx).notify({query:this,type:"updated",action:s})})},wBe);function oVe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:rVe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function cPe(t,s){return{data:t,dataUpdatedAt:s??Date.now(),error:null,isInvalidated:!1,status:"success"}}function dPe(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 Zm,Ji,pR,dm,z4,hT,Pv,nb,fR,mT,pT,B4,$4,ab,fT,Vo,T6,Bve,$ve,qve,Uve,Vve,Hve,Gve,cVe,jBe,lVe=(jBe=class extends OA{constructor(s,r){super();Sa(this,Vo);Sa(this,Zm);Sa(this,Ji);Sa(this,pR);Sa(this,dm);Sa(this,z4);Sa(this,hT);Sa(this,Pv);Sa(this,nb);Sa(this,fR);Sa(this,mT);Sa(this,pT);Sa(this,B4);Sa(this,$4);Sa(this,ab);Sa(this,fT,new Set);this.options=r,Dn(this,Zm,s),Dn(this,nb,null),Dn(this,Pv,Fve()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(cs(this,Ji).addObserver(this),uPe(cs(this,Ji),this.options)?Mi(this,Vo,T6).call(this):this.updateResult(),Mi(this,Vo,Uve).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Wve(cs(this,Ji),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Wve(cs(this,Ji),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Mi(this,Vo,Vve).call(this),Mi(this,Vo,Hve).call(this),cs(this,Ji).removeObserver(this)}setOptions(s){const r=this.options,n=cs(this,Ji);if(this.options=cs(this,Zm).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Yp(this.options.enabled,cs(this,Ji))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Mi(this,Vo,Gve).call(this),cs(this,Ji).setOptions(this.options),r._defaulted&&!Boe(this.options,r)&&cs(this,Zm).getQueryCache().notify({type:"observerOptionsUpdated",query:cs(this,Ji),observer:this});const a=this.hasListeners();a&&hPe(cs(this,Ji),n,this.options,r)&&Mi(this,Vo,T6).call(this),this.updateResult(),a&&(cs(this,Ji)!==n||Yp(this.options.enabled,cs(this,Ji))!==Yp(r.enabled,cs(this,Ji))||Fb(this.options.staleTime,cs(this,Ji))!==Fb(r.staleTime,cs(this,Ji)))&&Mi(this,Vo,Bve).call(this);const o=Mi(this,Vo,$ve).call(this);a&&(cs(this,Ji)!==n||Yp(this.options.enabled,cs(this,Ji))!==Yp(r.enabled,cs(this,Ji))||o!==cs(this,ab))&&Mi(this,Vo,qve).call(this,o)}getOptimisticResult(s){const r=cs(this,Zm).getQueryCache().build(cs(this,Zm),s),n=this.createResult(r,s);return Yvt(this,n)&&(Dn(this,dm,n),Dn(this,hT,this.options),Dn(this,z4,cs(this,Ji).state)),n}getCurrentResult(){return cs(this,dm)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&cs(this,Pv).status==="pending"&&cs(this,Pv).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,a))})}trackProp(s){cs(this,fT).add(s)}getCurrentQuery(){return cs(this,Ji)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=cs(this,Zm).defaultQueryOptions(s),n=cs(this,Zm).getQueryCache().build(cs(this,Zm),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Mi(this,Vo,T6).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),cs(this,dm)))}createResult(s,r){var $;const n=cs(this,Ji),a=this.options,o=cs(this,dm),l=cs(this,z4),i=cs(this,hT),u=s!==n?s.state:cs(this,pR),{state:p}=s;let f={...p},y=!1,_;if(r._optimisticResults){const V=this.hasListeners(),ee=!V&&uPe(s,r),Z=V&&hPe(s,n,r,a);(ee||Z)&&(f={...f,...oVe(p.data,s.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:b,errorUpdatedAt:N,status:w}=f;_=f.data;let S=!1;if(r.placeholderData!==void 0&&_===void 0&&w==="pending"){let V;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(V=o.data,S=!0):V=typeof r.placeholderData=="function"?r.placeholderData(($=cs(this,pT))==null?void 0:$.state.data,cs(this,pT)):r.placeholderData,V!==void 0&&(w="success",_=Ove(o==null?void 0:o.data,V,r),y=!0)}if(r.select&&_!==void 0&&!S)if(o&&_===(l==null?void 0:l.data)&&r.select===cs(this,fR))_=cs(this,mT);else try{Dn(this,fR,r.select),_=r.select(_),_=Ove(o==null?void 0:o.data,_,r),Dn(this,mT,_),Dn(this,nb,null)}catch(V){Dn(this,nb,V)}cs(this,nb)&&(b=cs(this,nb),_=cs(this,mT),N=Date.now(),w="error");const C=f.fetchStatus==="fetching",A=w==="pending",I=w==="error",L=A&&C,O=_!==void 0,q={status:w,fetchStatus:f.fetchStatus,isPending:A,isSuccess:w==="success",isError:I,isInitialLoading:L,isLoading:L,data:_,dataUpdatedAt:f.dataUpdatedAt,error:b,errorUpdatedAt:N,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:s.isFetched(),isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:C,isRefetching:C&&!A,isLoadingError:I&&!O,isPaused:f.fetchStatus==="paused",isPlaceholderData:y,isRefetchError:I&&O,isStale:jje(s,r),refetch:this.refetch,promise:cs(this,Pv),isEnabled:Yp(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const V=q.data!==void 0,ee=q.status==="error"&&!V,Z=ce=>{ee?ce.reject(q.error):V&&ce.resolve(q.data)},J=()=>{const ce=Dn(this,Pv,q.promise=Fve());Z(ce)},Y=cs(this,Pv);switch(Y.status){case"pending":s.queryHash===n.queryHash&&Z(Y);break;case"fulfilled":(ee||q.data!==Y.value)&&J();break;case"rejected":(!ee||q.error!==Y.reason)&&J();break}}return q}updateResult(){const s=cs(this,dm),r=this.createResult(cs(this,Ji),this.options);if(Dn(this,z4,cs(this,Ji).state),Dn(this,hT,this.options),cs(this,z4).data!==void 0&&Dn(this,pT,cs(this,Ji)),Boe(r,s))return;Dn(this,dm,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!cs(this,fT).size)return!0;const l=new Set(o??cs(this,fT));return this.options.throwOnError&&l.add("error"),Object.keys(cs(this,dm)).some(i=>{const d=i;return cs(this,dm)[d]!==s[d]&&l.has(d)})};Mi(this,Vo,cVe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Mi(this,Vo,Uve).call(this)}},Zm=new WeakMap,Ji=new WeakMap,pR=new WeakMap,dm=new WeakMap,z4=new WeakMap,hT=new WeakMap,Pv=new WeakMap,nb=new WeakMap,fR=new WeakMap,mT=new WeakMap,pT=new WeakMap,B4=new WeakMap,$4=new WeakMap,ab=new WeakMap,fT=new WeakMap,Vo=new WeakSet,T6=function(s){Mi(this,Vo,Gve).call(this);let r=cs(this,Ji).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(hm)),r},Bve=function(){Mi(this,Vo,Vve).call(this);const s=Fb(this.options.staleTime,cs(this,Ji));if(X8.isServer()||cs(this,dm).isStale||!Dve(s))return;const n=eVe(cs(this,dm).dataUpdatedAt,s)+1;Dn(this,B4,g4.setTimeout(()=>{cs(this,dm).isStale||this.updateResult()},n))},$ve=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(cs(this,Ji)):this.options.refetchInterval)??!1},qve=function(s){Mi(this,Vo,Hve).call(this),Dn(this,ab,s),!(X8.isServer()||Yp(this.options.enabled,cs(this,Ji))===!1||!Dve(cs(this,ab))||cs(this,ab)===0)&&Dn(this,$4,g4.setInterval(()=>{(this.options.refetchIntervalInBackground||vje.isFocused())&&Mi(this,Vo,T6).call(this)},cs(this,ab)))},Uve=function(){Mi(this,Vo,Bve).call(this),Mi(this,Vo,qve).call(this,Mi(this,Vo,$ve).call(this))},Vve=function(){cs(this,B4)!==void 0&&(g4.clearTimeout(cs(this,B4)),Dn(this,B4,void 0))},Hve=function(){cs(this,$4)!==void 0&&(g4.clearInterval(cs(this,$4)),Dn(this,$4,void 0))},Gve=function(){const s=cs(this,Zm).getQueryCache().build(cs(this,Zm),this.options);if(s===cs(this,Ji))return;const r=cs(this,Ji);Dn(this,Ji,s),Dn(this,pR,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},cVe=function(s){ru.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(cs(this,dm))}),cs(this,Zm).getQueryCache().notify({query:cs(this,Ji),type:"observerResultsUpdated"})})},jBe);function Zvt(t,s){return Yp(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&Yp(s.retryOnMount,t)===!1)}function uPe(t,s){return Zvt(t,s)||t.state.data!==void 0&&Wve(t,s,s.refetchOnMount)}function Wve(t,s,r){if(Yp(s.enabled,t)!==!1&&Fb(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&jje(t,s)}return!1}function hPe(t,s,r,n){return(t!==s||Yp(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&jje(t,r)}function jje(t,s){return Yp(s.enabled,t)!==!1&&t.isStaleByTime(Fb(s.staleTime,t))}function Yvt(t,s){return!Boe(t.getCurrentResult(),s)}function qoe(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:[]},d=0;const u=async()=>{let N=!1;const w=A=>{Uvt(A,()=>s.signal,()=>N=!0)},S=sVe(s.options,s.fetchOptions),C=async(A,I,L)=>{if(N)return Promise.reject();if(I==null&&A.pages.length)return Promise.resolve(A);const U=(()=>{const ee={client:s.client,queryKey:s.queryKey,pageParam:I,direction:L?"backward":"forward",meta:s.options.meta};return w(ee),ee})(),q=await S(U),{maxPages:$}=s.options,V=L?qvt:$vt;return{pages:V(A.pages,q,$),pageParams:V(A.pageParams,I,$)}};if(a&&o.length){const A=a==="backward",I=A?dVe:Kve,L={pages:o,pageParams:l},O=I(n,L);i=await C(L,O,A)}else{const A=t??o.length;do{const I=d===0?l[0]??n.initialPageParam:Kve(n,i);if(d>0&&I==null)break;i=await C(i,I),d++}while(d{var N,w;return(w=(N=s.options).persister)==null?void 0:w.call(N,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=u}}}function Kve(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 dVe(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 Xvt(t,s){return s?Kve(t,s)!=null:!1}function Qvt(t,s){return!s||!t.getPreviousPageParam?!1:dVe(t,s)!=null}var Jvt=class extends lVe{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:qoe()})}getOptimisticResult(t){return t.behavior=qoe(),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,N;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,d=(N=(b=r.fetchMeta)==null?void 0:b.fetchMore)==null?void 0:N.direction,u=l&&d==="forward",p=a&&d==="forward",f=l&&d==="backward",y=a&&d==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Xvt(s,r.data),hasPreviousPage:Qvt(s,r.data),isFetchNextPageError:u,isFetchingNextPage:p,isFetchPreviousPageError:f,isFetchingPreviousPage:y,isRefetchError:i&&!u&&!f,isRefetching:o&&!p&&!y}}},xR,Iy,Nh,q4,Ly,S_,NBe,e1t=(NBe=class extends aVe{constructor(s){super();Sa(this,Ly);Sa(this,xR);Sa(this,Iy);Sa(this,Nh);Sa(this,q4);Dn(this,xR,s.client),this.mutationId=s.mutationId,Dn(this,Nh,s.mutationCache),Dn(this,Iy,[]),this.state=s.state||uVe(),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,Iy).includes(s)||(cs(this,Iy).push(s),this.clearGcTimeout(),cs(this,Nh).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){Dn(this,Iy,cs(this,Iy).filter(r=>r!==s)),this.scheduleGc(),cs(this,Nh).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){cs(this,Iy).length||(this.state.status==="pending"?this.scheduleGc():cs(this,Nh).remove(this))}continue(){var s;return((s=cs(this,q4))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var l,i,d,u,p,f,y,_,b,N,w,S,C,A,I,L,O,U;const r=()=>{Mi(this,Ly,S_).call(this,{type:"continue"})},n={client:cs(this,xR),meta:this.options.meta,mutationKey:this.options.mutationKey};Dn(this,q4,nVe({fn:()=>this.options.mutationFn?this.options.mutationFn(s,n):Promise.reject(new Error("No mutationFn found")),onFail:(q,$)=>{Mi(this,Ly,S_).call(this,{type:"failed",failureCount:q,error:$})},onPause:()=>{Mi(this,Ly,S_).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>cs(this,Nh).canRun(this)}));const a=this.state.status==="pending",o=!cs(this,q4).canStart();try{if(a)r();else{Mi(this,Ly,S_).call(this,{type:"pending",variables:s,isPaused:o}),cs(this,Nh).config.onMutate&&await cs(this,Nh).config.onMutate(s,this,n);const $=await((i=(l=this.options).onMutate)==null?void 0:i.call(l,s,n));$!==this.state.context&&Mi(this,Ly,S_).call(this,{type:"pending",context:$,variables:s,isPaused:o})}const q=await cs(this,q4).start();return await((u=(d=cs(this,Nh).config).onSuccess)==null?void 0:u.call(d,q,s,this.state.context,this,n)),await((f=(p=this.options).onSuccess)==null?void 0:f.call(p,q,s,this.state.context,n)),await((_=(y=cs(this,Nh).config).onSettled)==null?void 0:_.call(y,q,null,this.state.variables,this.state.context,this,n)),await((N=(b=this.options).onSettled)==null?void 0:N.call(b,q,null,s,this.state.context,n)),Mi(this,Ly,S_).call(this,{type:"success",data:q}),q}catch(q){try{await((S=(w=cs(this,Nh).config).onError)==null?void 0:S.call(w,q,s,this.state.context,this,n))}catch($){Promise.reject($)}try{await((A=(C=this.options).onError)==null?void 0:A.call(C,q,s,this.state.context,n))}catch($){Promise.reject($)}try{await((L=(I=cs(this,Nh).config).onSettled)==null?void 0:L.call(I,void 0,q,this.state.variables,this.state.context,this,n))}catch($){Promise.reject($)}try{await((U=(O=this.options).onSettled)==null?void 0:U.call(O,void 0,q,s,this.state.context,n))}catch($){Promise.reject($)}throw Mi(this,Ly,S_).call(this,{type:"error",error:q}),q}finally{cs(this,Nh).runNext(this)}}},xR=new WeakMap,Iy=new WeakMap,Nh=new WeakMap,q4=new WeakMap,Ly=new WeakSet,S_=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),ru.batch(()=>{cs(this,Iy).forEach(n=>{n.onMutationUpdate(s)}),cs(this,Nh).notify({mutation:this,type:"updated",action:s})})},NBe);function uVe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Iv,vg,gR,kBe,t1t=(kBe=class extends OA{constructor(s={}){super();Sa(this,Iv);Sa(this,vg);Sa(this,gR);this.config=s,Dn(this,Iv,new Set),Dn(this,vg,new Map),Dn(this,gR,0)}build(s,r,n){const a=new e1t({client:s,mutationCache:this,mutationId:++Y7(this,gR)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){cs(this,Iv).add(s);const r=yz(s);if(typeof r=="string"){const n=cs(this,vg).get(r);n?n.push(s):cs(this,vg).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(cs(this,Iv).delete(s)){const r=yz(s);if(typeof r=="string"){const n=cs(this,vg).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&cs(this,vg).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=yz(s);if(typeof r=="string"){const n=cs(this,vg).get(r),a=n==null?void 0:n.find(o=>o.state.status==="pending");return!a||a===s}else return!0}runNext(s){var n;const r=yz(s);if(typeof r=="string"){const a=(n=cs(this,vg).get(r))==null?void 0:n.find(o=>o!==s&&o.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ru.batch(()=>{cs(this,Iv).forEach(s=>{this.notify({type:"removed",mutation:s})}),cs(this,Iv).clear(),cs(this,vg).clear()})}getAll(){return Array.from(cs(this,Iv))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>iPe(r,n))}findAll(s={}){return this.getAll().filter(r=>iPe(s,r))}notify(s){ru.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return ru.batch(()=>Promise.all(s.map(r=>r.continue().catch(hm))))}},Iv=new WeakMap,vg=new WeakMap,gR=new WeakMap,kBe);function yz(t){var s;return(s=t.options.scope)==null?void 0:s.id}var Lv,ib,Ym,Dv,l1,Rie,Zve,SBe,s1t=(SBe=class extends OA{constructor(r,n){super();Sa(this,l1);Sa(this,Lv);Sa(this,ib);Sa(this,Ym);Sa(this,Dv);Dn(this,Lv,r),this.setOptions(n),this.bindMethods(),Mi(this,l1,Rie).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,Lv).defaultMutationOptions(r),Boe(this.options,n)||cs(this,Lv).getMutationCache().notify({type:"observerOptionsUpdated",mutation:cs(this,Ym),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&GS(n.mutationKey)!==GS(this.options.mutationKey)?this.reset():((a=cs(this,Ym))==null?void 0:a.state.status)==="pending"&&cs(this,Ym).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=cs(this,Ym))==null||r.removeObserver(this)}onMutationUpdate(r){Mi(this,l1,Rie).call(this),Mi(this,l1,Zve).call(this,r)}getCurrentResult(){return cs(this,ib)}reset(){var r;(r=cs(this,Ym))==null||r.removeObserver(this),Dn(this,Ym,void 0),Mi(this,l1,Rie).call(this),Mi(this,l1,Zve).call(this)}mutate(r,n){var a;return Dn(this,Dv,n),(a=cs(this,Ym))==null||a.removeObserver(this),Dn(this,Ym,cs(this,Lv).getMutationCache().build(cs(this,Lv),this.options)),cs(this,Ym).addObserver(this),cs(this,Ym).execute(r)}},Lv=new WeakMap,ib=new WeakMap,Ym=new WeakMap,Dv=new WeakMap,l1=new WeakSet,Rie=function(){var n;const r=((n=cs(this,Ym))==null?void 0:n.state)??uVe();Dn(this,ib,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},Zve=function(r){ru.batch(()=>{var n,a,o,l,i,d,u,p;if(cs(this,Dv)&&this.hasListeners()){const f=cs(this,ib).variables,y=cs(this,ib).context,_={client:cs(this,Lv),meta:this.options.meta,mutationKey:this.options.mutationKey};if((r==null?void 0:r.type)==="success"){try{(a=(n=cs(this,Dv)).onSuccess)==null||a.call(n,r.data,f,y,_)}catch(b){Promise.reject(b)}try{(l=(o=cs(this,Dv)).onSettled)==null||l.call(o,r.data,null,f,y,_)}catch(b){Promise.reject(b)}}else if((r==null?void 0:r.type)==="error"){try{(d=(i=cs(this,Dv)).onError)==null||d.call(i,r.error,f,y,_)}catch(b){Promise.reject(b)}try{(p=(u=cs(this,Dv)).onSettled)==null||p.call(u,void 0,r.error,f,y,_)}catch(b){Promise.reject(b)}}}this.listeners.forEach(f=>{f(cs(this,ib))})})},SBe),Dy,CBe,r1t=(CBe=class extends OA{constructor(s={}){super();Sa(this,Dy);this.config=s,Dn(this,Dy,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??_je(a,r);let l=this.get(o);return l||(l=new Kvt({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){cs(this,Dy).has(s.queryHash)||(cs(this,Dy).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=cs(this,Dy).get(s.queryHash);r&&(s.destroy(),r===s&&cs(this,Dy).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){ru.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return cs(this,Dy).get(s)}getAll(){return[...cs(this,Dy).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>aPe(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>aPe(s,n)):r}notify(s){ru.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){ru.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){ru.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},Dy=new WeakMap,CBe),Hc,ob,lb,xT,gT,cb,yT,vT,MBe,n1t=(MBe=class{constructor(t={}){Sa(this,Hc);Sa(this,ob);Sa(this,lb);Sa(this,xT);Sa(this,gT);Sa(this,cb);Sa(this,yT);Sa(this,vT);Dn(this,Hc,t.queryCache||new r1t),Dn(this,ob,t.mutationCache||new t1t),Dn(this,lb,t.defaultOptions||{}),Dn(this,xT,new Map),Dn(this,gT,new Map),Dn(this,cb,0)}mount(){Y7(this,cb)._++,cs(this,cb)===1&&(Dn(this,yT,vje.subscribe(async t=>{t&&(await this.resumePausedMutations(),cs(this,Hc).onFocus())})),Dn(this,vT,$oe.subscribe(async t=>{t&&(await this.resumePausedMutations(),cs(this,Hc).onOnline())})))}unmount(){var t,s;Y7(this,cb)._--,cs(this,cb)===0&&((t=cs(this,yT))==null||t.call(this),Dn(this,yT,void 0),(s=cs(this,vT))==null||s.call(this),Dn(this,vT,void 0))}isFetching(t){return cs(this,Hc).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return cs(this,ob).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=cs(this,Hc).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=cs(this,Hc).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(Fb(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return cs(this,Hc).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,Hc).get(n.queryHash),o=a==null?void 0:a.state.data,l=Fvt(s,o);if(l!==void 0)return cs(this,Hc).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return ru.batch(()=>cs(this,Hc).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,Hc).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=cs(this,Hc);ru.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=cs(this,Hc);return ru.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=ru.batch(()=>cs(this,Hc).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(hm).catch(hm)}invalidateQueries(t,s={}){return ru.batch(()=>(cs(this,Hc).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=ru.batch(()=>cs(this,Hc).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(hm)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(hm)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=cs(this,Hc).build(this,s);return r.isStaleByTime(Fb(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(hm).catch(hm)}fetchInfiniteQuery(t){return t.behavior=qoe(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(hm).catch(hm)}ensureInfiniteQueryData(t){return t.behavior=qoe(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return $oe.isOnline()?cs(this,ob).resumePausedMutations():Promise.resolve()}getQueryCache(){return cs(this,Hc)}getMutationCache(){return cs(this,ob)}getDefaultOptions(){return cs(this,lb)}setDefaultOptions(t){Dn(this,lb,t)}setQueryDefaults(t,s){cs(this,xT).set(GS(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...cs(this,xT).values()],r={};return s.forEach(n=>{Y8(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){cs(this,gT).set(GS(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...cs(this,gT).values()],r={};return s.forEach(n=>{Y8(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...cs(this,lb).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=_je(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===bje&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...cs(this,lb).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){cs(this,Hc).clear(),cs(this,ob).clear()}},Hc=new WeakMap,ob=new WeakMap,lb=new WeakMap,xT=new WeakMap,gT=new WeakMap,cb=new WeakMap,yT=new WeakMap,vT=new WeakMap,MBe),hVe=k.createContext(void 0),es=t=>{const s=k.useContext(hVe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},a1t=({client:t,children:s})=>(k.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(hVe.Provider,{value:t,children:s})),mVe=k.createContext(!1),i1t=()=>k.useContext(mVe);mVe.Provider;function o1t(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var l1t=k.createContext(o1t()),c1t=()=>k.useContext(l1t),d1t=(t,s,r)=>{const n=r!=null&&r.state.error&&typeof t.throwOnError=="function"?wje(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||n)&&(s.isReset()||(t.retryOnMount=!1))},u1t=t=>{k.useEffect(()=>{t.clearReset()},[t])},h1t=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||wje(r,[t.error,n])),m1t=t=>{if(t.suspense){const r=a=>a==="static"?a:Math.max(a??1e3,1e3),n=t.staleTime;t.staleTime=typeof n=="function"?(...a)=>r(n(...a)):r(n),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},p1t=(t,s)=>t.isLoading&&t.isFetching&&!s,f1t=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,mPe=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function pVe(t,s,r){var y,_,b,N;const n=i1t(),a=c1t(),o=es(),l=o.defaultQueryOptions(t);(_=(y=o.getDefaultOptions().queries)==null?void 0:y._experimental_beforeQuery)==null||_.call(y,l);const i=o.getQueryCache().get(l.queryHash);l._optimisticResults=n?"isRestoring":"optimistic",m1t(l),d1t(l,a,i),u1t(a);const d=!o.getQueryCache().get(l.queryHash),[u]=k.useState(()=>new s(o,l)),p=u.getOptimisticResult(l),f=!n&&t.subscribed!==!1;if(k.useSyncExternalStore(k.useCallback(w=>{const S=f?u.subscribe(ru.batchCalls(w)):hm;return u.updateResult(),S},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),k.useEffect(()=>{u.setOptions(l)},[l,u]),f1t(l,p))throw mPe(l,u,a);if(h1t({result:p,errorResetBoundary:a,throwOnError:l.throwOnError,query:i,suspense:l.suspense}))throw p.error;if((N=(b=o.getDefaultOptions().queries)==null?void 0:b._experimental_afterQuery)==null||N.call(b,l,p),l.experimental_prefetchInRender&&!X8.isServer()&&p1t(p,n)){const w=d?mPe(l,u,a):i==null?void 0:i.promise;w==null||w.catch(hm).finally(()=>{u.updateResult()})}return l.notifyOnChangeProps?p:u.trackResult(p)}function ft(t,s){return pVe(t,lVe)}function Et(t,s){const r=es(),[n]=k.useState(()=>new s1t(r,t));k.useEffect(()=>{n.setOptions(t)},[n,t]);const a=k.useSyncExternalStore(k.useCallback(l=>n.subscribe(ru.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=k.useCallback((l,i)=>{n.mutate(l,i).catch(hm)},[n]);if(a.error&&wje(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function x1t(t,s){return pVe(t,Jvt)}/** * @remix-run/router v1.23.2 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Q8(){return Q8=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function Nje(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function y1t(){return Math.random().toString(36).substr(2,8)}function fPe(t,s){return{usr:t.state,key:t.key,idx:s}}function Yve(t,s,r,n){return r===void 0&&(r=null),Q8({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?FA(s):s,{state:r,key:s&&s.key||n||y1t()})}function Uoe(t){let{pathname:s="/",search:r="",hash:n=""}=t;return r&&r!=="?"&&(s+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(s+=n.charAt(0)==="#"?n:"#"+n),s}function FA(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 v1t(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=hb.Pop,d=null,u=p();u==null&&(u=0,l.replaceState(Q8({},l.state,{idx:u}),""));function p(){return(l.state||{idx:null}).idx}function f(){i=hb.Pop;let w=p(),S=w==null?null:w-u;u=w,d&&d({action:i,location:N.location,delta:S})}function y(w,S){i=hb.Push;let C=Yve(N.location,w,S);u=p()+1;let A=fPe(C,u),I=N.createHref(C);try{l.pushState(A,"",I)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;a.location.assign(I)}o&&d&&d({action:i,location:N.location,delta:1})}function _(w,S){i=hb.Replace;let C=Yve(N.location,w,S);u=p();let A=fPe(C,u),I=N.createHref(C);l.replaceState(A,"",I),o&&d&&d({action:i,location:N.location,delta:0})}function b(w){let S=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof w=="string"?w:Uoe(w);return C=C.replace(/ $/,"%20"),_d(S,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,S)}let N={get action(){return i},get location(){return t(a,l)},listen(w){if(d)throw new Error("A history only accepts one active listener");return a.addEventListener(pPe,f),d=w,()=>{a.removeEventListener(pPe,f),d=null}},createHref(w){return s(a,w)},createURL:b,encodeLocation(w){let S=b(w);return{pathname:S.pathname,search:S.search,hash:S.hash}},push:y,replace:_,go(w){return l.go(w)}};return N}var xPe;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(xPe||(xPe={}));function _1t(t,s,r){return r===void 0&&(r="/"),b1t(t,s,r)}function b1t(t,s,r,n){let a=typeof s=="string"?FA(s):s,o=kje(a.pathname||"/",r);if(o==null)return null;let l=fVe(t);w1t(l);let i=null;for(let d=0;i==null&&d{let d={relativePath:i===void 0?o.path||"":i,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};d.relativePath.startsWith("/")&&(_d(d.relativePath.startsWith(n),'Absolute route path "'+d.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),d.relativePath=d.relativePath.slice(n.length));let u=zb([n,d.relativePath]),p=r.concat(d);o.children&&o.children.length>0&&(_d(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),fVe(o.children,s,p,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:T1t(u,o.index),routesMeta:p})};return t.forEach((o,l)=>{var i;if(o.path===""||!((i=o.path)!=null&&i.includes("?")))a(o,l);else for(let d of xVe(o.path))a(o,l,d)}),s}function xVe(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=xVe(n.join("/")),i=[];return i.push(...l.map(d=>d===""?o:[o,d].join("/"))),a&&i.push(...l),i.map(d=>t.startsWith("/")&&d===""?"/":d)}function w1t(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:A1t(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const j1t=/^:[\w-]+$/,N1t=3,k1t=2,S1t=1,C1t=10,M1t=-2,gPe=t=>t==="*";function T1t(t,s){let r=t.split("/"),n=r.length;return r.some(gPe)&&(n+=M1t),s&&(n+=k1t),r.filter(a=>!gPe(a)).reduce((a,o)=>a+(j1t.test(o)?N1t:o===""?S1t:C1t),n)}function A1t(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 E1t(t,s,r){let{routesMeta:n}=t,a={},o="/",l=[];for(let i=0;i{let{paramName:y,isOptional:_}=p;if(y==="*"){let N=i[f]||"";l=o.slice(0,o.length-N.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 I1t(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),Nje(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let n=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,i,d)=>(n.push({paramName:i,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(n.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),n]}function L1t(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return Nje(!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 kje(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)||"/"}const D1t=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,R1t=t=>D1t.test(t);function O1t(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?FA(t):t,o;if(r)if(R1t(r))o=r;else{if(r.includes("//")){let l=r;r=r.replace(/\/\/+/g,"/"),Nje(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+r))}r.startsWith("/")?o=yPe(r.substring(1),"/"):o=yPe(r,s)}else o=s;return{pathname:o,search:B1t(n),hash:$1t(a)}}function yPe(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 Xxe(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 F1t(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function Sje(t,s){let r=F1t(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function Cje(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=FA(t):(a=Q8({},t),_d(!a.pathname||!a.pathname.includes("?"),Xxe("?","pathname","search",a)),_d(!a.pathname||!a.pathname.includes("#"),Xxe("#","pathname","hash",a)),_d(!a.search||!a.search.includes("#"),Xxe("#","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 d=O1t(a,i),u=l&&l!=="/"&&l.endsWith("/"),p=(o||l===".")&&r.endsWith("/");return!d.pathname.endsWith("/")&&(u||p)&&(d.pathname+="/"),d}const zb=t=>t.join("/").replace(/\/\/+/g,"/"),z1t=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),B1t=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,$1t=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function q1t(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const gVe=["post","put","patch","delete"];new Set(gVe);const U1t=["get",...gVe];new Set(U1t);/** * React Router v6.30.3 * * 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 J8(){return J8=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),k.useCallback(function(u,p){if(p===void 0&&(p={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let f=Cje(u,JSON.parse(l),o,p.relative==="path");t==null&&s!=="/"&&(f.pathname=f.pathname==="/"?s:zb([s,f.pathname])),(p.replace?n.replace:n.push)(f,p.state,p)},[s,n,l,o,t])}const W1t=k.createContext(null);function K1t(t){let s=k.useContext(b0).outlet;return s&&k.createElement(W1t.Provider,{value:t},s)}function ho(){let{matches:t}=k.useContext(b0),s=t[t.length-1];return s?s.params:{}}function _Ve(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=k.useContext(pw),{matches:a}=k.useContext(b0),{pathname:o}=Fl(),l=JSON.stringify(Sje(a,n.v7_relativeSplatPath));return k.useMemo(()=>Cje(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function Z1t(t,s){return Y1t(t,s)}function Y1t(t,s,r,n){zA()||_d(!1);let{navigator:a}=k.useContext(pw),{matches:o}=k.useContext(b0),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let u=Fl(),p;if(s){var f;let w=typeof s=="string"?FA(s):s;d==="/"||(f=w.pathname)!=null&&f.startsWith(d)||_d(!1),p=w}else p=u;let y=p.pathname||"/",_=y;if(d!=="/"){let w=d.replace(/^\//,"").split("/");_="/"+y.replace(/^\//,"").split("/").slice(w.length).join("/")}let b=_1t(t,{pathname:_}),N=t_t(b&&b.map(w=>Object.assign({},w,{params:Object.assign({},i,w.params),pathname:zb([d,a.encodeLocation?a.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?d:zb([d,a.encodeLocation?a.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),o,r,n);return s&&N?k.createElement(oue.Provider,{value:{location:J8({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:hb.Pop}},N):N}function X1t(){let t=a_t(),s=q1t(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return k.createElement(k.Fragment,null,k.createElement("h2",null,"Unexpected Application Error!"),k.createElement("h3",{style:{fontStyle:"italic"}},s),r?k.createElement("pre",{style:a},r):null,null)}const Q1t=k.createElement(X1t,null);class J1t extends k.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,r){return r.location!==s.location||r.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:r.error,location:r.location,revalidation:s.revalidation||r.revalidation}}componentDidCatch(s,r){console.error("React Router caught the following error during render",s,r)}render(){return this.state.error!==void 0?k.createElement(b0.Provider,{value:this.props.routeContext},k.createElement(yVe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function e_t(t){let{routeContext:s,match:r,children:n}=t,a=k.useContext(Mje);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),k.createElement(b0.Provider,{value:s},n)}function t_t(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||_d(!1),l=l.slice(0,Math.min(l.length,p+1))}let d=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let p=0;p=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((p,f,y)=>{let _,b=!1,N=null,w=null;r&&(_=i&&f.route.id?i[f.route.id]:void 0,N=f.route.errorElement||Q1t,d&&(u<0&&y===0?(o_t("route-fallback"),b=!0,w=null):u===y&&(b=!0,w=f.route.hydrateFallbackElement||null)));let S=s.concat(l.slice(0,y+1)),C=()=>{let A;return _?A=N:b?A=w:f.route.Component?A=k.createElement(f.route.Component,null):f.route.element?A=f.route.element:A=p,k.createElement(e_t,{match:f,routeContext:{outlet:p,matches:S,isDataRoute:r!=null},children:A})};return r&&(f.route.ErrorBoundary||f.route.errorElement||y===0)?k.createElement(J1t,{location:r.location,revalidation:r.revalidation,component:N,error:_,children:C(),routeContext:{outlet:null,matches:S,isDataRoute:!0}}):C()},null)}var bVe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(bVe||{}),wVe=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}(wVe||{});function s_t(t){let s=k.useContext(Mje);return s||_d(!1),s}function r_t(t){let s=k.useContext(V1t);return s||_d(!1),s}function n_t(t){let s=k.useContext(b0);return s||_d(!1),s}function jVe(t){let s=n_t(),r=s.matches[s.matches.length-1];return r.route.id||_d(!1),r.route.id}function a_t(){var t;let s=k.useContext(yVe),r=r_t(),n=jVe();return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function i_t(){let{router:t}=s_t(bVe.UseNavigateStable),s=jVe(wVe.UseNavigateStable),r=k.useRef(!1);return vVe(()=>{r.current=!0}),k.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,J8({fromRouteId:s},o)))},[t,s])}const vPe={};function o_t(t,s,r){vPe[t]||(vPe[t]=!0)}function l_t(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Qxe(t){let{to:s,replace:r,state:n,relative:a}=t;zA()||_d(!1);let{future:o,static:l}=k.useContext(pw),{matches:i}=k.useContext(b0),{pathname:d}=Fl(),u=br(),p=Cje(s,Sje(i,o.v7_relativeSplatPath),d,a==="path"),f=JSON.stringify(p);return k.useEffect(()=>u(JSON.parse(f),{replace:r,state:n,relative:a}),[u,f,a,r,n]),null}function c_t(t){return K1t(t.context)}function _s(t){_d(!1)}function d_t(t){let{basename:s="/",children:r=null,location:n,navigationType:a=hb.Pop,navigator:o,static:l=!1,future:i}=t;zA()&&_d(!1);let d=s.replace(/^\/*/,"/"),u=k.useMemo(()=>({basename:d,navigator:o,static:l,future:J8({v7_relativeSplatPath:!1},i)}),[d,i,o,l]);typeof n=="string"&&(n=FA(n));let{pathname:p="/",search:f="",hash:y="",state:_=null,key:b="default"}=n,N=k.useMemo(()=>{let w=kje(p,d);return w==null?null:{location:{pathname:w,search:f,hash:y,state:_,key:b},navigationType:a}},[d,p,f,y,_,b,a]);return N==null?null:k.createElement(pw.Provider,{value:u},k.createElement(oue.Provider,{children:r,value:N}))}function Voe(t){let{children:s,location:r}=t;return Z1t(Xve(s),r)}new Promise(()=>{});function Xve(t,s){s===void 0&&(s=[]);let r=[];return k.Children.forEach(t,(n,a)=>{if(!k.isValidElement(n))return;let o=[...s,a];if(n.type===k.Fragment){r.push.apply(r,Xve(n.props.children,o));return}n.type!==_s&&_d(!1),!n.props.index||!n.props.children||_d(!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=Xve(n.props.children,o)),r.push(l)}),r}/** * React Router DOM v6.30.3 * * 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 Qve(){return Qve=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function h_t(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function m_t(t,s){return t.button===0&&(!s||s==="_self")&&!h_t(t)}function Jve(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 p_t(t,s){let r=Jve(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const f_t=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],x_t="6";try{window.__reactRouterVersion=x_t}catch{}const g_t="startTransition",_Pe=Dde[g_t];function y_t(t){let{basename:s,children:r,future:n,window:a}=t,o=k.useRef();o.current==null&&(o.current=g1t({window:a,v5Compat:!0}));let l=o.current,[i,d]=k.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},p=k.useCallback(f=>{u&&_Pe?_Pe(()=>d(f)):d(f)},[d,u]);return k.useLayoutEffect(()=>l.listen(p),[l,p]),k.useEffect(()=>l_t(n),[n]),k.createElement(d_t,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const v_t=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",__t=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,da=k.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:d,to:u,preventScrollReset:p,viewTransition:f}=s,y=u_t(s,f_t),{basename:_}=k.useContext(pw),b,N=!1;if(typeof u=="string"&&__t.test(u)&&(b=u,v_t))try{let A=new URL(window.location.href),I=u.startsWith("//")?new URL(A.protocol+u):new URL(u),L=kje(I.pathname,_);I.origin===A.origin&&L!=null?u=L+I.search+I.hash:N=!0}catch{}let w=H1t(u,{relative:a}),S=b_t(u,{replace:l,state:i,target:d,preventScrollReset:p,relative:a,viewTransition:f});function C(A){n&&n(A),A.defaultPrevented||S(A)}return k.createElement("a",Qve({},y,{href:b||w,onClick:N||o?n:C,ref:r,target:d}))});var bPe;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(bPe||(bPe={}));var wPe;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(wPe||(wPe={}));function b_t(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,d=br(),u=Fl(),p=_Ve(t,{relative:l});return k.useCallback(f=>{if(m_t(f,r)){f.preventDefault();let y=n!==void 0?n:Uoe(u)===Uoe(p);d(t,{replace:y,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,d,p,n,a,r,t,o,l,i])}function Sc(t){let s=k.useRef(Jve(t)),r=k.useRef(!1),n=Fl(),a=k.useMemo(()=>p_t(n.search,r.current?null:s.current),[n.search]),o=br(),l=k.useCallback((i,d)=>{const u=Jve(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,d)},[o,a]);return[a,l]}var w_t=typeof Element<"u",j_t=typeof Map=="function",N_t=typeof Set=="function",k_t=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function Oie(t,s){if(t===s)return!0;if(t&&s&&typeof t=="object"&&typeof s=="object"){if(t.constructor!==s.constructor)return!1;var r,n,a;if(Array.isArray(t)){if(r=t.length,r!=s.length)return!1;for(n=r;n--!==0;)if(!Oie(t[n],s[n]))return!1;return!0}var o;if(j_t&&t instanceof Map&&s instanceof Map){if(t.size!==s.size)return!1;for(o=t.entries();!(n=o.next()).done;)if(!s.has(n.value[0]))return!1;for(o=t.entries();!(n=o.next()).done;)if(!Oie(n.value[1],s.get(n.value[0])))return!1;return!0}if(N_t&&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(k_t&&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(w_t&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!Oie(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var S_t=function(s,r){try{return Oie(s,r)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}};const C_t=ro(S_t);var M_t=function(t,s,r,n,a,o,l,i){if(!t){var d;if(s===void 0)d=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,a,o,l,i],p=0;d=new Error(s.replace(/%s/g,function(){return u[p++]})),d.name="Invariant Violation"}throw d.framesToPop=1,d}},T_t=M_t;const jPe=ro(T_t);var A_t=function(s,r,n,a){var o=n?n.call(a,s,r):void 0;if(o!==void 0)return!!o;if(s===r)return!0;if(typeof s!="object"||!s||typeof r!="object"||!r)return!1;var l=Object.keys(s),i=Object.keys(r);if(l.length!==i.length)return!1;for(var d=Object.prototype.hasOwnProperty.bind(r),u=0;u(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(NVe||{}),Jxe={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"]}},NPe=Object.values(NVe),Tje={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},P_t=Object.entries(Tje).reduce((t,[s,r])=>(t[r]=s,t),{}),Ag="data-rh",VM={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},HM=(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},I_t=t=>{let s=HM(t,"title");const r=HM(t,VM.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=HM(t,VM.DEFAULT_TITLE);return s||n||void 0},L_t=t=>HM(t,VM.ON_CHANGE_CLIENT_STATE)||(()=>{}),ege=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),D_t=(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),ZI=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&R_t(`Helmet: ${t} should be of type "Array". Instead found type "${typeof a[t]}"`),!1)).map(a=>a[t]).reverse().reduce((a,o)=>{const l={};o.filter(d=>{let u;const p=Object.keys(d);for(let y=0;ya.push(d));const i=Object.keys(l);for(let d=0;d{if(Array.isArray(t)&&t.length){for(let r=0;r({baseTag:D_t(["href"],t),bodyAttributes:ege("bodyAttributes",t),defer:HM(t,VM.DEFER),encode:HM(t,VM.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:ege("htmlAttributes",t),linkTags:ZI("link",["rel","href"],t),metaTags:ZI("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:ZI("noscript",["innerHTML"],t),onChangeClientState:L_t(t),scriptTags:ZI("script",["src","innerHTML"],t),styleTags:ZI("style",["cssText"],t),title:I_t(t),titleAttributes:ege("titleAttributes",t),prioritizeSeoTags:O_t(t,VM.PRIORITIZE_SEO_TAGS)}),kVe=t=>Array.isArray(t)?t.join(""):t,z_t=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(z_t(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},kPe=(t,s)=>({...t,[s]:void 0}),B_t=["noscript","script","style"],e1e=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),SVe=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),$_t=(t,s,r,n)=>{const a=SVe(r),o=kVe(s);return a?`<${t} ${Ag}="true" ${a}>${e1e(o,n)}`:`<${t} ${Ag}="true">${e1e(o,n)}`},q_t=(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}="${e1e(o[p],r)}"`;return u?`${u} ${f}`:f},""),i=o.innerHTML||o.cssText||"",d=B_t.indexOf(t)===-1;return`${n}<${t} ${Ag}="true" ${l}${d?"/>":`>${i}`}`},""),CVe=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=Tje[n];return r[a||n]=t[n],r},s),U_t=(t,s,r)=>{const n={key:s,[Ag]:!0},a=CVe(r,n);return[ht.createElement("title",a,s)]},Fie=(t,s)=>s.map((r,n)=>{const a={key:n,[Ag]:!0};return Object.keys(r).forEach(o=>{const i=Tje[o]||o;if(i==="innerHTML"||i==="cssText"){const d=r.innerHTML||r.cssText;a.dangerouslySetInnerHTML={__html:d}}else a[i]=r[o]}),ht.createElement(t,a)}),sx=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>U_t(t,s.title,s.titleAttributes),toString:()=>$_t(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>CVe(s),toString:()=>SVe(s)};default:return{toComponent:()=>Fie(t,s),toString:()=>q_t(t,s,r)}}},V_t=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=tge(t,Jxe.meta),o=tge(s,Jxe.link),l=tge(r,Jxe.script);return{priorityMethods:{toComponent:()=>[...Fie("meta",a.priority),...Fie("link",o.priority),...Fie("script",l.priority)],toString:()=>`${sx("meta",a.priority,n)} ${sx("link",o.priority,n)} ${sx("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},H_t=t=>{const{baseTag:s,bodyAttributes:r,encode:n=!0,htmlAttributes:a,noscriptTags:o,styleTags:l,title:i="",titleAttributes:d,prioritizeSeoTags:u}=t;let{linkTags:p,metaTags:f,scriptTags:y}=t,_={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:_,linkTags:p,metaTags:f,scriptTags:y}=V_t(t)),{priority:_,base:sx("base",s,n),bodyAttributes:sx("bodyAttributes",r,n),htmlAttributes:sx("htmlAttributes",a,n),link:sx("link",p,n),meta:sx("meta",f,n),noscript:sx("noscript",o,n),script:sx("script",y,n),style:sx("style",l,n),title:sx("title",{title:i,titleAttributes:d},n)}},t1e=H_t,vz=[],MVe=!!(typeof window<"u"&&window.document&&window.document.createElement),s1e=class{constructor(t,s){Cn(this,"instances",[]);Cn(this,"canUseDOM",MVe);Cn(this,"context");Cn(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?vz:this.instances,add:t=>{(this.canUseDOM?vz:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?vz:this.instances).indexOf(t);(this.canUseDOM?vz:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=t1e({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},G_t={},TVe=ht.createContext(G_t),U4,AVe=(U4=class extends k.Component{constructor(r){super(r);Cn(this,"helmetData");this.helmetData=new s1e(this.props.context||{},U4.canUseDOM)}render(){return ht.createElement(TVe.Provider,{value:this.helmetData.value},this.props.children)}},Cn(U4,"canUseDOM",MVe),U4),c5=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${Ag}]`),a=[].slice.call(n),o=[];let l;return s&&s.length&&s.forEach(i=>{const d=document.createElement(t);for(const u in i)if(Object.prototype.hasOwnProperty.call(i,u))if(u==="innerHTML")d.innerHTML=i.innerHTML;else if(u==="cssText")d.styleSheet?d.styleSheet.cssText=i.cssText:d.appendChild(document.createTextNode(i.cssText));else{const p=u,f=typeof i[p]>"u"?"":i[p];d.setAttribute(u,f)}d.setAttribute(Ag,"true"),a.some((u,p)=>(l=p,d.isEqualNode(u)))?a.splice(l,1):o.push(d)}),a.forEach(i=>{var d;return(d=i.parentNode)==null?void 0:d.removeChild(i)}),o.forEach(i=>r.appendChild(i)),{oldTags:a,newTags:o}},r1e=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(Ag),a=n?n.split(","):[],o=[...a],l=Object.keys(s);for(const i of l){const d=s[i]||"";r.getAttribute(i)!==d&&r.setAttribute(i,d),a.indexOf(i)===-1&&a.push(i);const u=o.indexOf(i);u!==-1&&o.splice(u,1)}for(let i=o.length-1;i>=0;i-=1)r.removeAttribute(o[i]);a.length===o.length?r.removeAttribute(Ag):r.getAttribute(Ag)!==l.join(",")&&r.setAttribute(Ag,l.join(","))},W_t=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=kVe(t)),r1e("title",s)},SPe=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:d,scriptTags:u,styleTags:p,title:f,titleAttributes:y}=t;r1e("body",n),r1e("html",a),W_t(f,y);const _={baseTag:c5("base",r),linkTags:c5("link",o),metaTags:c5("meta",l),noscriptTags:c5("noscript",i),scriptTags:c5("script",u),styleTags:c5("style",p)},b={},N={};Object.keys(_).forEach(w=>{const{newTags:S,oldTags:C}=_[w];S.length&&(b[w]=S),C.length&&(N[w]=_[w].oldTags)}),s&&s(),d(t,b,N)},YI=null,K_t=t=>{YI&&cancelAnimationFrame(YI),t.defer?YI=requestAnimationFrame(()=>{SPe(t,()=>{YI=null})}):(SPe(t),YI=null)},Z_t=K_t,CPe=class extends k.Component{constructor(){super(...arguments);Cn(this,"rendered",!1)}shouldComponentUpdate(s){return!E_t(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=F_t(s.get().map(o=>{const l={...o.props};return delete l.context,l}));AVe.canUseDOM?Z_t(a):t1e&&(n=t1e(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}},E0e,Nc=(E0e=class extends k.Component{shouldComponentUpdate(t){return!C_t(kPe(this.props,"helmetData"),kPe(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 jPe(NPe.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 ${NPe.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),jPe(!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((d,u)=>(d[P_t[u]||u]=o[u],d),{});let{type:i}=n;switch(typeof i=="symbol"?i=i.toString():this.warnOnInvalidChildren(n,a),i){case"Symbol(react.fragment)":s=this.mapChildrenToProps(a,s);break;case"link":case"meta":case"noscript":case"script":case"style":r=this.flattenArrayTypeChildren(n,r,l,a);break;default:s=this.mapObjectTypeChildren(n,s,l,a);break}}),this.mapArrayTypeChildrenToProps(r,s)}render(){const{children:t,...s}=this.props;let r={...s},{helmetData:n}=s;if(t&&(r=this.mapChildrenToProps(t,r)),n&&!(n instanceof s1e)){const a=n;n=new s1e(a.context,!0),delete r.helmetData}return n?ht.createElement(CPe,{...r,context:n.value}):ht.createElement(TVe.Consumer,null,a=>ht.createElement(CPe,{...r,context:a}))}},Cn(E0e,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),E0e);const Y_t=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Ua(async()=>{const{default:n}=await Promise.resolve().then(()=>BA);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class Aje extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class X_t extends Aje{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class Q_t extends Aje{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class J_t extends Aje{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var n1e;(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"})(n1e||(n1e={}));var ebt=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};class tbt{constructor(s,{headers:r={},customFetch:n,region:a=n1e.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=Y_t(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s,r={}){var n;return ebt(this,void 0,void 0,function*(){try{const{headers:a,method:o,body:l}=r;let i={},{region:d}=r;d||(d=this.region),d&&d!=="any"&&(i["x-region"]=d);let u;l&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)&&(typeof Blob<"u"&&l instanceof Blob||l instanceof ArrayBuffer?(i["Content-Type"]="application/octet-stream",u=l):typeof l=="string"?(i["Content-Type"]="text/plain",u=l):typeof FormData<"u"&&l instanceof FormData?u=l:(i["Content-Type"]="application/json",u=JSON.stringify(l)));const p=yield this.fetch(`${this.url}/${s}`,{method:o||"POST",headers:Object.assign(Object.assign(Object.assign({},i),this.headers),a),body:u}).catch(b=>{throw new X_t(b)}),f=p.headers.get("x-relay-error");if(f&&f==="true")throw new Q_t(p);if(!p.ok)throw new J_t(p);let y=((n=p.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),_;return y==="application/json"?_=yield p.json():y==="application/octet-stream"?_=yield p.blob():y==="text/event-stream"?_=p:y==="multipart/form-data"?_=yield p.formData():_=yield p.text(),{data:_,error:null}}catch(a){return{data:null,error:a}}})}}var sp={},Eje={},lue={},AR={},cue={},due={},sbt=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")},TT=sbt();const rbt=TT.fetch,EVe=TT.fetch.bind(TT),PVe=TT.Headers,nbt=TT.Request,abt=TT.Response,BA=Object.freeze(Object.defineProperty({__proto__:null,Headers:PVe,Request:nbt,Response:abt,default:EVe,fetch:rbt},Symbol.toStringTag,{value:"Module"})),ibt=cpt(BA);var uue={};Object.defineProperty(uue,"__esModule",{value:!0});let obt=class extends Error{constructor(s){super(s.message),this.name="PostgrestError",this.details=s.details,this.hint=s.hint,this.code=s.code}};uue.default=obt;var IVe=hd&&hd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(due,"__esModule",{value:!0});const lbt=IVe(ibt),cbt=IVe(uue);let dbt=class{constructor(s){this.shouldThrowOnError=!1,this.method=s.method,this.url=s.url,this.headers=s.headers,this.schema=s.schema,this.body=s.body,this.shouldThrowOnError=s.shouldThrowOnError,this.signal=s.signal,this.isMaybeSingle=s.isMaybeSingle,s.fetch?this.fetch=s.fetch:typeof fetch>"u"?this.fetch=lbt.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(s,r){return this.headers=Object.assign({},this.headers),this.headers[s]=r,this}then(s,r){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const n=this.fetch;let a=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var l,i,d;let u=null,p=null,f=null,y=o.status,_=o.statusText;if(o.ok){if(this.method!=="HEAD"){const S=await o.text();S===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?p=S:p=JSON.parse(S))}const N=(l=this.headers.Prefer)===null||l===void 0?void 0:l.match(/count=(exact|planned|estimated)/),w=(i=o.headers.get("content-range"))===null||i===void 0?void 0:i.split("/");N&&w&&w.length>1&&(f=parseInt(w[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(u={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,f=null,y=406,_="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{const N=await o.text();try{u=JSON.parse(N),Array.isArray(u)&&o.status===404&&(p=[],u=null,y=200,_="OK")}catch{o.status===404&&N===""?(y=204,_="No Content"):u={message:N}}if(u&&this.isMaybeSingle&&(!((d=u==null?void 0:u.details)===null||d===void 0)&&d.includes("0 rows"))&&(u=null,y=200,_="OK"),u&&this.shouldThrowOnError)throw new cbt.default(u)}return{error:u,data:p,count:f,status:y,statusText:_}});return this.shouldThrowOnError||(a=a.catch(o=>{var l,i,d;return{error:{message:`${(l=o==null?void 0:o.name)!==null&&l!==void 0?l:"FetchError"}: ${o==null?void 0:o.message}`,details:`${(i=o==null?void 0:o.stack)!==null&&i!==void 0?i:""}`,hint:"",code:`${(d=o==null?void 0:o.code)!==null&&d!==void 0?d:""}`},data:null,count:null,status:0,statusText:""}})),a.then(s,r)}returns(){return this}overrideTypes(){return this}};due.default=dbt;var ubt=hd&&hd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(cue,"__esModule",{value:!0});const hbt=ubt(due);let mbt=class extends hbt.default{select(s){let r=!1;const n=(s??"*").split("").map(a=>/\s/.test(a)&&!r?"":(a==='"'&&(r=!r),a)).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(s,{ascending:r=!0,nullsFirst:n,foreignTable:a,referencedTable:o=a}={}){const l=o?`${o}.order`:"order",i=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${i?`${i},`:""}${s}.${r?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(s,{foreignTable:r,referencedTable:n=r}={}){const a=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(a,`${s}`),this}range(s,r,{foreignTable:n,referencedTable:a=n}={}){const o=typeof a>"u"?"offset":`${a}.offset`,l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(o,`${s}`),this.url.searchParams.set(l,`${r-s+1}`),this}abortSignal(s){return this.signal=s,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:s=!1,verbose:r=!1,settings:n=!1,buffers:a=!1,wal:o=!1,format:l="text"}={}){var i;const d=[s?"analyze":null,r?"verbose":null,n?"settings":null,a?"buffers":null,o?"wal":null].filter(Boolean).join("|"),u=(i=this.headers.Accept)!==null&&i!==void 0?i:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${l}; for="${u}"; options=${d};`,l==="json"?this:this}rollback(){var s;return((s=this.headers.Prefer)!==null&&s!==void 0?s:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}};cue.default=mbt;var pbt=hd&&hd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(AR,"__esModule",{value:!0});const fbt=pbt(cue);let xbt=class extends fbt.default{eq(s,r){return this.url.searchParams.append(s,`eq.${r}`),this}neq(s,r){return this.url.searchParams.append(s,`neq.${r}`),this}gt(s,r){return this.url.searchParams.append(s,`gt.${r}`),this}gte(s,r){return this.url.searchParams.append(s,`gte.${r}`),this}lt(s,r){return this.url.searchParams.append(s,`lt.${r}`),this}lte(s,r){return this.url.searchParams.append(s,`lte.${r}`),this}like(s,r){return this.url.searchParams.append(s,`like.${r}`),this}likeAllOf(s,r){return this.url.searchParams.append(s,`like(all).{${r.join(",")}}`),this}likeAnyOf(s,r){return this.url.searchParams.append(s,`like(any).{${r.join(",")}}`),this}ilike(s,r){return this.url.searchParams.append(s,`ilike.${r}`),this}ilikeAllOf(s,r){return this.url.searchParams.append(s,`ilike(all).{${r.join(",")}}`),this}ilikeAnyOf(s,r){return this.url.searchParams.append(s,`ilike(any).{${r.join(",")}}`),this}is(s,r){return this.url.searchParams.append(s,`is.${r}`),this}in(s,r){const n=Array.from(new Set(r)).map(a=>typeof a=="string"&&new RegExp("[,()]").test(a)?`"${a}"`:`${a}`).join(",");return this.url.searchParams.append(s,`in.(${n})`),this}contains(s,r){return typeof r=="string"?this.url.searchParams.append(s,`cs.${r}`):Array.isArray(r)?this.url.searchParams.append(s,`cs.{${r.join(",")}}`):this.url.searchParams.append(s,`cs.${JSON.stringify(r)}`),this}containedBy(s,r){return typeof r=="string"?this.url.searchParams.append(s,`cd.${r}`):Array.isArray(r)?this.url.searchParams.append(s,`cd.{${r.join(",")}}`):this.url.searchParams.append(s,`cd.${JSON.stringify(r)}`),this}rangeGt(s,r){return this.url.searchParams.append(s,`sr.${r}`),this}rangeGte(s,r){return this.url.searchParams.append(s,`nxl.${r}`),this}rangeLt(s,r){return this.url.searchParams.append(s,`sl.${r}`),this}rangeLte(s,r){return this.url.searchParams.append(s,`nxr.${r}`),this}rangeAdjacent(s,r){return this.url.searchParams.append(s,`adj.${r}`),this}overlaps(s,r){return typeof r=="string"?this.url.searchParams.append(s,`ov.${r}`):this.url.searchParams.append(s,`ov.{${r.join(",")}}`),this}textSearch(s,r,{config:n,type:a}={}){let o="";a==="plain"?o="pl":a==="phrase"?o="ph":a==="websearch"&&(o="w");const l=n===void 0?"":`(${n})`;return this.url.searchParams.append(s,`${o}fts${l}.${r}`),this}match(s){return Object.entries(s).forEach(([r,n])=>{this.url.searchParams.append(r,`eq.${n}`)}),this}not(s,r,n){return this.url.searchParams.append(s,`not.${r}.${n}`),this}or(s,{foreignTable:r,referencedTable:n=r}={}){const a=n?`${n}.or`:"or";return this.url.searchParams.append(a,`(${s})`),this}filter(s,r,n){return this.url.searchParams.append(s,`${r}.${n}`),this}};AR.default=xbt;var gbt=hd&&hd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(lue,"__esModule",{value:!0});const XI=gbt(AR);let ybt=class{constructor(s,{headers:r={},schema:n,fetch:a}){this.url=s,this.headers=r,this.schema=n,this.fetch=a}select(s,{head:r=!1,count:n}={}){const a=r?"HEAD":"GET";let o=!1;const l=(s??"*").split("").map(i=>/\s/.test(i)&&!o?"":(i==='"'&&(o=!o),i)).join("");return this.url.searchParams.set("select",l),n&&(this.headers.Prefer=`count=${n}`),new XI.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(s,{count:r,defaultToNull:n=!0}={}){const a="POST",o=[];if(this.headers.Prefer&&o.push(this.headers.Prefer),r&&o.push(`count=${r}`),n||o.push("missing=default"),this.headers.Prefer=o.join(","),Array.isArray(s)){const l=s.reduce((i,d)=>i.concat(Object.keys(d)),[]);if(l.length>0){const i=[...new Set(l)].map(d=>`"${d}"`);this.url.searchParams.set("columns",i.join(","))}}return new XI.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:this.fetch,allowEmpty:!1})}upsert(s,{onConflict:r,ignoreDuplicates:n=!1,count:a,defaultToNull:o=!0}={}){const l="POST",i=[`resolution=${n?"ignore":"merge"}-duplicates`];if(r!==void 0&&this.url.searchParams.set("on_conflict",r),this.headers.Prefer&&i.push(this.headers.Prefer),a&&i.push(`count=${a}`),o||i.push("missing=default"),this.headers.Prefer=i.join(","),Array.isArray(s)){const d=s.reduce((u,p)=>u.concat(Object.keys(p)),[]);if(d.length>0){const u=[...new Set(d)].map(p=>`"${p}"`);this.url.searchParams.set("columns",u.join(","))}}return new XI.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:this.fetch,allowEmpty:!1})}update(s,{count:r}={}){const n="PATCH",a=[];return this.headers.Prefer&&a.push(this.headers.Prefer),r&&a.push(`count=${r}`),this.headers.Prefer=a.join(","),new XI.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:this.fetch,allowEmpty:!1})}delete({count:s}={}){const r="DELETE",n=[];return s&&n.push(`count=${s}`),this.headers.Prefer&&n.unshift(this.headers.Prefer),this.headers.Prefer=n.join(","),new XI.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};lue.default=ybt;var hue={},mue={};Object.defineProperty(mue,"__esModule",{value:!0});mue.version=void 0;mue.version="0.0.0-automated";Object.defineProperty(hue,"__esModule",{value:!0});hue.DEFAULT_HEADERS=void 0;const vbt=mue;hue.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${vbt.version}`};var LVe=hd&&hd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Eje,"__esModule",{value:!0});const _bt=LVe(lue),bbt=LVe(AR),wbt=hue;let jbt=class DVe{constructor(s,{headers:r={},schema:n,fetch:a}={}){this.url=s,this.headers=Object.assign(Object.assign({},wbt.DEFAULT_HEADERS),r),this.schemaName=n,this.fetch=a}from(s){const r=new URL(`${this.url}/${s}`);return new _bt.default(r,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(s){return new DVe(this.url,{headers:this.headers,schema:s,fetch:this.fetch})}rpc(s,r={},{head:n=!1,get:a=!1,count:o}={}){let l;const i=new URL(`${this.url}/rpc/${s}`);let d;n||a?(l=n?"HEAD":"GET",Object.entries(r).filter(([p,f])=>f!==void 0).map(([p,f])=>[p,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([p,f])=>{i.searchParams.append(p,f)})):(l="POST",d=r);const u=Object.assign({},this.headers);return o&&(u.Prefer=`count=${o}`),new bbt.default({method:l,url:i,headers:u,schema:this.schemaName,body:d,fetch:this.fetch,allowEmpty:!1})}};Eje.default=jbt;var $A=hd&&hd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(sp,"__esModule",{value:!0});sp.PostgrestError=sp.PostgrestBuilder=sp.PostgrestTransformBuilder=sp.PostgrestFilterBuilder=sp.PostgrestQueryBuilder=sp.PostgrestClient=void 0;const RVe=$A(Eje);sp.PostgrestClient=RVe.default;const OVe=$A(lue);sp.PostgrestQueryBuilder=OVe.default;const FVe=$A(AR);sp.PostgrestFilterBuilder=FVe.default;const zVe=$A(cue);sp.PostgrestTransformBuilder=zVe.default;const BVe=$A(due);sp.PostgrestBuilder=BVe.default;const $Ve=$A(uue);sp.PostgrestError=$Ve.default;var Nbt=sp.default={PostgrestClient:RVe.default,PostgrestQueryBuilder:OVe.default,PostgrestFilterBuilder:FVe.default,PostgrestTransformBuilder:zVe.default,PostgrestBuilder:BVe.default,PostgrestError:$Ve.default};const{PostgrestClient:kbt,PostgrestQueryBuilder:iEs,PostgrestFilterBuilder:oEs,PostgrestTransformBuilder:lEs,PostgrestBuilder:cEs,PostgrestError:dEs}=Nbt;let a1e;typeof window>"u"?a1e=require("ws"):a1e=window.WebSocket;const Sbt="2.11.10",Cbt={"X-Client-Info":`realtime-js/${Sbt}`},Mbt="1.0.0",qVe=1e4,Tbt=1e3;var GM;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(GM||(GM={}));var cm;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(cm||(cm={}));var bg;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(bg||(bg={}));var i1e;(function(t){t.websocket="websocket"})(i1e||(i1e={}));var d4;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(d4||(d4={}));class Abt{constructor(){this.HEADER_LENGTH=1}decode(s,r){return s.constructor===ArrayBuffer?r(this._binaryDecode(s)):r(typeof s=="string"?JSON.parse(s):{})}_binaryDecode(s){const r=new DataView(s),n=new TextDecoder;return this._decodeBroadcast(s,r,n)}_decodeBroadcast(s,r,n){const a=r.getUint8(1),o=r.getUint8(2);let l=this.HEADER_LENGTH+2;const i=n.decode(s.slice(l,l+a));l=l+a;const d=n.decode(s.slice(l,l+o));l=l+o;const u=JSON.parse(n.decode(s.slice(l,s.byteLength)));return{ref:null,topic:i,event:d,payload:u}}}class UVe{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)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var Ml;(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"})(Ml||(Ml={}));const MPe=(t,s,r={})=>{var n;const a=(n=r.skipTypes)!==null&&n!==void 0?n:[];return Object.keys(s).reduce((o,l)=>(o[l]=Ebt(l,t,s,a),o),{})},Ebt=(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)?VVe(o,l):o1e(l)},VVe=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return Dbt(s,r)}switch(t){case Ml.bool:return Pbt(s);case Ml.float4:case Ml.float8:case Ml.int2:case Ml.int4:case Ml.int8:case Ml.numeric:case Ml.oid:return Ibt(s);case Ml.json:case Ml.jsonb:return Lbt(s);case Ml.timestamp:return Rbt(s);case Ml.abstime:case Ml.date:case Ml.daterange:case Ml.int4range:case Ml.int8range:case Ml.money:case Ml.reltime:case Ml.text:case Ml.time:case Ml.timestamptz:case Ml.timetz:case Ml.tsrange:case Ml.tstzrange:return o1e(s);default:return o1e(s)}},o1e=t=>t,Pbt=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},Ibt=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},Lbt=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},Dbt=(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=>VVe(s,i))}return t},Rbt=t=>typeof t=="string"?t.replace(" ","T"):t,HVe=t=>{let s=t;return s=s.replace(/^ws/i,"http"),s=s.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),s.replace(/\/+$/,"")};class sge{constructor(s,r,n={},a=qVe){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 TPe;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(TPe||(TPe={}));class WL{constructor(s,r){this.channel=s,this.state={},this.pendingDiffs=[],this.joinRef=null,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=WL.syncState(this.state,a,o,l),this.pendingDiffs.forEach(d=>{this.state=WL.syncDiff(this.state,d,o,l)}),this.pendingDiffs=[],i()}),this.channel._on(n.diff,{},a=>{const{onJoin:o,onLeave:l,onSync:i}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(a):(this.state=WL.syncDiff(this.state,a,o,l),i())}),this.onJoin((a,o,l)=>{this.channel._trigger("presence",{event:"join",key:a,currentPresences:o,newPresences:l})}),this.onLeave((a,o,l)=>{this.channel._trigger("presence",{event:"leave",key:a,currentPresences:o,leftPresences:l})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(s,r,n,a){const o=this.cloneDeep(s),l=this.transformState(r),i={},d={};return this.map(o,(u,p)=>{l[u]||(d[u]=p)}),this.map(l,(u,p)=>{const f=o[u];if(f){const y=p.map(w=>w.presence_ref),_=f.map(w=>w.presence_ref),b=p.filter(w=>_.indexOf(w.presence_ref)<0),N=f.filter(w=>y.indexOf(w.presence_ref)<0);b.length>0&&(i[u]=b),N.length>0&&(d[u]=N)}else i[u]=p}),this.syncDiff(o,{joins:i,leaves:d},n,a)}static syncDiff(s,r,n,a){const{joins:o,leaves:l}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return n||(n=()=>{}),a||(a=()=>{}),this.map(o,(i,d)=>{var u;const p=(u=s[i])!==null&&u!==void 0?u:[];if(s[i]=this.cloneDeep(d),p.length>0){const f=s[i].map(_=>_.presence_ref),y=p.filter(_=>f.indexOf(_.presence_ref)<0);s[i].unshift(...y)}n(i,p,d)}),this.map(l,(i,d)=>{let u=s[i];if(!u)return;const p=d.map(f=>f.presence_ref);u=u.filter(f=>p.indexOf(f.presence_ref)<0),s[i]=u,a(i,u,d),u.length===0&&delete s[i]}),s}static map(s,r){return Object.getOwnPropertyNames(s).map(n=>r(n,s[n]))}static transformState(s){return s=this.cloneDeep(s),Object.getOwnPropertyNames(s).reduce((r,n)=>{const a=s[n];return"metas"in a?r[n]=a.metas.map(o=>(o.presence_ref=o.phx_ref,delete o.phx_ref,delete o.phx_ref_prev,o)):r[n]=a,r},{})}static cloneDeep(s){return JSON.parse(JSON.stringify(s))}onJoin(s){this.caller.onJoin=s}onLeave(s){this.caller.onLeave=s}onSync(s){this.caller.onSync=s}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var APe;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(APe||(APe={}));var EPe;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(EPe||(EPe={}));var wv;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(wv||(wv={}));class Pje{constructor(s,r={config:{}},n){this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=cm.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=s.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""},private:!1},r.config),this.timeout=this.socket.timeout,this.joinPush=new sge(this,bg.join,this.params,this.timeout),this.rejoinTimer=new UVe(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=cm.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(a=>a.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=cm.closed,this.socket._remove(this)}),this._onError(a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=cm.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=cm.errored,this.rejoinTimer.scheduleTimeout())}),this._on(bg.reply,{},(a,o)=>{this._trigger(this._replyEventName(o),a)}),this.presence=new WL(this),this.broadcastEndpointURL=HVe(this.socket.endPoint)+"/api/broadcast",this.private=this.params.config.private||!1}subscribe(s,r=this.timeout){var n,a;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:o,presence:l,private:i}}=this.params;this._onError(p=>s==null?void 0:s(wv.CHANNEL_ERROR,p)),this._onClose(()=>s==null?void 0:s(wv.CLOSED));const d={},u={broadcast:o,presence:l,postgres_changes:(a=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(p=>p.filter))!==null&&a!==void 0?a:[],private:i};this.socket.accessTokenValue&&(d.access_token=this.socket.accessTokenValue),this.updateJoinPayload(Object.assign({config:u},d)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:p})=>{var f;if(this.socket.setAuth(),p===void 0){s==null||s(wv.SUBSCRIBED);return}else{const y=this.bindings.postgres_changes,_=(f=y==null?void 0:y.length)!==null&&f!==void 0?f:0,b=[];for(let N=0;N<_;N++){const w=y[N],{filter:{event:S,schema:C,table:A,filter:I}}=w,L=p&&p[N];if(L&&L.event===S&&L.schema===C&&L.table===A&&L.filter===I)b.push(Object.assign(Object.assign({},w),{id:L.id}));else{this.unsubscribe(),this.state=cm.errored,s==null||s(wv.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=b,s&&s(wv.SUBSCRIBED);return}}).receive("error",p=>{this.state=cm.errored,s==null||s(wv.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(p).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(wv.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._on(s,r,n)}async send(s,r={}){var n,a;if(!this._canPush()&&s.type==="broadcast"){const{event:o,payload:l}=s,d={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:o,payload:l,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,d,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((a=u.body)===null||a===void 0?void 0:a.cancel()),u.ok?"ok":"error"}catch(u){return u.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var l,i,d;const u=this._push(s.type,s,r.timeout||this.timeout);s.type==="broadcast"&&!(!((d=(i=(l=this.params)===null||l===void 0?void 0:l.config)===null||i===void 0?void 0:i.broadcast)===null||d===void 0)&&d.ack)&&o("ok"),u.receive("ok",()=>o("ok")),u.receive("error",()=>o("error")),u.receive("timeout",()=>o("timed out"))})}updateJoinPayload(s){this.joinPush.updatePayload(s)}unsubscribe(s=this.timeout){this.state=cm.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(bg.close,"leave",this._joinRef())};return this.joinPush.destroy(),new Promise(n=>{const a=new sge(this,bg.leave,{},s);a.receive("ok",()=>{r(),n("ok")}).receive("timeout",()=>{r(),n("timed out")}).receive("error",()=>{n("error")}),a.send(),this._canPush()||a.trigger("ok",{})})}teardown(){this.pushBuffer.forEach(s=>s.destroy()),this.rejoinTimer&&clearTimeout(this.rejoinTimer.timer),this.joinPush.destroy()}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 sge(this,s,r,n);return this._canPush()?a.send():(a.startTimeout(),this.pushBuffer.push(a)),a}_onMessage(s,r,n){return r}_isMember(s){return this.topic===s}_joinRef(){return this.joinPush.ref}_trigger(s,r,n){var a,o;const l=s.toLocaleLowerCase(),{close:i,error:d,leave:u,join:p}=bg;if(n&&[i,d,u,p].indexOf(l)>=0&&n!==this._joinRef())return;let 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,N,w;return((b=_.filter)===null||b===void 0?void 0:b.event)==="*"||((w=(N=_.filter)===null||N===void 0?void 0:N.event)===null||w===void 0?void 0:w.toLocaleLowerCase())===l}).map(_=>_.callback(y,n)):(o=this.bindings[l])===null||o===void 0||o.filter(_=>{var b,N,w,S,C,A;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in _){const I=_.id,L=(b=_.filter)===null||b===void 0?void 0:b.event;return I&&((N=r.ids)===null||N===void 0?void 0:N.includes(I))&&(L==="*"||(L==null?void 0:L.toLocaleLowerCase())===((w=r.data)===null||w===void 0?void 0:w.type.toLocaleLowerCase()))}else{const I=(C=(S=_==null?void 0:_.filter)===null||S===void 0?void 0:S.event)===null||C===void 0?void 0:C.toLocaleLowerCase();return I==="*"||I===((A=r==null?void 0:r.event)===null||A===void 0?void 0:A.toLocaleLowerCase())}else return _.type.toLocaleLowerCase()===l}).map(_=>{if(typeof y=="object"&&"ids"in y){const b=y.data,{schema:N,table:w,commit_timestamp:S,type:C,errors:A}=b;y=Object.assign(Object.assign({},{schema:N,table:w,commit_timestamp:S,eventType:C,new:{},old:{},errors:A}),this._getPayloadRecords(b))}_.callback(y,n)})}_isClosed(){return this.state===cm.closed}_isJoined(){return this.state===cm.joined}_isJoining(){return this.state===cm.joining}_isLeaving(){return this.state===cm.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].filter(a=>{var o;return!(((o=a.type)===null||o===void 0?void 0:o.toLocaleLowerCase())===n&&Pje.isEqual(a.filter,r))}),this}static isEqual(s,r){if(Object.keys(s).length!==Object.keys(r).length)return!1;for(const n in s)if(s[n]!==r[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(s){this._on(bg.close,{},s)}_onError(s){this._on(bg.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=cm.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=MPe(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=MPe(s.columns,s.old_record)),r}}const PPe=()=>{},Obt=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class Fbt{constructor(s,r){var n;this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers=Cbt,this.params={},this.timeout=qVe,this.heartbeatIntervalMs=25e3,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=PPe,this.ref=0,this.logger=PPe,this.conn=null,this.sendBuffer=[],this.serializer=new Abt,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=o=>{let l;return o?l=o:typeof fetch>"u"?l=(...i)=>Ua(async()=>{const{default:d}=await Promise.resolve().then(()=>BA);return{default:d}},void 0).then(({default:d})=>d(...i)):l=fetch,(...i)=>l(...i)},this.endPoint=`${s}/${i1e.websocket}`,this.httpEndpoint=HVe(s),r!=null&&r.transport?this.transport=r.transport:this.transport=null,r!=null&&r.params&&(this.params=r.params),r!=null&&r.headers&&(this.headers=Object.assign(Object.assign({},this.headers),r.headers)),r!=null&&r.timeout&&(this.timeout=r.timeout),r!=null&&r.logger&&(this.logger=r.logger),(r!=null&&r.logLevel||r!=null&&r.log_level)&&(this.logLevel=r.logLevel||r.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),r!=null&&r.heartbeatIntervalMs&&(this.heartbeatIntervalMs=r.heartbeatIntervalMs);const a=(n=r==null?void 0:r.params)===null||n===void 0?void 0:n.apikey;if(a&&(this.accessTokenValue=a,this.apiKey=a),this.reconnectAfterMs=r!=null&&r.reconnectAfterMs?r.reconnectAfterMs:o=>[1e3,2e3,5e3,1e4][o-1]||1e4,this.encode=r!=null&&r.encode?r.encode:(o,l)=>l(JSON.stringify(o)),this.decode=r!=null&&r.decode?r.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new UVe(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(r==null?void 0:r.fetch),r!=null&&r.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.worker=(r==null?void 0:r.worker)||!1,this.workerUrl=r==null?void 0:r.workerUrl}this.accessToken=(r==null?void 0:r.accessToken)||null}connect(){if(!this.conn){if(this.transport||(this.transport=a1e),this.transport){typeof window<"u"&&this.transport===window.WebSocket?this.conn=new this.transport(this.endpointURL()):this.conn=new this.transport(this.endpointURL(),void 0,{headers:this.headers}),this.setupConnection();return}this.conn=new zbt(this.endpointURL(),void 0,{close:()=>{this.conn=null}})}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:Mbt}))}disconnect(s,r){this.conn&&(this.conn.onclose=function(){},s?this.conn.close(s,r??""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset(),this.channels.forEach(n=>n.teardown()))}getChannels(){return this.channels}async removeChannel(s){const r=await s.unsubscribe();return this.channels=this.channels.filter(n=>n._joinRef!==s._joinRef),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 GM.connecting:return d4.Connecting;case GM.open:return d4.Open;case GM.closing:return d4.Closing;default:return d4.Closed}}isConnected(){return this.connectionState()===d4.Open}channel(s,r={config:{}}){const n=`realtime:${s}`,a=this.getChannels().find(o=>o.topic===n);if(a)return a;{const o=new Pje(`realtime:${s}`,r,this);return this.channels.push(o),o}}push(s){const{topic:r,event:n,payload:a,ref:o}=s,l=()=>{this.encode(s,i=>{var d;(d=this.conn)===null||d===void 0||d.send(i)})};this.log("push",`${r} ${n} (${o})`,a),this.isConnected()?l():this.sendBuffer.push(l)}async setAuth(s=null){let r=s||this.accessToken&&await this.accessToken()||this.accessTokenValue;this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{r&&n.updateJoinPayload({access_token:r,version:this.headers&&this.headers["X-Client-Info"]}),n.joinedOnce&&n._isJoined()&&n._push(bg.access_token,{access_token:r})}))}async sendHeartbeat(){var s;if(!this.isConnected()){this.heartbeatCallback("disconnected");return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.heartbeatCallback("timeout"),(s=this.conn)===null||s===void 0||s.close(Tbt,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatCallback("sent"),await this.setAuth()}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)}setupConnection(){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))}_onConnMessage(s){this.decode(s.data,r=>{let{topic:n,event:a,payload:o,ref:l}=r;n==="phoenix"&&a==="phx_reply"&&this.heartbeatCallback(r.payload.status=="ok"?"ok":"error"),l&&l===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null),this.log("receive",`${o.status||""} ${n} ${a} ${l&&"("+l+")"||""}`,o),Array.from(this.channels).filter(i=>i._isMember(n)).forEach(i=>i._trigger(a,o,l)),this.stateChangeCallbacks.message.forEach(i=>i(r))})}_onConnOpen(){if(this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this.reconnectTimer.reset(),!this.worker)this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs);else{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})}this.stateChangeCallbacks.open.forEach(s=>s())}_onConnClose(s){this.log("transport","close",s),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(r=>r(s))}_onConnError(s){this.log("transport",s.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(r=>r(s))}_triggerChanError(){this.channels.forEach(s=>s._trigger(bg.error))}_appendParams(s,r){if(Object.keys(r).length===0)return s;const n=s.match(/\?/)?"&":"?",a=new URLSearchParams(r);return`${s}${n}${a}`}_workerObjectUrl(s){let r;if(s)r=s;else{const n=new Blob([Obt],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}}class zbt{constructor(s,r,n){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=GM.connecting,this.send=()=>{},this.url=null,this.url=s,this.close=n.close}}class Ije extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function Tu(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class Bbt extends Ije{constructor(s,r){super(s),this.name="StorageApiError",this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class l1e extends Ije{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}var $bt=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};const GVe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Ua(async()=>{const{default:n}=await Promise.resolve().then(()=>BA);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},qbt=()=>$bt(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Ua(()=>Promise.resolve().then(()=>BA),void 0)).Response:Response}),c1e=t=>{if(Array.isArray(t))return t.map(r=>c1e(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]=c1e(n)}),s};var jC=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};const rge=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Ubt=(t,s,r)=>jC(void 0,void 0,void 0,function*(){const n=yield qbt();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(a=>{s(new Bbt(rge(a),t.status||500))}).catch(a=>{s(new l1e(rge(a),a))}):s(new l1e(rge(t),t))}),Vbt=(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"},s==null?void 0:s.headers),n&&(a.body=JSON.stringify(n)),Object.assign(Object.assign({},a),r))};function ER(t,s,r,n,a,o){return jC(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,Vbt(s,n,a,o)).then(d=>{if(!d.ok)throw d;return n!=null&&n.noResolveJson?d:d.json()}).then(d=>l(d)).catch(d=>Ubt(d,i,n))})})}function Hoe(t,s,r,n){return jC(this,void 0,void 0,function*(){return ER(t,"GET",s,r,n)})}function R_(t,s,r,n,a){return jC(this,void 0,void 0,function*(){return ER(t,"POST",s,n,a,r)})}function Hbt(t,s,r,n,a){return jC(this,void 0,void 0,function*(){return ER(t,"PUT",s,n,a,r)})}function Gbt(t,s,r,n){return jC(this,void 0,void 0,function*(){return ER(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function WVe(t,s,r,n,a){return jC(this,void 0,void 0,function*(){return ER(t,"DELETE",s,n,a,r)})}var Wm=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};const Wbt={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},IPe={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Kbt{constructor(s,r={},n,a){this.url=s,this.headers=r,this.bucketId=n,this.fetch=GVe(a)}uploadOrUpdate(s,r,n,a){return Wm(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},IPe),a);let i=Object.assign(Object.assign({},this.headers),s==="POST"&&{"x-upsert":String(l.upsert)});const d=l.metadata;typeof Blob<"u"&&n instanceof Blob?(o=new FormData,o.append("cacheControl",l.cacheControl),d&&o.append("metadata",this.encodeMetadata(d)),o.append("",n)):typeof FormData<"u"&&n instanceof FormData?(o=n,o.append("cacheControl",l.cacheControl),d&&o.append("metadata",this.encodeMetadata(d))):(o=n,i["cache-control"]=`max-age=${l.cacheControl}`,i["content-type"]=l.contentType,d&&(i["x-metadata"]=this.toBase64(this.encodeMetadata(d)))),a!=null&&a.headers&&(i=Object.assign(Object.assign({},i),a.headers));const u=this._removeEmptyFolders(r),p=this._getFinalPath(u),f=yield this.fetch(`${this.url}/object/${p}`,Object.assign({method:s,body:o,headers:i},l!=null&&l.duplex?{duplex:l.duplex}:{})),y=yield f.json();return f.ok?{data:{path:u,id:y.Id,fullPath:y.Key},error:null}:{data:null,error:y}}catch(o){if(Tu(o))return{data:null,error:o};throw o}})}upload(s,r,n){return Wm(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return Wm(this,void 0,void 0,function*(){const o=this._removeEmptyFolders(s),l=this._getFinalPath(o),i=new URL(this.url+`/object/upload/sign/${l}`);i.searchParams.set("token",r);try{let d;const u=Object.assign({upsert:IPe.upsert},a),p=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&n instanceof Blob?(d=new FormData,d.append("cacheControl",u.cacheControl),d.append("",n)):typeof FormData<"u"&&n instanceof FormData?(d=n,d.append("cacheControl",u.cacheControl)):(d=n,p["cache-control"]=`max-age=${u.cacheControl}`,p["content-type"]=u.contentType);const f=yield this.fetch(i.toString(),{method:"PUT",body:d,headers:p}),y=yield f.json();return f.ok?{data:{path:o,fullPath:y.Key},error:null}:{data:null,error:y}}catch(d){if(Tu(d))return{data:null,error:d};throw d}})}createSignedUploadUrl(s,r){return Wm(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 R_(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 Ije("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(Tu(n))return{data:null,error:n};throw n}})}update(s,r,n){return Wm(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return Wm(this,void 0,void 0,function*(){try{return{data:yield R_(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(Tu(a))return{data:null,error:a};throw a}})}copy(s,r,n){return Wm(this,void 0,void 0,function*(){try{return{data:{path:(yield R_(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(Tu(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return Wm(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield R_(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(Tu(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return Wm(this,void 0,void 0,function*(){try{const a=yield R_(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(Tu(a))return{data:null,error:a};throw a}})}download(s,r){return Wm(this,void 0,void 0,function*(){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}`:"";try{const i=this._getFinalPath(s);return{data:yield(yield Hoe(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(i){if(Tu(i))return{data:null,error:i};throw i}})}info(s){return Wm(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield Hoe(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:c1e(n),error:null}}catch(n){if(Tu(n))return{data:null,error:n};throw n}})}exists(s){return Wm(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield Gbt(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(Tu(n)&&n instanceof l1e){const a=n.originalError;if([400,404].includes(a==null?void 0:a.status))return{data:!1,error:n}}throw n}})}getPublicUrl(s,r){const n=this._getFinalPath(s),a=[],o=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";o!==""&&a.push(o);const i=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",d=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});d!==""&&a.push(d);let u=a.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${n}${u}`)}}}remove(s){return Wm(this,void 0,void 0,function*(){try{return{data:yield WVe(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(Tu(r))return{data:null,error:r};throw r}})}list(s,r,n){return Wm(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},Wbt),r),{prefix:s||""});return{data:yield R_(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(Tu(a))return{data:null,error:a};throw a}})}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}`}_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 Zbt="2.7.1",Ybt={"X-Client-Info":`storage-js/${Zbt}`};var d5=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};class Xbt{constructor(s,r={},n){this.url=s,this.headers=Object.assign(Object.assign({},Ybt),r),this.fetch=GVe(n)}listBuckets(){return d5(this,void 0,void 0,function*(){try{return{data:yield Hoe(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(s){if(Tu(s))return{data:null,error:s};throw s}})}getBucket(s){return d5(this,void 0,void 0,function*(){try{return{data:yield Hoe(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(Tu(r))return{data:null,error:r};throw r}})}createBucket(s,r={public:!1}){return d5(this,void 0,void 0,function*(){try{return{data:yield R_(this.fetch,`${this.url}/bucket`,{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(Tu(n))return{data:null,error:n};throw n}})}updateBucket(s,r){return d5(this,void 0,void 0,function*(){try{return{data:yield Hbt(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(Tu(n))return{data:null,error:n};throw n}})}emptyBucket(s){return d5(this,void 0,void 0,function*(){try{return{data:yield R_(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(Tu(r))return{data:null,error:r};throw r}})}deleteBucket(s){return d5(this,void 0,void 0,function*(){try{return{data:yield WVe(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(Tu(r))return{data:null,error:r};throw r}})}}class Qbt extends Xbt{constructor(s,r={},n){super(s,r,n)}from(s){return new Kbt(this.url,this.headers,s,this.fetch)}}const Jbt="2.49.10";let A6="";typeof Deno<"u"?A6="deno":typeof document<"u"?A6="web":typeof navigator<"u"&&navigator.product==="ReactNative"?A6="react-native":A6="node";const ewt={"X-Client-Info":`supabase-js-${A6}/${Jbt}`},twt={headers:ewt},swt={schema:"public"},rwt={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},nwt={};var awt=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};const iwt=t=>{let s;return t?s=t:typeof fetch>"u"?s=EVe:s=fetch,(...r)=>s(...r)},owt=()=>typeof Headers>"u"?PVe:Headers,lwt=(t,s,r)=>{const n=iwt(r),a=owt();return(o,l)=>awt(void 0,void 0,void 0,function*(){var i;const d=(i=yield s())!==null&&i!==void 0?i:t;let u=new a(l==null?void 0:l.headers);return u.has("apikey")||u.set("apikey",t),u.has("Authorization")||u.set("Authorization",`Bearer ${d}`),n(o,Object.assign(Object.assign({},l),{headers:u}))})};var cwt=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};function dwt(t){return t.endsWith("/")?t:t+"/"}function uwt(t,s){var r,n;const{db:a,auth:o,realtime:l,global:i}=t,{db:d,auth:u,realtime:p,global:f}=s,y={db:Object.assign(Object.assign({},d),a),auth:Object.assign(Object.assign({},u),o),realtime:Object.assign(Object.assign({},p),l),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:()=>cwt(this,void 0,void 0,function*(){return""})};return t.accessToken?y.accessToken=t.accessToken:delete y.accessToken,y}const KVe="2.69.1",I5=30*1e3,d1e=3,nge=d1e*I5,hwt="http://localhost:9999",mwt="supabase.auth.token",pwt={"X-Client-Info":`gotrue-js/${KVe}`},u1e="X-Supabase-Api-Version",ZVe={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},fwt=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,xwt=6e5;class Lje extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Ai(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class gwt extends Lje{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function ywt(t){return Ai(t)&&t.name==="AuthApiError"}class YVe extends Lje{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class fw extends Lje{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class C_ extends fw{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function vwt(t){return Ai(t)&&t.name==="AuthSessionMissingError"}class age extends fw{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class _z extends fw{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class bz extends fw{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 _wt(t){return Ai(t)&&t.name==="AuthImplicitGrantRedirectError"}class LPe extends fw{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 h1e extends fw{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function ige(t){return Ai(t)&&t.name==="AuthRetryableFetchError"}class DPe extends fw{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class KL extends fw{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const RPe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),OPe=` \r=`.split(""),bwt=(()=>{const t=new Array(128);for(let s=0;s-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 FPe(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{Nwt(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 jwt(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}wwt(n,s)}}function Nwt(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 kwt(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function Cwt(t){return Math.round(Date.now()/1e3)+t}function Mwt(){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 Sy=()=>typeof window<"u"&&typeof document<"u",F2={tested:!1,writable:!1},ZL=()=>{if(!Sy())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(F2.tested)return F2.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),F2.tested=!0,F2.writable=!0}catch{F2.tested=!0,F2.writable=!1}return F2.writable};function Twt(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 QVe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Ua(async()=>{const{default:n}=await Promise.resolve().then(()=>BA);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Awt=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",JVe=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},wz=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},jz=async(t,s)=>{await t.removeItem(s)};class pue{constructor(){this.promise=new pue.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}pue.promiseConstructor=Promise;function oge(t){const s=t.split(".");if(s.length!==3)throw new KL("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function Pwt(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 Iwt(t){return("0"+t.toString(16)).substr(-2)}function Lwt(){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,Iwt).join("")}async function Dwt(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 Rwt(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 Dwt(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function u5(t,s,r=!1){const n=Lwt();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await JVe(t,`${s}-code-verifier`,a);const o=await Rwt(n);return[o,n===o?"plain":"s256"]}const Owt=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function Fwt(t){const s=t.headers.get(u1e);if(!s||!s.match(Owt))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function zwt(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 Bwt(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")}}var $wt=function(t,s){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);at.msg||t.message||t.error_description||t.error||JSON.stringify(t),qwt=[502,503,504];async function zPe(t){var s;if(!Awt(t))throw new h1e(n4(t),0);if(qwt.includes(t.status))throw new h1e(n4(t),t.status);let r;try{r=await t.json()}catch(o){throw new YVe(n4(o),o)}let n;const a=Fwt(t);if(a&&a.getTime()>=ZVe["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 DPe(n4(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new C_}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 DPe(n4(r),t.status,r.weak_password.reasons);throw new gwt(n4(r),t.status||500,n)}const Uwt=(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 Yi(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[u1e]||(o[u1e]=ZVe["2024-01-01"].name),n!=null&&n.jwt&&(o.Authorization=`Bearer ${n.jwt}`);const l=(a=n==null?void 0:n.query)!==null&&a!==void 0?a:{};n!=null&&n.redirectTo&&(l.redirect_to=n.redirectTo);const i=Object.keys(l).length?"?"+new URLSearchParams(l).toString():"",d=await Vwt(t,s,r+i,{headers:o,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(d):{data:Object.assign({},d),error:null}}async function Vwt(t,s,r,n,a,o){const l=Uwt(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(d){throw console.error(d),new h1e(n4(d),0)}if(i.ok||await zPe(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(d){await zPe(d)}}function M_(t){var s;let r=null;Kwt(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=Cwt(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function BPe(t){const s=M_(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 Z_(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function Hwt(t){return{data:t,error:null}}function Gwt(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=$wt(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),i={action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o},d=Object.assign({},l);return{data:{properties:i,user:d},error:null}}function Wwt(t){return t}function Kwt(t){return t.access_token&&t.refresh_token&&t.expires_in}var Zwt=function(t,s){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a0&&(_.forEach(b=>{const N=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(b.split(";")[1].split("=")[1]);u[`${w}Page`]=N}),u.total=parseInt(y)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ai(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){try{return await Yi(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:Z_})}catch(r){if(Ai(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){try{return await Yi(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:Z_})}catch(n){if(Ai(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){try{return await Yi(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:Z_})}catch(n){if(Ai(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){try{const{data:r,error:n}=await Yi(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(Ai(r))return{data:null,error:r};throw r}}async _deleteFactor(s){try{return{data:await Yi(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(Ai(r))return{data:null,error:r};throw r}}}const Xwt={getItem:t=>ZL()?globalThis.localStorage.getItem(t):null,setItem:(t,s)=>{ZL()&&globalThis.localStorage.setItem(t,s)},removeItem:t=>{ZL()&&globalThis.localStorage.removeItem(t)}};function $Pe(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}function Qwt(){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)}}const h5={debug:!!(globalThis&&ZL()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class eHe extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class Jwt extends eHe{}async function e2t(t,s,r){h5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),h5.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){h5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{h5.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw h5.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new Jwt(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(h5.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()}}))}Qwt();const t2t={url:hwt,storageKey:mwt,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:pwt,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function qPe(t,s,r){return await r()}class eD{constructor(s){var r,n;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=eD.nextInstanceID,eD.nextInstanceID+=1,this.instanceID>0&&Sy()&&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({},t2t),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 Ywt({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=QVe(a.fetch),this.lock=a.lock||qPe,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:Sy()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=e2t:this.lock=qPe,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)},this.persistSession?a.storage?this.storage=a.storage:ZL()?this.storage=Xwt:(this.memoryStorage={},this.storage=$Pe(this.memoryStorage)):(this.memoryStorage={},this.storage=$Pe(this.memoryStorage)),Sy()&&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} (${KVe}) ${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=Twt(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),Sy()&&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),_wt(o)){const d=(s=o.details)===null||s===void 0?void 0:s.code;if(d==="identity_already_exists"||d==="identity_not_found"||d==="single_identity_not_deletable")return{error:o}}return await this._removeSession(),{error:o}}const{session:l,redirectType:i}=a;return this._debug("#_initialize()","detected session in URL",l,"redirect type",i),await this._saveSession(l),setTimeout(async()=>{i==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",l):await this._notifyAllSubscribers("SIGNED_IN",l)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return Ai(r)?{error:r}:{error:new YVe("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await Yi(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:M_}),{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const d=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",d)),{data:{user:u,session:d},error:null}}catch(o){if(Ai(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 u5(this.storage,this.storageKey)),o=await Yi(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:M_})}else if("phone"in s){const{phone:p,password:f,options:y}=s;o=await Yi(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:M_})}else throw new _z("You must provide either an email or phone number and a password");const{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const d=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",d)),{data:{user:u,session:d},error:null}}catch(o){if(Ai(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 Yi(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:BPe})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await Yi(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:BPe})}else throw new _z("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 age}:(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(Ai(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 _exchangeCodeForSession(s){const r=await wz(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await Yi(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:M_});if(await jz(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new age}:(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(Ai(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 Yi(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:M_}),{data:d,error:u}=i;return u?{data:{user:null,session:null},error:u}:!d||!d.session||!d.user?{data:{user:null,session:null},error:new age}:(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",d.session)),{data:d,error:u})}catch(r){if(Ai(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(s){var r,n,a,o,l;try{if("email"in s){const{email:i,options:d}=s;let u=null,p=null;this.flowType==="pkce"&&([u,p]=await u5(this.storage,this.storageKey));const{error:f}=await Yi(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:i,data:(r=d==null?void 0:d.data)!==null&&r!==void 0?r:{},create_user:(n=d==null?void 0:d.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},code_challenge:u,code_challenge_method:p},redirectTo:d==null?void 0:d.emailRedirectTo});return{data:{user:null,session:null},error:f}}if("phone"in s){const{phone:i,options:d}=s,{data:u,error:p}=await Yi(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:i,data:(a=d==null?void 0:d.data)!==null&&a!==void 0?a:{},create_user:(o=d==null?void 0:d.shouldCreateUser)!==null&&o!==void 0?o:!0,gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},channel:(l=d==null?void 0:d.channel)!==null&&l!==void 0?l:"sms"}});return{data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:p}}throw new _z("You must provide either an email or phone number.")}catch(i){if(Ai(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 Yi(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:M_});if(i)throw i;if(!l)throw new Error("An error occurred on token verification.");const d=l.session,u=l.user;return d!=null&&d.access_token&&(await this._saveSession(d),await this._notifyAllSubscribers(s.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",d)),{data:{user:u,session:d},error:null}}catch(a){if(Ai(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 u5(this.storage,this.storageKey)),await Yi(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:Hwt})}catch(o){if(Ai(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 C_;const{error:a}=await Yi(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(Ai(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 Yi(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 Yi(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 _z("You must provide either an email or phone number and a type")}catch(r){if(Ai(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 wz(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()(!l&&u==="user"&&(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."),l=!0,this.suppressGetSessionWarning=!0),Reflect.get(d,u,p))})}return{data:{session:s},error:null}}const{session:a,error:o}=await this._callRefreshToken(s.refresh_token);return o?{data:{session:null},error:o}:{data:{session:a},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(s){return s?await this._getUser(s):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(s){try{return s?await Yi(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:Z_}):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 C_}:await Yi(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:Z_})})}catch(r){if(Ai(r))return vwt(r)&&(await this._removeSession(),await jz(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 C_;const l=a.session;let i=null,d=null;this.flowType==="pkce"&&s.email!=null&&([i,d]=await u5(this.storage,this.storageKey));const{data:u,error:p}=await Yi(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},s),{code_challenge:i,code_challenge_method:d}),jwt:l.access_token,xform:Z_});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(Ai(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 C_;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=oge(s.access_token);if(l.exp&&(n=l.exp,a=n<=r),a){const{session:i,error:d}=await this._callRefreshToken(s.refresh_token);if(d)return{data:{user:null,session:null},error:d};if(!i)return{data:{user:null,session:null},error:null};o=i}else{const{data:i,error:d}=await this._getUser(s.access_token);if(d)throw d;o={access_token:s.access_token,refresh_token:s.refresh_token,user:i.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)}return{data:{user:o.user,session:o},error:null}}catch(r){if(Ai(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 C_;const{session: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(Ai(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!Sy())throw new bz("No browser detected.");if(s.error||s.error_description||s.error_code)throw new bz(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 LPe("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new bz("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 LPe("No code detected.");const{data:C,error:A}=await this._exchangeCodeForSession(s.code);if(A)throw A;const I=new URL(window.location.href);return I.searchParams.delete("code"),window.history.replaceState(window.history.state,"",I.toString()),{data:{session:C.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:o,refresh_token:l,expires_in:i,expires_at:d,token_type:u}=s;if(!o||!i||!l||!u)throw new bz("No session defined in URL");const p=Math.round(Date.now()/1e3),f=parseInt(i);let y=p+f;d&&(y=parseInt(d));const _=y-p;_*1e3<=I5&&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:N,error:w}=await this._getUser(o);if(w)throw w;const S={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:f,expires_at:y,refresh_token:l,token_type:u,user:N.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:S,redirectType:s.type},error:null}}catch(n){if(Ai(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 wz(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&&!(ywt(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await jz(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=Mwt(),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 u5(this.storage,this.storageKey,!0));try{return await Yi(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(Ai(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(Ai(r))return{data:null,error:r};throw r}}async linkIdentity(s){var r;try{const{data:n,error:a}=await this._useSession(async o=>{var l,i,d,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:(d=s.options)===null||d===void 0?void 0:d.queryParams,skipBrowserRedirect:!0});return await Yi(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 Sy()&&!(!((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(Ai(n))return{data:{provider:s.provider,url:null},error:n};throw n}}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 Yi(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(Ai(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 Pwt(async a=>(a>0&&await Ewt(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await Yi(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:M_})),(a,o)=>{const l=200*Math.pow(2,a);return o&&ige(o)&&Date.now()+l-n{try{await i.callback(s,r)}catch(d){o.push(d)}});if(await Promise.all(l),o.length>0){for(let i=0;ithis._autoRefreshTokenTick(),I5);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)/I5);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${I5}ms, refresh threshold is ${d1e} ticks`),a<=d1e&&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 eHe)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Sy()||!(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 u5(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 Yi(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(Ai(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}:{issuer:s.issuer}),{data:d,error:u}=await Yi(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"&&(!((a=d==null?void 0:d.totp)===null||a===void 0)&&a.qr_code)&&(d.totp.qr_code=`data:image/svg+xml;utf-8,${d.totp.qr_code}`),{data:d,error:null})})}catch(r){if(Ai(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{data:l,error:i}=await Yi(this.fetch,"POST",`${this.url}/factors/${s.factorId}/verify`,{body:{code:s.code,challenge_id:s.challengeId},headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return i?{data:null,error:i}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+l.expires_in},l)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",l),{data:l,error:i})})}catch(r){if(Ai(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;return o?{data:null,error:o}:await Yi(this.fetch,"POST",`${this.url}/factors/${s.factorId}/challenge`,{body:{channel:s.channel},headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(Ai(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(){const{data:{user:s},error:r}=await this.getUser();if(r)return{data:null,error:r};const n=(s==null?void 0:s.factors)||[],a=n.filter(l=>l.factor_type==="totp"&&l.status==="verified"),o=n.filter(l=>l.factor_type==="phone"&&l.status==="verified");return{data:{all:n,totp:a,phone:o},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async s=>{var r,n;const{data:{session:a},error:o}=s;if(o)return{data:null,error:o};if(!a)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:l}=oge(a.access_token);let i=null;l.aal&&(i=l.aal);let d=i;((n=(r=a.user.factors)===null||r===void 0?void 0:r.filter(f=>f.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(d="aal2");const p=l.amr||[];return{data:{currentLevel:i,nextLevel:d,currentAuthenticationMethods:p},error:null}}))}async fetchJwk(s,r={keys:[]}){let n=r.keys.find(l=>l.kid===s);if(n||(n=this.jwks.keys.find(l=>l.kid===s),n&&this.jwks_cached_at+xwt>Date.now()))return n;const{data:a,error:o}=await Yi(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;if(!a.keys||a.keys.length===0)throw new KL("JWKS is empty");if(this.jwks=a,this.jwks_cached_at=Date.now(),n=a.keys.find(l=>l.kid===s),!n)throw new KL("No matching signing key found in JWKS");return n}async getClaims(s,r={keys:[]}){try{let n=s;if(!n){const{data:_,error:b}=await this.getSession();if(b||!_.session)return{data:null,error:b};n=_.session.access_token}const{header:a,payload:o,signature:l,raw:{header:i,payload:d}}=oge(n);if(zwt(o.exp),!a.kid||a.alg==="HS256"||!("crypto"in globalThis&&"subtle"in globalThis.crypto)){const{error:_}=await this.getUser(n);if(_)throw _;return{data:{claims:o,header:a,signature:l},error:null}}const u=Bwt(a.alg),p=await this.fetchJwk(a.kid,r),f=await crypto.subtle.importKey("jwk",p,u,!0,["verify"]);if(!await crypto.subtle.verify(u,f,l,Swt(`${i}.${d}`)))throw new KL("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(Ai(n))return{data:null,error:n};throw n}}}eD.nextInstanceID=0;const s2t=eD;class r2t extends s2t{constructor(s){super(s)}}var n2t=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};class a2t{constructor(s,r,n){var a,o,l;if(this.supabaseUrl=s,this.supabaseKey=r,!s)throw new Error("supabaseUrl is required.");if(!r)throw new Error("supabaseKey is required.");const i=dwt(s),d=new URL(i);this.realtimeUrl=new URL("realtime/v1",d),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",d),this.storageUrl=new URL("storage/v1",d),this.functionsUrl=new URL("functions/v1",d);const u=`sb-${d.hostname.split(".")[0]}-auth-token`,p={db:swt,realtime:nwt,auth:Object.assign(Object.assign({},rwt),{storageKey:u}),global:twt},f=uwt(n??{},p);this.storageKey=(a=f.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(o=f.global.headers)!==null&&o!==void 0?o:{},f.accessToken?(this.accessToken=f.accessToken,this.auth=new Proxy({},{get:(y,_)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(_)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((l=f.auth)!==null&&l!==void 0?l:{},this.headers,f.global.fetch),this.fetch=lwt(r,this._getAccessToken.bind(this),f.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},f.realtime)),this.rest=new kbt(new URL("rest/v1",d).href,{headers:this.headers,schema:f.db.schema,fetch:this.fetch}),f.accessToken||this._listenForAuthEvents()}get functions(){return new tbt(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}get storage(){return new Qbt(this.storageUrl.href,this.headers,this.fetch)}from(s){return this.rest.from(s)}schema(s){return this.rest.schema(s)}rpc(s,r={},n={}){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()}_getAccessToken(){var s,r;return n2t(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();const{data:n}=yield this.auth.getSession();return(r=(s=n.session)===null||s===void 0?void 0:s.access_token)!==null&&r!==void 0?r:null})}_initSupabaseAuthClient({autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,storageKey:o,flowType:l,lock:i,debug:d},u,p){const f={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new r2t({url:this.authUrl.href,headers:Object.assign(Object.assign({},f),u),storageKey:o,autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,flowType:l,lock:i,debug:d,fetch:p,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(s){return new Fbt(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:s==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const i2t=(t,s,r)=>new a2t(t,s,r),o2t="https://relzejiswnotikjgvjhz.supabase.co",l2t="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",G=i2t(o2t,l2t,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),tHe=k.createContext(void 0),c2t=({children:t})=>{const[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState(!0),[i,d]=k.useState(!0),[u,p]=k.useState(!1),[f,y]=k.useState(!1),[_,b]=k.useState(null),[N,w]=k.useState([]),[S,C]=k.useState(null),A=k.useRef(null),I=k.useRef(!1),L=k.useRef(!1),O=br(),U=()=>{p(!1),y(!1),b(null),w([]),C(null),A.current=null,I.current=!1},q=async Z=>{if(!(I.current&&A.current===Z)&&!L.current){L.current=!0,d(!0);try{console.log("Checking roles via RPC for user:",Z);const[{data:J,error:Y},{data:ce,error:ae}]=await Promise.all([G.rpc("has_role",{_user_id:Z,_role:"admin"}),G.rpc("has_role",{_user_id:Z,_role:"brokerage_manager"})]);if(Y||ae)console.error("Role RPC errors:",{isAdminError:Y,isBrokerError:ae}),p(!1),y(!1);else{const fe=!!J,xe=!!ce;console.log("RPC roles result:",{adminValue:fe,brokerValue:xe}),p(fe),y(xe)}const{data:ie,error:le}=await G.from("profiles").select("brokerage_id").eq("id",Z).single();if(b(!le&&ie?ie.brokerage_id:null),ce){console.log("Fetching managed brokerages for user:",Z);const{data:fe,error:xe}=await G.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",Z);if(console.log("Managed brokerage assignments result:",{assignments:fe,assignmentsError:xe}),xe||!fe){console.error("Error fetching managed brokerage assignments:",xe),w([]);return}const he=Array.from(new Set(fe.map(Te=>Te.brokerage_id).filter(Boolean)));if(he.length===0){w([]);return}const{data:we,error:Ne}=await G.from("brokerages").select("id, name").in("id",he);if(console.log("Managed brokerages details result:",{brokeragesData:we,brokeragesError:Ne}),Ne||!we){console.error("Error fetching managed brokerages details:",Ne),w([]);return}const Ve=we.map(Te=>({id:Te.id,name:Te.name})).sort((Te,Ae)=>he.indexOf(Te.id)-he.indexOf(Ae.id));console.log("Parsed managed brokerages:",Ve),w(Ve),Ve.length>0&&C(Te=>Te??Ve[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),w([]);A.current=Z,I.current=!0}catch(J){console.error("Unexpected error in checkRoles:",J),U()}finally{L.current=!1,d(!1)}}};k.useEffect(()=>{let Z=!0,J=!1;const Y=()=>{!Z||J||(J=!0,l(!1))},{data:{subscription:ce}}=G.auth.onAuthStateChange((le,fe)=>{console.log("Auth event:",le),Z&&(a(fe),r((fe==null?void 0:fe.user)??null),Y(),le==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{O("/profile?reset=true")},100)),fe!=null&&fe.user?(!I.current||A.current!==fe.user.id)&&setTimeout(()=>{q(fe.user.id)},0):(U(),d(!1)))}),ae=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),Y()},4e3);return(async()=>{try{const{data:{session:le}}=await G.auth.getSession();if(!Z)return;a(le),r((le==null?void 0:le.user)??null),le!=null&&le.user?await q(le.user.id):U()}catch(le){console.error("Error restoring auth session:",le),Z&&(a(null),r(null),U())}finally{Y()}})(),()=>{Z=!1,window.clearTimeout(ae),ce.unsubscribe()}},[]);const $=async(Z,J)=>{const{error:Y}=await G.auth.signInWithPassword({email:Z,password:J});if(Y)throw me.error(Y.message),Y;me.success("Welcome back!");const ce=sessionStorage.getItem("redirectAfterLogin")||"/dashboard";sessionStorage.removeItem("redirectAfterLogin"),O(ce)},V=async(Z,J,Y)=>{const ce=`${window.location.origin}/dashboard`,{error:ae}=await G.auth.signUp({email:Z,password:J,options:{emailRedirectTo:ce,data:{name:Y}}});if(ae)throw me.error(ae.message),ae;me.success("Account created! Welcome to LevelUp."),O("/dashboard")},ee=async()=>{try{const{data:{session:Z}}=await G.auth.getSession();if(Z){const{error:J}=await G.auth.signOut();J?J.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",J.message):(console.error("Sign out error:",J),me.error(J.message)):me.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),a(null),p(!1),y(!1),b(null),w([]),C(null),O("/auth")}catch(Z){console.error("Unexpected sign out error:",Z),O("/auth")}};return e.jsx(tHe.Provider,{value:{user:s,session:n,loading:o,rolesLoading:i,signIn:$,signUp:V,signOut:ee,isAdmin:u,isBrokerageManager:f,brokerageId:_,managedBrokerages:N,selectedBrokerageId:S,setSelectedBrokerageId:C},children:t})},$s=()=>{const t=k.useContext(tHe);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},sHe=k.createContext(void 0),z2="levelup_admin_session",__="levelup_impersonation",lge="levelup_impersonation_return",d2t=({children:t})=>{const[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(!1);k.useEffect(()=>{const u=sessionStorage.getItem(__);if(u)try{const p=JSON.parse(u);r(!0),a(p)}catch{sessionStorage.removeItem(__)}},[]);const i=async(u,p)=>{l(!0);try{const{data:{session:f}}=await G.auth.getSession();if(!f)return me.error("No active session found"),!1;const y={access_token:f.access_token,refresh_token:f.refresh_token};sessionStorage.setItem(z2,JSON.stringify(y)),p&&sessionStorage.setItem(lge,p);const _=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.access_token}`},body:JSON.stringify({targetUserId:u})}),b=await _.json();if(!_.ok)throw new Error(b.error||"Failed to impersonate user");const N={id:b.targetUser.id,name:b.targetUser.name,email:b.targetUser.email};if(sessionStorage.setItem(__,JSON.stringify(N)),b.method==="session"){const{error:w}=await G.auth.setSession({access_token:b.access_token,refresh_token:b.refresh_token});if(w)throw console.error("Set session error:",w),sessionStorage.removeItem(z2),sessionStorage.removeItem(__),new Error("Failed to establish impersonation session")}else{const w=b.type||"recovery",{error:S}=await G.auth.verifyOtp({token_hash:b.token_hash,type:w});if(S)throw console.error("Verify OTP error:",S),sessionStorage.removeItem(z2),sessionStorage.removeItem(__),new Error("Failed to establish impersonation session")}return r(!0),a(N),me.success(`Now viewing as ${N.name}`),window.location.href="/dashboard",!0}catch(f){return console.error("Impersonation error:",f),me.error(f.message||"Failed to impersonate user"),sessionStorage.removeItem(z2),sessionStorage.removeItem(__),!1}finally{l(!1)}},d=async()=>{l(!0);try{const u=sessionStorage.getItem(z2);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(z2),sessionStorage.removeItem(__),f){console.error("Failed to restore admin session:",f),me.error("Admin session expired, please sign in again"),window.location.href="/auth";return}r(!1),a(null),me.success("Returned to your account");const y=sessionStorage.getItem(lge)||"/admin/members";sessionStorage.removeItem(lge),window.location.href=y}catch(u){console.error("Stop impersonation error:",u),me.error("Failed to restore admin session"),sessionStorage.removeItem(z2),sessionStorage.removeItem(__),window.location.href="/auth"}finally{l(!1)}};return e.jsx(sHe.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:d,isLoading:o},children:t})},fue=()=>{const t=k.useContext(sHe);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t};var u2t=Symbol.for("react.lazy"),Goe=Dde[" use ".trim().toString()];function h2t(t){return typeof t=="object"&&t!==null&&"then"in t}function rHe(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===u2t&&"_payload"in t&&h2t(t._payload)}function qA(t){const s=m2t(t),r=k.forwardRef((n,a)=>{let{children:o,...l}=n;rHe(o)&&typeof Goe=="function"&&(o=Goe(o._payload));const i=k.Children.toArray(o),d=i.find(f2t);if(d){const u=d.props.children,p=i.map(f=>f===d?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:k.isValidElement(u)?k.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var Dje=qA("Slot");function m2t(t){const s=k.forwardRef((r,n)=>{let{children:a,...o}=r;if(rHe(a)&&typeof Goe=="function"&&(a=Goe(a._payload)),k.isValidElement(a)){const l=g2t(a),i=x2t(o,a.props);return a.type!==k.Fragment&&(i.ref=n?Mm(n,l):l),k.cloneElement(a,i)}return k.Children.count(a)>1?k.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var p2t=Symbol("radix.slottable");function f2t(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===p2t}function x2t(t,s){const r={...s};for(const n in s){const a=t[n],o=s[n];/^on[A-Z]/.test(n)?a&&o?r[n]=(...i)=>{const d=o(...i);return a(...i),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function g2t(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)}const tD=wC("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-full px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),K=k.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?Dje:"button";return e.jsx(l,{className:Rt(tD({variant:s,size:r,className:t})),ref:o,...a})});K.displayName="Button";const y2t=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=fue();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(Qc,{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(ps,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Sr,{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"})]})})]})})},nHe=k.createContext(void 0),m5="levelup_acting_as",Nz="levelup_acting_as_self",v2t=({children:t})=>{const{user:s}=$s(),[r,n]=k.useState(!1),[a,o]=k.useState([]),[l,i]=k.useState(null),[d,u]=k.useState({}),[p,f]=k.useState(!0),[y,_]=k.useState(()=>sessionStorage.getItem(Nz)==="true");k.useEffect(()=>{if(!(s!=null&&s.id)){n(!1),o([]),i(null),u({}),f(!1);return}(async()=>{f(!0);try{const{data:A}=await G.rpc("has_role",{_user_id:s.id,_role:"assistant"});if(!A){n(!1),o([]),i(null),u({}),f(!1);return}n(!0);const{data:I,error:L}=await G.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(L||!I||I.length===0){o([]),f(!1);return}const O=I.map($=>$.agent_id),{data:U}=await G.from("profiles").select("id, name, email, avatar_url").in("id",O),q=(U||[]).map($=>({id:$.id,name:$.name||$.email||"Unknown",email:$.email||"",avatar_url:$.avatar_url}));if(o(q),sessionStorage.getItem(Nz)==="true")_(!0),i(null),u({});else{const $=sessionStorage.getItem(m5);if($){const V=q.find(ee=>ee.id===$);if(V){i(V);const ee=I.find(Z=>Z.agent_id===$);u((ee==null?void 0:ee.permissions)||{})}else if(q.length>0){i(q[0]);const ee=I.find(Z=>Z.agent_id===q[0].id);u((ee==null?void 0:ee.permissions)||{}),sessionStorage.setItem(m5,q[0].id)}}else if(q.length>0){i(q[0]);const V=I.find(ee=>ee.agent_id===q[0].id);u((V==null?void 0:V.permissions)||{}),sessionStorage.setItem(m5,q[0].id)}}}catch(A){console.error("Error loading assistant data:",A)}finally{f(!1)}})()},[s==null?void 0:s.id]);const b=C=>{i(C),_(!1),sessionStorage.removeItem(Nz),C?(sessionStorage.setItem(m5,C.id),G.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(s==null?void 0:s.id)||"").eq("agent_id",C.id).single().then(({data:A})=>{u((A==null?void 0:A.permissions)||{})})):(sessionStorage.removeItem(m5),u({}))},N=()=>{_(!0),i(null),u({}),sessionStorage.setItem(Nz,"true"),sessionStorage.removeItem(m5)},w=C=>!r||y?!0:d[C]===!0,S=r&&l&&!y?l.id:(s==null?void 0:s.id)||null;return e.jsx(nHe.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:b,effectiveUserId:S,permissions:d,hasPermission:w,isLoading:p,isActingAsSelf:y,setActingAsSelf:N},children:t})},Rje=()=>{const t=k.useContext(nHe);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},_a=()=>{const{effectiveUserId:t}=Rje();return t};function _2t(t,s=[]){let r=[];function n(o,l){const i=k.createContext(l);i.displayName=o+"Context";const d=r.length;r=[...r,l];const u=f=>{var S;const{scope:y,children:_,...b}=f,N=((S=y==null?void 0:y[t])==null?void 0:S[d])||i,w=k.useMemo(()=>b,Object.values(b));return e.jsx(N.Provider,{value:w,children:_})};u.displayName=o+"Provider";function p(f,y){var N;const _=((N=y==null?void 0:y[t])==null?void 0:N[d])||i,b=k.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=>k.createContext(l));return function(i){const d=(i==null?void 0:i[t])||o;return k.useMemo(()=>({[`__scope${t}`]:{...i,[t]:d}}),[i,d])}};return a.scopeName=t,[n,b2t(a,...s)]}function b2t(...t){const s=t[0];if(t.length===1)return s;const r=()=>{const n=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const l=n.reduce((i,{useScope:d,scopeName:u})=>{const f=d(o)[`__scope${u}`];return{...i,...f}},{});return k.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}var w2t=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Oje=w2t.reduce((t,s)=>{const r=qA(`Primitive.${s}`),n=k.forwardRef((a,o)=>{const{asChild:l,...i}=a,d=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{}),aHe={exports:{}},iHe={};/** * @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 AT=k;function j2t(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var N2t=typeof Object.is=="function"?Object.is:j2t,k2t=AT.useState,S2t=AT.useEffect,C2t=AT.useLayoutEffect,M2t=AT.useDebugValue;function T2t(t,s){var r=s(),n=k2t({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return C2t(function(){a.value=r,a.getSnapshot=s,cge(a)&&o({inst:a})},[t,r,s]),S2t(function(){return cge(a)&&o({inst:a}),t(function(){cge(a)&&o({inst:a})})},[t]),M2t(r),r}function cge(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!N2t(t,r)}catch{return!0}}function A2t(t,s){return s()}var E2t=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?A2t:T2t;iHe.useSyncExternalStore=AT.useSyncExternalStore!==void 0?AT.useSyncExternalStore:E2t;aHe.exports=iHe;var P2t=aHe.exports;function I2t(){return P2t.useSyncExternalStore(L2t,()=>!0,()=>!1)}function L2t(){return()=>{}}var Fje="Avatar",[D2t]=_2t(Fje),[R2t,oHe]=D2t(Fje),lHe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=k.useState("idle");return e.jsx(R2t,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(Oje.span,{...n,ref:s})})});lHe.displayName=Fje;var cHe="AvatarImage",dHe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=oHe(cHe,r),i=O2t(n,o),d=ed(u=>{a(u),l.onImageLoadingStatusChange(u)});return rd(()=>{i!=="idle"&&d(i)},[i,d]),i==="loaded"?e.jsx(Oje.img,{...o,ref:s,src:n}):null});dHe.displayName=cHe;var uHe="AvatarFallback",hHe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=oHe(uHe,r),[l,i]=k.useState(n===void 0);return k.useEffect(()=>{if(n!==void 0){const d=window.setTimeout(()=>i(!0),n);return()=>window.clearTimeout(d)}},[n]),l&&o.imageLoadingStatus!=="loaded"?e.jsx(Oje.span,{...a,ref:s}):null});hHe.displayName=uHe;function UPe(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function O2t(t,{referrerPolicy:s,crossOrigin:r}){const n=I2t(),a=k.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=k.useState(()=>UPe(o,t));return rd(()=>{i(UPe(o,t))},[o,t]),rd(()=>{const d=f=>()=>{i(f)};if(!o)return;const u=d("loaded"),p=d("error");return o.addEventListener("load",u),o.addEventListener("error",p),s&&(o.referrerPolicy=s),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",u),o.removeEventListener("error",p)}},[o,r,s]),l}var mHe=lHe,pHe=dHe,fHe=hHe;const vn=k.forwardRef(({className:t,...s},r)=>e.jsx(mHe,{ref:r,className:Rt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));vn.displayName=mHe.displayName;const Ca=k.forwardRef(({className:t,...s},r)=>e.jsx(pHe,{ref:r,className:Rt("aspect-square h-full w-full",t),...s}));Ca.displayName=pHe.displayName;const _n=k.forwardRef(({className:t,...s},r)=>e.jsx(fHe,{ref:r,className:Rt("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));_n.displayName=fHe.displayName;const F2t=wC("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 Ye({className:t,variant:s,...r}){return e.jsx("div",{className:Rt(F2t({variant:s}),t),...r})}var z2t=k.createContext(void 0);function xw(t){const s=k.useContext(z2t);return t||s||"ltr"}var dge=0;function xue(){k.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??VPe()),document.body.insertAdjacentElement("beforeend",t[1]??VPe()),dge++,()=>{dge===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),dge--}},[])}function VPe(){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 uge="focusScope.autoFocusOnMount",hge="focusScope.autoFocusOnUnmount",HPe={bubbles:!1,cancelable:!0},B2t="FocusScope",PR=k.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,d]=k.useState(null),u=ed(a),p=ed(o),f=k.useRef(null),y=Ma(s,N=>d(N)),_=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(n){let N=function(A){if(_.paused||!i)return;const I=A.target;i.contains(I)?f.current=I:T_(f.current,{select:!0})},w=function(A){if(_.paused||!i)return;const I=A.relatedTarget;I!==null&&(i.contains(I)||T_(f.current,{select:!0}))},S=function(A){if(document.activeElement===document.body)for(const L of A)L.removedNodes.length>0&&T_(i)};document.addEventListener("focusin",N),document.addEventListener("focusout",w);const C=new MutationObserver(S);return i&&C.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",N),document.removeEventListener("focusout",w),C.disconnect()}}},[n,i,_.paused]),k.useEffect(()=>{if(i){WPe.add(_);const N=document.activeElement;if(!i.contains(N)){const S=new CustomEvent(uge,HPe);i.addEventListener(uge,u),i.dispatchEvent(S),S.defaultPrevented||($2t(G2t(xHe(i)),{select:!0}),document.activeElement===N&&T_(i))}return()=>{i.removeEventListener(uge,u),setTimeout(()=>{const S=new CustomEvent(hge,HPe);i.addEventListener(hge,p),i.dispatchEvent(S),S.defaultPrevented||T_(N??document.body,{select:!0}),i.removeEventListener(hge,p),WPe.remove(_)},0)}}},[i,u,p,_]);const b=k.useCallback(N=>{if(!r&&!n||_.paused)return;const w=N.key==="Tab"&&!N.altKey&&!N.ctrlKey&&!N.metaKey,S=document.activeElement;if(w&&S){const C=N.currentTarget,[A,I]=q2t(C);A&&I?!N.shiftKey&&S===I?(N.preventDefault(),r&&T_(A,{select:!0})):N.shiftKey&&S===A&&(N.preventDefault(),r&&T_(I,{select:!0})):S===C&&N.preventDefault()}},[r,n,_.paused]);return e.jsx(dn.div,{tabIndex:-1,...l,ref:y,onKeyDown:b})});PR.displayName=B2t;function $2t(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(T_(n,{select:s}),document.activeElement!==r)return}function q2t(t){const s=xHe(t),r=GPe(s,t),n=GPe(s.reverse(),t);return[r,n]}function xHe(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 GPe(t,s){for(const r of t)if(!U2t(r,{upTo:s}))return r}function U2t(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 V2t(t){return t instanceof HTMLInputElement&&"select"in t}function T_(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&V2t(t)&&s&&t.select()}}var WPe=H2t();function H2t(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=KPe(t,s),t.unshift(s)},remove(s){var r;t=KPe(t,s),(r=t[0])==null||r.resume()}}}function KPe(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function G2t(t){return t.filter(s=>s.tagName!=="A")}var mge="rovingFocusGroup.onEntryFocus",W2t={bubbles:!1,cancelable:!0},IR="RovingFocusGroup",[m1e,gHe,K2t]=jR(IR),[Z2t,gw]=bd(IR,[K2t]),[Y2t,X2t]=Z2t(IR),yHe=k.forwardRef((t,s)=>e.jsx(m1e.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(m1e.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Q2t,{...t,ref:s})})}));yHe.displayName=IR;var Q2t=k.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...f}=t,y=k.useRef(null),_=Ma(s,y),b=xw(o),[N,w]=Bu({prop:l,defaultProp:i??null,onChange:d,caller:IR}),[S,C]=k.useState(!1),A=ed(u),I=gHe(r),L=k.useRef(!1),[O,U]=k.useState(0);return k.useEffect(()=>{const q=y.current;if(q)return q.addEventListener(mge,A),()=>q.removeEventListener(mge,A)},[A]),e.jsx(Y2t,{scope:r,orientation:n,dir:b,loop:a,currentTabStopId:N,onItemFocus:k.useCallback(q=>w(q),[w]),onItemShiftTab:k.useCallback(()=>C(!0),[]),onFocusableItemAdd:k.useCallback(()=>U(q=>q+1),[]),onFocusableItemRemove:k.useCallback(()=>U(q=>q-1),[]),children:e.jsx(dn.div,{tabIndex:S||O===0?-1:0,"data-orientation":n,...f,ref:_,style:{outline:"none",...t.style},onMouseDown:Tr(t.onMouseDown,()=>{L.current=!0}),onFocus:Tr(t.onFocus,q=>{const $=!L.current;if(q.target===q.currentTarget&&$&&!S){const V=new CustomEvent(mge,W2t);if(q.currentTarget.dispatchEvent(V),!V.defaultPrevented){const ee=I().filter(ae=>ae.focusable),Z=ee.find(ae=>ae.active),J=ee.find(ae=>ae.id===N),ce=[Z,J,...ee].filter(Boolean).map(ae=>ae.ref.current);bHe(ce,p)}}L.current=!1}),onBlur:Tr(t.onBlur,()=>C(!1))})})}),vHe="RovingFocusGroupItem",_He=k.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,d=mu(),u=o||d,p=X2t(vHe,r),f=p.currentTabStopId===u,y=gHe(r),{onFocusableItemAdd:_,onFocusableItemRemove:b,currentTabStopId:N}=p;return k.useEffect(()=>{if(n)return _(),()=>b()},[n,_,b]),e.jsx(m1e.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(dn.span,{tabIndex:f?0:-1,"data-orientation":p.orientation,...i,ref:s,onMouseDown:Tr(t.onMouseDown,w=>{n?p.onItemFocus(u):w.preventDefault()}),onFocus:Tr(t.onFocus,()=>p.onItemFocus(u)),onKeyDown:Tr(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const S=tjt(w,p.orientation,p.dir);if(S!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let A=y().filter(I=>I.focusable).map(I=>I.ref.current);if(S==="last")A.reverse();else if(S==="prev"||S==="next"){S==="prev"&&A.reverse();const I=A.indexOf(w.currentTarget);A=p.loop?sjt(A,I+1):A.slice(I+1)}setTimeout(()=>bHe(A))}}),children:typeof l=="function"?l({isCurrentTabStop:f,hasTabStop:N!=null}):l})})});_He.displayName=vHe;var J2t={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ejt(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function tjt(t,s,r){const n=ejt(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return J2t[n]}function bHe(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function sjt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var gue=yHe,yue=_He;function rjt(t){const s=njt(t),r=k.forwardRef((n,a)=>{const{children:o,...l}=n,i=k.Children.toArray(o),d=i.find(ijt);if(d){const u=d.props.children,p=i.map(f=>f===d?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:k.isValidElement(u)?k.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}function njt(t){const s=k.forwardRef((r,n)=>{const{children:a,...o}=r;if(k.isValidElement(a)){const l=ljt(a),i=ojt(o,a.props);return a.type!==k.Fragment&&(i.ref=n?Mm(n,l):l),k.cloneElement(a,i)}return k.Children.count(a)>1?k.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var ajt=Symbol("radix.slottable");function ijt(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===ajt}function ojt(t,s){const r={...s};for(const n in s){const a=t[n],o=s[n];/^on[A-Z]/.test(n)?a&&o?r[n]=(...i)=>{const d=o(...i);return a(...i),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function ljt(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 cjt=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},p5=new WeakMap,kz=new WeakMap,Sz={},pge=0,wHe=function(t){return t&&(t.host||wHe(t.parentNode))},djt=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=wHe(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})},ujt=function(t,s,r,n){var a=djt(s,Array.isArray(t)?t:[t]);Sz[r]||(Sz[r]=new WeakMap);var o=Sz[r],l=[],i=new Set,d=new Set(a),u=function(f){!f||i.has(f)||(i.add(f),u(f.parentNode))};a.forEach(u);var p=function(f){!f||d.has(f)||Array.prototype.forEach.call(f.children,function(y){if(i.has(y))p(y);else try{var _=y.getAttribute(n),b=_!==null&&_!=="false",N=(p5.get(y)||0)+1,w=(o.get(y)||0)+1;p5.set(y,N),o.set(y,w),l.push(y),N===1&&b&&kz.set(y,!0),w===1&&y.setAttribute(r,"true"),b||y.setAttribute(n,"true")}catch(S){console.error("aria-hidden: cannot operate on ",y,S)}})};return p(s),i.clear(),pge++,function(){l.forEach(function(f){var y=p5.get(f)-1,_=o.get(f)-1;p5.set(f,y),o.set(f,_),y||(kz.has(f)||f.removeAttribute(n),kz.delete(f)),_||f.removeAttribute(r)}),pge--,pge||(p5=new WeakMap,p5=new WeakMap,kz=new WeakMap,Sz={})}},vue=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=cjt(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live], script"))),ujt(n,a,r,"aria-hidden")):function(){return null}},zy=function(){return zy=Object.assign||function(s){for(var r,n=1,a=arguments.length;n"u")return Mjt;var s=Tjt(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])}},Ejt=SHe(),WM="data-scroll-locked",Pjt=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(mjt,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(WM,`] { 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(zie,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(Bie,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(zie," .").concat(zie,` { right: 0 `).concat(n,`; } .`).concat(Bie," .").concat(Bie,` { margin-right: 0 `).concat(n,`; } body[`).concat(WM,`] { `).concat(pjt,": ").concat(i,`px; } `)},YPe=function(){var t=parseInt(document.body.getAttribute(WM)||"0",10);return isFinite(t)?t:0},Ijt=function(){k.useEffect(function(){return document.body.setAttribute(WM,(YPe()+1).toString()),function(){var t=YPe()-1;t<=0?document.body.removeAttribute(WM):document.body.setAttribute(WM,t.toString())}},[])},Ljt=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;Ijt();var o=k.useMemo(function(){return Ajt(a)},[a]);return k.createElement(Ejt,{styles:Pjt(o,!s,a,r?"":"!important")})},p1e=!1;if(typeof window<"u")try{var Cz=Object.defineProperty({},"passive",{get:function(){return p1e=!0,!0}});window.addEventListener("test",Cz,Cz),window.removeEventListener("test",Cz,Cz)}catch{p1e=!1}var f5=p1e?{passive:!1}:!1,Djt=function(t){return t.tagName==="TEXTAREA"},CHe=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!Djt(t)&&r[s]==="visible")},Rjt=function(t){return CHe(t,"overflowY")},Ojt=function(t){return CHe(t,"overflowX")},XPe=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=MHe(t,n);if(a){var o=THe(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},Fjt=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},zjt=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},MHe=function(t,s){return t==="v"?Rjt(s):Ojt(s)},THe=function(t,s){return t==="v"?Fjt(s):zjt(s)},Bjt=function(t,s){return t==="h"&&s==="rtl"?-1:1},$jt=function(t,s,r,n,a){var o=Bjt(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,d=s.contains(i),u=!1,p=l>0,f=0,y=0;do{if(!i)break;var _=THe(t,i),b=_[0],N=_[1],w=_[2],S=N-w-o*b;(b||S)&&MHe(t,i)&&(f+=S,y+=b);var C=i.parentNode;i=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!d&&i!==document.body||d&&(s.contains(i)||s===i));return(p&&Math.abs(f)<1||!p&&Math.abs(y)<1)&&(u=!0),u},Mz=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},QPe=function(t){return[t.deltaX,t.deltaY]},JPe=function(t){return t&&"current"in t?t.current:t},qjt=function(t,s){return t[0]===s[0]&&t[1]===s[1]},Ujt=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},Vjt=0,x5=[];function Hjt(t){var s=k.useRef([]),r=k.useRef([0,0]),n=k.useRef(),a=k.useState(Vjt++)[0],o=k.useState(SHe)[0],l=k.useRef(t);k.useEffect(function(){l.current=t},[t]),k.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var N=hjt([t.lockRef.current],(t.shards||[]).map(JPe),!0).filter(Boolean);return N.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),N.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var i=k.useCallback(function(N,w){if("touches"in N&&N.touches.length===2||N.type==="wheel"&&N.ctrlKey)return!l.current.allowPinchZoom;var S=Mz(N),C=r.current,A="deltaX"in N?N.deltaX:C[0]-S[0],I="deltaY"in N?N.deltaY:C[1]-S[1],L,O=N.target,U=Math.abs(A)>Math.abs(I)?"h":"v";if("touches"in N&&U==="h"&&O.type==="range")return!1;var q=window.getSelection(),$=q&&q.anchorNode,V=$?$===O||$.contains(O):!1;if(V)return!1;var ee=XPe(U,O);if(!ee)return!0;if(ee?L=U:(L=U==="v"?"h":"v",ee=XPe(U,O)),!ee)return!1;if(!n.current&&"changedTouches"in N&&(A||I)&&(n.current=L),!L)return!0;var Z=n.current||L;return $jt(Z,w,N,Z==="h"?A:I)},[]),d=k.useCallback(function(N){var w=N;if(!(!x5.length||x5[x5.length-1]!==o)){var S="deltaY"in w?QPe(w):Mz(w),C=s.current.filter(function(L){return L.name===w.type&&(L.target===w.target||w.target===L.shadowParent)&&qjt(L.delta,S)})[0];if(C&&C.should){w.cancelable&&w.preventDefault();return}if(!C){var A=(l.current.shards||[]).map(JPe).filter(Boolean).filter(function(L){return L.contains(w.target)}),I=A.length>0?i(w,A[0]):!l.current.noIsolation;I&&w.cancelable&&w.preventDefault()}}},[]),u=k.useCallback(function(N,w,S,C){var A={name:N,delta:w,target:S,should:C,shadowParent:Gjt(S)};s.current.push(A),setTimeout(function(){s.current=s.current.filter(function(I){return I!==A})},1)},[]),p=k.useCallback(function(N){r.current=Mz(N),n.current=void 0},[]),f=k.useCallback(function(N){u(N.type,QPe(N),N.target,i(N,t.lockRef.current))},[]),y=k.useCallback(function(N){u(N.type,Mz(N),N.target,i(N,t.lockRef.current))},[]);k.useEffect(function(){return x5.push(o),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:y}),document.addEventListener("wheel",d,f5),document.addEventListener("touchmove",d,f5),document.addEventListener("touchstart",p,f5),function(){x5=x5.filter(function(N){return N!==o}),document.removeEventListener("wheel",d,f5),document.removeEventListener("touchmove",d,f5),document.removeEventListener("touchstart",p,f5)}},[]);var _=t.removeScrollBar,b=t.inert;return k.createElement(k.Fragment,null,b?k.createElement(o,{styles:Ujt(a)}):null,_?k.createElement(Ljt,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function Gjt(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const Wjt=bjt(kHe,Hjt);var LR=k.forwardRef(function(t,s){return k.createElement(_ue,zy({},t,{ref:s,sideCar:Wjt}))});LR.classNames=_ue.classNames;var f1e=["Enter"," "],Kjt=["ArrowDown","PageUp","Home"],AHe=["ArrowUp","PageDown","End"],Zjt=[...Kjt,...AHe],Yjt={ltr:[...f1e,"ArrowRight"],rtl:[...f1e,"ArrowLeft"]},Xjt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},DR="Menu",[sD,Qjt,Jjt]=jR(DR),[NC,EHe]=bd(DR,[Jjt,_0,gw]),bue=_0(),PHe=gw(),[eNt,kC]=NC(DR),[tNt,RR]=NC(DR),IHe=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=bue(s),[d,u]=k.useState(null),p=k.useRef(!1),f=ed(o),y=xw(a);return k.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(CR,{...i,children:e.jsx(eNt,{scope:s,open:r,onOpenChange:f,content:d,onContentChange:u,children:e.jsx(tNt,{scope:s,onClose:k.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:y,modal:l,children:n})})})};IHe.displayName=DR;var sNt="MenuAnchor",zje=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=bue(r);return e.jsx(RA,{...a,...n,ref:s})});zje.displayName=sNt;var Bje="MenuPortal",[rNt,LHe]=NC(Bje,{forceMount:void 0}),DHe=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=kC(Bje,s);return e.jsx(rNt,{scope:s,forceMount:r,children:e.jsx(wd,{present:r||o.open,children:e.jsx(PA,{asChild:!0,container:a,children:n})})})};DHe.displayName=Bje;var Nx="MenuContent",[nNt,$je]=NC(Nx),RHe=k.forwardRef((t,s)=>{const r=LHe(Nx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=kC(Nx,t.__scopeMenu),l=RR(Nx,t.__scopeMenu);return e.jsx(sD.Provider,{scope:t.__scopeMenu,children:e.jsx(wd,{present:n||o.open,children:e.jsx(sD.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(aNt,{...a,ref:s}):e.jsx(iNt,{...a,ref:s})})})})}),aNt=k.forwardRef((t,s)=>{const r=kC(Nx,t.__scopeMenu),n=k.useRef(null),a=Ma(s,n);return k.useEffect(()=>{const o=n.current;if(o)return vue(o)},[]),e.jsx(qje,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Tr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),iNt=k.forwardRef((t,s)=>{const r=kC(Nx,t.__scopeMenu);return e.jsx(qje,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),oNt=rjt("MenuContent.ScrollLock"),qje=k.forwardRef((t,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:y,onDismiss:_,disableOutsideScroll:b,...N}=t,w=kC(Nx,r),S=RR(Nx,r),C=bue(r),A=PHe(r),I=Qjt(r),[L,O]=k.useState(null),U=k.useRef(null),q=Ma(s,U,w.onContentChange),$=k.useRef(0),V=k.useRef(""),ee=k.useRef(0),Z=k.useRef(null),J=k.useRef("right"),Y=k.useRef(0),ce=b?LR:k.Fragment,ae=b?{as:oNt,allowPinchZoom:!0}:void 0,ie=fe=>{var ze,Ee;const xe=V.current+fe,he=I().filter(ve=>!ve.disabled),we=document.activeElement,Ne=(ze=he.find(ve=>ve.ref.current===we))==null?void 0:ze.textValue,Ve=he.map(ve=>ve.textValue),Te=vNt(Ve,xe,Ne),Ae=(Ee=he.find(ve=>ve.textValue===Te))==null?void 0:Ee.ref.current;(function ve(Re){V.current=Re,window.clearTimeout($.current),Re!==""&&($.current=window.setTimeout(()=>ve(""),1e3))})(xe),Ae&&setTimeout(()=>Ae.focus())};k.useEffect(()=>()=>window.clearTimeout($.current),[]),xue();const le=k.useCallback(fe=>{var he,we;return J.current===((he=Z.current)==null?void 0:he.side)&&bNt(fe,(we=Z.current)==null?void 0:we.area)},[]);return e.jsx(nNt,{scope:r,searchRef:V,onItemEnter:k.useCallback(fe=>{le(fe)&&fe.preventDefault()},[le]),onItemLeave:k.useCallback(fe=>{var xe;le(fe)||((xe=U.current)==null||xe.focus(),O(null))},[le]),onTriggerLeave:k.useCallback(fe=>{le(fe)&&fe.preventDefault()},[le]),pointerGraceTimerRef:ee,onPointerGraceIntentChange:k.useCallback(fe=>{Z.current=fe},[]),children:e.jsx(ce,{...ae,children:e.jsx(PR,{asChild:!0,trapped:a,onMountAutoFocus:Tr(o,fe=>{var xe;fe.preventDefault(),(xe=U.current)==null||xe.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(mw,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:y,onDismiss:_,children:e.jsx(gue,{asChild:!0,...A,dir:S.dir,orientation:"vertical",loop:n,currentTabStopId:L,onCurrentTabStopIdChange:O,onEntryFocus:Tr(d,fe=>{S.isUsingKeyboardRef.current||fe.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(MR,{role:"menu","aria-orientation":"vertical","data-state":QHe(w.open),"data-radix-menu-content":"",dir:S.dir,...C,...N,ref:q,style:{outline:"none",...N.style},onKeyDown:Tr(N.onKeyDown,fe=>{const he=fe.target.closest("[data-radix-menu-content]")===fe.currentTarget,we=fe.ctrlKey||fe.altKey||fe.metaKey,Ne=fe.key.length===1;he&&(fe.key==="Tab"&&fe.preventDefault(),!we&&Ne&&ie(fe.key));const Ve=U.current;if(fe.target!==Ve||!Zjt.includes(fe.key))return;fe.preventDefault();const Ae=I().filter(ze=>!ze.disabled).map(ze=>ze.ref.current);AHe.includes(fe.key)&&Ae.reverse(),gNt(Ae)}),onBlur:Tr(t.onBlur,fe=>{fe.currentTarget.contains(fe.target)||(window.clearTimeout($.current),V.current="")}),onPointerMove:Tr(t.onPointerMove,rD(fe=>{const xe=fe.target,he=Y.current!==fe.clientX;if(fe.currentTarget.contains(xe)&&he){const we=fe.clientX>Y.current?"right":"left";J.current=we,Y.current=fe.clientX}}))})})})})})})});RHe.displayName=Nx;var lNt="MenuGroup",Uje=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(dn.div,{role:"group",...n,ref:s})});Uje.displayName=lNt;var cNt="MenuLabel",OHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(dn.div,{...n,ref:s})});OHe.displayName=cNt;var Woe="MenuItem",eIe="menu.itemSelect",wue=k.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=k.useRef(null),l=RR(Woe,t.__scopeMenu),i=$je(Woe,t.__scopeMenu),d=Ma(s,o),u=k.useRef(!1),p=()=>{const f=o.current;if(!r&&f){const y=new CustomEvent(eIe,{bubbles:!0,cancelable:!0});f.addEventListener(eIe,_=>n==null?void 0:n(_),{once:!0}),nje(f,y),y.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(FHe,{...a,ref:d,disabled:r,onClick:Tr(t.onClick,p),onPointerDown:f=>{var y;(y=t.onPointerDown)==null||y.call(t,f),u.current=!0},onPointerUp:Tr(t.onPointerUp,f=>{var y;u.current||(y=f.currentTarget)==null||y.click()}),onKeyDown:Tr(t.onKeyDown,f=>{const y=i.searchRef.current!=="";r||y&&f.key===" "||f1e.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});wue.displayName=Woe;var FHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=$je(Woe,r),i=PHe(r),d=k.useRef(null),u=Ma(s,d),[p,f]=k.useState(!1),[y,_]=k.useState("");return k.useEffect(()=>{const b=d.current;b&&_((b.textContent??"").trim())},[o.children]),e.jsx(sD.ItemSlot,{scope:r,disabled:n,textValue:a??y,children:e.jsx(yue,{asChild:!0,...i,focusable:!n,children:e.jsx(dn.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:u,onPointerMove:Tr(t.onPointerMove,rD(b=>{n?l.onItemLeave(b):(l.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Tr(t.onPointerLeave,rD(b=>l.onItemLeave(b))),onFocus:Tr(t.onFocus,()=>f(!0)),onBlur:Tr(t.onBlur,()=>f(!1))})})})}),dNt="MenuCheckboxItem",zHe=k.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(VHe,{scope:t.__scopeMenu,checked:r,children:e.jsx(wue,{role:"menuitemcheckbox","aria-checked":Koe(r)?"mixed":r,...a,ref:s,"data-state":Hje(r),onSelect:Tr(a.onSelect,()=>n==null?void 0:n(Koe(r)?!0:!r),{checkForDefaultPrevented:!1})})})});zHe.displayName=dNt;var BHe="MenuRadioGroup",[uNt,hNt]=NC(BHe,{value:void 0,onValueChange:()=>{}}),$He=k.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=ed(n);return e.jsx(uNt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(Uje,{...a,ref:s})})});$He.displayName=BHe;var qHe="MenuRadioItem",UHe=k.forwardRef((t,s)=>{const{value:r,...n}=t,a=hNt(qHe,t.__scopeMenu),o=r===a.value;return e.jsx(VHe,{scope:t.__scopeMenu,checked:o,children:e.jsx(wue,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":Hje(o),onSelect:Tr(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});UHe.displayName=qHe;var Vje="MenuItemIndicator",[VHe,mNt]=NC(Vje,{checked:!1}),HHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=mNt(Vje,r);return e.jsx(wd,{present:n||Koe(o.checked)||o.checked===!0,children:e.jsx(dn.span,{...a,ref:s,"data-state":Hje(o.checked)})})});HHe.displayName=Vje;var pNt="MenuSeparator",GHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(dn.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});GHe.displayName=pNt;var fNt="MenuArrow",WHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=bue(r);return e.jsx(TR,{...a,...n,ref:s})});WHe.displayName=fNt;var xNt="MenuSub",[uEs,KHe]=NC(xNt),E6="MenuSubTrigger",ZHe=k.forwardRef((t,s)=>{const r=kC(E6,t.__scopeMenu),n=RR(E6,t.__scopeMenu),a=KHe(E6,t.__scopeMenu),o=$je(E6,t.__scopeMenu),l=k.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:d}=o,u={__scopeMenu:t.__scopeMenu},p=k.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return k.useEffect(()=>p,[p]),k.useEffect(()=>{const f=i.current;return()=>{window.clearTimeout(f),d(null)}},[i,d]),e.jsx(zje,{asChild:!0,...u,children:e.jsx(FHe,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":QHe(r.open),...t,ref:Mm(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:Tr(t.onPointerMove,rD(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:Tr(t.onPointerLeave,rD(f=>{var _,b;p();const y=(_=r.content)==null?void 0:_.getBoundingClientRect();if(y){const N=(b=r.content)==null?void 0:b.dataset.side,w=N==="right",S=w?-5:5,C=y[w?"left":"right"],A=y[w?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+S,y:f.clientY},{x:C,y:y.top},{x:A,y:y.top},{x:A,y:y.bottom},{x:C,y:y.bottom}],side:N}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Tr(t.onKeyDown,f=>{var _;const y=o.searchRef.current!=="";t.disabled||y&&f.key===" "||Yjt[n.dir].includes(f.key)&&(r.onOpenChange(!0),(_=r.content)==null||_.focus(),f.preventDefault())})})})});ZHe.displayName=E6;var YHe="MenuSubContent",XHe=k.forwardRef((t,s)=>{const r=LHe(Nx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=kC(Nx,t.__scopeMenu),l=RR(Nx,t.__scopeMenu),i=KHe(YHe,t.__scopeMenu),d=k.useRef(null),u=Ma(s,d);return e.jsx(sD.Provider,{scope:t.__scopeMenu,children:e.jsx(wd,{present:n||o.open,children:e.jsx(sD.Slot,{scope:t.__scopeMenu,children:e.jsx(qje,{id:i.contentId,"aria-labelledby":i.triggerId,...a,ref:u,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{var f;l.isUsingKeyboardRef.current&&((f=d.current)==null||f.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Tr(t.onFocusOutside,p=>{p.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Tr(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:Tr(t.onKeyDown,p=>{var _;const f=p.currentTarget.contains(p.target),y=Xjt[l.dir].includes(p.key);f&&y&&(o.onOpenChange(!1),(_=i.trigger)==null||_.focus(),p.preventDefault())})})})})})});XHe.displayName=YHe;function QHe(t){return t?"open":"closed"}function Koe(t){return t==="indeterminate"}function Hje(t){return Koe(t)?"indeterminate":t?"checked":"unchecked"}function gNt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function yNt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function vNt(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=yNt(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const d=l.find(u=>u.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function _Nt(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 bNt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return _Nt(r,s)}function rD(t){return s=>s.pointerType==="mouse"?t(s):void 0}var wNt=IHe,jNt=zje,NNt=DHe,kNt=RHe,SNt=Uje,CNt=OHe,MNt=wue,TNt=zHe,ANt=$He,ENt=UHe,PNt=HHe,INt=GHe,LNt=WHe,DNt=ZHe,RNt=XHe,jue="DropdownMenu",[ONt]=bd(jue,[EHe]),Dm=EHe(),[FNt,JHe]=ONt(jue),eGe=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,d=Dm(s),u=k.useRef(null),[p,f]=Bu({prop:a,defaultProp:o??!1,onChange:l,caller:jue});return e.jsx(FNt,{scope:s,triggerId:mu(),triggerRef:u,contentId:mu(),open:p,onOpenChange:f,onOpenToggle:k.useCallback(()=>f(y=>!y),[f]),modal:i,children:e.jsx(wNt,{...d,open:p,onOpenChange:f,dir:n,modal:i,children:r})})};eGe.displayName=jue;var tGe="DropdownMenuTrigger",sGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=JHe(tGe,r),l=Dm(r);return e.jsx(jNt,{asChild:!0,...l,children:e.jsx(dn.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:Mm(s,o.triggerRef),onPointerDown:Tr(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Tr(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});sGe.displayName=tGe;var zNt="DropdownMenuPortal",rGe=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Dm(s);return e.jsx(NNt,{...n,...r})};rGe.displayName=zNt;var nGe="DropdownMenuContent",aGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=JHe(nGe,r),o=Dm(r),l=k.useRef(!1);return e.jsx(kNt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Tr(t.onCloseAutoFocus,i=>{var d;l.current||(d=a.triggerRef.current)==null||d.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Tr(t.onInteractOutside,i=>{const d=i.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,p=d.button===2||u;(!a.modal||p)&&(l.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});aGe.displayName=nGe;var BNt="DropdownMenuGroup",$Nt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Dm(r);return e.jsx(SNt,{...a,...n,ref:s})});$Nt.displayName=BNt;var qNt="DropdownMenuLabel",iGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Dm(r);return e.jsx(CNt,{...a,...n,ref:s})});iGe.displayName=qNt;var UNt="DropdownMenuItem",oGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Dm(r);return e.jsx(MNt,{...a,...n,ref:s})});oGe.displayName=UNt;var VNt="DropdownMenuCheckboxItem",lGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Dm(r);return e.jsx(TNt,{...a,...n,ref:s})});lGe.displayName=VNt;var HNt="DropdownMenuRadioGroup",GNt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Dm(r);return e.jsx(ANt,{...a,...n,ref:s})});GNt.displayName=HNt;var WNt="DropdownMenuRadioItem",cGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Dm(r);return e.jsx(ENt,{...a,...n,ref:s})});cGe.displayName=WNt;var KNt="DropdownMenuItemIndicator",dGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Dm(r);return e.jsx(PNt,{...a,...n,ref:s})});dGe.displayName=KNt;var ZNt="DropdownMenuSeparator",uGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Dm(r);return e.jsx(INt,{...a,...n,ref:s})});uGe.displayName=ZNt;var YNt="DropdownMenuArrow",XNt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Dm(r);return e.jsx(LNt,{...a,...n,ref:s})});XNt.displayName=YNt;var QNt="DropdownMenuSubTrigger",hGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Dm(r);return e.jsx(DNt,{...a,...n,ref:s})});hGe.displayName=QNt;var JNt="DropdownMenuSubContent",mGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Dm(r);return e.jsx(RNt,{...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)"}})});mGe.displayName=JNt;var ekt=eGe,tkt=sGe,skt=rGe,pGe=aGe,fGe=iGe,xGe=oGe,gGe=lGe,yGe=cGe,vGe=dGe,_Ge=uGe,bGe=hGe,wGe=mGe;const Ud=ekt,Vd=tkt,rkt=k.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(bGe,{ref:a,className:Rt("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(ja,{className:"ml-auto h-4 w-4"})]}));rkt.displayName=bGe.displayName;const nkt=k.forwardRef(({className:t,...s},r)=>e.jsx(wGe,{ref:r,className:Rt("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}));nkt.displayName=wGe.displayName;const jd=k.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(skt,{children:e.jsx(pGe,{ref:n,sideOffset:s,className:Rt("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=pGe.displayName;const xa=k.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(xGe,{ref:n,className:Rt("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}));xa.displayName=xGe.displayName;const akt=k.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(gGe,{ref:a,className:Rt("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(vGe,{children:e.jsx(ea,{className:"h-4 w-4"})})}),s]}));akt.displayName=gGe.displayName;const ikt=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(yGe,{ref:n,className:Rt("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(vGe,{children:e.jsx(sd,{className:"h-2 w-2 fill-current"})})}),s]}));ikt.displayName=yGe.displayName;const x1e=k.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(fGe,{ref:n,className:Rt("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));x1e.displayName=fGe.displayName;const Jb=k.forwardRef(({className:t,...s},r)=>e.jsx(_Ge,{ref:r,className:Rt("-mx-1 my-1 h-px bg-muted",t),...s}));Jb.displayName=_Ge.displayName;const okt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=Rje();if(!t)return null;const l=i=>i.split(" ").map(d=>d[0]).join("").toUpperCase().slice(0,2);return e.jsx("div",{className:"fixed top-0 left-0 right-0 z-[2147483647] bg-primary text-primary-foreground px-4 py-1.5 shadow-lg",style:{height:"40px"},children:e.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4 h-full",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(Ei,{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(cr,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),e.jsxs(Ud,{children:[e.jsx(Vd,{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(Ei,{className:"h-4 w-4"}),e.jsx("strong",{children:"My Account"})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(vn,{className:"h-5 w-5",children:[e.jsx(Ca,{src:s.avatar_url||void 0}),e.jsx(_n,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(Fi,{className:"h-3 w-3"})]})}),e.jsxs(jd,{align:"start",className:"z-[2147483647]",children:[e.jsxs(xa,{onClick:o,className:"gap-2",children:[e.jsx(Ei,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(Ye,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(Jb,{}),r.map(i=>e.jsxs(xa,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(vn,{className:"h-6 w-6",children:[e.jsx(Ca,{src:i.avatar_url||void 0}),e.jsx(_n,{className:"text-[10px]",children:l(i.name)})]}),e.jsx("span",{children:i.name}),!a&&i.id===(s==null?void 0:s.id)&&e.jsx(Ye,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(Ye,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:a?"Personal Mode":"Assistant Mode"})]})})},rr=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,rolesLoading:o,isAdmin:l,isBrokerageManager:i}=$s(),d=Fl();if(a||(s||r)&&o)return 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..."})]})});if(!n){const u=d.pathname+d.search+d.hash;return u&&u!=="/auth"&&sessionStorage.setItem("redirectAfterLogin",u),e.jsx(Qxe,{to:"/auth",replace:!0})}return s&&!l?e.jsx(Qxe,{to:"/dashboard",replace:!0}):r&&!i&&!l?e.jsx(Qxe,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t})};var Gje={};(function t(s,r,n,a){var o=!!(s.Worker&&s.Blob&&s.Promise&&s.OffscreenCanvas&&s.OffscreenCanvasRenderingContext2D&&s.HTMLCanvasElement&&s.HTMLCanvasElement.prototype.transferControlToOffscreen&&s.URL&&s.URL.createObjectURL),l=typeof Path2D=="function"&&typeof DOMMatrix=="function",i=function(){if(!s.OffscreenCanvas)return!1;try{var xe=new OffscreenCanvas(1,1),he=xe.getContext("2d");he.fillRect(0,0,1,1);var we=xe.transferToImageBitmap();he.createPattern(we,"no-repeat")}catch{return!1}return!0}();function d(){}function u(xe){var he=r.exports.Promise,we=he!==void 0?he:s.Promise;return typeof we=="function"?new we(xe):(xe(d,d),null)}var p=function(xe,he){return{transform:function(we){if(xe)return we;if(he.has(we))return he.get(we);var Ne=new OffscreenCanvas(we.width,we.height),Ve=Ne.getContext("2d");return Ve.drawImage(we,0,0),he.set(we,Ne),Ne},clear:function(){he.clear()}}}(i,new Map),f=function(){var xe=Math.floor(16.666666666666668),he,we,Ne={},Ve=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(he=function(Te){var Ae=Math.random();return Ne[Ae]=requestAnimationFrame(function ze(Ee){Ve===Ee||Ve+xe-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 ckt(){const t=es();return Et({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 dkt(){const t=es(),{user:s}=$s();return Et({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"]})}})}function ukt(t){const s=hkt(t),r=k.forwardRef((n,a)=>{const{children:o,...l}=n,i=k.Children.toArray(o),d=i.find(pkt);if(d){const u=d.props.children,p=i.map(f=>f===d?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:k.isValidElement(u)?k.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}function hkt(t){const s=k.forwardRef((r,n)=>{const{children:a,...o}=r;if(k.isValidElement(a)){const l=xkt(a),i=fkt(o,a.props);return a.type!==k.Fragment&&(i.ref=n?Mm(n,l):l),k.cloneElement(a,i)}return k.Children.count(a)>1?k.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var mkt=Symbol("radix.slottable");function pkt(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===mkt}function fkt(t,s){const r={...s};for(const n in s){const a=t[n],o=s[n];/^on[A-Z]/.test(n)?a&&o?r[n]=(...i)=>{const d=o(...i);return a(...i),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function xkt(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 Nue="Dialog",[jGe,NGe]=bd(Nue),[gkt,Kg]=jGe(Nue),kGe=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=k.useRef(null),d=k.useRef(null),[u,p]=Bu({prop:n,defaultProp:a??!1,onChange:o,caller:Nue});return e.jsx(gkt,{scope:s,triggerRef:i,contentRef:d,contentId:mu(),titleId:mu(),descriptionId:mu(),open:u,onOpenChange:p,onOpenToggle:k.useCallback(()=>p(f=>!f),[p]),modal:l,children:r})};kGe.displayName=Nue;var SGe="DialogTrigger",CGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Kg(SGe,r),o=Ma(s,a.triggerRef);return e.jsx(dn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Zje(a.open),...n,ref:o,onClick:Tr(t.onClick,a.onOpenToggle)})});CGe.displayName=SGe;var Wje="DialogPortal",[ykt,MGe]=jGe(Wje,{forceMount:void 0}),TGe=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=Kg(Wje,s);return e.jsx(ykt,{scope:s,forceMount:r,children:k.Children.map(n,l=>e.jsx(wd,{present:r||o.open,children:e.jsx(PA,{asChild:!0,container:a,children:l})}))})};TGe.displayName=Wje;var Zoe="DialogOverlay",AGe=k.forwardRef((t,s)=>{const r=MGe(Zoe,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Kg(Zoe,t.__scopeDialog);return o.modal?e.jsx(wd,{present:n||o.open,children:e.jsx(_kt,{...a,ref:s})}):null});AGe.displayName=Zoe;var vkt=ukt("DialogOverlay.RemoveScroll"),_kt=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Kg(Zoe,r);return e.jsx(LR,{as:vkt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(dn.div,{"data-state":Zje(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),WS="DialogContent",EGe=k.forwardRef((t,s)=>{const r=MGe(WS,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Kg(WS,t.__scopeDialog);return e.jsx(wd,{present:n||o.open,children:o.modal?e.jsx(bkt,{...a,ref:s}):e.jsx(wkt,{...a,ref:s})})});EGe.displayName=WS;var bkt=k.forwardRef((t,s)=>{const r=Kg(WS,t.__scopeDialog),n=k.useRef(null),a=Ma(s,r.contentRef,n);return k.useEffect(()=>{const o=n.current;if(o)return vue(o)},[]),e.jsx(PGe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Tr(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Tr(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Tr(t.onFocusOutside,o=>o.preventDefault())})}),wkt=k.forwardRef((t,s)=>{const r=Kg(WS,t.__scopeDialog),n=k.useRef(!1),a=k.useRef(!1);return e.jsx(PGe,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var d,u;(d=t.onInteractOutside)==null||d.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((u=r.triggerRef.current)==null?void 0:u.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),PGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=Kg(WS,r),d=k.useRef(null),u=Ma(s,d);return xue(),e.jsxs(e.Fragment,{children:[e.jsx(PR,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(mw,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":Zje(i.open),...l,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(Nkt,{titleId:i.titleId}),e.jsx(Skt,{contentRef:d,descriptionId:i.descriptionId})]})]})}),Kje="DialogTitle",IGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Kg(Kje,r);return e.jsx(dn.h2,{id:a.titleId,...n,ref:s})});IGe.displayName=Kje;var LGe="DialogDescription",DGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Kg(LGe,r);return e.jsx(dn.p,{id:a.descriptionId,...n,ref:s})});DGe.displayName=LGe;var RGe="DialogClose",OGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Kg(RGe,r);return e.jsx(dn.button,{type:"button",...n,ref:s,onClick:Tr(t.onClick,()=>a.onOpenChange(!1))})});OGe.displayName=RGe;function Zje(t){return t?"open":"closed"}var FGe="DialogTitleWarning",[jkt,zGe]=zxt(FGe,{contentName:WS,titleName:Kje,docsSlug:"dialog"}),Nkt=({titleId:t})=>{const s=zGe(FGe),r=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return k.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},kkt="DialogDescriptionWarning",Skt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${zGe(kkt).contentName}}.`;return k.useEffect(()=>{var o;const a=(o=t.current)==null?void 0:o.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(n))},[n,t,s]),null},kue=kGe,Yje=CGe,Sue=TGe,UA=AGe,VA=EGe,OR=IGe,FR=DGe,zR=OGe;const fs=kue,ui=Yje,Ckt=Sue,hEs=zR,BGe=k.forwardRef(({className:t,...s},r)=>e.jsx(UA,{ref:r,className:Rt("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}));BGe.displayName=UA.displayName;const ms=k.forwardRef(({className:t,children:s,overlayClassName:r,...n},a)=>e.jsxs(Ckt,{children:[e.jsx(BGe,{className:r}),e.jsxs(VA,{ref:a,className:Rt("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(zR,{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(Sr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ms.displayName=VA.displayName;const ks=({className:t,...s})=>e.jsx("div",{className:Rt("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});ks.displayName="DialogHeader";const gn=({className:t,...s})=>e.jsx("div",{className:Rt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});gn.displayName="DialogFooter";const bs=k.forwardRef(({className:t,...s},r)=>e.jsx(OR,{ref:r,className:Rt("text-lg font-semibold leading-none tracking-tight",t),...s}));bs.displayName=OR.displayName;const Rr=k.forwardRef(({className:t,...s},r)=>e.jsx(FR,{ref:r,className:Rt("text-sm text-muted-foreground",t),...s}));Rr.displayName=FR.displayName;const Mkt={points_earned:Hi,listing_created:Mn,deal_closed:_c,custom:Gn},sIe={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"},rIe=()=>{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 Tkt(){const{user:t}=$s(),s=es(),{data:r}=lkt(),n=ckt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),d=k.useCallback(()=>{const _=Date.now()+3e3,b={startVelocity:30,spread:360,ticks:60,zIndex:9999},N=(S,C)=>Math.random()*(C-S)+S,w=setInterval(()=>{const S=_-Date.now();if(S<=0){clearInterval(w);return}const C=50*(S/3e3);tIe({...b,particleCount:C,origin:{x:N(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),tIe({...b,particleCount:C,origin:{x:N(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);k.useEffect(()=>{rIe()||r&&r.length>0&&!a&&(o(r[0]),i(!0),setTimeout(d,100))},[r,a,d]);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(rIe()||!a)return null;const p=Mkt[a.celebration_type]||Gn,f=sIe[a.celebration_type]||sIe.custom;return e.jsx(fs,{open:l,onOpenChange:y=>!y&&u(),children:e.jsxs(ms,{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(qr,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(qr,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(qr,{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 $Ge="/assets/levelup-logo-horizontal-DEFNc0ms.png",Xje="/assets/levelup-logo-white-C2RAgAoG.png",Akt="/assets/listings-hero-BI9Ki9Dq.jpg",Fe=k.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:Rt("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 qGe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(hd,function(){let r,n,a;function o(i,d){if(!r)r=d;else if(!n)n=d;else{const u={};r(u),a=d(u);const p="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+")(undefined, sharedChunk); self.onerror = null;";typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(a.workerUrl=window.URL.createObjectURL(new Blob([p],{type:"text/javascript"})))}}o(["exports"],function(i){var d=1e-6,u=typeof Float32Array<"u"?Float32Array:Array;function p(x,c){var h=c[0],g=c[1],j=c[2],T=c[3],P=h*T-j*g;return P?(x[0]=T*(P=1/P),x[1]=-g*P,x[2]=-j*P,x[3]=h*P,x):null}function f(){var x=new u(9);return u!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[5]=0,x[6]=0,x[7]=0),x[0]=1,x[4]=1,x[8]=1,x}function y(x,c){var h=c[0],g=c[1],j=c[2],T=c[3],P=c[4],R=c[5],F=c[6],H=c[7],Q=c[8];return x[0]=P*Q-R*H,x[1]=j*H-g*Q,x[2]=g*R-j*P,x[3]=R*F-T*Q,x[4]=h*Q-j*F,x[5]=j*T-h*R,x[6]=T*H-P*F,x[7]=g*F-h*H,x[8]=h*P-g*T,x}function _(x,c,h){var g=c[0],j=c[1],T=c[2],P=c[3],R=c[4],F=c[5],H=c[6],Q=c[7],se=c[8],re=h[0],oe=h[1],ue=h[2],_e=h[3],ke=h[4],Pe=h[5],We=h[6],qe=h[7],rt=h[8];return x[0]=re*g+oe*P+ue*H,x[1]=re*j+oe*R+ue*Q,x[2]=re*T+oe*F+ue*se,x[3]=_e*g+ke*P+Pe*H,x[4]=_e*j+ke*R+Pe*Q,x[5]=_e*T+ke*F+Pe*se,x[6]=We*g+qe*P+rt*H,x[7]=We*j+qe*R+rt*Q,x[8]=We*T+qe*F+rt*se,x}function b(){var x=new u(16);return u!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[11]=0,x[12]=0,x[13]=0,x[14]=0),x[0]=1,x[5]=1,x[10]=1,x[15]=1,x}function N(x){var c=new u(16);return c[0]=x[0],c[1]=x[1],c[2]=x[2],c[3]=x[3],c[4]=x[4],c[5]=x[5],c[6]=x[6],c[7]=x[7],c[8]=x[8],c[9]=x[9],c[10]=x[10],c[11]=x[11],c[12]=x[12],c[13]=x[13],c[14]=x[14],c[15]=x[15],c}function w(x){return x[0]=1,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=1,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=1,x[11]=0,x[12]=0,x[13]=0,x[14]=0,x[15]=1,x}function S(x,c){var h=c[0],g=c[1],j=c[2],T=c[3],P=c[4],R=c[5],F=c[6],H=c[7],Q=c[8],se=c[9],re=c[10],oe=c[11],ue=c[12],_e=c[13],ke=c[14],Pe=c[15],We=h*R-g*P,qe=h*F-j*P,rt=h*H-T*P,it=g*F-j*R,ot=g*H-T*R,It=j*H-T*F,wt=Q*_e-se*ue,At=Q*ke-re*ue,kt=Q*Pe-oe*ue,St=se*ke-re*_e,rs=se*Pe-oe*_e,is=re*Pe-oe*ke,us=We*is-qe*rs+rt*St+it*kt-ot*At+It*wt;return us?(x[0]=(R*is-F*rs+H*St)*(us=1/us),x[1]=(j*rs-g*is-T*St)*us,x[2]=(_e*It-ke*ot+Pe*it)*us,x[3]=(re*ot-se*It-oe*it)*us,x[4]=(F*kt-P*is-H*At)*us,x[5]=(h*is-j*kt+T*At)*us,x[6]=(ke*rt-ue*It-Pe*qe)*us,x[7]=(Q*It-re*rt+oe*qe)*us,x[8]=(P*rs-R*kt+H*wt)*us,x[9]=(g*kt-h*rs-T*wt)*us,x[10]=(ue*ot-_e*rt+Pe*We)*us,x[11]=(se*rt-Q*ot-oe*We)*us,x[12]=(R*At-P*St-F*wt)*us,x[13]=(h*St-g*At+j*wt)*us,x[14]=(_e*qe-ue*it-ke*We)*us,x[15]=(Q*it-se*qe+re*We)*us,x):null}function C(x,c,h){var g=c[0],j=c[1],T=c[2],P=c[3],R=c[4],F=c[5],H=c[6],Q=c[7],se=c[8],re=c[9],oe=c[10],ue=c[11],_e=c[12],ke=c[13],Pe=c[14],We=c[15],qe=h[0],rt=h[1],it=h[2],ot=h[3];return x[0]=qe*g+rt*R+it*se+ot*_e,x[1]=qe*j+rt*F+it*re+ot*ke,x[2]=qe*T+rt*H+it*oe+ot*Pe,x[3]=qe*P+rt*Q+it*ue+ot*We,x[4]=(qe=h[4])*g+(rt=h[5])*R+(it=h[6])*se+(ot=h[7])*_e,x[5]=qe*j+rt*F+it*re+ot*ke,x[6]=qe*T+rt*H+it*oe+ot*Pe,x[7]=qe*P+rt*Q+it*ue+ot*We,x[8]=(qe=h[8])*g+(rt=h[9])*R+(it=h[10])*se+(ot=h[11])*_e,x[9]=qe*j+rt*F+it*re+ot*ke,x[10]=qe*T+rt*H+it*oe+ot*Pe,x[11]=qe*P+rt*Q+it*ue+ot*We,x[12]=(qe=h[12])*g+(rt=h[13])*R+(it=h[14])*se+(ot=h[15])*_e,x[13]=qe*j+rt*F+it*re+ot*ke,x[14]=qe*T+rt*H+it*oe+ot*Pe,x[15]=qe*P+rt*Q+it*ue+ot*We,x}function A(x,c,h){var g,j,T,P,R,F,H,Q,se,re,oe,ue,_e=h[0],ke=h[1],Pe=h[2];return c===x?(x[12]=c[0]*_e+c[4]*ke+c[8]*Pe+c[12],x[13]=c[1]*_e+c[5]*ke+c[9]*Pe+c[13],x[14]=c[2]*_e+c[6]*ke+c[10]*Pe+c[14],x[15]=c[3]*_e+c[7]*ke+c[11]*Pe+c[15]):(j=c[1],T=c[2],P=c[3],R=c[4],F=c[5],H=c[6],Q=c[7],se=c[8],re=c[9],oe=c[10],ue=c[11],x[0]=g=c[0],x[1]=j,x[2]=T,x[3]=P,x[4]=R,x[5]=F,x[6]=H,x[7]=Q,x[8]=se,x[9]=re,x[10]=oe,x[11]=ue,x[12]=g*_e+R*ke+se*Pe+c[12],x[13]=j*_e+F*ke+re*Pe+c[13],x[14]=T*_e+H*ke+oe*Pe+c[14],x[15]=P*_e+Q*ke+ue*Pe+c[15]),x}function I(x,c,h){var g=h[0],j=h[1],T=h[2];return x[0]=c[0]*g,x[1]=c[1]*g,x[2]=c[2]*g,x[3]=c[3]*g,x[4]=c[4]*j,x[5]=c[5]*j,x[6]=c[6]*j,x[7]=c[7]*j,x[8]=c[8]*T,x[9]=c[9]*T,x[10]=c[10]*T,x[11]=c[11]*T,x[12]=c[12],x[13]=c[13],x[14]=c[14],x[15]=c[15],x}function L(x,c,h){var g=Math.sin(h),j=Math.cos(h),T=c[4],P=c[5],R=c[6],F=c[7],H=c[8],Q=c[9],se=c[10],re=c[11];return c!==x&&(x[0]=c[0],x[1]=c[1],x[2]=c[2],x[3]=c[3],x[12]=c[12],x[13]=c[13],x[14]=c[14],x[15]=c[15]),x[4]=T*j+H*g,x[5]=P*j+Q*g,x[6]=R*j+se*g,x[7]=F*j+re*g,x[8]=H*j-T*g,x[9]=Q*j-P*g,x[10]=se*j-R*g,x[11]=re*j-F*g,x}function O(x,c,h){var g=Math.sin(h),j=Math.cos(h),T=c[0],P=c[1],R=c[2],F=c[3],H=c[8],Q=c[9],se=c[10],re=c[11];return c!==x&&(x[4]=c[4],x[5]=c[5],x[6]=c[6],x[7]=c[7],x[12]=c[12],x[13]=c[13],x[14]=c[14],x[15]=c[15]),x[0]=T*j-H*g,x[1]=P*j-Q*g,x[2]=R*j-se*g,x[3]=F*j-re*g,x[8]=T*g+H*j,x[9]=P*g+Q*j,x[10]=R*g+se*j,x[11]=F*g+re*j,x}function U(x,c,h){var g=Math.sin(h),j=Math.cos(h),T=c[0],P=c[1],R=c[2],F=c[3],H=c[4],Q=c[5],se=c[6],re=c[7];return c!==x&&(x[8]=c[8],x[9]=c[9],x[10]=c[10],x[11]=c[11],x[12]=c[12],x[13]=c[13],x[14]=c[14],x[15]=c[15]),x[0]=T*j+H*g,x[1]=P*j+Q*g,x[2]=R*j+se*g,x[3]=F*j+re*g,x[4]=H*j-T*g,x[5]=Q*j-P*g,x[6]=se*j-R*g,x[7]=re*j-F*g,x}function q(x,c){return x[0]=c[0],x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=c[1],x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=c[2],x[11]=0,x[12]=0,x[13]=0,x[14]=0,x[15]=1,x}function $(x,c,h){var g,j,T,P=h[0],R=h[1],F=h[2],H=Math.sqrt(P*P+R*R+F*F);return H0&&(T=1/Math.sqrt(T)),x[0]=c[0]*T,x[1]=c[1]*T,x[2]=c[2]*T,x}function Re(x,c){return x[0]*c[0]+x[1]*c[1]+x[2]*c[2]}function Ue(x,c,h){var g=c[0],j=c[1],T=c[2],P=h[0],R=h[1],F=h[2];return x[0]=j*F-T*R,x[1]=T*P-g*F,x[2]=g*R-j*P,x}function ye(x,c,h,g){var j=c[0],T=c[1],P=c[2];return x[0]=j+g*(h[0]-j),x[1]=T+g*(h[1]-T),x[2]=P+g*(h[2]-P),x}function ct(x,c,h){var g=c[0],j=c[1],T=c[2],P=h[3]*g+h[7]*j+h[11]*T+h[15];return x[0]=(h[0]*g+h[4]*j+h[8]*T+h[12])/(P=P||1),x[1]=(h[1]*g+h[5]*j+h[9]*T+h[13])/P,x[2]=(h[2]*g+h[6]*j+h[10]*T+h[14])/P,x}function pe(x,c,h){var g=c[0],j=c[1],T=c[2];return x[0]=g*h[0]+j*h[3]+T*h[6],x[1]=g*h[1]+j*h[4]+T*h[7],x[2]=g*h[2]+j*h[5]+T*h[8],x}function Ge(x,c,h){var g=h[0],j=h[1],T=h[2],P=h[3],R=c[0],F=c[1],H=c[2],Q=j*H-T*F,se=T*R-g*H,re=g*F-j*R;return x[0]=R+P*(Q+=Q)+j*(re+=re)-T*(se+=se),x[1]=F+P*se+T*Q-g*re,x[2]=H+P*re+g*se-j*Q,x}function tt(x){return x[0]=0,x[1]=0,x[2]=0,x}function st(x,c){return x[0]===c[0]&&x[1]===c[1]&&x[2]===c[2]}var Ce=fe,et=xe,Ct=ce;function Ot(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0),x}function ut(x,c,h){return x[0]=c[0]*h,x[1]=c[1]*h,x[2]=c[2]*h,x[3]=c[3]*h,x}function Oe(x,c){var h=c[0],g=c[1],j=c[2],T=c[3],P=h*h+g*g+j*j+T*T;return P>0&&(P=1/Math.sqrt(P)),x[0]=h*P,x[1]=g*P,x[2]=j*P,x[3]=T*P,x}function Xe(x,c){return x[0]*c[0]+x[1]*c[1]+x[2]*c[2]+x[3]*c[3]}function at(x,c,h){var g=c[0],j=c[1],T=c[2],P=c[3];return x[0]=h[0]*g+h[4]*j+h[8]*T+h[12]*P,x[1]=h[1]*g+h[5]*j+h[9]*T+h[13]*P,x[2]=h[2]*g+h[6]*j+h[10]*T+h[14]*P,x[3]=h[3]*g+h[7]*j+h[11]*T+h[15]*P,x}function Ke(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0),x[3]=1,x}function He(x){return x[0]=0,x[1]=0,x[2]=0,x[3]=1,x}function gt(x,c,h){h*=.5;var g=c[0],j=c[1],T=c[2],P=c[3],R=Math.sin(h),F=Math.cos(h);return x[0]=g*F+P*R,x[1]=j*F+T*R,x[2]=T*F-j*R,x[3]=P*F-g*R,x}function Mt(x,c,h){h*=.5;var g=c[0],j=c[1],T=c[2],P=c[3],R=Math.sin(h),F=Math.cos(h);return x[0]=g*F-T*R,x[1]=j*F+P*R,x[2]=T*F+g*R,x[3]=P*F-j*R,x}J(),Ot();var Wt,xs,Cs,Us=Oe,Ar=(Wt=J(),xs=ae(1,0,0),Cs=ae(0,1,0),function(x,c,h){var g=Re(c,h);return g<-.999999?(Ue(Wt,xs,c),Ct(Wt)<1e-6&&Ue(Wt,Cs,c),ve(Wt,Wt),function(j,T,P){P*=.5;var R=Math.sin(P);j[0]=R*T[0],j[1]=R*T[1],j[2]=R*T[2],j[3]=Math.cos(P)}(x,Wt,Math.PI),x):g>.999999?(x[0]=0,x[1]=0,x[2]=0,x[3]=1,x):(Ue(Wt,c,h),x[0]=Wt[0],x[1]=Wt[1],x[2]=Wt[2],x[3]=1+g,Us(x,x))});function Bt(){var x=new u(2);return u!=Float32Array&&(x[0]=0,x[1]=0),x}function Xs(x,c){var h=new u(2);return h[0]=x,h[1]=c,h}function Nr(x,c,h){return x[0]=c,x[1]=h,x}function Vs(x,c,h){return x[0]=c[0]+h[0],x[1]=c[1]+h[1],x}function ar(x,c,h){return x[0]=c[0]-h[0],x[1]=c[1]-h[1],x}function Or(x,c,h){return x[0]=c[0]*h,x[1]=c[1]*h,x}function Rn(x){var c=x[0],h=x[1];return Math.sqrt(c*c+h*h)}function bn(x,c){var h=c[0],g=c[1],j=h*h+g*g;return j>0&&(j=1/Math.sqrt(j)),x[0]=c[0]*j,x[1]=c[1]*j,x}function ir(x,c){return x[0]*c[0]+x[1]*c[1]}Ke(),Ke(),f();var or,hr,an=ar;function Gr(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}Bt();var Va=function(){if(hr)return or;function x(c,h,g,j){this.cx=3*c,this.bx=3*(g-c)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*h,this.by=3*(j-h)-this.cy,this.ay=1-this.cy-this.by,this.p1x=c,this.p1y=h,this.p2x=g,this.p2y=j}return hr=1,or=x,x.prototype={sampleCurveX:function(c){return((this.ax*c+this.bx)*c+this.cx)*c},sampleCurveY:function(c){return((this.ay*c+this.by)*c+this.cy)*c},sampleCurveDerivativeX:function(c){return(3*this.ax*c+2*this.bx)*c+this.cx},solveCurveX:function(c,h){if(h===void 0&&(h=1e-6),c<0)return 0;if(c>1)return 1;for(var g=c,j=0;j<8;j++){var T=this.sampleCurveX(g)-c;if(Math.abs(T)T?R=g:F=g,g=.5*(F-R)+R;return g},solve:function(c,h){return this.sampleCurveY(this.solveCurveX(c,h))}},or}(),$a=Gr(Va);function Xt(x,c){this.x=x,this.y=c}function Qa(x,c){if(Array.isArray(x)){if(!Array.isArray(c)||x.length!==c.length)return!1;for(let h=0;h=1)return 1;const c=x*x,h=c*x;return 4*(x<.5?h:3*(x-c)+h-.75)}function $t(x,c,h,g){const j=new $a(x,c,h,g);return function(T){return j.solve(T)}}const Se=$t(.25,.1,.25,1);function De(x,c,h){return Math.min(h,Math.max(c,x))}function Ze(x,c,h){return(h=De((h-x)/(c-x),0,1))*h*(3-2*h)}function xt(x,c,h){const g=h-c,j=((x-c)%g+g)%g+c;return j===c?h:j}function _t(x,c,h){if(!x.length)return h(null,[]);let g=x.length;const j=new Array(x.length);let T=null;x.forEach((P,R)=>{c(P,(F,H)=>{F&&(T=F),j[R]=H,--g===0&&h(T,j)})})}let Pt=1;function Yt(){return Pt++}function Vt(x){return x<=1?1:Math.pow(2,Math.ceil(Math.log2(x)))}function Qt(x,c){x.forEach(h=>{c[h]&&(c[h]=c[h].bind(c))})}function Es(x,c,h){const g={};for(const j in x)g[j]=c.call(this,x[j],j,x);return g}function ys(x,c,h){const g={};for(const j in x)c.call(this,x[j],j,x)&&(g[j]=x[j]);return g}function lr(x){return Array.isArray(x)?x.map(lr):typeof x=="object"&&x?Es(x,lr):x}function Fr(x,c){for(let h=0;h=0)return!0;return!1}const Br={};function zr(x){Br[x]||(typeof console<"u"&&console.warn(x),Br[x]=!0)}function un(x,c,h){return(h.y-x.y)*(c.x-x.x)>(c.y-x.y)*(h.x-x.x)}function Vn(x){let c=0;for(let h,g,j=0,T=x.length,P=T-1;j@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(h,g,j,T)=>{const P=j||T;return c[g]=!P||P.toLowerCase(),""}),c["max-age"]){const h=parseInt(c["max-age"],10);isNaN(h)?delete c["max-age"]:c["max-age"]=h}return c}let Ha,no=null;function ai(x,c){return[x[4*c],x[4*c+1],x[4*c+2],x[4*c+3]]}function zi(x,c,h,g){for(;c>1;x[j]>1;x[j]<=g?c=j+1:h=j}return c}function fi(x){return x>0?1/(1.001-x):1+x}function Ki(x){return x>0?1-1/(1.001-x):-x}function Bi(x,c,h){return(x-c.min)*(h.max-h.min)/(c.max-c.min)+h.min}const oa={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(!oa.API_URL)return null;try{const x=new URL(oa.API_URL);return x.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":x.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1",TILE_PROVIDER_URLS:Object.assign(Object.create(null),{pmtiles:"/mapbox-gl-js/mapbox-gl-pmtiles-provider-v0.0.1.js"})};function Jo(){return new URL(oa.DRACO_URL,oa.API_URL).href}function Cc(){if(typeof WebAssembly!="object")throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(function(){if(Ha===void 0){if(typeof WebAssembly!="object")return!1;const x=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);Ha=WebAssembly.validate(x)}return Ha}()?oa.MESHOPT_SIMD_URL:oa.MESHOPT_URL,oa.API_URL).href}function Bl(){return new URL(oa.BUILDING_GEN_URL,oa.API_URL).href}function Hd(x){return oa.API_URL_REGEX.test(x)}function vu(x){return oa.API_SPRITE_REGEX.test(x)}let Rm,Nd,_u,Om,Vu,Fm;function xh(){return Rm==null&&(Rm=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Rm}const Gd={now:()=>Om!==void 0?Om:performance.now(),setNow(x){Om=x},restoreNow(){Om=void 0},frame(x){const c=requestAnimationFrame(x);return{cancel:()=>cancelAnimationFrame(c)}},getImageData(x,c=0){const{width:h,height:g}=x;Vu||(Vu=document.createElement("canvas"));const j=Vu.getContext("2d",{willReadFrequently:!0});if(!j)throw new Error("failed to create canvas 2d context");return(h>Vu.width||g>Vu.height)&&(Vu.width=h,Vu.height=g),j.clearRect(-c,-c,h+2*c,g+2*c),j.drawImage(x,0,0,h,g),j.getImageData(-c,-c,h+2*c,g+2*c)},resolveURL:x=>(Nd||(Nd=document.createElement("a")),Nd.href=x,Nd.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(_u==null&&(_u=window.matchMedia("(prefers-reduced-motion: reduce)")),_u.matches)},hasCanvasFingerprintNoise(){if(Fm!==void 0)return Fm;if(!xh())return Fm=!1,!1;const x=new OffscreenCanvas(85,1),c=x.getContext("2d",{willReadFrequently:!0});let h=0;for(let j=0;j0?`?${T}`:""}`}const Ux="mapbox-tiles";let I1=500,Np=50;const Ef=["language","worldview","jobid"];let Wd;function FC(){try{return caches}catch{}}function P0(){const x=FC();x&&Wd==null&&(Wd=x.open(Ux))}let kp=1/0;const Vx={supported:!1,testSupport:function(x){!I0&&Sp&&($l?ty(x):nc=x)}};let nc,Sp,I0=!1,$l=!1;const Iw=typeof self<"u"?self:{};function ty(x){const c=x.createTexture();x.bindTexture(x.TEXTURE_2D,c);try{if(x.texImage2D(x.TEXTURE_2D,0,x.RGBA,x.RGBA,x.UNSIGNED_BYTE,Sp),x.isContextLost())return;Vx.supported=!0}catch{}x.deleteTexture(c),I0=!0}Iw.document&&(Sp=Iw.document.createElement("img"),Sp.onload=function(){nc&&ty(nc),nc=null,$l=!0},Sp.onerror=function(){I0=!0,nc=null},Sp.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Pf={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(Pf);class L0 extends Error{constructor(c,h,g){h===401&&Hd(g)&&(c+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(c),this.status=h,this.url=g}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}function Lw(x){return typeof x=="object"&&x!==null&&"status"in x&&x.status===404}const Pa=vi()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Hx=function(x,c){return/^file:/.test(h=x.url)||/^file:/.test(Pa())&&!/^\w+:/.test(h)?function(g,j){const T=new XMLHttpRequest;T.open(g.method||"GET",g.url,!0),g.type==="arrayBuffer"&&(T.responseType="arraybuffer");for(const P in g.headers)T.setRequestHeader(P,g.headers[P]);return g.type==="json"&&(T.responseType="text",T.setRequestHeader("Accept","application/json")),T.withCredentials=g.credentials==="include",T.onerror=()=>{j(new Error(T.statusText))},T.onload=()=>{if((T.status>=200&&T.status<300||T.status===0)&&T.response!==null){let P=T.response;if(g.type==="json")try{P=JSON.parse(T.response)}catch(F){return j(F)}const R=new Headers;T.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(F=>{const H=F.split(": "),Q=H.shift(),se=H.join(": ");R.append(Q,se)}),j(null,P,R)}else j(new L0(T.statusText,T.status,g.url))},T.send(g.body),{cancel:()=>T.abort()}}(x,c):function(g,j){const T=new AbortController,P=new Request(g.url,{method:g.method||"GET",body:g.body,credentials:g.credentials,headers:g.headers,referrer:Pa(),referrerPolicy:g.referrerPolicy,signal:T.signal});let R=!1,F=!1;const H=(Q=P.url).indexOf("sku=")>0&&Hd(Q);var Q;g.type==="json"&&P.headers.set("Accept","application/json");const se=(oe,ue,_e)=>{if(F)return;if(oe&&oe.message!=="SecurityError"&&zr(oe.toString()),ue&&_e)return re(ue);const ke=Date.now();fetch(P).then(Pe=>{if(Pe.ok){const We=H?Pe.clone():null;return re(Pe,We,ke)}return j(new L0(Pe.statusText,Pe.status,g.url))}).catch(Pe=>{Pe.name!=="AbortError"&&j(new Error(`${Pe.message} ${g.url}`))})},re=(oe,ue,_e)=>{(g.type==="arrayBuffer"?oe.arrayBuffer():g.type==="json"?oe.json():oe.text()).then(ke=>{F||(ue&&_e&&function(Pe,We,qe){if(P0(),Wd==null)return;const rt=To(We.headers.get("cache-control")||"");if(rt["no-store"])return;const it={status:We.status,statusText:We.statusText,headers:new Headers};We.headers.forEach((kt,St)=>it.headers.set(St,kt)),rt["max-age"]&&it.headers.set("Expires",new Date(qe+1e3*rt["max-age"]).toUTCString());const ot=it.headers.get("expires");if(!ot||new Date(ot).getTime()-qe<42e4)return;let It=P1(Pe.url,{persistentParams:Ef});if(We.status===206){const kt=Pe.headers.get("Range");if(!kt)return;it.status=200,It=jp(It,{range:kt})}const wt=new Response((At=We.status)!==200&&At!==404&&[101,103,204,205,304].includes(At)?null:We.body,it);var At;P0(),Wd!=null&&Wd.then(kt=>kt.put(It,wt)).catch(kt=>zr(kt.message))}(P,ue,_e),R=!0,j(null,ke,oe.headers))}).catch(ke=>{F||j(new Error(ke.message))})};return H?function(oe,ue){if(P0(),Wd==null)return ue(null);Wd.then(_e=>{let ke=P1(oe.url,{persistentParams:Ef});const Pe=oe.headers.get("Range");Pe&&(ke=jp(ke,{range:Pe})),_e.match(ke).then(We=>{const qe=function(rt){if(!rt)return!1;const it=new Date(rt.headers.get("expires")||0),ot=To(rt.headers.get("cache-control")||"");return Number(it)>Date.now()&&!ot["no-cache"]}(We);_e.delete(ke).catch(ue),qe&&_e.put(ke,We.clone()).catch(ue),ue(null,We,qe)}).catch(ue)}).catch(ue)}(P,se):se(null,null),{cancel:()=>{F=!0,R||T.abort()}}}(x,c);var h},If=function(x,c){return Hx(Object.assign(x,{type:"arrayBuffer"}),c)};function OE(x){const c=document.createElement("a");return c.href=x,c.protocol===location.protocol&&c.host===location.host}let L1,Lf;L1=[],Lf=0;const Cp=function(x,c){if(Vx.supported&&(x.headers||(x.headers={}),x.headers.accept="image/webp,*/*"),Lf>=oa.MAX_PARALLEL_IMAGE_REQUESTS){const T={requestParameters:x,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return L1.push(T),T}Lf++;let h=!1;const g=()=>{if(!h)for(h=!0,Lf--;L1.length&&Lf{g(),T?c(T):P&&function(F,H){const Q=new Blob([new Uint8Array(F)],{type:"image/png"});createImageBitmap(Q).then(se=>{H(null,se)}).catch(se=>{H(new Error(`Could not load image because of ${se.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(P,(F,H)=>c(F,H,R))});return{cancel:()=>{j.cancel(),g()}}};var D0,D1,zC,Gx={exports:{}},BC={exports:{}},R1={exports:{}},FE=function(){if(zC)return Gx.exports;zC=1;var x=(D0||(D0=1,BC.exports=function(h,g){var j,T,P,R,F,H,Q,se;for(T=h.length-(j=3&h.length),P=g,F=3432918353,H=461845907,se=0;se>>16)*F&65535)<<16)&4294967295)<<15|Q>>>17))*H+(((Q>>>16)*H&65535)<<16)&4294967295)<<13|P>>>19))+((5*(P>>>16)&65535)<<16)&4294967295))+(((R>>>16)+58964&65535)<<16);switch(Q=0,j){case 3:Q^=(255&h.charCodeAt(se+2))<<16;case 2:Q^=(255&h.charCodeAt(se+1))<<8;case 1:P^=Q=(65535&(Q=(Q=(65535&(Q^=255&h.charCodeAt(se)))*F+(((Q>>>16)*F&65535)<<16)&4294967295)<<15|Q>>>17))*H+(((Q>>>16)*H&65535)<<16)&4294967295}return P^=h.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}),BC.exports),c=(D1||(D1=1,R1.exports=function(h,g){for(var j,T=h.length,P=g^T,R=0;T>=4;)j=1540483477*(65535&(j=255&h.charCodeAt(R)|(255&h.charCodeAt(++R))<<8|(255&h.charCodeAt(++R))<<16|(255&h.charCodeAt(++R))<<24))+((1540483477*(j>>>16)&65535)<<16),P=1540483477*(65535&P)+((1540483477*(P>>>16)&65535)<<16)^(j=1540483477*(65535&(j^=j>>>24))+((1540483477*(j>>>16)&65535)<<16)),T-=4,++R;switch(T){case 3:P^=(255&h.charCodeAt(R+2))<<16;case 2:P^=(255&h.charCodeAt(R+1))<<8;case 1:P=1540483477*(65535&(P^=255&h.charCodeAt(R)))+((1540483477*(P>>>16)&65535)<<16)}return P=1540483477*(65535&(P^=P>>>13))+((1540483477*(P>>>16)&65535)<<16),(P^=P>>>15)>>>0}),R1.exports);return Gx.exports=x,Gx.exports.murmur3=x,Gx.exports.murmur2=c,Gx.exports}(),jt=Gr(FE);class Ps{constructor(c,...h){Object.assign(this,h[0]||{}),this.type=c}}class nr extends Ps{constructor(c,h={}){super("error",Object.assign({error:c},h))}}function Yr(x,c,h){h[x]&&h[x].indexOf(c)!==-1||(h[x]=h[x]||[],h[x].push(c))}function pn(x,c,h){if(h&&h[x]){const g=h[x].indexOf(c);g!==-1&&h[x].splice(g,1)}}class Na{on(c,h){return this._listeners=this._listeners||{},Yr(c,h,this._listeners),this}off(c,h){return pn(c,h,this._listeners),pn(c,h,this._oneTimeListeners),this}once(c,h){return h?(this._oneTimeListeners=this._oneTimeListeners||{},Yr(c,h,this._oneTimeListeners),this):new Promise(g=>{this.once(c,g)})}fire(c,h){const g=typeof c=="string"?new Ps(c,h):c,j=g.type;if(this.listens(j)){g.target=this;const T=this._listeners&&this._listeners[j]?this._listeners[j].slice():[];for(const F of T)F.call(this,g);const P=this._oneTimeListeners&&this._oneTimeListeners[j]?this._oneTimeListeners[j].slice():[];for(const F of P)pn(j,F,this._oneTimeListeners),F.call(this,g);const R=this._eventedParent;if(R){const F=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(g,F),R.fire(g)}}else g instanceof nr&&console.error(g.error);return this}listens(c){return!!(this._listeners&&this._listeners[c]&&this._listeners[c].length>0||this._oneTimeListeners&&this._oneTimeListeners[c]&&this._oneTimeListeners[c].length>0||this._eventedParent&&this._eventedParent.listens(c))}setEventedParent(c,h){return this._eventedParent=c,this._eventedParentData=h,this}}class Bn{constructor(c){typeof c=="string"?this.name=c:(this.name=c.name,this.iconsetId=c.iconsetId)}static from(c){return new Bn(c)}static toString(c){return c.iconsetId?`${c.name}${c.iconsetId}`:c.name}static parse(c){const[h,g]=c.split("");return new Bn({name:h,iconsetId:g})}static isEqual(c,h){return c.name===h.name&&c.iconsetId===h.iconsetId}toString(){return Bn.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var Ri,Mp={},zm=function(){if(Ri)return Mp;Ri=1;var x={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function c(T){return(T=Math.round(T))<0?0:T>255?255:T}function h(T){return c(T[T.length-1]==="%"?parseFloat(T)/100*255:parseInt(T))}function g(T){return(P=T[T.length-1]==="%"?parseFloat(T)/100:parseFloat(T))<0?0:P>1?1:P;var P}function j(T,P,R){return R<0?R+=1:R>1&&(R-=1),6*R<1?T+(P-T)*R*6:2*R<1?P:3*R<2?T+(P-T)*(2/3-R)*6:T}try{Mp.parseCSSColor=function(T){var P,R=T.replace(/ /g,"").toLowerCase();if(R in x)return x[R].slice();if(R[0]==="#")return R.length===4?(P=parseInt(R.substr(1),16))>=0&&P<=4095?[(3840&P)>>4|(3840&P)>>8,240&P|(240&P)>>4,15&P|(15&P)<<4,1]:null:R.length===7&&(P=parseInt(R.substr(1),16))>=0&&P<=16777215?[(16711680&P)>>16,(65280&P)>>8,255&P,1]:null;var F=R.indexOf("("),H=R.indexOf(")");if(F!==-1&&H+1===R.length){var Q=R.substr(0,F),se=R.substr(F+1,H-(F+1)).split(","),re=1;switch(Q){case"rgba":if(se.length!==4)return null;re=g(se.pop());case"rgb":return se.length!==3?null:[h(se[0]),h(se[1]),h(se[2]),re];case"hsla":if(se.length!==4)return null;re=g(se.pop());case"hsl":if(se.length!==3)return null;var oe=(parseFloat(se[0])%360+360)%360/360,ue=g(se[1]),_e=g(se[2]),ke=_e<=.5?_e*(ue+1):_e+ue-_e*ue,Pe=2*_e-ke;return[c(255*j(Pe,ke,oe+1/3)),c(255*j(Pe,ke,oe)),c(255*j(Pe,ke,oe-1/3)),re];default:return null}}return null}}catch{}return Mp}();class la{constructor(c,h,g,j=1){this.r=c,this.g=h,this.b=g,this.a=j}static parse(c){if(!c)return;if(c instanceof la)return c;if(typeof c!="string")return;const h=zm.parseCSSColor(c);return h?new la(h[0]/255,h[1]/255,h[2]/255,h[3]):void 0}toString(){const[c,h,g,j]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*c)},${Math.round(255*h)},${Math.round(255*g)},${j})`}toNonPremultipliedRenderColor(c){const{r:h,g,b:j,a:T}=this;return new O1(c,h,g,j,T)}toPremultipliedRenderColor(c){const{r:h,g,b:j,a:T}=this;return new F1(c,h*T,g*T,j*T,T)}clone(){return new la(this.r,this.g,this.b,this.a)}}class R0{constructor(c,h,g,j,T,P=!1){if(this.premultiplied=!1,this.premultiplied=P,c){const R=c.image.height,F=R*R;this.premultiplied?(h=T===0?0:h/T*(R-1),g=T===0?0:g/T*(R-1),j=T===0?0:j/T*(R-1)):(h*=R-1,g*=R-1,j*=R-1),h=Math.max(0,Math.min(R-1,h)),g=Math.max(0,Math.min(R-1,g)),j=Math.max(0,Math.min(R-1,j));const H=Math.floor(h),Q=Math.floor(g),se=Math.floor(j),re=Math.ceil(h),oe=Math.ceil(g),ue=Math.ceil(j),_e=h-H,ke=g-Q,Pe=j-se,We=c.image.data,qe=4*(H+Q*F+se*R),rt=4*(H+Q*F+ue*R),it=4*(H+oe*F+se*R),ot=4*(H+oe*F+ue*R),It=4*(re+Q*F+se*R),wt=4*(re+Q*F+ue*R),At=4*(re+oe*F+se*R),kt=4*(re+oe*F+ue*R);this.r=en(en(en(We[qe],We[rt],Pe),en(We[it],We[ot],Pe),ke),en(en(We[It],We[wt],Pe),en(We[At],We[kt],Pe),ke),_e)/255*(this.premultiplied?T:1),this.g=en(en(en(We[qe+1],We[rt+1],Pe),en(We[it+1],We[ot+1],Pe),ke),en(en(We[It+1],We[wt+1],Pe),en(We[At+1],We[kt+1],Pe),ke),_e)/255*(this.premultiplied?T:1),this.b=en(en(en(We[qe+2],We[rt+2],Pe),en(We[it+2],We[ot+2],Pe),ke),en(en(We[It+2],We[wt+2],Pe),en(We[At+2],We[kt+2],Pe),ke),_e)/255*(this.premultiplied?T:1),this.a=T}else this.r=h,this.g=g,this.b=j,this.a=T}toArray(){const{r:c,g:h,b:g,a:j}=this;return[255*c,255*h,255*g,j]}toHslaArray(){let{r:c,g:h,b:g,a:j}=this;if(this.premultiplied){if(j===0)return[0,0,0,0];const ue=1/j;c*=ue,h*=ue,g*=ue}const T=Math.min(Math.max(c,0),1),P=Math.min(Math.max(h,0),1),R=Math.min(Math.max(g,0),1),F=Math.min(T,P,R),H=Math.max(T,P,R),Q=H-F,se=.5*(F+H);if(Q===0)return[0,0,100*se,j];const re=se>.5?Q/(2-H-F):Q/(H+F);let oe;switch(H){case T:oe=60*((P-R)/Q+(Pen(g,c[j],h))}la.black=new la(0,0,0,1),la.white=new la(1,1,1,1),la.transparent=new la(0,0,0,0),la.red=new la(1,0,0,1),la.blue=new la(0,0,1,1);var $C=Object.freeze({__proto__:null,array:Tp,color:function(x,c,h){return new la(en(x.r,c.r,h),en(x.g,c.g,h),en(x.b,c.b,h),en(x.a,c.a,h))},number:en});class Bm extends Error{constructor(c,h){super(h),this.message=h,this.key=c}}class O0{constructor(c,h=[]){this.parent=c,this.bindings={};for(const[g,j]of h)this.bindings[g]=j}concat(c){return new O0(this,c)}get(c){if(this.bindings[c])return this.bindings[c];if(this.parent)return this.parent.get(c);throw new Error(`${c} not found in scope.`)}has(c){return!!this.bindings[c]||!!this.parent&&this.parent.has(c)}}const Wx={kind:"null"},Dr={kind:"number"},ri={kind:"string"},ii={kind:"boolean"},bu={kind:"color"},sy={kind:"object"},oi={kind:"value"},F0={kind:"collator"},Dw={kind:"formatted"},Rw={kind:"resolvedImage"};function Kd(x,c){return{kind:"array",itemType:x,N:c}}function Nl(x){if(x.kind==="array"){const c=Nl(x.itemType);return typeof x.N=="number"?`array<${c}, ${x.N}>`:x.itemType.kind==="value"?"array":`array<${c}>`}return x.kind}const ape=[Wx,Dr,ri,ii,bu,Dw,sy,Kd(oi),Rw];function Ow(x,c){if(c.kind==="error")return null;if(x.kind==="array"){if(c.kind==="array"&&(c.N===0&&c.itemType.kind==="value"||!Ow(x.itemType,c.itemType))&&(typeof x.N!="number"||x.N===c.N))return null}else{if(x.kind===c.kind)return null;if(x.kind==="value"){for(const h of ape)if(!Ow(h,c))return null}}return`Expected ${Nl(x)} but found ${Nl(c)} instead.`}function zE(x,c){return c.some(h=>h.kind===x.kind)}function z1(x,c){return c.some(h=>h==="null"?x===null:h==="array"?Array.isArray(x):h==="object"?x&&!Array.isArray(x)&&typeof x=="object":h===typeof x)}function Kx(x,c){return x.kind==="array"&&c.kind==="array"?x.N===c.N&&Kx(x.itemType,c.itemType):x.kind===c.kind}class BE{constructor(c,h,g){this.sensitivity=c?h?"variant":"case":h?"accent":"base",this.locale=g,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(c,h){return this.collator.compare(c,h)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Fw{constructor(c,h,g,j,T){this.text=c.normalize?c.normalize():c,this.image=h,this.scale=g,this.fontStack=j,this.textColor=T}}class kd{constructor(c){this.sections=c}static fromString(c){return new kd([new Fw(c,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(c=>c.text.length!==0||!!c.image&&c.image.hasPrimary())}static factory(c){return c instanceof kd?c:kd.fromString(c)}toString(){return this.sections.length===0?"":this.sections.map(c=>c.text).join("")}serialize(){const c=["format"];for(const h of this.sections){if(h.image){const j=h.image.getPrimary().id.toString();c.push(["image",j]);continue}c.push(h.text);const g={};h.fontStack&&(g["text-font"]=["literal",h.fontStack.split(",")]),h.scale&&(g["font-scale"]=h.scale),h.textColor&&(g["text-color"]=["rgba"].concat(h.textColor.toNonPremultipliedRenderColor(null).toArray())),c.push(g)}return c}}class $m{constructor(c,h={}){this.id=Bn.from(c),this.params=h.params,this.sx=h.sx||1,this.sy=h.sy||1}toString(){return JSON.stringify(this)}static parse(c){let h,g,j,T;try{({id:h,params:g,sx:j,sy:T}=JSON.parse(c)||{})}catch{return null}return h?new $m(h,{params:g,sx:j,sy:T}):null}scaleSelf(c,h=c){return this.sx*=c,this.sy*=h,this}}class Hu{constructor(c,h,g,j,T=!1){this.primaryId=Bn.from(c),this.primaryOptions=h,g&&(this.secondaryId=Bn.from(g)),this.secondaryOptions=j,this.available=T}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new $m(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new $m(this.secondaryId,this.secondaryOptions):null}static from(c){return typeof c=="string"?Hu.build({name:c}):c}static build(c,h,g,j){return!c||typeof c=="object"&&!("name"in c)?null:new Hu(c,g,h,j)}}function IO(x,c,h,g){return typeof x=="number"&&x>=0&&x<=255&&typeof c=="number"&&c>=0&&c<=255&&typeof h=="number"&&h>=0&&h<=255?g===void 0||typeof g=="number"&&g>=0&&g<=1?null:`Invalid rgba value [${[x,c,h,g].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof g=="number"?[x,c,h,g]:[x,c,h]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function B1(x){if(x===null||typeof x=="string"||typeof x=="boolean"||typeof x=="number"||x instanceof la||x instanceof BE||x instanceof kd||x instanceof Hu)return!0;if(Array.isArray(x)){for(const c of x)if(!B1(c))return!1;return!0}if(typeof x=="object"){for(const c in x)if(!B1(x[c]))return!1;return!0}return!1}function Oo(x){if(x===null)return Wx;if(typeof x=="string")return ri;if(typeof x=="boolean")return ii;if(typeof x=="number")return Dr;if(x instanceof la)return bu;if(x instanceof BE)return F0;if(x instanceof kd)return Dw;if(x instanceof Hu)return Rw;if(Array.isArray(x)){const c=x.length;let h;for(const g of x){const j=Oo(g);if(h){if(h===j)continue;h=oi;break}h=j}return Kd(h||oi,c)}return sy}function Jr(x){const c=typeof x;return x===null?"":c==="string"||c==="number"||c==="boolean"?String(x):x instanceof kd||x instanceof Hu||x instanceof la?x.toString():JSON.stringify(x)}class kr{constructor(c,h){this.type=c,this.value=h}static parse(c,h){if(c.length!==2)return h.error(`'literal' expression requires exactly one argument, but found ${c.length-1} instead.`);if(!B1(c[1]))return h.error("invalid value");const g=c[1];let j=Oo(g);const T=h.expectedType;return j.kind!=="array"||j.N!==0||!T||T.kind!=="array"||typeof T.N=="number"&&T.N!==0||(j=T),new kr(j,g)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof la?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof kd?this.value.serialize():this.value}}class ol{constructor(c){this.name="ExpressionEvaluationError",this.message=c}toJSON(){return this.message}}const sn={string:ri,number:Dr,boolean:ii,object:sy};class Zh{constructor(c,h){this.type=c,this.args=h}static parse(c,h){if(c.length<2)return h.error("Expected at least one argument.");let g,j=1;const T=c[0];if(T==="array"){let R,F;if(c.length>2){const H=c[1];if(typeof H!="string"||!(H in sn)||H==="object")return h.error('The item type argument of "array" must be one of string, number, boolean',1);R=sn[H],j++}else R=oi;if(c.length>3){if(c[2]!==null&&(typeof c[2]!="number"||c[2]<0||c[2]!==Math.floor(c[2])))return h.error('The length argument to "array" must be a positive integer literal',2);F=c[2],j++}g=Kd(R,F)}else g=sn[T];const P=[];for(;jc.outputDefined())}serialize(){const c=this.type,h=[c.kind];if(c.kind==="array"){const g=c.itemType;if(g.kind==="string"||g.kind==="number"||g.kind==="boolean"){h.push(g.kind);const j=c.N;(typeof j=="number"||this.args.length>1)&&h.push(j)}}return h.concat(this.args.map(g=>g.serialize()))}}class z0{constructor(c){this.type=Dw,this.sections=c}static parse(c,h){if(c.length<2)return h.error("Expected at least one argument.");const g=c[1];if(!Array.isArray(g)&&typeof g=="object")return h.error("First argument must be an image or text section.");const j=[];let T=!1;for(let P=1;P<=c.length-1;++P){const R=c[P];if(T&&typeof R=="object"&&!Array.isArray(R)){T=!1;let F=null;if(R["font-scale"]&&(F=h.parseObjectValue(R["font-scale"],P,"font-scale",Dr),!F))return null;let H=null;if(R["text-font"]&&(H=h.parseObjectValue(R["text-font"],P,"text-font",Kd(ri)),!H))return null;let Q=null;if(R["text-color"]&&(Q=h.parseObjectValue(R["text-color"],P,"text-color",bu),!Q))return null;const se=j[j.length-1];se.scale=F,se.font=H,se.textColor=Q}else{const F=h.parse(c[P],P,oi);if(!F)return null;const H=F.type.kind;if(H!=="string"&&H!=="value"&&H!=="null"&&H!=="resolvedImage")return h.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");T=!0,j.push({content:F,scale:null,font:null,textColor:null})}}return new z0(j)}evaluate(c){return new kd(this.sections.map(h=>{const g=h.content.evaluate(c);return Kx(Oo(g),Rw)?new Fw("",g,null,null,null):new Fw(Jr(g),null,h.scale?h.scale.evaluate(c):null,h.font?h.font.evaluate(c).join(","):null,h.textColor?h.textColor.evaluate(c):null)}))}eachChild(c){for(const h of this.sections)c(h.content),h.scale&&c(h.scale),h.font&&c(h.font),h.textColor&&c(h.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const h of this.sections){c.push(h.content.serialize());const g={};h.scale&&(g["font-scale"]=h.scale.serialize()),h.font&&(g["text-font"]=h.font.serialize()),h.textColor&&(g["text-color"]=h.textColor.serialize()),c.push(g)}return c}}class Wr{constructor(c,h,g,j){this._imageWarnHistory={},this.type=Rw,this.namePrimary=c,this.nameSecondary=h,g&&(this.paramsPrimary=g.params,this.iconsetIdPrimary=g.iconset?g.iconset.id:void 0),j&&(this.paramsSecondary=j.params,this.iconsetIdSecondary=j.iconset?j.iconset.id:void 0)}static parse(c,h){if(c.length<2)return h.error("Expected two or more arguments.");let g=1;const j=[];function T(){if(gBn.isEqual(P,T)),j.available){const P=j.getSecondary()?j.getSecondary().id:null;P&&(j.available=c.availableImages.some(R=>Bn.isEqual(R,P)))}}return j}eachChild(c){if(c(this.namePrimary),this.paramsPrimary)for(const h in this.paramsPrimary)this.paramsPrimary[h]&&c(this.paramsPrimary[h]);if(this.nameSecondary&&(c(this.nameSecondary),this.paramsSecondary))for(const h in this.paramsSecondary)this.paramsSecondary[h]&&c(this.paramsSecondary[h])}outputDefined(){return!1}serializeOptions(c,h){const g={};if(h&&(g.iconset={id:h}),c){g.params={};for(const j in c)c[j]&&(g.params[j]=c[j].serialize())}return Object.keys(g).length>0?g:void 0}serialize(){const c=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const h=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);h&&c.push(h)}if(this.nameSecondary&&(c.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const h=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);h&&c.push(h)}return c}}function zw(x){return UC(x)?"string":Bw(x)?"number":$w(x)?"boolean":Array.isArray(x)?"array":x===null?"null":qC(x)?"object":typeof x}function qC(x){return x!=null&&!Array.isArray(x)&&typeof x!="function"&&!(x instanceof String||x instanceof Number||x instanceof Boolean)&&typeof x=="object"}function UC(x){return typeof x=="string"||x instanceof String}function Bw(x){return typeof x=="number"||x instanceof Number}function $w(x){return typeof x=="boolean"||x instanceof Boolean}const ipe={"to-boolean":ii,"to-color":bu,"to-number":Dr,"to-string":ri};class Ap{constructor(c,h){this.type=c,this.args=h}static parse(c,h){if(c.length<2)return h.error("Expected at least one argument.");const g=c[0],j=[];let T=Wx;if(g==="to-array"){if(!Array.isArray(c[1]))return null;const P=c[1].length;if(h.expectedType){if(h.expectedType.kind!=="array")return h.error(`Expected ${h.expectedType.kind} but found array.`);T=Kd(h.expectedType.itemType,P)}else{if(!(P>0&&B1(c[1][0])))return null;T=Kd(Oo(c[1][0]),P)}for(let R=0;R4?`Invalid rbga value ${JSON.stringify(h)}: expected an array containing either three or four numeric values.`:IO(h[0],h[1],h[2],h[3]),!g))return new la(h[0]/255,h[1]/255,h[2]/255,h[3])}throw new ol(g||`Could not parse color from value '${typeof h=="string"?h:String(JSON.stringify(h))}'`)}if(this.type.kind==="number"){let h=null;for(const g of this.args){if(h=g.evaluate(c),h===null)return 0;const j=Number(h);if(!isNaN(j))return j}throw new ol(`Could not convert ${JSON.stringify(h)} to number.`)}return this.type.kind==="formatted"?kd.fromString(Jr(this.args[0].evaluate(c))):this.type.kind==="resolvedImage"?Hu.build(Jr(this.args[0].evaluate(c))):this.type.kind==="array"?this.args.map(h=>h.evaluate(c)):Jr(this.args[0].evaluate(c))}eachChild(c){this.args.forEach(c)}outputDefined(){return this.args.every(c=>c.outputDefined())}serialize(){if(this.type.kind==="formatted")return new z0([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Wr(this.args[0]).serialize();const c=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(h=>{c.push(h.serialize())}),c}}const B0=["Unknown","Point","LineString","Polygon"];class qw{constructor(c,h,g){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=c,this.options=h,this.iconImageUseTheme=g}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?B0[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(c){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const c=this.featureDistanceData.center,h=this.featureDistanceData.scale,{x:g,y:j}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(g*h-c[0])+this.featureDistanceData.bearing[1]*(j*h-c[1])}return 0}parseColor(c){let h=this._parseColorCache[c];return h||(h=this._parseColorCache[c]=la.parse(c)),h}getConfig(c){return this.options?this.options.get(c):null}}class ac{constructor(c,h,g,j,T){this.name=c,this.type=h,this._evaluate=g,this.args=j,this._overloadIndex=T}evaluate(c){if(!this._evaluate){const h=ac.definitions[this.name];this._evaluate=Array.isArray(h)?h[2]:h.overloads[this._overloadIndex][1]}return this._evaluate(c,this.args)}eachChild(c){this.args.forEach(c)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(c=>c.serialize()))}static parse(c,h){const g=c[0],j=ac.definitions[g];if(!j)return h.error(`Unknown expression "${g}". If you wanted a literal array, use ["literal", [...]].`,0);const T=Array.isArray(j)?j[0]:j.type,P=Array.isArray(j)?[[j[1],j[2]]]:j.overloads,R=[];let F=null,H=-1;for(const[Q,se]of P){if(Array.isArray(Q)&&Q.length!==c.length-1)continue;R.push(Q),H++,F=new XC(h.registry,h.path,null,h.scope,void 0,h._scope,h.options,h.iconImageUseTheme);const re=[];let oe=!1;for(let ue=1;uere)).map(ry).join(" | "),se=[];for(let re=1;reh;){if(g-h>600){const F=g-h+1,H=c-h+1,Q=Math.log(F),se=.5*Math.exp(2*Q/3),re=.5*Math.sqrt(Q*se*(F-se)/F)*(H-F/2<0?-1:1);LO(x,c,Math.max(h,Math.floor(c-H*se/F+re)),Math.min(g,Math.floor(c+(F-H)*se/F+re)),j)}const T=x[c];let P=h,R=g;for(Uw(x,h,c),j(x[g],T)>0&&Uw(x,h,g);P0;)R--}j(x[h],T)===0?Uw(x,h,R):(R++,Uw(x,R,g)),R<=c&&(h=R+1),c<=R&&(g=R-1)}}function Uw(x,c,h){const g=x[c];x[c]=x[h],x[h]=g}function HC(x,c){return xc?1:0}function DO(x){let c=0;for(let h,g,j=0,T=x.length,P=T-1;j=c[2]||x[1]<=c[1]||x[3]>=c[3])}function ope(x,c,h){const g=x[0]-c[0],j=x[1]-c[1],T=x[0]-h[0],P=x[1]-h[1];return g*P-T*j===0&&g*T<=0&&j*P<=0}function $E(x,c,h){return c[1]>x[1]!=h[1]>x[1]&&x[0]<(h[0]-c[0])*(x[1]-c[1])/(h[1]-c[1])+c[0]}function $1(x,c,h=!1){let g=!1;for(let j=0,T=c.length;j0&&R<0||P<0&&R>0}function Hw(x,c,h,g){return(j=[g[0]-h[0],g[1]-h[1]])[0]*(T=[c[0]-x[0],c[1]-x[1]])[1]-j[1]*T[0]!==0&&!(!RO(x,c,h,g)||!RO(h,g,x,c));var j,T}function qE(x){const c=new Xt(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),h=new Xt(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const g of x[0])c.x>g.x&&(c.x=g.x),c.y>g.y&&(c.y=g.y),h.xh[2]){const j=.5*g;let T=x[0]-h[0]>j?-g:h[0]-x[0]>j?g:0;T===0&&(T=x[0]-h[2]>j?-g:h[2]-x[0]>j?g:0),x[0]+=T}Ep(c,x)}function HE(x,c,h,g){const j=Math.pow(2,g.z)*ny,T=[g.x*ny,g.y*ny],P=[];if(!x)return P;for(const R of x)for(const F of R){const H=[F.x+T[0],F.y+T[1]];qm(H,c,h,j),P.push(H)}return P}function GE(x,c,h,g){const j=Math.pow(2,g.z)*ny,T=[g.x*ny,g.y*ny],P=[];if(!x)return P;for(const F of x){const H=[];for(const Q of F){const se=[Q.x+T[0],Q.y+T[1]];Ep(c,se),H.push(se)}P.push(H)}if(c[2]-c[0]<=j/2){(R=c)[0]=R[1]=1/0,R[2]=R[3]=-1/0;for(const F of P)for(const H of F)qm(H,c,h,j)}var R;return P}class ay{constructor(c,h){this.type=ii,this.geojson=c,this.geometries=h}static parse(c,h){if(c.length!==2)return h.error(`'within' expression requires exactly one argument, but found ${c.length-1} instead.`);if(B1(c[1])){const g=c[1];if(g.type==="FeatureCollection")for(let j=0;jh)return WC(T,P,(h-(g-R))/R)}return c[c.length-1]}pointToSegmentDistance(c,h,g){let[j,T]=h,P=Yh(g[0]-j)*this.kx,R=(g[1]-T)*this.ky;if(P!==0||R!==0){const F=(Yh(c[0]-j)*this.kx*P+(c[1]-T)*this.ky*R)/(P*P+R*R);F>1?(j=g[0],T=g[1]):F>0&&(j+=P/this.kx*F,T+=R/this.ky*F)}return P=Yh(c[0]-j)*this.kx,R=(c[1]-T)*this.ky,Math.sqrt(P*P+R*R)}pointOnLine(c,h){let g=1/0,j=c[0][0],T=c[0][1],P=0,R=0;for(let F=0;F1?(H=c[F+1][0],Q=c[F+1][1]):oe>0&&(H+=se/this.kx*oe,Q+=re/this.ky*oe)),se=Yh(h[0]-H)*this.kx,re=(h[1]-Q)*this.ky;const ue=se*se+re*re;ueT.index||j.index===T.index&&j.t>T.t){const H=j;j=T,T=H}const P=[j.point],R=j.index+1,F=T.index;!ZE(g[R],P[0])&&R<=F&&P.push(g[R]);for(let H=R+1;H<=F;H++)P.push(g[H]);return ZE(g[F],T.point)||P.push(T.point),P}lineSliceAlong(c,h,g){let j=0;const T=[];for(let P=0;Pc&&T.length===0&&T.push(WC(R,F,(c-(j-H))/H)),j>=h)return T.push(WC(R,F,(h-(j-H))/H)),T;j>c&&T.push(F)}return T}bufferPoint(c,h){const g=h/this.ky,j=h/this.kx;return[c[0]-j,c[1]-g,c[0]+j,c[1]+g]}bufferBBox(c,h){const g=h/this.ky,j=h/this.kx;return[c[0]-j,c[1]-g,c[2]+j,c[3]+g]}insideBBox(c,h){return Yh(c[0]-h[0])>=0&&Yh(c[0]-h[2])<=0&&c[1]>=h[1]&&c[1]<=h[3]}}function ZE(x,c){return x[0]===c[0]&&x[1]===c[1]}function WC(x,c,h){const g=Yh(c[0]-x[0]);return[x[0]+g*h,x[1]+(c[1]-x[1])*h]}function Yh(x){for(;x<-180;)x+=360;for(;x>180;)x-=360;return x}class Ww{constructor(c=[],h=(g,j)=>gj?1:0){if(this.data=c,this.length=this.data.length,this.compare=h,this.length>0)for(let g=(this.length>>1)-1;g>=0;g--)this._down(g)}push(c){this.data.push(c),this._up(this.length++)}pop(){if(this.length===0)return;const c=this.data[0],h=this.data.pop();return--this.length>0&&(this.data[0]=h,this._down(0)),c}peek(){return this.data[0]}_up(c){const{data:h,compare:g}=this,j=h[c];for(;c>0;){const T=c-1>>1,P=h[T];if(g(j,P)>=0)break;h[c]=P,c=T}h[c]=j}_down(c){const{data:h,compare:g}=this,j=this.length>>1,T=h[c];for(;c=0)break;h[c]=h[P],c=P}h[c]=T}}var sr=8192;function FO(x,c){return c.dist-x.dist}function zO(x){const c=[1/0,1/0,-1/0,-1/0];if(c.length!==x.length)return!1;for(let h=0;h=x[0]&&x[1]x[1])return[null,null];const h=q0(x);if(c){if(h===2)return[x,null];const g=Math.floor(h/2);return[[x[0],x[0]+g],[x[0]+g,x[1]]]}{if(h===1)return[x,null];const g=Math.floor(h/2)-1;return[[x[0],x[0]+g],[x[0]+g+1,x[1]]]}}function iy(x,c){const h=[1/0,1/0,-1/0,-1/0];if(!Pp(c,x.length))return h;for(let g=c[0];g<=c[1];++g)Ep(h,x[g]);return h}function Kw(x){const c=[1/0,1/0,-1/0,-1/0];for(let h=0;hc[2]&&(g=x[0]-c[2]),x[1]>c[3]&&(j=x[1]-c[3]),x[3]=g)return g;if(Vw(j,T)){if(VO(x,c))return 0}else if(VO(c,x))return 0;let P=g;for(const R of x)for(let F=0,H=R.length,Q=H-1;F=T)continue;const Q=H.range1;if(q0(Q)<=R){if(!Pp(Q,x.length))return NaN;if(c){const se=ao(x,Q,h,g);if((T=Math.min(T,se))===0)return T}else for(let se=Q[0];se<=Q[1];++se){const re=hpe(x[se],h,g);if((T=Math.min(T,re))===0)return T}}else{const se=V1(Q,c);if(se[0]!==null){const re=H1(iy(x,se[0]),F,g);re=P)continue;const se=Q.range1,re=Q.range2;if(q0(se)<=F&&q0(re)<=H){if(!Pp(se,x.length)||!Pp(re,h.length))return NaN;if(c&&g?P=Math.min(P,upe(x,se,h,re,j)):c||g?c&&!g?P=Math.min(P,qO(h,re,x,se,j)):!c&&g&&(P=Math.min(P,qO(x,se,h,re,j))):P=Math.min(P,UO(x,se,h,re,j)),P===0)return P}else{const oe=V1(se,c),ue=V1(re,g);KC(R,P,j,x,h,oe[0],ue[0]),KC(R,P,j,x,h,oe[0],ue[1]),KC(R,P,j,x,h,oe[1],ue[0]),KC(R,P,j,x,h,oe[1],ue[1])}}return P}function XE(x,c,h,g,j=1/0){let T=j;const P=iy(x,[0,x.length-1]);for(const R of h)if(!(T!==1/0&&H1(P,iy(R,[0,R.length-1]),g)>=T)&&(T=Math.min(T,HO(x,c,R,!0,g,T)),T===0))return T;return T}function ZC(x,c,h,g,j=1/0){let T=j;const P=iy(x,[0,x.length-1]);for(const R of h){if(T!==1/0&&H1(P,Kw(R),g)>=T)continue;const F=ppe(x,c,R,g,T);if(isNaN(F))return F;if((T=Math.min(T,F))===0)return T}return T}function QE(x){return x==="Point"||x==="MultiPoint"||x==="LineString"||x==="MultiLineString"||x==="Polygon"||x==="MultiPolygon"}class U0{constructor(c,h){this.type=Dr,this.geojson=c,this.geometries=h}static parse(c,h){if(c.length!==2)return h.error(`'distance' expression requires either one argument, but found ' ${c.length-1} instead.`);if(B1(c[1])){const g=c[1];if(g.type==="FeatureCollection"){for(let j=0;j{c&&!V0(h)&&(c=!1)}),c}function G1(x){if(x instanceof ac&&x.name==="feature-state")return!1;let c=!0;return x.eachChild(h=>{c&&!G1(h)&&(c=!1)}),c}function Df(x,c){if(x instanceof ac&&c.indexOf(x.name)>=0)return!1;let h=!0;return x.eachChild(g=>{h&&!Df(g,c)&&(h=!1)}),h}function GO(x,c,h){return[x,c,h].filter(Boolean).join("")}function JE(x,c){switch(x){case"string":return Jr(c);case"number":return+c;case"boolean":return!!c;case"color":return la.parse(c);case"formatted":return kd.fromString(Jr(c));case"resolvedImage":return Hu.build(Jr(c))}return c}function WO(x,c,h,g){return g!==void 0&&(x=g*Math.round(x/g)),c!==void 0&&xh&&(x=h),x}class W1{constructor(c,h,g,j=!1){this.type=c,this.key=h,this.scope=g,this.featureConstant=j}static parse(c,h){let g=h.expectedType;if(g==null&&(g=oi),c.length<2||c.length>3)return h.error("Invalid number of arguments for 'config' expression.");const j=h.parse(c[1],1);if(!(j instanceof kr))return h.error("Key name of 'config' expression must be a string literal.");let T,P=!0;const R=Jr(j.value);if(c.length>=3){const F=h.parse(c[2],2);if(!(F instanceof kr))return h.error("Scope of 'config' expression must be a string literal.");T=Jr(F.value)}if(h.options){const F=GO(R,T,h._scope),H=h.options.get(F);H&&(P=V0(H.value||H.default))}return new W1(g,R,T,P)}evaluate(c){const h=GO(this.key,this.scope,c.scope),g=c.getConfig(h);if(!g)return null;const{type:j,value:T,values:P,minValue:R,maxValue:F,stepValue:H}=g,Q=g.default.evaluate(c);let se=Q;if(T){const re=c.scope;c.scope=(re||"").split("").slice(1).join(""),se=T.evaluate(c),c.scope=re}return j&&(se=JE(j,se)),se===void 0||R===void 0&&F===void 0&&H===void 0||(typeof se=="number"?se=WO(se,R,F,H):Array.isArray(se)&&(se=se.map(re=>typeof re=="number"?WO(re,R,F,H):re))),T!==void 0&&se!==void 0&&P&&!P.includes(se)&&(se=Q,j&&(se=JE(j,se))),(j&&j!==this.type||se!==void 0&&!Kx(Oo(se),this.type))&&(se=JE(this.type.kind,se)),se}eachChild(){}outputDefined(){return!1}serialize(){const c=["config",this.key];return this.scope&&c.concat(this.scope),c}}class YC{constructor(c,h){this.type=h.type,this.name=c,this.boundExpression=h}static parse(c,h){if(c.length!==2||typeof c[1]!="string")return h.error("'var' expression requires exactly one string literal argument.");const g=c[1];return h.scope.has(g)?new YC(g,h.scope.get(g)):h.error(`Unknown variable "${g}". Make sure "${g}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(c){return this.boundExpression.evaluate(c)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class XC{constructor(c,h=[],g,j=new O0,T=[],P,R,F){this.registry=c,this.path=h,this.key=h.map(H=>typeof H=="string"?`['${H}']`:`[${H}]`).join(""),this.scope=j,this.errors=T,this.expectedType=g,this._scope=P,this.options=R,this.iconImageUseTheme=F}parse(c,h,g,j,T={}){return h||g?this.concat(h,null,g,j)._parse(c,T):this._parse(c,T)}parseObjectValue(c,h,g,j,T,P={}){return this.concat(h,g,j,T)._parse(c,P)}_parse(c,h){function g(j,T,P){return P==="assert"?new Zh(T,[j]):P==="coerce"?new Ap(T,[j]):j}if(c!==null&&typeof c!="string"&&typeof c!="boolean"&&typeof c!="number"||(c=["literal",c]),Array.isArray(c)){if(c.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const j=typeof c[0]=="string"?this.registry[c[0]]:void 0;if(j){let T=j.parse(c,this);if(!T)return null;if(this.expectedType){const P=this.expectedType,R=T.type;if(P.kind!=="string"&&P.kind!=="number"&&P.kind!=="boolean"&&P.kind!=="object"&&P.kind!=="array"||R.kind!=="value")if(P.kind!=="color"&&P.kind!=="formatted"&&P.kind!=="resolvedImage"||R.kind!=="value"&&R.kind!=="string"){if(this.checkSubtype(P,R))return null}else T=g(T,P,h.typeAnnotation||"coerce");else T=g(T,P,h.typeAnnotation||"assert")}if(!(T instanceof kr)&&T.type.kind!=="resolvedImage"&&eP(T)){const P=new qw(this._scope,this.options,this.iconImageUseTheme);try{T=new kr(T.type,T.evaluate(P))}catch(R){return this.error(R.message),null}}return T}return Ap.parse(["to-array",c],this)}return this.error(c===void 0?"'undefined' value invalid. Use null instead.":typeof c=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof c} instead.`)}concat(c,h,g,j){let T=typeof c=="number"?this.path.concat(c):this.path;T=typeof h=="string"?T.concat(h):T;const P=j?this.scope.concat(j):this.scope;return new XC(this.registry,T,g||null,P,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(c,...h){const g=`${this.key}${h.map(j=>`[${j}]`).join("")}`;this.errors.push(new Bm(g,c))}checkSubtype(c,h){const g=Ow(c,h);return g&&this.error(g),g}}function eP(x){if(x instanceof YC)return eP(x.boundExpression);if(x instanceof ac&&x.name==="error"||x instanceof VC||x instanceof ay||x instanceof U0||x instanceof W1)return!1;const c=x instanceof Ap||x instanceof Zh;let h=!0;return x.eachChild(g=>{h=c?h&&eP(g):h&&g instanceof kr}),!!h&&V0(x)&&Df(x,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed","is-active-floor"])}function QC(x,c){const h=x.length-1;let g,j,T=0,P=h,R=0;for(;T<=P;)if(R=Math.floor((T+P)/2),g=x[R],j=x[R+1],g<=c){if(R===h||cc))throw new ol("Input is not a number.");P=R-1}return 0}class Zw{constructor(c,h,g){this.type=c,this.input=h,this.labels=[],this.outputs=[];for(const[j,T]of g)this.labels.push(j),this.outputs.push(T)}static parse(c,h){if(c.length-1<4)return h.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if((c.length-1)%2!=0)return h.error("Expected an even number of arguments.");const g=h.parse(c[1],1,Dr);if(!g)return null;const j=[];let T=null;h.expectedType&&h.expectedType.kind!=="value"&&(T=h.expectedType);for(let P=1;P=R)return h.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',H);const se=h.parse(F,Q,T);if(!se)return null;T=T||se.type,j.push([R,se])}return new Zw(T,g,j)}evaluate(c){const h=this.labels,g=this.outputs;if(h.length===1)return g[0].evaluate(c);const j=this.input.evaluate(c);if(j<=h[0])return g[0].evaluate(c);const T=h.length;return j>=h[T-1]?g[T-1].evaluate(c):g[QC(h,j)].evaluate(c)}eachChild(c){c(this.input);for(const h of this.outputs)c(h)}outputDefined(){return this.outputs.every(c=>c.outputDefined())}serialize(){const c=["step",this.input.serialize()];for(let h=0;h0&&c.push(this.labels[h]),c.push(this.outputs[h].serialize());return c}}const KO=.95047,ZO=1.08883,YO=4/29,K1=6/29,XO=3*K1*K1,fpe=K1*K1*K1,xpe=Math.PI/180,gpe=180/Math.PI;function tP(x){return x>fpe?Math.pow(x,1/3):x/XO+YO}function sP(x){return x>K1?x*x*x:XO*(x-YO)}function Yw(x){return 255*(x<=.0031308?12.92*x:1.055*Math.pow(x,1/2.4)-.055)}function Z1(x){return(x/=255)<=.04045?x/12.92:Math.pow((x+.055)/1.055,2.4)}function rP(x){const c=Z1(x.r),h=Z1(x.g),g=Z1(x.b),j=tP((.4124564*c+.3575761*h+.1804375*g)/KO),T=tP((.2126729*c+.7151522*h+.072175*g)/1);return{l:116*T-16,a:500*(j-T),b:200*(T-tP((.0193339*c+.119192*h+.9503041*g)/ZO)),alpha:x.a}}function QO(x){let c=(x.l+16)/116,h=isNaN(x.a)?c:c+x.a/500,g=isNaN(x.b)?c:c-x.b/200;return c=1*sP(c),h=KO*sP(h),g=ZO*sP(g),new la(Yw(3.2404542*h-1.5371385*c-.4985314*g),Yw(-.969266*h+1.8760108*c+.041556*g),Yw(.0556434*h-.2040259*c+1.0572252*g),x.alpha)}function ype(x,c,h){const g=c-x;return x+h*(g>180||g<-180?g-360*Math.round(g/360):g)}const Xw={forward:rP,reverse:QO,interpolate:function(x,c,h){return{l:en(x.l,c.l,h),a:en(x.a,c.a,h),b:en(x.b,c.b,h),alpha:en(x.alpha,c.alpha,h)}}},Y1={forward:function(x){const{l:c,a:h,b:g}=rP(x),j=Math.atan2(g,h)*gpe;return{h:j<0?j+360:j,c:Math.sqrt(h*h+g*g),l:c,alpha:x.a}},reverse:function(x){const c=x.h*xpe,h=x.c;return QO({l:x.l,a:Math.cos(c)*h,b:Math.sin(c)*h,alpha:x.alpha})},interpolate:function(x,c,h){return{h:ype(x.h,c.h,h),c:en(x.c,c.c,h),l:en(x.l,c.l,h),alpha:en(x.alpha,c.alpha,h)}}};var nP=Object.freeze({__proto__:null,hcl:Y1,lab:Xw});class Sd{constructor(c,h,g,j,T){this.type=c,this.operator=h,this.interpolation=g,this.input=j,this.labels=[],this.outputs=[];for(const[P,R]of T)this.labels.push(P),this.outputs.push(R)}static interpolationFactor(c,h,g,j){let T=0;if(c.name==="exponential")T=JC(h,c.base,g,j);else if(c.name==="linear")T=JC(h,1,g,j);else if(c.name==="cubic-bezier"){const P=c.controlPoints;T=new $a(P[0],P[1],P[2],P[3]).solve(JC(h,1,g,j))}return T}static parse(c,h){let[g,j,T,...P]=c;if(!Array.isArray(j)||j.length===0)return h.error("Expected an interpolation type expression.",1);if(j[0]==="linear")j={name:"linear"};else if(j[0]==="exponential"){const H=j[1];if(typeof H!="number")return h.error("Exponential interpolation requires a numeric base.",1,1);j={name:"exponential",base:H}}else{if(j[0]!=="cubic-bezier")return h.error(`Unknown interpolation type ${String(j[0])}`,1,0);{const H=j.slice(1);if(H.length!==4||H.some(Q=>typeof Q!="number"||Q<0||Q>1))return h.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);j={name:"cubic-bezier",controlPoints:H}}}if(c.length-1<4)return h.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if(c.length-1>3&&(c.length-1)%2!=0)return h.error("Expected an even number of arguments.");if(T=h.parse(T,2,Dr),!T)return null;const R=[];let F=null;g==="interpolate-hcl"||g==="interpolate-lab"?F=bu:h.expectedType&&h.expectedType.kind!=="value"&&(F=h.expectedType);for(let H=0;H=Q)return h.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',re);const ue=h.parse(se,oe,F);if(!ue)return null;F=F||ue.type,R.push([Q,ue])}return F.kind==="number"||F.kind==="color"||F.kind==="array"&&F.itemType.kind==="number"&&typeof F.N=="number"?new Sd(F,g,j,T,R):h.error(`Type ${Nl(F)} is not interpolatable.`)}evaluate(c){const h=this.labels,g=this.outputs;if(h.length===1)return g[0].evaluate(c);const j=this.input.evaluate(c);if(j<=h[0])return g[0].evaluate(c);const T=h.length;if(j>=h[T-1])return g[T-1].evaluate(c);const P=QC(h,j),R=Sd.interpolationFactor(this.interpolation,j,h[P],h[P+1]),F=g[P].evaluate(c),H=g[P+1].evaluate(c);return this.operator==="interpolate"?$C[this.type.kind.toLowerCase()](F,H,R):this.operator==="interpolate-hcl"?Y1.reverse(Y1.interpolate(Y1.forward(F),Y1.forward(H),R)):Xw.reverse(Xw.interpolate(Xw.forward(F),Xw.forward(H),R))}eachChild(c){c(this.input);for(const h of this.outputs)c(h)}outputDefined(){return this.outputs.every(c=>c.outputDefined())}serialize(){let c;c=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const h=[this.operator,c,this.input.serialize()];for(let g=0;gOw(j,R.type));return new Qw(P?oi:g,T)}evaluate(c){let h,g=null,j=0;for(const T of this.args){if(j++,g=T.evaluate(c),g&&g instanceof Hu&&!g.available&&(h||(h=g),g=null,j===this.args.length))return h;if(g!==null)break}return g}eachChild(c){this.args.forEach(c)}outputDefined(){return this.args.every(c=>c.outputDefined())}serialize(){const c=["coalesce"];return this.eachChild(h=>{c.push(h.serialize())}),c}}class e3{constructor(c,h){this.type=h.type,this.bindings=[].concat(c),this.result=h}evaluate(c){return this.result.evaluate(c)}eachChild(c){for(const h of this.bindings)c(h[1]);c(this.result)}static parse(c,h){if(c.length<4)return h.error(`Expected at least 3 arguments, but found ${c.length-1} instead.`);const g=[];for(let T=1;T=g.length)throw new ol("Array index out of bounds: index exceeds array size");if(h!==Math.floor(h))throw new ol("Array index must be an integer. Use at-interpolated for fractional indices");return g[h]}eachChild(c){c(this.index),c(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class e2{constructor(c,h,g){this.type=c,this.index=h,this.input=g}static parse(c,h){if(c.length!==3)return h.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const g=h.parse(c[1],1,Dr),j=h.parse(c[2],2,Kd(h.expectedType||oi));return g&&j?new e2(j.type.itemType,g,j):null}evaluate(c){const h=this.index.evaluate(c),g=this.input.evaluate(c);if(h<0)throw new ol(`Array index out of bounds: ${h} < 0.`);if(h>g.length-1)throw new ol(`Array index out of bounds: ${h} > ${g.length-1}.`);if(h===Math.floor(h))return g[h];const j=Math.floor(h),T=Math.ceil(h),P=g[j],R=g[T];if(typeof P!="number"||typeof R!="number")throw new ol(`Cannot interpolate between non-number values at index ${h}.`);const F=h-j;return P*(1-F)+R*F}eachChild(c){c(this.index),c(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class t2{constructor(c,h){this.type=ii,this.needle=c,this.haystack=h}static parse(c,h){if(c.length!==3)return h.error(`Expected 2 arguments, but found ${c.length-1} instead.`),null;const g=h.parse(c[1],1,oi),j=h.parse(c[2],2,oi);return g&&j?zE(g.type,[ii,ri,Dr,Wx,oi])?new t2(g,j):(h.error(`Expected first argument to be of type boolean, string, number or null, but found ${Nl(g.type)} instead`),null):null}evaluate(c){const h=this.needle.evaluate(c),g=this.haystack.evaluate(c);if(g==null)return!1;if(!z1(h,["boolean","string","number","null"]))throw new ol(`Expected first argument to be of type boolean, string, number or null, but found ${Nl(Oo(h))} instead.`);if(!z1(g,["string","array"]))throw new ol(`Expected second argument to be of type array or string, but found ${Nl(Oo(g))} instead.`);return g.indexOf(h)>=0}eachChild(c){c(this.needle),c(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class t3{constructor(c,h,g){this.type=Dr,this.needle=c,this.haystack=h,this.fromIndex=g}static parse(c,h){if(c.length<=2||c.length>=5)return h.error(`Expected 3 or 4 arguments, but found ${c.length-1} instead.`),null;const g=h.parse(c[1],1,oi),j=h.parse(c[2],2,oi);if(!g||!j)return null;if(!zE(g.type,[ii,ri,Dr,Wx,oi]))return h.error(`Expected first argument to be of type boolean, string, number or null, but found ${Nl(g.type)} instead`),null;if(c.length===4){const T=h.parse(c[3],3,Dr);return T?new t3(g,j,T):null}return new t3(g,j)}evaluate(c){const h=this.needle.evaluate(c),g=this.haystack.evaluate(c);if(!z1(h,["boolean","string","number","null"]))throw new ol(`Expected first argument to be of type boolean, string, number or null, but found ${Nl(Oo(h))} instead.`);if(!z1(g,["string","array"]))throw new ol(`Expected second argument to be of type array or string, but found ${Nl(Oo(g))} instead.`);if(this.fromIndex){const j=this.fromIndex.evaluate(c);return g.indexOf(h,j)}return g.indexOf(h)}eachChild(c){c(this.needle),c(this.haystack),this.fromIndex&&c(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const c=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),c]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class aP{constructor(c,h,g,j,T,P){this.inputType=c,this.type=h,this.input=g,this.cases=j,this.outputs=T,this.otherwise=P}static parse(c,h){if(c.length<5)return h.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if(c.length%2!=1)return h.error("Expected an even number of arguments.");let g,j;h.expectedType&&h.expectedType.kind!=="value"&&(j=h.expectedType);const T={},P=[];for(let H=2;HNumber.MAX_SAFE_INTEGER)return re.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof ue=="number"&&Math.floor(ue)!==ue)return re.error("Numeric branch labels must be integer values.");if(g){if(re.checkSubtype(g,Oo(ue)))return null}else g=Oo(ue);if(T[String(ue)]!==void 0)return re.error("Branch labels must be unique.");T[String(ue)]=P.length}const oe=h.parse(se,H,j);if(!oe)return null;j=j||oe.type,P.push(oe)}const R=h.parse(c[1],1,oi);if(!R)return null;const F=h.parse(c[c.length-1],c.length-1,j);return F?R.type.kind!=="value"&&h.concat(1).checkSubtype(g,R.type)?null:new aP(g,j,R,T,P,F):null}evaluate(c){const h=this.input.evaluate(c);return(Kx(Oo(h),this.inputType)&&this.outputs[this.cases[h]]||this.otherwise).evaluate(c)}eachChild(c){c(this.input),this.outputs.forEach(c),c(this.otherwise)}outputDefined(){return this.outputs.every(c=>c.outputDefined())&&this.otherwise.outputDefined()}serialize(){const c=["match",this.input.serialize()],h=Object.keys(this.cases).sort(),g=[],j={};for(const P of h){const R=j[this.cases[P]];R===void 0?(j[this.cases[P]]=g.length,g.push([this.cases[P],[P]])):g[R][1].push(P)}const T=P=>this.inputType.kind==="number"?Number(P):P;for(const[P,R]of g)c.push(R.length===1?T(R[0]):R.map(T)),c.push(this.outputs[P].serialize());return c.push(this.otherwise.serialize()),c}}class s3{constructor(c,h,g){this.type=c,this.branches=h,this.otherwise=g}static parse(c,h){if(c.length<4)return h.error(`Expected at least 3 arguments, but found only ${c.length-1}.`),null;if(c.length%2!=0)return h.error("Expected an odd number of arguments."),null;let g;h.expectedType&&h.expectedType.kind!=="value"&&(g=h.expectedType);const j=[];for(let P=1;Ph.outputDefined())&&this.otherwise.outputDefined()}serialize(){const c=["case"];return this.eachChild(h=>{c.push(h.serialize())}),c}}class s2{constructor(c,h,g,j){this.type=c,this.input=h,this.beginIndex=g,this.endIndex=j}static parse(c,h){if(c.length<=2||c.length>=5)return h.error(`Expected 3 or 4 arguments, but found ${c.length-1} instead.`),null;const g=h.parse(c[1],1,oi),j=h.parse(c[2],2,Dr);if(!g||!j)return null;if(!zE(g.type,[Kd(oi),ri,oi]))return h.error(`Expected first argument to be of type array or string, but found ${Nl(g.type)} instead`),null;if(c.length===4){const T=h.parse(c[3],3,Dr);return T?new s2(g.type,g,j,T):null}return new s2(g.type,g,j)}evaluate(c){const h=this.input.evaluate(c),g=this.beginIndex.evaluate(c);if(!z1(h,["string","array"]))throw new ol(`Expected first argument to be of type array or string, but found ${Nl(Oo(h))} instead.`);if(this.endIndex){const j=this.endIndex.evaluate(c);return h.slice(g,j)}return h.slice(g)}eachChild(c){c(this.input),c(this.beginIndex),this.endIndex&&c(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const c=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),c]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class iP{constructor(c,h){this.type=Kd(ri),this.str=c,this.delimiter=h}static parse(c,h){if(c.length!==3)return h.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const g=h.parse(c[1],1,ri),j=h.parse(c[2],2,ri);return g&&j?new iP(g,j):void 0}evaluate(c){const h=this.str.evaluate(c),g=this.delimiter.evaluate(c);return h.split(g)}eachChild(c){c(this.str),c(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function JO(x,c){return x==="=="||x==="!="?c.kind==="boolean"||c.kind==="string"||c.kind==="number"||c.kind==="null"||c.kind==="value":c.kind==="string"||c.kind==="number"||c.kind==="value"}function eF(x,c,h,g){return g.compare(c,h)===0}function H0(x,c,h){const g=x!=="=="&&x!=="!=";return class UGe{constructor(T,P,R){this.type=ii,this.lhs=T,this.rhs=P,this.collator=R,this.hasUntypedArgument=T.type.kind==="value"||P.type.kind==="value"}static parse(T,P){if(T.length!==3&&T.length!==4)return P.error("Expected two or three arguments.");const R=T[0];let F=P.parse(T[1],1,oi);if(!F)return null;if(!JO(R,F.type))return P.concat(1).error(`"${R}" comparisons are not supported for type '${Nl(F.type)}'.`);let H=P.parse(T[2],2,oi);if(!H)return null;if(!JO(R,H.type))return P.concat(2).error(`"${R}" comparisons are not supported for type '${Nl(H.type)}'.`);if(F.type.kind!==H.type.kind&&F.type.kind!=="value"&&H.type.kind!=="value")return P.error(`Cannot compare types '${Nl(F.type)}' and '${Nl(H.type)}'.`);g&&(F.type.kind==="value"&&H.type.kind!=="value"?F=new Zh(H.type,[F]):F.type.kind!=="value"&&H.type.kind==="value"&&(H=new Zh(F.type,[H])));let Q=null;if(T.length===4){if(F.type.kind!=="string"&&H.type.kind!=="string"&&F.type.kind!=="value"&&H.type.kind!=="value")return P.error("Cannot use collator to compare non-string types.");if(Q=P.parse(T[3],3,F0),!Q)return null}return new UGe(F,H,Q)}evaluate(T){const P=this.lhs.evaluate(T),R=this.rhs.evaluate(T);if(g&&this.hasUntypedArgument){const F=Oo(P),H=Oo(R);if(F.kind!==H.kind||F.kind!=="string"&&F.kind!=="number")throw new ol(`Expected arguments for "${x}" to be (string, string) or (number, number), but found (${F.kind}, ${H.kind}) instead.`)}if(this.collator&&!g&&this.hasUntypedArgument){const F=Oo(P),H=Oo(R);if(F.kind!=="string"||H.kind!=="string")return c(T,P,R)}return this.collator?h(T,P,R,this.collator.evaluate(T)):c(T,P,R)}eachChild(T){T(this.lhs),T(this.rhs),this.collator&&T(this.collator)}outputDefined(){return!0}serialize(){const T=[x];return this.eachChild(P=>{T.push(P.serialize())}),T}}}const tF=H0("==",function(x,c,h){return c===h},eF),r3=H0("!=",function(x,c,h){return c!==h},function(x,c,h,g){return!eF(0,c,h,g)}),vpe=H0("<",function(x,c,h){return c",function(x,c,h){return c>h},function(x,c,h,g){return g.compare(c,h)>0}),_pe=H0("<=",function(x,c,h){return c<=h},function(x,c,h,g){return g.compare(c,h)<=0}),bpe=H0(">=",function(x,c,h){return c>=h},function(x,c,h,g){return g.compare(c,h)>=0});class n3{constructor(c,h,g,j,T,P){this.type=ri,this.number=c,this.locale=h,this.currency=g,this.unit=j,this.minFractionDigits=T,this.maxFractionDigits=P}static parse(c,h){if(c.length!==3)return h.error("Expected two arguments.");const g=h.parse(c[1],1,Dr);if(!g)return null;const j=c[2];if(typeof j!="object"||Array.isArray(j))return h.error("NumberFormat options argument must be an object.");let T=null;if(j.locale&&(T=h.parseObjectValue(j.locale,2,"locale",ri),!T))return null;let P=null;if(j.currency&&(P=h.parseObjectValue(j.currency,2,"currency",ri),!P))return null;let R=null;if(j.unit&&(R=h.parseObjectValue(j.unit,2,"unit",ri),!R))return null;let F=null;if(j["min-fraction-digits"]&&(F=h.parseObjectValue(j["min-fraction-digits"],2,"min-fraction-digits",Dr),!F))return null;let H=null;return j["max-fraction-digits"]&&(H=h.parseObjectValue(j["max-fraction-digits"],2,"max-fraction-digits",Dr),!H)?null:new n3(g,T,P,R,F,H)}evaluate(c){return new Intl.NumberFormat(this.locale?this.locale.evaluate(c):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(c):void 0,unit:this.unit?this.unit.evaluate(c):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(c):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(c):void 0}).format(this.number.evaluate(c))}eachChild(c){c(this.number),this.locale&&c(this.locale),this.currency&&c(this.currency),this.unit&&c(this.unit),this.minFractionDigits&&c(this.minFractionDigits),this.maxFractionDigits&&c(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const c={};return this.locale&&(c.locale=this.locale.serialize()),this.currency&&(c.currency=this.currency.serialize()),this.unit&&(c.unit=this.unit.serialize()),this.minFractionDigits&&(c["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(c["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),c]}}class a3{constructor(c){this.type=Dr,this.input=c}static parse(c,h){if(c.length!==2)return h.error(`Expected 1 argument, but found ${c.length-1} instead.`),null;const g=h.parse(c[1],1);return g?g.type.kind!=="array"&&g.type.kind!=="string"&&g.type.kind!=="value"?(h.error(`Expected argument of type string or array, but found ${Nl(g.type)} instead.`),null):new a3(g):null}evaluate(c){const h=this.input.evaluate(c);if(typeof h=="string"||Array.isArray(h))return h.length;throw new ol(`Expected value to be of type string or array, but found ${Nl(Oo(h))} instead.`)}eachChild(c){c(this.input)}outputDefined(){return!1}serialize(){const c=["length"];return this.eachChild(h=>{c.push(h.serialize())}),c}}function rF(x){return function(){x=1831565813+(x|=0)|0;let c=Math.imul(x^x>>>15,1|x);return c=c+Math.imul(c^c>>>7,61|c)^c,((c^c>>>14)>>>0)/4294967296}}const X1={"==":tF,"!=":r3,">":sF,"<":vpe,">=":bpe,"<=":_pe,array:Zh,at:Jw,"at-interpolated":e2,boolean:Zh,case:s3,coalesce:Qw,collator:VC,format:z0,image:Wr,in:t2,"index-of":t3,interpolate:Sd,"interpolate-hcl":Sd,"interpolate-lab":Sd,length:a3,let:e3,literal:kr,match:aP,number:Zh,"number-format":n3,object:Zh,slice:s2,step:Zw,string:Zh,"to-boolean":Ap,"to-color":Ap,"to-number":Ap,"to-string":Ap,var:YC,within:ay,distance:U0,config:W1,split:iP};function nF(x,[c,h,g,j]){c=c.evaluate(x),h=h.evaluate(x),g=g.evaluate(x);const T=j?j.evaluate(x):1,P=IO(c,h,g,T);if(P)throw new ol(P);return new la(c/255,h/255,g/255,T)}function aF(x,[c,h,g,j]){c=c.evaluate(x),h=h.evaluate(x),g=g.evaluate(x);const T=j?j.evaluate(x):1,P=function(H,Q,se,re){return typeof H=="number"&&H>=0&&H<=360?typeof Q=="number"&&Q>=0&&Q<=100&&typeof se=="number"&&se>=0&&se<=100?re===void 0||typeof re=="number"&&re>=0&&re<=1?null:`Invalid hsla value [${[H,Q,se,re].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof re=="number"?[H,Q,se,re]:[H,Q,se]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof re=="number"?[H,Q,se,re]:[H,Q,se]).join(", ")}]: 'h' must be between 0 and 360.`}(c,h,g,T);if(P)throw new ol(P);const R=`hsla(${c}, ${h}%, ${g}%, ${T})`,F=la.parse(R);if(!F)throw new ol(`Failed to parse HSLA color: ${R}`);return F}function r2(x,c){return x in c}function i3(x,c){const h=c[x];return h===void 0?null:h}function oy(x){return{type:x}}function o3(x){if(x instanceof W1)return new Set([x.key]);let c=new Set;return x.eachChild(h=>{c=new Set([...c,...o3(h)])}),c}function l3(x){if(x instanceof ac&&x.name==="is-active-floor")return!0;let c=!1;return x.eachChild(h=>{!c&&l3(h)&&(c=!0)}),c}function iF(x){return{result:"success",value:x}}function ly(x){return{result:"error",value:x}}function n2(x,c){return!!x&&!!x.parameters&&x.parameters.indexOf(c)>-1}function c3(x){return x["property-type"]==="data-driven"}function oF(x){return n2(x.expression,"measure-light")}function oP(x){return n2(x.expression,"zoom")}function d3(x){return!!x.expression&&x.expression.interpolated}function lP(x){return typeof x=="object"&&x!==null&&!Array.isArray(x)}function lF(x){return x}function cF(x,c){const h=c.type==="color",g=x.stops&&typeof x.stops[0][0]=="object",j=g||!(g||x.property!==void 0),T=x.type||(d3(c)?"exponential":"interval");if(h&&((x=Object.assign({},x)).stops&&(x.stops=x.stops.map(H=>[H[0],la.parse(H[1])])),x.default=la.parse(x.default?x.default:c.default)),x.colorSpace&&x.colorSpace!=="rgb"&&!nP[x.colorSpace])throw new Error(`Unknown color space: ${x.colorSpace}`);let P,R,F;if(T==="exponential")P=dF;else if(T==="interval")P=jpe;else if(T==="categorical"){P=wpe,R=Object.create(null);for(const H of x.stops)R[H[0]]=H[1];F=typeof x.stops[0][0]}else{if(T!=="identity")throw new Error(`Unknown function type "${T}"`);P=uF}if(g){const H={},Q=[];for(let oe=0;oeoe[0]),evaluate:({zoom:oe},ue)=>dF({stops:se,base:x.base},c,oe).evaluate(oe,ue)}}if(j){const H=T==="exponential"?{name:"exponential",base:x.base!==void 0?x.base:1}:null;return{kind:"camera",interpolationType:H,interpolationFactor:Sd.interpolationFactor.bind(void 0,H),zoomStops:x.stops.map(Q=>Q[0]),evaluate:({zoom:Q})=>P(x,c,Q,R,F)}}return{kind:"source",evaluate(H,Q){const se=Q&&Q.properties?Q.properties[x.property]:void 0;return se===void 0?Rf(x.default,c.default):P(x,c,se,R,F)}}}function Rf(x,c,h){return x!==void 0?x:c!==void 0?c:h!==void 0?h:void 0}function wpe(x,c,h,g,j){return Rf(typeof h===j?g[h]:void 0,x.default,c.default)}function jpe(x,c,h){if(!Bw(h))return Rf(x.default,c.default);const g=x.stops.length;if(g===1||h<=x.stops[0][0])return x.stops[0][1];if(h>=x.stops[g-1][0])return x.stops[g-1][1];const j=QC(x.stops.map(T=>T[0]),h);return x.stops[j][1]}function dF(x,c,h){const g=x.base!==void 0?x.base:1;if(!Bw(h))return Rf(x.default,c.default);const j=x.stops.length;if(j===1||h<=x.stops[0][0])return x.stops[0][1];if(h>=x.stops[j-1][0])return x.stops[j-1][1];const T=QC(x.stops.map(Q=>Q[0]),h),P=function(Q,se,re,oe){const ue=oe-re,_e=Q-re;return ue===0?0:se===1?_e/ue:(Math.pow(se,_e)-1)/(Math.pow(se,ue)-1)}(h,g,x.stops[T][0],x.stops[T+1][0]),R=x.stops[T][1],F=x.stops[T+1][1];let H=$C[c.type]||lF;if(x.colorSpace&&x.colorSpace!=="rgb"){const Q=nP[x.colorSpace];H=(se,re)=>Q.reverse(Q.interpolate(Q.forward(se),Q.forward(re),P))}return typeof R.evaluate=="function"?{evaluate(...Q){const se=R.evaluate.apply(void 0,Q),re=F.evaluate.apply(void 0,Q);if(se!==void 0&&re!==void 0)return H(se,re,P)}}:H(R,F,P)}function uF(x,c,h){return c.type==="color"?h=la.parse(h):c.type==="formatted"?h=kd.fromString(h.toString()):c.type==="resolvedImage"?h=Hu.build(h.toString()):zw(h)===c.type||c.type==="enum"&&c.values[h]||(h=void 0),Rf(h,x.default,c.default)}ac.register(X1,{error:[{kind:"error"},[ri],(x,[c])=>{throw new ol(c.evaluate(x))}],typeof:[ri,[oi],(x,[c])=>Nl(Oo(c.evaluate(x)))],"to-rgba":[Kd(Dr,4),[bu],(x,[c])=>c.evaluate(x).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Kd(Dr,4),[bu],(x,[c])=>c.evaluate(x).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[bu,[Dr,Dr,Dr],nF],rgba:[bu,[Dr,Dr,Dr,Dr],nF],hsl:[bu,[Dr,Dr,Dr],aF],hsla:[bu,[Dr,Dr,Dr,Dr],aF],has:{type:ii,overloads:[[[ri],(x,[c])=>r2(c.evaluate(x),x.properties())],[[ri,sy],(x,[c,h])=>r2(c.evaluate(x),h.evaluate(x))]]},get:{type:oi,overloads:[[[ri],(x,[c])=>i3(c.evaluate(x),x.properties())],[[ri,sy],(x,[c,h])=>i3(c.evaluate(x),h.evaluate(x))]]},"feature-state":[oi,[ri],(x,[c])=>i3(c.evaluate(x),x.featureState||{})],properties:[sy,[],x=>x.properties()],"geometry-type":[ri,[],x=>x.geometryType()],worldview:[ri,[],x=>x.globals.worldview||""],"is-active-floor":[ii,oy(ri),(x,c)=>{if(!(x.globals&&x.globals.activeFloors&&x.globals.activeFloors.size>0))return!1;if(c.length===0)return!0;const h=x.globals.activeFloors;return c.some(g=>{const j=g.evaluate(x);return h.has(j)})}],id:[oi,[],x=>x.id()],zoom:[Dr,[],x=>x.globals.zoom],pitch:[Dr,[],x=>x.globals.pitch||0],"distance-from-center":[Dr,[],x=>x.distanceFromCenter()],"measure-light":[Dr,[ri],(x,[c])=>x.measureLight(c.evaluate(x))],"heatmap-density":[Dr,[],x=>x.globals.heatmapDensity||0],"line-progress":[Dr,[],x=>x.globals.lineProgress||0],"raster-value":[Dr,[],x=>x.globals.rasterValue||0],"raster-particle-speed":[Dr,[],x=>x.globals.rasterParticleSpeed||0],"sky-radial-progress":[Dr,[],x=>x.globals.skyRadialProgress||0],accumulated:[oi,[],x=>x.globals.accumulated===void 0?null:x.globals.accumulated],"+":[Dr,oy(Dr),(x,c)=>{let h=0;for(const g of c)h+=g.evaluate(x);return h}],"*":[Dr,oy(Dr),(x,c)=>{let h=1;for(const g of c)h*=g.evaluate(x);return h}],"-":{type:Dr,overloads:[[[Dr,Dr],(x,[c,h])=>c.evaluate(x)-h.evaluate(x)],[[Dr],(x,[c])=>-c.evaluate(x)]]},"/":[Dr,[Dr,Dr],(x,[c,h])=>c.evaluate(x)/h.evaluate(x)],"%":[Dr,[Dr,Dr],(x,[c,h])=>c.evaluate(x)%h.evaluate(x)],ln2:[Dr,[],()=>Math.LN2],pi:[Dr,[],()=>Math.PI],e:[Dr,[],()=>Math.E],"^":[Dr,[Dr,Dr],(x,[c,h])=>Math.pow(c.evaluate(x),h.evaluate(x))],sqrt:[Dr,[Dr],(x,[c])=>Math.sqrt(c.evaluate(x))],log10:[Dr,[Dr],(x,[c])=>Math.log(c.evaluate(x))/Math.LN10],ln:[Dr,[Dr],(x,[c])=>Math.log(c.evaluate(x))],log2:[Dr,[Dr],(x,[c])=>Math.log2(c.evaluate(x))],sin:[Dr,[Dr],(x,[c])=>Math.sin(c.evaluate(x))],cos:[Dr,[Dr],(x,[c])=>Math.cos(c.evaluate(x))],tan:[Dr,[Dr],(x,[c])=>Math.tan(c.evaluate(x))],asin:[Dr,[Dr],(x,[c])=>Math.asin(c.evaluate(x))],acos:[Dr,[Dr],(x,[c])=>Math.acos(c.evaluate(x))],atan:[Dr,[Dr],(x,[c])=>Math.atan(c.evaluate(x))],min:[Dr,oy(Dr),(x,c)=>Math.min(...c.map(h=>h.evaluate(x)))],max:[Dr,oy(Dr),(x,c)=>Math.max(...c.map(h=>h.evaluate(x)))],abs:[Dr,[Dr],(x,[c])=>Math.abs(c.evaluate(x))],round:[Dr,[Dr],(x,[c])=>{const h=c.evaluate(x);return h<0?-Math.round(-h):Math.round(h)}],floor:[Dr,[Dr],(x,[c])=>Math.floor(c.evaluate(x))],ceil:[Dr,[Dr],(x,[c])=>Math.ceil(c.evaluate(x))],"filter-==":[ii,[ri,oi],(x,[c,h])=>x.properties()[c.value]===h.value],"filter-id-==":[ii,[oi],(x,[c])=>x.id()===c.value],"filter-type-==":[ii,[ri],(x,[c])=>x.geometryType()===c.value],"filter-<":[ii,[ri,oi],(x,[c,h])=>{const g=x.properties()[c.value],j=h.value;return typeof g==typeof j&&g{const h=x.id(),g=c.value;return typeof h==typeof g&&h":[ii,[ri,oi],(x,[c,h])=>{const g=x.properties()[c.value],j=h.value;return typeof g==typeof j&&g>j}],"filter-id->":[ii,[oi],(x,[c])=>{const h=x.id(),g=c.value;return typeof h==typeof g&&h>g}],"filter-<=":[ii,[ri,oi],(x,[c,h])=>{const g=x.properties()[c.value],j=h.value;return typeof g==typeof j&&g<=j}],"filter-id-<=":[ii,[oi],(x,[c])=>{const h=x.id(),g=c.value;return typeof h==typeof g&&h<=g}],"filter->=":[ii,[ri,oi],(x,[c,h])=>{const g=x.properties()[c.value],j=h.value;return typeof g==typeof j&&g>=j}],"filter-id->=":[ii,[oi],(x,[c])=>{const h=x.id(),g=c.value;return typeof h==typeof g&&h>=g}],"filter-has":[ii,[oi],(x,[c])=>c.value in x.properties()],"filter-has-id":[ii,[],x=>x.id()!==null&&x.id()!==void 0],"filter-type-in":[ii,[Kd(ri)],(x,[c])=>c.value.indexOf(x.geometryType())>=0],"filter-id-in":[ii,[Kd(oi)],(x,[c])=>c.value.indexOf(x.id())>=0],"filter-in-small":[ii,[ri,Kd(oi)],(x,[c,h])=>h.value.indexOf(x.properties()[c.value])>=0],"filter-in-large":[ii,[ri,Kd(oi)],(x,[c,h])=>function(g,j,T,P){for(;T<=P;){const R=T+P>>1;if(j[R]===g)return!0;j[R]>g?P=R-1:T=R+1}return!1}(x.properties()[c.value],h.value,0,h.value.length-1)],all:{type:ii,overloads:[[[ii,ii],(x,[c,h])=>c.evaluate(x)&&h.evaluate(x)],[oy(ii),(x,c)=>{for(const h of c)if(!h.evaluate(x))return!1;return!0}]]},any:{type:ii,overloads:[[[ii,ii],(x,[c,h])=>c.evaluate(x)||h.evaluate(x)],[oy(ii),(x,c)=>{for(const h of c)if(h.evaluate(x))return!0;return!1}]]},"!":[ii,[ii],(x,[c])=>!c.evaluate(x)],"is-supported-script":[ii,[ri],(x,[c])=>{const h=x.globals&&x.globals.isSupportedScript;return!h||h(c.evaluate(x))}],upcase:[ri,[ri],(x,[c])=>c.evaluate(x).toUpperCase()],downcase:[ri,[ri],(x,[c])=>c.evaluate(x).toLowerCase()],concat:[ri,oy(oi),(x,c)=>c.map(h=>Jr(h.evaluate(x))).join("")],"resolved-locale":[ri,[F0],(x,[c])=>c.evaluate(x).resolvedLocale()],random:[Dr,[Dr,Dr,oi],(x,c)=>{const[h,g,j]=c.map(P=>P.evaluate(x));if(h>g||h===g)return h;let T;if(typeof j=="string")T=function(P){let R=0;if(P.length===0)return R;for(let F=0;FJSON.stringify(se)).join(", ")}, but found ${JSON.stringify(Q)} instead.`);return Q}catch(Q){const se=Q;return this._warningHistory[se.message]||(this._warningHistory[se.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${se.message}`)),this._defaultValue}}}function a2(x){return Array.isArray(x)&&x.length>0&&typeof x[0]=="string"&&x[0]in X1}function cy(x,c,h,g,j){const T=new XC(X1,[],c?function(R){const F={color:bu,string:ri,number:Dr,enum:ri,boolean:ii,formatted:Dw,resolvedImage:Rw};return R.type==="array"?Kd(F[R.value]||oi,R.length):F[R.type]}(c):void 0,void 0,void 0,h,g,j),P=T.parse(x,void 0,void 0,void 0,c&&c.type==="string"?{typeAnnotation:"coerce"}:void 0);return P?iF(new u3(P,c,h,g,j)):ly(T.errors)}class Q1{constructor(c,h,g,j){this.kind=c,this._styleExpression=h,this.isLightConstant=g,this.isLineProgressConstant=j,this.isStateDependent=c!=="constant"&&!G1(h.expression),this.configDependencies=o3(h.expression),this.isIndoorDependent=l3(h.expression)}evaluateWithoutErrorHandling(c,h,g,j,T,P){return this._styleExpression.evaluateWithoutErrorHandling(c,h,g,j,T,P)}evaluate(c,h,g,j,T,P,R){return this._styleExpression.evaluate(c,h,g,j,T,P,void 0,void 0,R)}}class G0{constructor(c,h,g,j,T,P){this.kind=c,this.zoomStops=g,this._styleExpression=h,this.isStateDependent=c!=="camera"&&!G1(h.expression),this.isIndoorDependent=l3(h.expression),this.isLightConstant=T,this.isLineProgressConstant=P,this.configDependencies=o3(h.expression),this.interpolationType=j}evaluateWithoutErrorHandling(c,h,g,j,T,P){return this._styleExpression.evaluateWithoutErrorHandling(c,h,g,j,T,P)}evaluate(c,h,g,j,T,P){return this._styleExpression.evaluate(c,h,g,j,T,P)}interpolationFactor(c,h,g){return this.interpolationType?Sd.interpolationFactor(this.interpolationType,c,h,g):0}}function cP(x,c,h,g,j){if((x=cy(x,c,h,g,j)).result==="error")return x;const T=x.value.expression,P=V0(T);if(!P&&!c3(c))return ly([new Bm("","data expressions not supported")]);const R=Df(T,["zoom","pitch","distance-from-center"]);if(!R&&!oP(c))return ly([new Bm("","zoom expressions not supported")]);const F=Df(T,["measure-light"]);if(!F&&!oF(c))return ly([new Bm("","measure-light expression not supported")]);const H=Df(T,["line-progress"]);if(!H&&!function(re){return n2(re.expression,"line-progress")}(c))return ly([new Bm("","line-progress expression not supported")]);const Q=c.expression&&c.expression.relaxZoomRestriction,se=Ip(T);return se||R||Q?se instanceof Bm?ly([se]):se instanceof Sd&&!d3(c)?ly([new Bm("",'"interpolate" expressions cannot be used with this property')]):iF(se?new G0(P&&H?"camera":"composite",x.value,se.labels,se instanceof Sd?se.interpolation:void 0,F,H):new Q1(P&&H?"constant":"source",x.value,F,H)):ly([new Bm("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class h3{constructor(c,h){this._parameters=c,this._specification=h,Object.assign(this,cF(this._parameters,this._specification))}static deserialize(c){return new h3(c._parameters,c._specification)}static serialize(c){return{_parameters:c._parameters,_specification:c._specification}}}function Ip(x){let c=null;if(x instanceof e3)c=Ip(x.result);else if(x instanceof Qw){for(const h of x.args)if(c=Ip(h),c)break}else(x instanceof Zw||x instanceof Sd)&&x.input instanceof ac&&x.input.name==="zoom"&&(c=x);return c instanceof Bm||x.eachChild(h=>{const g=Ip(h);g instanceof Bm?c=g:c&&g&&c!==g&&(c=new Bm("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),c}var dP,hF,i2=function(){if(hF)return dP;hF=1,dP=c;var x=3;function c(h,g,j){var T=this.cells=[];if(h instanceof ArrayBuffer){this.arrayBuffer=h;var P=new Int32Array(this.arrayBuffer);h=P[0],this.d=(g=P[1])+2*(j=P[2]);for(var R=0;R=re[_e+0]&&T>=re[_e+1])?(F[ue]=!0,R.push(se[ue])):F[ue]=!1}}},c.prototype._forEachCell=function(h,g,j,T,P,R,F,H){for(var Q=this._convertToCellCoord(h),se=this._convertToCellCoord(g),re=this._convertToCellCoord(j),oe=this._convertToCellCoord(T),ue=Q;ue<=re;ue++)for(var _e=se;_e<=oe;_e++){var ke=this.d*_e+ue;if((!H||H(this._convertFromCellCoord(ue),this._convertFromCellCoord(_e),this._convertFromCellCoord(ue+1),this._convertFromCellCoord(_e+1)))&&P.call(this,h,g,j,T,ke,R,F,H))return}},c.prototype._convertFromCellCoord=function(h){return(h-this.padding)/this.scale},c.prototype._convertToCellCoord=function(h){return Math.max(0,Math.min(this.d-1,Math.floor(h*this.scale)+this.padding))},c.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var h=this.cells,g=x+this.cells.length+1+1,j=0,T=0;T=0||(j[T]=Yx(x[T],c)));x instanceof Error&&(j.message=x.message)}if(j.$name)throw new Error("$name property is reserved for worker serialization logic.");return g!=="Object"&&(j.$name=g),j}throw new Error("can't serialize object of type "+typeof x)}function dy(x){if(x==null||typeof x=="boolean"||typeof x=="number"||typeof x=="string"||x instanceof Boolean||x instanceof Number||x instanceof String||x instanceof Date||x instanceof RegExp||o2(x)||x instanceof ImageBitmap||ArrayBuffer.isView(x)||x instanceof ImageData)return x;if(Array.isArray(x))return x.map(dy);if(typeof x=="object"){const c=x.$name||"Object";if(c==="Map"){const j=x.entries||[],T=new Map;for(let P=0;Px>=1536&&x<=1791,m3=x=>x>=1872&&x<=1919,p3=x=>x>=2208&&x<=2303,f3=x=>x>=11904&&x<=12031,Xx=x=>x>=12032&&x<=12255,uP=x=>x>=12272&&x<=12287,l2=x=>x>=12288&&x<=12351,c2=x=>x>=12352&&x<=12447,K0=x=>x>=12448&&x<=12543,hP=x=>x>=12544&&x<=12591,x3=x=>x>=12704&&x<=12735,Of=x=>x>=12736&&x<=12783,pF=x=>x>=12784&&x<=12799,fF=x=>x>=12800&&x<=13055,xF=x=>x>=13056&&x<=13311,mP=x=>x>=13312&&x<=19903,g3=x=>x>=19968&&x<=40959,d2=x=>x>=40960&&x<=42127,pP=x=>x>=42128&&x<=42191,fP=x=>x>=44032&&x<=55215,y3=x=>x>=63744&&x<=64255,xP=x=>x>=64336&&x<=65023,gF=x=>x>=65040&&x<=65055,gP=x=>x>=65072&&x<=65103,yF=x=>x>=65104&&x<=65135,yP=x=>x>=65136&&x<=65279,vP=x=>x>=65280&&x<=65519;function _P(x){for(const c of x)if(bP(c.charCodeAt(0)))return!0;return!1}function Npe(x){for(const c of x)if(!kpe(c.charCodeAt(0)))return!1;return!0}function kpe(x){return!(mF(x)||m3(x)||p3(x)||xP(x)||yP(x))}function Spe(x){return!(x<11904||!(x3(x)||hP(x)||gP(x)||y3(x)||xF(x)||f3(x)||Of(x)||l2(x)||mP(x)||g3(x)||fF(x)||vP(x)||c2(x)||uP(x)||Xx(x)||pF(x)||K0(x)||gF(x)||pP(x)||d2(x)))}function bP(x){return!(x!==746&&x!==747&&(x<4352||!(x3(x)||hP(x)||gP(x)&&!(x>=65097&&x<=65103)||y3(x)||xF(x)||f3(x)||Of(x)||!(!l2(x)||x>=12296&&x<=12305||x>=12308&&x<=12319||x===12336)||mP(x)||g3(x)||fF(x)||(c=>c>=12592&&c<=12687)(x)||(c=>c>=43360&&c<=43391)(x)||(c=>c>=55216&&c<=55295)(x)||(c=>c>=4352&&c<=4607)(x)||fP(x)||c2(x)||uP(x)||(c=>c>=12688&&c<=12703)(x)||Xx(x)||pF(x)||K0(x)&&x!==12540||!(!vP(x)||x===65288||x===65289||x===65293||x>=65306&&x<=65310||x===65339||x===65341||x===65343||x>=65371&&x<=65503||x===65507||x>=65512&&x<=65519)||!(!yF(x)||x>=65112&&x<=65118||x>=65123&&x<=65126)||(c=>c>=5120&&c<=5759)(x)||(c=>c>=6320&&c<=6399)(x)||gF(x)||(c=>c>=19904&&c<=19967)(x)||d2(x)||pP(x))))}function vF(x){return x===12312||x===12313||x===12316||x===12540||x===12448}function Z0(x){return!(bP(x)||function(c){return!!((h=>h>=128&&h<=255)(c)&&(c===167||c===169||c===174||c===177||c===188||c===189||c===190||c===215||c===247)||(h=>h>=8192&&h<=8303)(c)&&(c===8214||c===8224||c===8225||c===8240||c===8241||c===8251||c===8252||c===8258||c===8263||c===8264||c===8265||c===8273)||(h=>h>=8448&&h<=8527)(c)||(h=>h>=8528&&h<=8591)(c)||(h=>h>=8960&&h<=9215)(c)&&(c>=8960&&c<=8967||c>=8972&&c<=8991||c>=8996&&c<=9e3||c===9003||c>=9085&&c<=9114||c>=9150&&c<=9165||c===9167||c>=9169&&c<=9179||c>=9186&&c<=9215)||(h=>h>=9216&&h<=9279)(c)&&c!==9251||(h=>h>=9280&&h<=9311)(c)||(h=>h>=9312&&h<=9471)(c)||(h=>h>=9632&&h<=9727)(c)||(h=>h>=9728&&h<=9983)(c)&&!(c>=9754&&c<=9759)||(h=>h>=11008&&h<=11263)(c)&&(c>=11026&&c<=11055||c>=11088&&c<=11097||c>=11192&&c<=11243)||l2(c)||K0(c)||(h=>h>=57344&&h<=63743)(c)||gP(c)||yF(c)||vP(c)||c===8734||c===8756||c===8757||c>=9984&&c<=10087||c>=10102&&c<=10131||c===65532||c===65533)}(x))}function _F(x){return mF(x)||m3(x)||p3(x)||xP(x)||yP(x)}function wP(x){return x>=1424&&x<=2303||xP(x)||yP(x)}function v3(x,c){return!(!c&&wP(x)||x>=2304&&x<=3583||x>=3840&&x<=4255||(h=>h>=6016&&h<=6143)(x))}function Cpe(x){for(const c of x)if(wP(c.charCodeAt(0)))return!0;return!1}const gh={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let Ff=null,Zd=gh.unavailable,Xh=null;const bF=function(x){x&&typeof x=="string"&&x.indexOf("NetworkError")>-1&&(Zd=gh.error),Ff&&Ff(x)};function jP(){NP.fire(new Ps("pluginStateChange",{pluginStatus:Zd,pluginURL:Xh}))}const NP=new Na,kP=function(){return Zd},wF=function(){if(Zd!==gh.deferred||!Xh)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Zd=gh.loading,jP(),Xh&&If({url:Xh},x=>{x?bF(x):(Zd=gh.loaded,jP())})},Qx={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Zd===gh.loaded||Qx.applyArabicShaping!=null,isLoading:()=>Zd===gh.loading,setState(x){Zd=x.pluginStatus,Xh=x.pluginURL},isParsing:()=>Zd===gh.parsing,isParsed:()=>Zd===gh.parsed,getPluginURL:()=>Xh},jF=function(){Qx.isLoading()||Qx.isLoaded()||kP()!=="deferred"||wF()};class Ga{constructor(c,h){this.zoom=c,h?(this.now=h.now,this.fadeDuration=h.fadeDuration,this.transition=h.transition,this.pitch=h.pitch,this.brightness=h.brightness,this.worldview=h.worldview,this.activeFloors=h.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(c){return function(h,g){for(const j of h)if(!v3(j.charCodeAt(0),g))return!1;return!0}(c,Qx.isLoaded())}}class e_{constructor(c,h,g,j,T){this.property=c,this.value=h,this.expression=function(P,R,F,H,Q){if(lP(P))return new h3(P,R);if(a2(P)||Array.isArray(P)&&P.length>0){const se=cP(P,R,F,H,Q);if(se.result==="error")throw new Error(se.value.map(re=>`${re.key}: ${re.message}`).join(", "));return se.value}{let se=P;return typeof P=="string"&&R.type==="color"&&(se=la.parse(P)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>se}}}(h===void 0?c.specification.default:h,c.specification,g,j,T)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(c,h,g,j){return this.property.possiblyEvaluate(this,c,h,g,j)}}class _3{constructor(c,h,g,j){this.property=c,this.value=new e_(c,void 0,h,g,j)}transitioned(c,h){return new t_(this.property,this.value,h,Object.assign({},c.transition,this.transition),c.now)}untransitioned(){return new t_(this.property,this.value,null,{},0)}}class b3{constructor(c,h,g,j){this._properties=c,this._values=Object.create(c.defaultTransitionablePropertyValues),this._scope=h,this._options=g,this._iconImageUseTheme=j,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(c){return lr(this._values[c].value.value)}setValue(c,h){this._values.hasOwnProperty(c)||(this._values[c]=new _3(this._values[c].property,this._scope,this._options,this._iconImageUseTheme)),this._values[c].value=new e_(this._values[c].property,h===null?void 0:lr(h),this._scope,this._options,this._iconImageUseTheme),this._values[c].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[c].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[c].value.isIndoorDependent())}setTransitionOrValue(c,h){h&&(this._options=h);const g=this._properties.properties;if(c)for(const j in c){const T=c[j];if(j.endsWith("-transition")){const P=j.slice(0,-11);g[P]&&this.setTransition(P,T)}else g.hasOwnProperty(j)&&this.setValue(j,T)}}getTransition(c){return lr(this._values[c].transition)}setTransition(c,h){this._values.hasOwnProperty(c)||(this._values[c]=new _3(this._values[c].property)),this._values[c].transition=lr(h)||void 0}serialize(){const c={};for(const h of Object.keys(this._values)){const g=this.getValue(h);g!==void 0&&(c[h]=g);const j=this.getTransition(h);j!==void 0&&(c[`${h}-transition`]=j)}return c}transitioned(c,h){const g=new SP(this._properties);for(const j of Object.keys(this._values))g._values[j]=this._values[j].transitioned(c,h._values[j]);return g}untransitioned(){const c=new SP(this._properties);for(const h of Object.keys(this._values))c._values[h]=this._values[h].untransitioned();return c}isIndoorDependent(){return this._isIndoorDependent}}class t_{constructor(c,h,g,j,T){const P=j.delay||0,R=j.duration||0;T=T||0,this.property=c,this.value=h,this.begin=T+P,this.end=this.begin+R,c.specification.transition&&(j.delay||j.duration)&&(this.prior=g)}possiblyEvaluate(c,h,g){const j=c.now||0,T=this.value.possiblyEvaluate(c,h,g),P=this.prior;if(P){if(j>this.end)return this.prior=null,T;if(this.value.isDataDriven())return this.prior=null,T;if(j":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-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]},"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-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]},"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},"line-blend-mode":{"type":"enum","values":{"default":1,"multiply":1,"additive":1},"default":"default","expression":{"parameters":["zoom"]}}},"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"]},"appearance":true,"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"]},"appearance":true,"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":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"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":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,"appearance":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"]}},"raster-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1},"default":"sea","expression":{}}},"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":{}},"model-ignore-line-cutout":{"type":"boolean","default":false,"expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function NF(x){return x instanceof Number||x instanceof String||x instanceof Boolean?x.valueOf():x}function w3(x){if(Array.isArray(x))return x.map(w3);if(x instanceof Object&&!(x instanceof Number||x instanceof String||x instanceof Boolean)){const c={};for(const h in x)c[h]=w3(x[h]);return c}return NF(x)}function MP(x){if(x===!0||x===!1)return!0;if(!Array.isArray(x)||x.length===0)return!1;switch(x[0]){case"has":return x.length>=2&&x[1]!=="$id"&&x[1]!=="$type";case"in":return x.length>=3&&(typeof x[1]!="string"||Array.isArray(x[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return x.length!==3||Array.isArray(x[1])||Array.isArray(x[2]);case"any":case"all":for(const c of x.slice(1))if(!MP(c)&&typeof c!="boolean")return!1;return!0;default:return!0}}function j3(x,c="",h=null,g="fill"){if(x==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};MP(x)||(x=N3(x));const j=x;let T=!0;try{T=function(Q){if(!r_(Q))return Q;let se=w3(Q);return SF(se),se=kF(se),se}(j)}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(j,null,2)} `)}let P=null,R=null;if(g!=="background"&&g!=="sky"&&g!=="slot"){R=Ht[`filter_${g}`];const Q=cy(T,R,c,h);if(Q.result==="error")throw new Error(Q.value.map(se=>`${se.key}: ${se.message}`).join(", "));P=(se,re,oe)=>Q.value.evaluate(se,re,{},oe)}let F=null,H=null;if(T!==j){const Q=cy(j,R,c,h);if(Q.result==="error")throw new Error(Q.value.map(se=>`${se.key}: ${se.message}`).join(", "));F=(se,re,oe,ue,_e)=>Q.value.evaluate(se,re,{},oe,void 0,void 0,ue,_e),H=!V0(Q.value.expression)}return{filter:P,dynamicFilter:F||void 0,needGeometry:MF(T),needFeature:!!H}}function kF(x){if(!Array.isArray(x))return x;const c=function(h){if(CF.has(h[0])){for(let g=1;gkF(h))}function SF(x){let c=!1;const h=[];if(x[0]==="case"){for(let g=1;g",">=","<","<=","to-boolean"]);function Mpe(x,c){return xc?1:0}function MF(x){if(!Array.isArray(x))return!1;if(x[0]==="within"||x[0]==="distance")return!0;for(let c=1;c"||c==="<="||c===">="?k3(x[1],x[2],c):c==="any"?(h=x.slice(1),["any"].concat(h.map(N3))):c==="all"?["all"].concat(x.slice(1).map(N3)):c==="none"?["all"].concat(x.slice(1).map(N3).map(u2)):c==="in"?TP(x[1],x.slice(2)):c==="!in"?u2(TP(x[1],x.slice(2))):c==="has"?eg(x[1]):c!=="!has"||u2(eg(x[1]));var h}function k3(x,c,h){switch(x){case"$type":return[`filter-type-${h}`,c];case"$id":return[`filter-id-${h}`,c];default:return[`filter-${h}`,x,c]}}function TP(x,c){if(c.length===0)return!1;switch(x){case"$type":return["filter-type-in",["literal",c]];case"$id":return["filter-id-in",["literal",c]];default:return c.length>200&&!c.some(h=>typeof h!=typeof c[0])?["filter-in-large",x,["literal",c.sort(Mpe)]]:["filter-in-small",x,["literal",c]]}}function eg(x){switch(x){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",x]}}function u2(x){return["!",x]}const h2="";function X0(x,c){return c?`${x}${h2}${c}`:x}function TF(x){const c=x.indexOf(h2);return c>=0?x.slice(c+1):""}let AF;const AP=()=>AF||(AF=new Xi({"icon-size":new Hs(Ht.layout_symbol["icon-size"]),"icon-image":new Hs(Ht.layout_symbol["icon-image"]),"icon-rotate":new Hs(Ht.layout_symbol["icon-rotate"]),"icon-offset":new Hs(Ht.layout_symbol["icon-offset"]),"text-size":new Hs(Ht.layout_symbol["text-size"]),"text-rotate":new Hs(Ht.layout_symbol["text-rotate"]),"text-offset":new Hs(Ht.layout_symbol["text-offset"])}));let EP;const PP=()=>EP||(EP=new Xi({"icon-opacity":new Hs(Ht.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Hs(Ht.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Hs(Ht.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Hs(Ht.paint_symbol["text-emissive-strength"]),"icon-color":new Hs(Ht.paint_symbol["icon-color"]),"icon-halo-color":new Hs(Ht.paint_symbol["icon-halo-color"]),"icon-halo-width":new Hs(Ht.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Hs(Ht.paint_symbol["icon-halo-blur"]),"icon-translate":new Hs(Ht.paint_symbol["icon-translate"]),"text-opacity":new Hs(Ht.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Hs(Ht.paint_symbol["text-occlusion-opacity"]),"text-color":new Hs(Ht.paint_symbol["text-color"],{runtimeType:bu,getOverride:x=>x.textColor,hasOverride:x=>!!x.textColor}),"text-halo-color":new Hs(Ht.paint_symbol["text-halo-color"]),"text-halo-width":new Hs(Ht.paint_symbol["text-halo-width"]),"text-halo-blur":new Hs(Ht.paint_symbol["text-halo-blur"]),"text-translate":new Hs(Ht.paint_symbol["text-translate"]),"symbol-z-offset":new Hs(Ht.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"})}));class Tpe{constructor(c,h,g,j,T,P){this._conditionSpec=c,this._propertiesSpec=g;const R=cy(c,Ht.appearance.condition);if(R.result==="success"&&(this.condition=R.value),this.name=h,g){this.layoutProperties=new Jx(AP()),this.unevaluatedLayout=new CP(AP(),j,T,P),this.paintProperties=new Jx(PP()),this.unevaluatedPaint=new CP(PP(),j,T,"");for(const F in g)F in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(F,g[F]):F in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(F,g[F])}}isActive(c){return!(this.condition||!c.isHidden||this.name!=="hidden")||this.condition.evaluate(c.globals,c.feature,c.featureState,c.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(c){return this.layoutProperties.get(c)}getPaintProperty(c){return this.paintProperties.get(c)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(c){return this.unevaluatedLayout._values[c]}getUnevaluatedPaintProperty(c){return this.unevaluatedPaint._values[c]}recalculate(c,h,g){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(c,void 0,h,g)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(c,void 0,h,""))}serialize(){const c={};c.condition=this.condition.expression.serialize(),this.name&&(c.name=this.name);const h=this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},g=this.unevaluatedPaint?this.unevaluatedPaint.serialize():{},j=Object.assign({},h,g);return Object.keys(j).length>0&&(c.properties=j),c}hasIconLayoutProperties(){const c=this.hasLayoutProperty("icon-image"),h=this.hasLayoutProperty("icon-size"),g=this.hasLayoutProperty("icon-offset"),j=this.hasLayoutProperty("icon-rotate");return c||h||g||j}hasTextLayoutProperties(){const c=this.hasLayoutProperty("text-size"),h=this.hasLayoutProperty("text-offset"),g=this.hasLayoutProperty("text-rotate");return c||h||g}hasIconPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(c=>!c.endsWith("-use-theme")).some(c=>(c.startsWith("icon-")||c==="symbol-z-offset")&&this.hasPaintProperty(c))}hasTextPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(c=>!c.endsWith("-use-theme")).some(c=>(c.startsWith("text-")||c==="symbol-z-offset")&&this.hasPaintProperty(c))}hasLayoutProperty(c){return this.unevaluatedLayout&&this.unevaluatedLayout._values[c].value!==void 0}hasPaintProperty(c){return this.unevaluatedPaint&&this.unevaluatedPaint._values[c].value!==void 0}}const IP="-transition",Ape=new Set(["fill","line","background","hillshade","raster"]);class Yd extends Na{constructor(c,h,g,j,T,P){if(super(),this.id=c.id,this.fqid=X0(this.id,g),this.type=c.type,this.scope=g,this.lut=j,this.options=T,this.iconImageUseTheme=P,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},c.type!=="custom"){if(this.metadata=c.metadata,this.minzoom=c.minzoom,this.maxzoom=c.maxzoom,c.type&&c.type!=="background"&&c.type!=="sky"&&c.type!=="slot"){this.source=c.source,this.sourceLayer=c["source-layer"],this.filter=c.filter;const R=cy(this.filter,Ht[`filter_${c.type}`]);R.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...R.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||R.value.isIndoorDependent)}if(c.slot&&(this.slot=c.slot),c.appearances&&this.setAppearances(c.appearances),h.layout&&(this._unevaluatedLayout=new CP(h.layout,this.scope,T,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),h.paint){this._transitionablePaint=new b3(h.paint,this.scope,T);for(const R in c.paint)this.setPaintProperty(R,c.paint[R]);for(const R in c.layout)this.setLayoutProperty(R,c.layout[R]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Jx(h.paint)}}}onAdd(c){}onRemove(c){}isDraped(c){return!this.is3D(!0)&&Ape.has(this.type)}getLayoutProperty(c){return c==="visibility"?this.visibility:this._unevaluatedLayout.getValue(c)}setLayoutProperty(c,h){if(this.type==="custom"&&c==="visibility")return void(this.visibility=h);const g=this._unevaluatedLayout;g._properties.properties[c]&&(g.setValue(c,h),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...g.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||g.isIndoorDependent(),c==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(c){this.appearances=[],c.forEach(h=>{this.appearances.push(new Tpe(h.condition,h.name,h.properties,this.scope,this.options,this.iconImageUseTheme))}),this.appearancesVersion++}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(c){return c.endsWith(IP)?this._transitionablePaint.getTransition(c.slice(0,-11)):this._transitionablePaint.getValue(c)}isPaintProperty(c){return!!this._transitionablePaint._properties.properties[c]}setPaintProperty(c,h){const g=this._transitionablePaint,j=g._properties.properties;if(c.endsWith(IP)){const se=c.slice(0,-11);return j[se]&&g.setTransition(se,h||void 0),!1}if(!j[c])return!1;const T=g._values[c],P=T.value.isDataDriven(),R=T.value;g.setValue(c,h),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...g.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||g.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(c);const F=g._values[c].value,H=F.isDataDriven(),Q=c.endsWith("pattern")||c==="line-dasharray";return H||P||Q||this._handleOverridablePaintPropertyUpdate(c,R,F)}_handleSpecialPaintPropertyUpdate(c){}getProgramIds(){return null}getDefaultProgramParams(c,h,g){return null}_handleOverridablePaintPropertyUpdate(c,h,g){return!1}isHidden(c){return!!(this.minzoom&&c=this.maxzoom)||this.visibility==="none"}updateTransitions(c){this._transitioningPaint=this._transitionablePaint.transitioned(c,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(c,h){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(c,void 0,h,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(c,void 0,h)}serialize(){const c={id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.appearances.length!==0&&(c.appearances=this.appearances.map(h=>h.serialize())),ys(c,(h,g)=>!(h===void 0||g==="layout"&&!Object.keys(h).length||g==="paint"&&!Object.keys(h).length))}is3D(c){return!1}hasElevation(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const c in this.paint._values){const h=this.paint.get(c);if(h instanceof Y0&&c3(h.property.specification)&&(h.value.kind==="source"||h.value.kind==="composite")&&h.value.isStateDependent)return!0}for(const c of this.appearances)if(!G1(c.condition.expression))return!0;return!1}compileFilter(c){this._filterCompiled||(this._featureFilter=j3(this.filter,this.scope,c),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(c){this._stats&&(c.renderPass==="shadow"?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(c,h,g){return{}}queryRadius(c){}queryIntersectsFeature(c,h,g,j,T,P,R,F,H,Q){}}const S3={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class m2{constructor(c,h){this._structArray=c,this._pos1=h*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const Epe=new ArrayBuffer(0);class Di{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(c,h){return c._trim(),h&&c.arrayBuffer&&h.add(c.arrayBuffer),{length:c.length,arrayBuffer:c.arrayBuffer}}static deserialize(c){const h=Object.create(this.prototype);return h.arrayBuffer=c.arrayBuffer,h.length=c.length,c.arrayBuffer?h.capacity=c.arrayBuffer.byteLength/h.bytesPerElement:(h.capacity=0,h.arrayBuffer=Epe),h._refreshViews(),h}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(c){this.reserve(c),this.length=c}reserve(c){if(c>this.capacity){this._reallocCount++,this.capacity=Math.max(c,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const h=this.uint8;this._refreshViews(),h&&this.uint8.set(h)}}reserveForAdditional(c){this.reserve(this.length+c)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...c){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...c){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function ia(x,c=1){let h=0,g=0;return{members:x.map(j=>{const T=S3[j.type].BYTES_PER_ELEMENT,P=h=EF(h,Math.max(c,T)),R=j.components||1;return g=Math.max(g,T),h+=T*R,{name:j.name,type:j.type,components:R,offset:P}}),size:EF(h,Math.max(g,c)),alignment:c}}function EF(x,c){return Math.ceil(x/c)*c}class yh extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h){const g=this.length;return this.resize(g+1),this.emplace(g,c,h)}emplace(c,h,g){const j=2*c;return this.int16[j+0]=h,this.int16[j+1]=g,c}}yh.prototype.bytesPerElement=4,gr(yh,"StructArrayLayout2i4");class zf extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g){const j=this.length;return this.resize(j+1),this.emplace(j,c,h,g)}emplace(c,h,g,j){const T=3*c;return this.int16[T+0]=h,this.int16[T+1]=g,this.int16[T+2]=j,c}}zf.prototype.bytesPerElement=6,gr(zf,"StructArrayLayout3i6");class id extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,g,j){const T=this.length;return this.resize(T+1),this.emplace(T,c,h,g,j)}emplace(c,h,g,j,T){const P=4*c;return this.int16[P+0]=h,this.int16[P+1]=g,this.uint16[P+2]=j,this.uint16[P+3]=T,c}}id.prototype.bytesPerElement=8,gr(id,"StructArrayLayout2i2ui8");class Qh extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.float32[1*c+0]=h,c}}Qh.prototype.bytesPerElement=4,gr(Qh,"StructArrayLayout1f4");class LP extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g){const j=this.length;return this.resize(j+1),this.emplace(j,c,h,g)}emplace(c,h,g,j){const T=4*c,P=2*c;return this.int16[T+0]=h,this.int16[T+1]=g,this.float32[P+1]=j,c}}LP.prototype.bytesPerElement=8,gr(LP,"StructArrayLayout2i1f8");class DP extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g){const j=this.length;return this.resize(j+1),this.emplace(j,c,h,g)}emplace(c,h,g,j){const T=4*c;return this.int16[T+0]=h,this.int16[T+1]=g,this.int16[T+2]=j,c}}DP.prototype.bytesPerElement=8,gr(DP,"StructArrayLayout3i8");class RP extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g,j){const T=this.length;return this.resize(T+1),this.emplace(T,c,h,g,j)}emplace(c,h,g,j,T){const P=4*c;return this.int16[P+0]=h,this.int16[P+1]=g,this.int16[P+2]=j,this.int16[P+3]=T,c}}RP.prototype.bytesPerElement=8,gr(RP,"StructArrayLayout4i8");class OP extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T){const P=this.length;return this.resize(P+1),this.emplace(P,c,h,g,j,T)}emplace(c,h,g,j,T,P){const R=5*c;return this.int16[R+0]=h,this.int16[R+1]=g,this.int16[R+2]=j,this.int16[R+3]=T,this.int16[R+4]=P,c}}OP.prototype.bytesPerElement=10,gr(OP,"StructArrayLayout5i10");class p2 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R){const F=this.length;return this.resize(F+1),this.emplace(F,c,h,g,j,T,P,R)}emplace(c,h,g,j,T,P,R,F){const H=6*c,Q=12*c,se=3*c;return this.int16[H+0]=h,this.int16[H+1]=g,this.uint8[Q+4]=j,this.uint8[Q+5]=T,this.uint8[Q+6]=P,this.uint8[Q+7]=R,this.float32[se+2]=F,c}}p2.prototype.bytesPerElement=12,gr(p2,"StructArrayLayout2i4ub1f12");class Um extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g){const j=this.length;return this.resize(j+1),this.emplace(j,c,h,g)}emplace(c,h,g,j){const T=3*c;return this.float32[T+0]=h,this.float32[T+1]=g,this.float32[T+2]=j,c}}Um.prototype.bytesPerElement=12,gr(Um,"StructArrayLayout3f12");class Bf extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T){const P=this.length;return this.resize(P+1),this.emplace(P,c,h,g,j,T)}emplace(c,h,g,j,T,P){const R=6*c,F=3*c;return this.uint16[R+0]=h,this.uint16[R+1]=g,this.uint16[R+2]=j,this.uint16[R+3]=T,this.float32[F+2]=P,c}}Bf.prototype.bytesPerElement=12,gr(Bf,"StructArrayLayout4ui1f12");class n_ extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,g,j){const T=this.length;return this.resize(T+1),this.emplace(T,c,h,g,j)}emplace(c,h,g,j,T){const P=4*c;return this.uint16[P+0]=h,this.uint16[P+1]=g,this.uint16[P+2]=j,this.uint16[P+3]=T,c}}n_.prototype.bytesPerElement=8,gr(n_,"StructArrayLayout4ui8");class C3 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P){const R=this.length;return this.resize(R+1),this.emplace(R,c,h,g,j,T,P)}emplace(c,h,g,j,T,P,R){const F=6*c;return this.int16[F+0]=h,this.int16[F+1]=g,this.int16[F+2]=j,this.int16[F+3]=T,this.int16[F+4]=P,this.int16[F+5]=R,c}}C3.prototype.bytesPerElement=12,gr(C3,"StructArrayLayout6i12");class FP extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H,Q,se,re){const oe=this.length;return this.resize(oe+1),this.emplace(oe,c,h,g,j,T,P,R,F,H,Q,se,re)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,oe){const ue=12*c;return this.int16[ue+0]=h,this.int16[ue+1]=g,this.int16[ue+2]=j,this.int16[ue+3]=T,this.uint16[ue+4]=P,this.uint16[ue+5]=R,this.uint16[ue+6]=F,this.uint16[ue+7]=H,this.int16[ue+8]=Q,this.int16[ue+9]=se,this.int16[ue+10]=re,this.int16[ue+11]=oe,c}}FP.prototype.bytesPerElement=24,gr(FP,"StructArrayLayout4i4ui4i24");class zP extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P){const R=this.length;return this.resize(R+1),this.emplace(R,c,h,g,j,T,P)}emplace(c,h,g,j,T,P,R){const F=10*c,H=5*c;return this.int16[F+0]=h,this.int16[F+1]=g,this.int16[F+2]=j,this.float32[H+2]=T,this.float32[H+3]=P,this.float32[H+4]=R,c}}zP.prototype.bytesPerElement=20,gr(zP,"StructArrayLayout3i3f20");class tg extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j){const T=this.length;return this.resize(T+1),this.emplace(T,c,h,g,j)}emplace(c,h,g,j,T){const P=4*c;return this.float32[P+0]=h,this.float32[P+1]=g,this.float32[P+2]=j,this.float32[P+3]=T,c}}tg.prototype.bytesPerElement=16,gr(tg,"StructArrayLayout4f16");class f2 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.uint32[1*c+0]=h,c}}f2.prototype.bytesPerElement=4,gr(f2,"StructArrayLayout1ul4");class Vm extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h){const g=this.length;return this.resize(g+1),this.emplace(g,c,h)}emplace(c,h,g){const j=2*c;return this.uint16[j+0]=h,this.uint16[j+1]=g,c}}Vm.prototype.bytesPerElement=4,gr(Vm,"StructArrayLayout2ui4");class M3 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H,Q,se,re,oe){const ue=this.length;return this.resize(ue+1),this.emplace(ue,c,h,g,j,T,P,R,F,H,Q,se,re,oe)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue){const _e=20*c,ke=10*c;return this.int16[_e+0]=h,this.int16[_e+1]=g,this.int16[_e+2]=j,this.int16[_e+3]=T,this.int16[_e+4]=P,this.float32[ke+3]=R,this.float32[ke+4]=F,this.float32[ke+5]=H,this.float32[ke+6]=Q,this.int16[_e+14]=se,this.uint32[ke+8]=re,this.uint16[_e+18]=oe,this.uint16[_e+19]=ue,c}}M3.prototype.bytesPerElement=40,gr(M3,"StructArrayLayout5i4f1i1ul2ui40");class x2 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R){const F=this.length;return this.resize(F+1),this.emplace(F,c,h,g,j,T,P,R)}emplace(c,h,g,j,T,P,R,F){const H=8*c;return this.int16[H+0]=h,this.int16[H+1]=g,this.int16[H+2]=j,this.int16[H+4]=T,this.int16[H+5]=P,this.int16[H+6]=R,this.int16[H+7]=F,c}}x2.prototype.bytesPerElement=16,gr(x2,"StructArrayLayout3i2i2i16");class BP extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T){const P=this.length;return this.resize(P+1),this.emplace(P,c,h,g,j,T)}emplace(c,h,g,j,T,P){const R=4*c,F=8*c;return this.float32[R+0]=h,this.float32[R+1]=g,this.float32[R+2]=j,this.int16[F+6]=T,this.int16[F+7]=P,c}}BP.prototype.bytesPerElement=16,gr(BP,"StructArrayLayout2f1f2i16");class g2 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P){const R=this.length;return this.resize(R+1),this.emplace(R,c,h,g,j,T,P)}emplace(c,h,g,j,T,P,R){const F=20*c,H=5*c;return this.uint8[F+0]=h,this.uint8[F+1]=g,this.float32[H+1]=j,this.float32[H+2]=T,this.float32[H+3]=P,this.float32[H+4]=R,c}}g2.prototype.bytesPerElement=20,gr(g2,"StructArrayLayout2ub4f20");class Ao extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,g){const j=this.length;return this.resize(j+1),this.emplace(j,c,h,g)}emplace(c,h,g,j){const T=3*c;return this.uint16[T+0]=h,this.uint16[T+1]=g,this.uint16[T+2]=j,c}}Ao.prototype.bytesPerElement=6,gr(Ao,"StructArrayLayout3ui6");class T3 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e,ke,Pe,We,qe,rt,it){const ot=this.length;return this.resize(ot+1),this.emplace(ot,c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e,ke,Pe,We,qe,rt,it)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e,ke,Pe,We,qe,rt,it,ot){const It=30*c,wt=15*c,At=60*c;return this.int16[It+0]=h,this.int16[It+1]=g,this.int16[It+2]=j,this.float32[wt+2]=T,this.float32[wt+3]=P,this.uint16[It+8]=R,this.uint16[It+9]=F,this.uint32[wt+5]=H,this.uint32[wt+6]=Q,this.uint32[wt+7]=se,this.uint16[It+16]=re,this.uint16[It+17]=oe,this.uint16[It+18]=ue,this.float32[wt+10]=_e,this.float32[wt+11]=ke,this.uint8[At+48]=Pe,this.uint8[At+49]=We,this.uint8[At+50]=qe,this.uint32[wt+13]=rt,this.int16[It+28]=it,this.uint8[At+58]=ot,c}}T3.prototype.bytesPerElement=60,gr(T3,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class $P extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e,ke,Pe,We,qe,rt,it,ot,It,wt,At,kt,St,rs,is,us,ws,hs,Ds){const ts=this.length;return this.resize(ts+1),this.emplace(ts,c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e,ke,Pe,We,qe,rt,it,ot,It,wt,At,kt,St,rs,is,us,ws,hs,Ds)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e,ke,Pe,We,qe,rt,it,ot,It,wt,At,kt,St,rs,is,us,ws,hs,Ds,ts){const vs=20*c,Ms=40*c,Rs=80*c;return this.float32[vs+0]=h,this.float32[vs+1]=g,this.int16[Ms+4]=j,this.int16[Ms+5]=T,this.int16[Ms+6]=P,this.int16[Ms+7]=R,this.int16[Ms+8]=F,this.int16[Ms+9]=H,this.int16[Ms+10]=Q,this.int16[Ms+11]=se,this.int16[Ms+12]=re,this.uint16[Ms+13]=oe,this.uint16[Ms+14]=ue,this.uint16[Ms+15]=_e,this.uint16[Ms+16]=ke,this.uint16[Ms+17]=Pe,this.uint16[Ms+18]=We,this.uint16[Ms+19]=qe,this.uint16[Ms+20]=rt,this.uint16[Ms+21]=it,this.uint16[Ms+22]=ot,this.uint16[Ms+23]=It,this.uint16[Ms+24]=wt,this.uint16[Ms+25]=At,this.uint16[Ms+26]=kt,this.uint16[Ms+27]=St,this.uint32[vs+14]=rs,this.float32[vs+15]=is,this.float32[vs+16]=us,this.float32[vs+17]=ws,this.float32[vs+18]=hs,this.uint8[Rs+76]=Ds,this.uint16[Ms+39]=ts,c}}$P.prototype.bytesPerElement=80,gr($P,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class A3 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P){const R=this.length;return this.resize(R+1),this.emplace(R,c,h,g,j,T,P)}emplace(c,h,g,j,T,P,R){const F=6*c;return this.float32[F+0]=h,this.float32[F+1]=g,this.float32[F+2]=j,this.float32[F+3]=T,this.float32[F+4]=P,this.float32[F+5]=R,c}}A3.prototype.bytesPerElement=24,gr(A3,"StructArrayLayout6f24");class Q0 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T){const P=this.length;return this.resize(P+1),this.emplace(P,c,h,g,j,T)}emplace(c,h,g,j,T,P){const R=5*c;return this.float32[R+0]=h,this.float32[R+1]=g,this.float32[R+2]=j,this.float32[R+3]=T,this.float32[R+4]=P,c}}Q0.prototype.bytesPerElement=20,gr(Q0,"StructArrayLayout5f20");class y2 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R){const F=this.length;return this.resize(F+1),this.emplace(F,c,h,g,j,T,P,R)}emplace(c,h,g,j,T,P,R,F){const H=7*c;return this.float32[H+0]=h,this.float32[H+1]=g,this.float32[H+2]=j,this.float32[H+3]=T,this.float32[H+4]=P,this.float32[H+5]=R,this.float32[H+6]=F,c}}y2.prototype.bytesPerElement=28,gr(y2,"StructArrayLayout7f28");class qP extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H,Q,se){const re=this.length;return this.resize(re+1),this.emplace(re,c,h,g,j,T,P,R,F,H,Q,se)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re){const oe=11*c;return this.float32[oe+0]=h,this.float32[oe+1]=g,this.float32[oe+2]=j,this.float32[oe+3]=T,this.float32[oe+4]=P,this.float32[oe+5]=R,this.float32[oe+6]=F,this.float32[oe+7]=H,this.float32[oe+8]=Q,this.float32[oe+9]=se,this.float32[oe+10]=re,c}}qP.prototype.bytesPerElement=44,gr(qP,"StructArrayLayout11f44");class UP extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H){const Q=this.length;return this.resize(Q+1),this.emplace(Q,c,h,g,j,T,P,R,F,H)}emplace(c,h,g,j,T,P,R,F,H,Q){const se=9*c;return this.float32[se+0]=h,this.float32[se+1]=g,this.float32[se+2]=j,this.float32[se+3]=T,this.float32[se+4]=P,this.float32[se+5]=R,this.float32[se+6]=F,this.float32[se+7]=H,this.float32[se+8]=Q,c}}UP.prototype.bytesPerElement=36,gr(UP,"StructArrayLayout9f36");class J0 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h){const g=this.length;return this.resize(g+1),this.emplace(g,c,h)}emplace(c,h,g){const j=2*c;return this.float32[j+0]=h,this.float32[j+1]=g,c}}J0.prototype.bytesPerElement=8,gr(J0,"StructArrayLayout2f8");class VP extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,g,j){const T=this.length;return this.resize(T+1),this.emplace(T,c,h,g,j)}emplace(c,h,g,j,T){const P=6*c;return this.uint32[3*c+0]=h,this.uint16[P+2]=g,this.uint16[P+3]=j,this.uint16[P+4]=T,c}}VP.prototype.bytesPerElement=12,gr(VP,"StructArrayLayout1ul3ui12");class ev extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.uint16[1*c+0]=h,c}}ev.prototype.bytesPerElement=2,gr(ev,"StructArrayLayout1ui2");class HP extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e,ke){const Pe=this.length;return this.resize(Pe+1),this.emplace(Pe,c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e,ke)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e,ke,Pe){const We=16*c;return this.float32[We+0]=h,this.float32[We+1]=g,this.float32[We+2]=j,this.float32[We+3]=T,this.float32[We+4]=P,this.float32[We+5]=R,this.float32[We+6]=F,this.float32[We+7]=H,this.float32[We+8]=Q,this.float32[We+9]=se,this.float32[We+10]=re,this.float32[We+11]=oe,this.float32[We+12]=ue,this.float32[We+13]=_e,this.float32[We+14]=ke,this.float32[We+15]=Pe,c}}HP.prototype.bytesPerElement=64,gr(HP,"StructArrayLayout16f64");class E3 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R){const F=this.length;return this.resize(F+1),this.emplace(F,c,h,g,j,T,P,R)}emplace(c,h,g,j,T,P,R,F){const H=10*c,Q=5*c;return this.uint16[H+0]=h,this.uint16[H+1]=g,this.uint16[H+2]=j,this.uint16[H+3]=T,this.float32[Q+2]=P,this.float32[Q+3]=R,this.float32[Q+4]=F,c}}E3.prototype.bytesPerElement=20,gr(E3,"StructArrayLayout4ui3f20");class P3 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.int16[1*c+0]=h,c}}P3.prototype.bytesPerElement=2,gr(P3,"StructArrayLayout1i2");class I3 extends Di{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.uint8[1*c+0]=h,c}}I3.prototype.bytesPerElement=1,gr(I3,"StructArrayLayout1ub1");class PF extends m2{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}PF.prototype.size=40;class GP extends M3{get(c){return new PF(this,c)}}gr(GP,"CollisionBoxArray");class IF extends m2{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(c){this._structArray.uint8[this._pos1+49]=c}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(c){this._structArray.uint8[this._pos1+50]=c}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(c){this._structArray.uint32[this._pos4+13]=c}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(c){this._structArray.uint8[this._pos1+58]=c}}IF.prototype.size=60;class LF extends T3{get(c){return new IF(this,c)}}gr(LF,"PlacedSymbolArray");class v2 extends m2{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(c){this._structArray.uint32[this._pos4+14]=c}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(c){this._structArray.float32[this._pos4+18]=c}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}v2.prototype.size=80;class DF extends $P{get(c){return new v2(this,c)}}gr(DF,"SymbolInstanceArray");class RF extends Qh{getoffsetX(c){return this.float32[1*c+0]}}gr(RF,"GlyphOffsetArray");class _2 extends yh{getx(c){return this.int16[2*c+0]}gety(c){return this.int16[2*c+1]}}gr(_2,"SymbolLineVertexArray");class OF extends m2{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}OF.prototype.size=12;class WP extends VP{get(c){return new OF(this,c)}}gr(WP,"FeatureIndexArray");class FF extends Vm{geta_centroid_pos0(c){return this.uint16[2*c+0]}geta_centroid_pos1(c){return this.uint16[2*c+1]}}gr(FF,"FillExtrusionCentroidArray");class KP extends m2{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}KP.prototype.size=6;class ZP extends zf{get(c){return new KP(this,c)}}gr(ZP,"FillExtrusionWallArray");const zF=ia([{name:"a_pos",components:2,type:"Int16"}],4),Ppe=ia([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),Ipe=ia([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class wi{constructor(c=[]){this.segments=c}_prepareSegment(c,h,g,j,T){let P=this.segments[this.segments.length-1];return c>wi.MAX_VERTEX_ARRAY_LENGTH&&zr(`Max vertices per segment is ${wi.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${c}`),(!P||P.vertexLength+c>wi.MAX_VERTEX_ARRAY_LENGTH||P.sortKey!==j||T!==void 0&&P&&P.batchIndex!==void 0&&P.batchIndex!==T)&&(P={vertexOffset:h,primitiveOffset:g,vertexLength:0,primitiveLength:0},j!==void 0&&(P.sortKey=j),T!==void 0&&(P.batchIndex=T),this.segments.push(P)),P}prepareSegment(c,h,g,j,T){return this._prepareSegment(c,h.length,g.length,j,T)}get(){return this.segments}destroy(){for(const c of this.segments)for(const h in c.vaos)c.vaos[h].destroy()}static simpleSegment(c,h,g,j){return new wi([{vertexOffset:c,primitiveOffset:h,vertexLength:g,primitiveLength:j,vaos:{},sortKey:0}])}}function L3(x,c){return 256*(x=De(Math.floor(x),0,255))+De(Math.floor(c),0,255)}wi.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,gr(wi,"SegmentVector");const Lpe=ia([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Dpe=ia([{name:"a_pattern_b",components:4,type:"Uint16"}]),Rpe=ia([{name:"a_dash",components:4,type:"Uint16"}]);class b2{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(c,h,g,j){this.ids.push(YP(c)),this.positions.push(h,g,j)}eachPosition(c,h){const g=YP(c);let j=0,T=this.ids.length-1;for(;j>1;this.ids[P]>=g?T=P:j=P+1}for(;this.ids[j]===g;)h(this.positions[3*j],this.positions[3*j+1],this.positions[3*j+2]),j++}static serialize(c,h){const g=new Float64Array(c.ids),j=new Uint32Array(c.positions);return w2(g,j,0,g.length-1),h&&(h.add(g.buffer),h.add(j.buffer)),{ids:g,positions:j}}static deserialize(c){const h=new b2;let g;h.ids=c.ids,h.positions=c.positions;for(const j of h.ids)j!==g&&h.uniqueIds.push(j),g=j;return h.indexed=!0,h}}function YP(x){const c=+x;return Number.isSafeInteger(c)?c:jt(String(x))}function w2(x,c,h,g){for(;h>1];let T=h-1,P=g+1;for(;;){do T++;while(x[T]j);if(T>=P)break;Jh(x,T,P),Jh(c,3*T,3*P),Jh(c,3*T+1,3*P+1),Jh(c,3*T+2,3*P+2)}P-h`u_${T}`),this.type=g,this.context=j}setUniform(c,h,g,j,T){const P=j.constantOr(this.value);h.set(c,T,P instanceof la?P.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):P)}getBinding(c,h){return this.type==="color"?new Fpe(c):new kl(c)}}class te{constructor(c,h){this.uniformNames=h.map(g=>`u_${g}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(c,h){this.pixelRatio=c.pixelRatio||1,this.pattern=c.tl.concat(c.br),this.patternTransition=h?h.tl.concat(h.br):this.pattern}setUniform(c,h,g,j,T){let P=null;T!=="u_pattern"&&T!=="u_dash"||(P=this.pattern),T==="u_pattern_b"&&(P=this.patternTransition),T==="u_pixel_ratio"&&(P=this.pixelRatio),P&&h.set(c,T,P)}getBinding(c,h){return h==="u_pattern"||h==="u_pattern_b"||h==="u_dash"?new Ope(c):new kl(c)}}class ne{constructor(c,h,g,j){this.expression=c,this.type=g,this.maxValue=0,this.paintVertexAttributes=h.map(T=>({name:`a_${T}`,type:"Float32",components:g==="color"?2:1,offset:0})),this.paintVertexArray=new j}populatePaintArray(c,h,g,j,T,P,R,F){const H=this.paintVertexArray.length,Q=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Ga(0,{brightness:P,worldview:F}),h,{},T,j,R):this.expression.kind==="constant"&&this.expression.value,se=B(this.lutExpression,h,{},j,T,P,R,F);this.paintVertexArray.resize(c),this._setPaintValue(H,c,Q,se?null:this.context.lut)}updatePaintArray(c,h,g,j,T,P,R,F){const H=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:R,worldview:F},g,j,void 0,T):this.expression.kind==="constant"&&this.expression.value,Q=B(this.lutExpression,g,j,T,void 0,R,void 0,F);this._setPaintValue(c,h,H,Q?null:this.context.lut)}_setPaintValue(c,h,g,j){if(this.type==="color"){const T=z(g.toPremultipliedRenderColor(j));for(let P=c;P`u_${R}_t`),this.type=g,this.useIntegerZoom=j,this.context=T,this.maxValue=0,this.paintVertexAttributes=h.map(R=>({name:`a_${R}`,type:"Float32",components:g==="color"?4:2,offset:0})),this.paintVertexArray=new P}populatePaintArray(c,h,g,j,T,P,R,F){const H=this.expression.evaluate(new Ga(this.context.zoom,{brightness:P,worldview:F}),h,{},T,j,R),Q=this.expression.evaluate(new Ga(this.context.zoom+1,{brightness:P,worldview:F}),h,{},T,j,R),se=B(this.lutExpression,h,{},j,T,P,R,F),re=this.paintVertexArray.length;this.paintVertexArray.resize(c),this._setPaintValue(re,c,H,Q,se?null:this.context.lut)}updatePaintArray(c,h,g,j,T,P,R,F){const H=this.expression.evaluate({zoom:this.context.zoom,brightness:R,worldview:F},g,j,void 0,T),Q=this.expression.evaluate({zoom:this.context.zoom+1,brightness:R,worldview:F},g,j,void 0,T),se=B(this.lutExpression,g,j,T,void 0,R,void 0,F);this._setPaintValue(c,h,H,Q,se?null:this.context.lut)}_setPaintValue(c,h,g,j,T){if(this.type==="color"){const P=z(g.toPremultipliedRenderColor(T)),R=z(j.toPremultipliedRenderColor(T));for(let F=c;F!0){this.binders={},this._buffers=[],this.context=h;const j=[],T=c;for(const P in c.paint._values){const R=T.paint.get(P);if(P.endsWith("-use-theme")||!g(P)||!(R instanceof Y0&&c3(R.property.specification)))continue;const F=Le(P,c.type),H=R.value,Q=R.property.specification.type,se=!!R.property.useIntegerZoom,re=P==="line-dasharray"||P.endsWith("pattern"),oe=T.paint.get(`${P}-use-theme`),ue=P==="line-dasharray"&&T.layout.get("line-cap").value.kind!=="constant"||oe&&oe.value.kind!=="constant";if(H.kind!=="constant"||ue)if(H.kind==="source"||ue||re){const _e=lt(P,Q,"source");this.binders[P]=re?new je(H,F,Q,_e,c.id):new ne(H,F,Q,_e),j.push(`/a_${P}`)}else{const _e=lt(P,Q,"composite");this.binders[P]=new de(H,F,Q,se,h,_e),j.push(`/z_${P}`)}else this.binders[P]=re?new te(H.value,F):new W(H.value,F,Q,h),j.push(`/u_${P}`);oe&&(this.binders[P].lutExpression=oe.value)}this.cacheKey=j.sort().join("")}getMaxValue(c){const h=this.binders[c];return h instanceof ne||h instanceof de?h.maxValue:0}populatePaintArrays(c,h,g,j,T,P,R,F){for(const H in this.binders){const Q=this.binders[H];Q.context=this.context,(Q instanceof ne||Q instanceof de||Q instanceof je)&&Q.populatePaintArray(c,h,g,j,T,P,R,F)}}setConstantPatternPositions(c,h){for(const g in this.binders){const j=this.binders[g];j instanceof te&&j.setConstantPatternPositions(c,h)}}getPatternTransitionVertexBuffer(c){const h=this.binders[c];return h instanceof je?h.paintTransitionVertexBuffer:null}updatePaintArrays(c,h,g,j,T,P,R,F,H,Q){let se=!1;const re=Object.keys(c),oe=re.length!==0&&!F,ue=oe?re:h.uniqueIds;this.context.lut=T.lut;for(const _e in this.binders){const ke=this.binders[_e];if(ke.context=this.context,(ke instanceof ne||ke instanceof de||ke instanceof je)&&ke.expression&&ke.expression.kind&&ke.expression.kind!=="constant"&&(ke.expression.isStateDependent===!0||ke.expression.isLightConstant===!1)){const Pe=T.paint.get(_e);ke.expression=Pe.value;for(const We of ue){const qe=c[We.toString()];h.eachPosition(We,(rt,it,ot)=>{const It=j.feature(rt);ke.updatePaintArray(it,ot,It,qe,P,R,H,Q)})}if(!oe)for(const We of g.uniqueIds){const qe=c[We.toString()];g.eachPosition(We,(rt,it,ot)=>{const It=j.feature(rt);ke.updatePaintArray(it,ot,It,qe,P,R,H,Q)})}se=!0}}return se}defines(){const c=[];for(const h in this.binders){const g=this.binders[h];(g instanceof W||g instanceof te)&&c.push(...g.uniformNames.map(j=>`#define HAS_UNIFORM_${j}`))}return c}getPaintVertexBuffers(){return this._buffers}getUniforms(c){const h=[];for(const g in this.binders){const j=this.binders[g];if(j instanceof W||j instanceof te||j instanceof de)for(const T of j.uniformNames)h.push({name:T,property:g,binding:j.getBinding(c,T)})}return h}setUniforms(c,h,g,j,T){for(const{name:P,property:R,binding:F}of g)this.binders[R].setUniform(c,F,T,j.get(R),P)}updatePaintBuffers(){this._buffers=[];for(const c in this.binders){const h=this.binders[c];(h instanceof ne||h instanceof de||h instanceof je)&&h.paintVertexBuffer&&this._buffers.push(h.paintVertexBuffer),h instanceof je&&h.paintTransitionVertexBuffer&&this._buffers.push(h.paintTransitionVertexBuffer)}}upload(c){for(const h in this.binders){const g=this.binders[h];(g instanceof ne||g instanceof de||g instanceof je)&&g.upload(c)}this.updatePaintBuffers()}destroy(){for(const c in this.binders){const h=this.binders[c];(h instanceof ne||h instanceof de||h instanceof je)&&h.destroy()}}}class Me{constructor(c,h,g=()=>!0){this.programConfigurations={};for(const j of c)this.programConfigurations[j.id]=new be(j,h,g);this.needsUpload=!1,this._featureMap=new b2,this._featureMapWithoutIds=new b2,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(c,h,g,j,T,P,R,F,H){for(const Q in this.programConfigurations)this.programConfigurations[Q].populatePaintArrays(c,h,j,T,P,R,F,H);h.id!==void 0?this._featureMap.add(h.id,g,this._bufferOffset,c):(this._featureMapWithoutIds.add(this._idlessCounter,g,this._bufferOffset,c),this._idlessCounter+=1),this._bufferOffset=c,this.needsUpload=!0}updatePaintArrays(c,h,g,j,T,P,R,F){for(const H of g)this.needsUpload=this.programConfigurations[H.id].updatePaintArrays(c,this._featureMap,this._featureMapWithoutIds,h,H,j,T,P,R||0,F)||this.needsUpload}get(c){return this.programConfigurations[c]}upload(c){if(this.needsUpload){for(const h in this.programConfigurations)this.programConfigurations[h].upload(c);this.needsUpload=!1}}destroy(){for(const c in this.programConfigurations)this.programConfigurations[c].destroy()}}const $e={"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 Le(x,c){return $e[x]||[x.replace(`${c}-`,"").replace(/-/g,"_")]}const Je={"line-pattern":{source:Bf,composite:Bf},"fill-pattern":{source:Bf,composite:Bf},"fill-extrusion-pattern":{source:Bf,composite:Bf},"line-dasharray":{source:n_,composite:n_}},Qe={color:{source:J0,composite:tg},number:{source:Qh,composite:J0}};function lt(x,c,h){const g=Je[x];return g&&g[h]||Qe[c][h]}gr(W,"ConstantBinder"),gr(te,"PatternConstantBinder"),gr(ne,"SourceExpressionBinder"),gr(je,"PatternCompositeBinder"),gr(de,"CompositeExpressionBinder"),gr(be,"ProgramConfiguration",{omit:["_buffers"]}),gr(Me,"ProgramConfigurationSet");const mt=sr/Math.PI/2,nt=64,zt=[nt,32,16],bt=-mt,Dt=mt;function pt(x,c,h,g=mt){return h=Kt(h),[x*Math.sin(h)*g,-c*g,x*Math.cos(h)*g]}function vt(x,c,h){return pt(Math.cos(Kt(x)),Math.sin(Kt(x)),c,h)}const Tt=63710088e-1,Gt=2*Math.PI*Tt;class qt{constructor(c,h){if(isNaN(c)||isNaN(h))throw new Error(`Invalid LngLat object: (${c}, ${h})`);if(this.lng=+c,this.lat=+h,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new qt(xt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(c){const h=Math.PI/180,g=this.lat*h,j=c.lat*h,T=Math.sin(g)*Math.sin(j)+Math.cos(g)*Math.cos(j)*Math.cos((c.lng-this.lng)*h);return Tt*Math.acos(Math.min(T,1))}toBounds(c=0){const h=360*c/40075017,g=h/Math.cos(Math.PI/180*this.lat);return new ns({lng:this.lng-g,lat:this.lat-h},{lng:this.lng+g,lat:this.lat+h})}toEcef(c){return vt(this.lat,this.lng,mt+c*mt/Tt)}static convert(c){if(c instanceof qt)return c;if(Array.isArray(c)&&(c.length===2||c.length===3))return new qt(Number(c[0]),Number(c[1]));if(!Array.isArray(c)&&typeof c=="object"&&c!==null)return new qt(Number("lng"in c?c.lng:c.lon),Number(c.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class ns{constructor(c,h){c&&(h?this.setSouthWest(c).setNorthEast(h):Array.isArray(c)&&c.length===4?this.setSouthWest([c[0],c[1]]).setNorthEast([c[2],c[3]]):this.setSouthWest(c[0]).setNorthEast(c[1]))}setNorthEast(c){return this._ne=c instanceof qt?new qt(c.lng,c.lat):qt.convert(c),this}setSouthWest(c){return this._sw=c instanceof qt?new qt(c.lng,c.lat):qt.convert(c),this}extend(c){const h=this._sw,g=this._ne;let j,T;if(c instanceof qt)j=c,T=c;else{if(!(c instanceof ns))return Array.isArray(c)?c.length===4||c.every(Array.isArray)?this.extend(ns.convert(c)):this.extend(qt.convert(c)):typeof c=="object"&&c!==null&&c.hasOwnProperty("lat")&&(c.hasOwnProperty("lon")||c.hasOwnProperty("lng"))?this.extend(qt.convert(c)):this;if(j=c._sw,T=c._ne,!j||!T)return this}return h||g?(h.lng=Math.min(j.lng,h.lng),h.lat=Math.min(j.lat,h.lat),g.lng=Math.max(T.lng,g.lng),g.lat=Math.max(T.lat,g.lat)):(this._sw=new qt(j.lng,j.lat),this._ne=new qt(T.lng,T.lat)),this}getCenter(){return new qt((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 qt(this.getWest(),this.getNorth())}getSouthEast(){return new qt(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(c){const{lng:h,lat:g}=qt.convert(c);let j=this._sw.lng<=h&&h<=this._ne.lng;return this._sw.lng>this._ne.lng&&(j=this._sw.lng>=h&&h>=this._ne.lng),this._sw.lat<=g&&g<=this._ne.lat&&j}static convert(c){if(c)return c instanceof ns?c:new ns(c)}}function Jt(x){return Gt*Math.cos(x*Math.PI/180)}function Ns(x){return(180+x)/360}function Is(x){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+x*Math.PI/360)))/360}function Zt(x,c){return x/Jt(c)}function Ut(x){return 360*x-180}function ss(x){return 360/Math.PI*Math.atan(Math.exp((180-360*x)*Math.PI/180))-90}function as(x,c){return x*Jt(ss(c))}const ds=85.051129;function Qs(x){return Math.cos(Kt(De(x,-85.051129,ds)))}function Gs(x,c){const h=De(c,0,25.5),g=Math.pow(2,h);return Qs(x)*Gt/(512*g)}function Ws(x){return 1/Math.cos(x*Math.PI/180)}function Ts(x,c=0){const h=Math.exp(Math.PI*(1-(x.y+c/sr)/(1<=F?(Ir(x,c,h,H,Q,T,se,R,F),Ir(x,H,Q,g,j,se,P,R,F)):x.push(P)}function pr(x,c,h){let g=x[0],j=g.x,T=g.y;c(g);const P=[g];for(let R=1;Rx.x+1||gx.y+1)&&zr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),x}function Ur(x,c,h){const g=x.loadGeometry(),j=x.extent,T=sr/j;if(c&&h&&h.projection.isReprojectedInTileSpace){const P=1<{const oe=Ut((c.x+re.x/j)/P),ue=ss((c.y+re.y/j)/P),_e=Q.project(oe,ue);re.x=(_e.x*R-F)*j,re.y=(_e.y*R-H)*j};for(let re=0;re=j||ue.y<0||ue.y>=j||(se(ue),oe.push(ue));g[re]=oe}}for(const P of g)for(const R of P)$n(R,T);return g}function qn(x,c){return{type:x.type,id:x.id,properties:x.properties,geometry:c?Ur(x):[]}}class ln{constructor(c,h,g,j,T){this.properties={},this.extent=g,this.type=0,this.id=void 0,this._pbf=c,this._geometry=-1,this._keys=j,this._values=T,c.readFields(Ta,this,h)}loadGeometry(){const c=this._pbf;c.pos=this._geometry;const h=c.readVarint()+c.pos,g=[];let j,T=1,P=0,R=0,F=0;for(;c.pos>3}if(P--,T===1||T===2)R+=c.readSVarint(),F+=c.readSVarint(),T===1&&(j&&g.push(j),j=[]),j&&j.push(new Xt(R,F));else{if(T!==7)throw new Error(`unknown command ${T}`);j&&j.push(j[0].clone())}}return j&&g.push(j),g}bbox(){const c=this._pbf;c.pos=this._geometry;const h=c.readVarint()+c.pos;let g=1,j=0,T=0,P=0,R=1/0,F=-1/0,H=1/0,Q=-1/0;for(;c.pos>3}if(j--,g===1||g===2)T+=c.readSVarint(),P+=c.readSVarint(),TF&&(F=T),PQ&&(Q=P);else if(g!==7)throw new Error(`unknown command ${g}`)}return[R,H,F,Q]}toGeoJSON(c,h,g){const j=this.extent*Math.pow(2,g),T=this.extent*c,P=this.extent*h,R=this.loadGeometry();function F(re){return[360*(re.x+T)/j-180,360/Math.PI*Math.atan(Math.exp((1-2*(re.y+P)/j)*Math.PI))-90]}function H(re){return re.map(F)}let Q;if(this.type===1){const re=[];for(const ue of R)re.push(ue[0]);const oe=H(re);Q=re.length===1?{type:"Point",coordinates:oe[0]}:{type:"MultiPoint",coordinates:oe}}else if(this.type===2){const re=R.map(H);Q=re.length===1?{type:"LineString",coordinates:re[0]}:{type:"MultiLineString",coordinates:re}}else{if(this.type!==3)throw new Error("unknown feature type");{const re=function(ue){const _e=ue.length;if(_e<=1)return[ue];const ke=[];let Pe,We;for(let qe=0;qe<_e;qe++){const rt=hi(ue[qe]);rt!==0&&(We===void 0&&(We=rt<0),We===rt<0?(Pe&&ke.push(Pe),Pe=[ue[qe]]):Pe&&Pe.push(ue[qe]))}return Pe&&ke.push(Pe),ke}(R),oe=[];for(const ue of re)oe.push(ue.map(H));Q=oe.length===1?{type:"Polygon",coordinates:oe[0]}:{type:"MultiPolygon",coordinates:oe}}}const se={type:"Feature",geometry:Q,properties:this.properties};return this.id!=null&&(se.id=this.id),se}}function Ta(x,c,h){x===1?c.id=h.readVarint():x===2?function(g,j){const T=g.readVarint()+g.pos;for(;g.pos=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[c];const h=this._pbf.readVarint()+this._pbf.pos;return new ln(this._pbf,h,this.extent,this._keys,this._values)}}function ji(x,c,h){x===15?c.version=h.readVarint():x===1?c.name=h.readString():x===5?c.extent=h.readVarint():x===2?c._features.push(h.pos):x===3?c._keys.push(h.readString()):x===4&&c._values.push(function(g){let j=null;const T=g.readVarint()+g.pos;for(;g.pos>3;j=P===1?g.readString():P===2?g.readFloat():P===3?g.readDouble():P===4?g.readVarint64():P===5?g.readVarint():P===6?g.readSVarint():P===7?g.readBoolean():null}if(j==null)throw new Error("unknown feature value");return j}(h))}class Fa{constructor(c,h){this.layers=c.readFields(In,{},h)}}function In(x,c,h){if(x===3){const g=new Zi(h,h.readVarint()+h.pos);g.length&&(c[g.name]=g)}}const Ln="3d_elevation_id",Ni="level";class Qi{constructor(){this._valid=!1}reset(c){return this.feature=c,this._valid=!0,this._geometry=c.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(this._valid=!1),this}geometry(c,h){return this._valid&&c(h(this._geometry)),this}require(c,h,g){return this.get(c,!0,h,g)}optional(c,h,g){return this.get(c,!1,h,g)}success(){return this._valid}get(c,h,g,j){const T=this.feature.properties.hasOwnProperty(c)?+this.feature.properties[c]:void 0;return this._valid&&T!==void 0&&!Number.isNaN(T)?g(j?j(T):T):h&&(this._valid=!1),this}}class za{constructor(c,h){this.featureFunc=c,this.vertexFunc=h}parseFeature(c,h,g){return this.featureFunc(c,h,g)}parseVertex(c,h,g){return this.vertexFunc(c,h,g)}}const wn=new za((x,c,h)=>x.reset(c).require(Ln,g=>{h.id=g}).optional("fixed_height_relative",g=>{h.constantHeight=g},mi.decodeRelativeHeight).geometry(g=>{h.bounds=g},qE).success(),(x,c,h)=>x.reset(c).require(Ln,g=>{h.id=g}).require("elevation_idx",g=>{h.idx=g}).require("extent",g=>{h.extent=g}).require("height_relative",g=>{h.height=g},mi.decodeRelativeHeight).geometry(g=>{h.position=g},mi.getPoint).success()),$i=new za((x,c,h)=>x.reset(c).require(Ln,g=>{h.id=g}).optional("fixed_height",g=>{h.constantHeight=g},mi.decodeMetricHeight).geometry(g=>{h.bounds=g},qE).success(),(x,c,h)=>x.reset(c).require(Ln,g=>{h.id=g}).require("elevation_idx",g=>{h.idx=g}).require("extent",g=>{h.extent=g}).require("height",g=>{h.height=g},mi.decodeMetricHeight).geometry(g=>{h.position=g},mi.getPoint).success());class mi{static getPoint(c){return Xs(c[0][0].x,c[0][0].y)}static decodeRelativeHeight(c){return 1e-4*c*5}static decodeMetricHeight(c){return 1e-4*c}static getVersionSchema(c){return c?c==="1.0.1"?$i:void 0:wn}static parse(c){const h=[],g=[],j=c.length,T=new Qi;for(let P=0;P=0);if(T===0)return 0;T!==c.length&&(h=!1)}return h?2:1}function Sl(x,c){for(const h of x.projections){const g=ll(c,x.points[0],h.axis);if(h.projection[1]g[1])return 0}return 1}function Mc(x,c){let h=0;const g=[0,0,0,0];for(let j=0;j=0&&h++;return h}class vh{constructor(c,h){this.points=c||new Array(8).fill([0,0,0]),this.planes=h||new Array(6).fill([0,0,0,0]),this.bounds=Ja.fromPoints(this.points),this.projections=[],this.frustumEdges=[Ce([],this.points[2],this.points[3]),Ce([],this.points[0],this.points[3]),Ce([],this.points[4],this.points[0]),Ce([],this.points[5],this.points[1]),Ce([],this.points[6],this.points[2]),Ce([],this.points[7],this.points[3])];for(const g of this.frustumEdges){const j=[0,-g[2],g[1]],T=[g[2],0,-g[0]];this.projections.push({axis:j,projection:ll(this.points,this.points[0],j)}),this.projections.push({axis:T,projection:ll(this.points,this.points[0],T)})}}static fromInvProjectionMatrix(c,h,g,j){const T=Math.pow(2,g),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(H=>{const Q=at([],H,c),se=1/Q[3]/h*T;return(re=Q)[0]=(oe=Q)[0]*(ue=[se,se,j?1/Q[3]:se,se])[0],re[1]=oe[1]*ue[1],re[2]=oe[2]*ue[2],re[3]=oe[3]*ue[3],re;var re,oe,ue}),R=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(H=>{const Q=ve([],Ue([],Ce([],P[H[0]],P[H[1]]),Ce([],P[H[2]],P[H[1]]))),se=-Re(Q,P[H[1]]);return Q.concat(se)}),F=[];for(let H=0;HH[1]||H[0]>F[1])return 0}return 1}containsPoint(c){for(const h of this.planes){const g=h[3];if(Re([h[0],h[1],h[2]],c)+g<0)return!1}return!0}}class Ja{static fromPoints(c){const h=[1/0,1/0,1/0],g=[-1/0,-1/0,-1/0];for(const j of c)he(h,h,j),we(g,g,j);return new Ja(h,g)}static fromTileIdAndHeight(c,h,g){const j=1<c.max[h]||c.min[h]>this.max[h])return!1;return!0}intersectsAabbXY(c){return!(this.min[0]>c.max[0]||c.min[0]>this.max[0]||this.min[1]>c.max[1]||c.min[1]>this.max[1])}encapsulate(c){for(let h=0;h<3;h++)this.min[h]=Math.min(this.min[h],c.min[h]),this.max[h]=Math.max(this.max[h],c.max[h])}encapsulatePoint(c){for(let h=0;h<3;h++)this.min[h]=Math.min(this.min[h],c[h]),this.max[h]=Math.max(this.max[h],c[h])}closestPoint(c){return[Math.max(Math.min(this.max[0],c[0]),this.min[0]),Math.max(Math.min(this.max[1],c[1]),this.min[1]),Math.max(Math.min(this.max[2],c[2]),this.min[2])]}}gr(Ja,"Aabb");class em{constructor(c,h){this.feature=c,this.metersToTile=h,this.index=0}get(){const c=this.feature.vertices[this.index],h=this.feature.vertexProps[this.index].dir,g=h[1],j=-h[0],T=(c.extent+1)*this.metersToTile;return[new Xt(Math.trunc(c.position[0]+g*T),Math.trunc(c.position[1]+j*T)),new Xt(Math.trunc(c.position[0]-g*T),Math.trunc(c.position[1]-j*T))]}next(){this.index++}valid(){return this.index{return R.a0?Ne(F,F,1/H):ie(F,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(c){if(this.edges.length===0)return;let h=0,g=Number.POSITIVE_INFINITY,j=0;const[T,P,R,F,H,Q,se]=this._tmpVec2;Nr(se,c.x,c.y);const re=new Ho(se,null);for(let oe=0;oe0?ir(F,R)/rt:0,ot=De(it,0,1),It=Math.abs((it-ot)*this.edgeProps[oe].len);ar(H,se,ke),Nr(Q,_e[1],-_e[0]);const wt=It+Math.abs(ir(H,Q));wt=0;--P){const R=this.edges[P].a,F=this.edges[P].b,{position:H,height:Q,extent:se}=this.vertices[R],{position:re,height:oe,extent:ue}=this.vertices[F],_e=this.vertexProps[R].dir,ke=this.vertexProps[F].dir;if(ie(h,H[0]/c,H[1]/c,Q),ie(g,re[0]/c,re[1]/c,oe),ie(j,_e[1],-_e[0],0),Ne(j,j,se),ie(T,ke[1],-ke[0],0),Ne(T,T,ue),this.distSqLines(ae(h[0]+.5*j[0],h[1]+.5*j[1],h[2]+.5*j[2]),ae(g[0]-.5*T[0],g[1]-.5*T[1],g[2]-.5*T[2]),ae(h[0]-.5*j[0],h[1]-.5*j[1],h[2]-.5*j[2]),ae(g[0]+.5*T[0],g[1]+.5*T[1],g[2]+.5*T[2]))<=.0025000000000000005)continue;const Pe=this.vertices.length,We=Vs(Bt(),H,re);this.vertices.push({position:Or(We,We,.5),height:.5*(Q+oe),extent:.5*(se+ue)});const qe=Vs(Bt(),_e,ke);this.vertexProps.push({dir:bn(qe,qe)}),this.edges.splice(P,1),this.edgeProps.splice(P,1),this.edges.push({a:R,b:Pe}),this.edges.push({a:Pe,b:F});const rt=ar(Bt(),this.vertices[Pe].position,H),it=Rn(rt),ot={vec:rt,dir:Or(Bt(),rt,1/it),len:it};this.edgeProps.push(ot),this.edgeProps.push(ot)}}distSqLines(c,h,g,j){const T=fe(J(),h,c),P=fe(J(),j,g),R=fe(J(),c,g),F=Re(T,T),H=Re(T,P),Q=Re(T,R),se=Re(P,P),re=Re(P,R),oe=F*se-H*H;if(oe===0)return Ae(ye(T,g,j,Re(R,P)/Re(P,P)),c);const ue=(F*re-H*Q)/oe;return Ae(ye(T,c,h,(H*re-Q*se)/oe),ye(P,g,j,ue))}}class Ci{static parseFrom(c,h){const g=mi.parse(c);if(!g)return[];let{vertices:j,features:T}=g;const P=1/Ts(h);T.sort((Q,se)=>Q.id-se.id),j.sort((Q,se)=>Q.id-se.id||Q.idx-se.idx),j=j.filter((Q,se,re)=>se===re.findIndex(oe=>oe.id===Q.id&&oe.idx===Q.idx));const R=new Array;let F=0;const H=j.length;for(const Q of T){if(Q.constantHeight){R.push(new tm(Q.id,Q.bounds,Q.constantHeight));continue}for(;F!==H&&j[F].idj.id===g)}}class Pi{constructor(c,h){this.zScale=1,this.xOffset=0,this.yOffset=0,c.equals(h)||(this.zScale=Math.pow(2,h.z-c.z),this.xOffset=(c.x*this.zScale-h.x)*sr,this.yOffset=(c.y*this.zScale-h.y)*sr)}constantElevation(c,h){if(c.constantHeight!=null)return this.computeBiasedHeight(c.constantHeight,h)}pointElevation(c,h,g){const j=this.constantElevation(h,g);return j??(c.x=c.x*this.zScale+this.xOffset,c.y=c.y*this.zScale+this.yOffset,this.computeBiasedHeight(h.pointElevation(c),g))}computeBiasedHeight(c,h){return h<=0?c:c+h*Ze(0,h,c>=0?c:Math.abs(.5*c))}}gr(tm,"ElevationFeature");class li{constructor(c){this.zoom=c.zoom,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(h=>h.fqid),this.index=c.index,this.hasPattern=!1,this.projection=c.projection,this.layoutVertexArray=new yh,this.indexArray=new Ao,this.segments=new wi,this.programConfigurations=new Me(c.layers,{zoom:c.zoom,lut:c.lut}),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,this.elevationMode!=="none"&&(this.elevatedLayoutVertexArray=new Qh),this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(c,h,g,j){const T=this.layers[0],P=[];let R=null;T.type==="circle"&&(R=T.layout.get("circle-sort-key"));for(const{feature:H,id:Q,index:se,sourceLayerIndex:re}of c){const oe=this.layers[0]._featureFilter.needGeometry,ue=qn(H,oe);if(!this.layers[0]._featureFilter.filter(new Ga(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),ue,g))continue;const _e=R?R.evaluate(ue,{},g):void 0,ke={id:Q,properties:H.properties,type:H.type,sourceLayerIndex:re,index:se,geometry:oe?ue.geometry:Ur(H,g,j),patterns:{},sortKey:_e};P.push(ke)}R&&P.sort((H,Q)=>H.sortKey-Q.sortKey);let F=null;j.projection.name==="globe"&&(this.globeExtVertexArray=new C3,F=j.projection);for(const H of P){const{geometry:Q,index:se,sourceLayerIndex:re}=H,oe=c[se].feature;this.addFeature(H,Q,se,h.availableImages,g,F,h.brightness,h.elevationFeatures),h.featureIndex.insert(oe,Q,se,re,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(c,h,g,j,T,P,R){this.programConfigurations.updatePaintArrays(c,h,T,g,j,P,R,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,zF.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,Ipe.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,Ppe.members))),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy())}addFeature(c,h,g,j,T,P,R,F){let H;this.elevationMode!=="none"&&(H=Ci.getElevationFeature(c,F));for(const Q of h)for(const se of Q){const re=se.x,oe=se.y;if(re<0||re>=sr||oe<0||oe>=sr)continue;if(P){const ke=P.projectTilePoint(re,oe,T),Pe=P.upVector(T,re,oe);this.addGlobeExtVertex(ke,Pe),this.addGlobeExtVertex(ke,Pe),this.addGlobeExtVertex(ke,Pe),this.addGlobeExtVertex(ke,Pe)}const ue=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,c.sortKey),_e=ue.vertexLength;if(this.addCircleVertex(re,oe,-1,-1),this.addCircleVertex(re,oe,1,-1),this.addCircleVertex(re,oe,1,1),this.addCircleVertex(re,oe,-1,1),this.elevationMode!=="none"){const ke=H?H.pointElevation(new Xt(re,oe)):0;this.hasElevation=this.hasElevation||ke!==0;for(let Pe=0;Pe<4;Pe++)this.elevatedLayoutVertexArray.emplaceBack(ke)}this.indexArray.emplaceBack(_e,_e+1,_e+2),this.indexArray.emplaceBack(_e,_e+2,_e+3),ue.vertexLength+=4,ue.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,g,{},j,T,R,void 0,this.worldview)}addCircleVertex(c,h,g,j){this.layoutVertexArray.emplaceBack(2*c+(g+1)/2,2*h+(j+1)/2)}addGlobeExtVertex(c,h){this.globeExtVertexArray.emplaceBack(c.x,c.y,c.z,h[0]*16384,h[1]*16384,h[2]*16384)}}function Fo(x,c){for(let h=0;h1){if(uy(x,c))return!0;for(let g=0;g1?h:h.sub(c)._mult(j)._add(c))}function i_(x,c){let h,g,j,T=!1;for(let P=0;Pc.y!=j.y>c.y&&c.x<(j.x-g.x)*(c.y-g.y)/(j.y-g.y)+g.x&&(T=!T)}return T}function Gu(x,c){let h=!1;for(let g=0,j=x.length-1;gc.y!=P.y>c.y&&c.x<(P.x-T.x)*(c.y-T.y)/(P.y-T.y)+T.x&&(h=!h)}return h}function hy(x,c,h,g,j){for(const P of x)if(c<=P.x&&h<=P.y&&g>=P.x&&j>=P.y)return!0;const T=[new Xt(c,h),new Xt(c,j),new Xt(g,j),new Xt(g,h)];if(x.length>2){for(const P of T)if(Gu(x,P))return!0}for(let P=0;Pj.x&&c.x>j.x||x.yj.y&&c.y>j.y)return!1;const T=un(x,c,h[0]);return T!==un(x,c,h[1])||T!==un(x,c,h[2])||T!==un(x,c,h[3])}function py(x,c,h,g,j,T){let P=c.y-x.y,R=x.x-c.x;if(T=T||0){const F=P*P+R*R;if(F===0)return!0;const H=Math.sqrt(F);P/=H,R/=H}return!((h.x-x.x)*P+(h.y-x.y)*R-T<0||(g.x-x.x)*P+(g.y-x.y)*R-T<0||(j.x-x.x)*P+(j.y-x.y)*R-T<0)}function R3(x,c,h,g,j,T,P){return!(py(x,c,g,j,T,P)||py(c,h,g,j,T,P)||py(h,x,g,j,T,P)||py(g,j,x,c,h,P)||py(j,T,x,c,h,P)||py(T,g,x,c,h,P))}function o_(x,c,h){const g=c.paint.get(x).value;return g.kind==="constant"?g.value:h.programConfigurations.get(c.id).getMaxValue(x)}function BF(x){return Math.sqrt(x[0]*x[0]+x[1]*x[1])}function u3e(x,c,h,g,j){if(!c[0]&&!c[1])return x;const T=Xt.convert(c)._mult(j);h==="viewport"&&T._rotate(-g);const P=[];for(let R=0;R>h&&c.y===this.y>>h}url(c,h){const g=function(T,P,R){const F=2**R,H=2*Math.PI*6378137,Q=H*(T/F-.5),se=H*(.5-(P+1)/F);return`${Q},${se},${Q+H/F},${se+H/F}`}(this.x,this.y,this.z),j=function(T,P,R){let F,H="";for(let Q=T;Q>0;Q--)F=1<this.canonical.z?new wu(c,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new wu(c,this.wrap,c,this.canonical.x>>h,this.canonical.y>>h)}calculateScaledKey(c,h=!0){if(this.overscaledZ===c&&h)return this.key;if(c>this.canonical.z)return O3(this.wrap*+h,c,this.canonical.z,this.canonical.x,this.canonical.y);{const g=this.canonical.z-c;return O3(this.wrap*+h,c,c,this.canonical.x>>g,this.canonical.y>>g)}}isChildOf(c){if(c.wrap!==this.wrap)return!1;const h=this.canonical.z-c.canonical.z;return c.overscaledZ===0||c.overscaledZ>h&&c.canonical.y===this.canonical.y>>h}children(c){if(this.overscaledZ>=c)return[new wu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const h=this.canonical.z+1,g=2*this.canonical.x,j=2*this.canonical.y;return[new wu(h,this.wrap,h,g,j),new wu(h,this.wrap,h,g+1,j),new wu(h,this.wrap,h,g,j+1),new wu(h,this.wrap,h,g+1,j+1)]}isLessThan(c){return this.wrapc.wrap)&&(this.overscaledZc.overscaledZ)&&(this.canonical.xc.canonical.x)&&this.canonical.y{let c=x.canonical.x-1,h=x.wrap;return c<0&&(c=(1<{let c=x.canonical.x+1,h=x.wrap;return c===1<new wu(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,(x.canonical.y===0?1<new wu(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,x.canonical.y===(1<1?null:function(g,j,T,P){const R=Math.sin(T);return g*(Math.sin((1-P)*T)/R)+j*(Math.sin(P*T)/R)}(x.a[c],x.b[c],x.angle,De(h,0,1))+x.center[c]}function fy(x){if(x.z<=1)return odt[x.z+2*x.y+x.x];const c=Bpe(UF(x));return Ja.fromPoints(c)}function rv(x,c,h){return Ne(x,x,1-h),Ve(x,x,c,h)}function y3e(x,c){const h=nv(c.zoom);if(h===0)return fy(x);const g=UF(x),j=Bpe(g),T=Ns(g.getWest())*c.worldSize,P=Ns(g.getEast())*c.worldSize,R=Is(g.getNorth())*c.worldSize,F=Is(g.getSouth())*c.worldSize,H=[T,R,0],Q=[P,R,0],se=[T,F,0],re=[P,F,0],oe=S([],c.globeMatrix);return ct(H,H,oe),ct(Q,Q,oe),ct(se,se,oe),ct(re,re,oe),j[0]=rv(j[0],se,h),j[1]=rv(j[1],re,h),j[2]=rv(j[2],Q,h),j[3]=rv(j[3],H,h),Ja.fromPoints(j)}function v3e(x,c,h){for(const g of x)ct(g,g,c),Ne(g,g,h)}function _3e(x,c,h,g){const j=c/x.worldSize,T=x.globeMatrix;if(h.z<=1){const At=fy(h).getCorners();return v3e(At,T,j),Ja.fromPoints(At)}const P=UF(h,g),R=Bpe(P,mt+qF(x._tileCoverLift));v3e(R,T,j);const F=Number.MAX_VALUE,H=[-F,-F,-F],Q=[F,F,F];if(P.contains(x.center)){for(const St of R)he(Q,Q,St),we(H,H,St);H[2]=0;const At=x.point,kt=[At.x*j,At.y*j,0];return he(Q,Q,kt),we(H,H,kt),new Ja(Q,H)}if(x._tileCoverLift>0){for(const At of R)he(Q,Q,At),we(H,H,At);return new Ja(Q,H)}const se=[T[12]*j,T[13]*j,T[14]*j],re=P.getCenter(),oe=De(x.center.lat,-85.051129,ds),ue=De(re.lat,-85.051129,ds),_e=Ns(x.center.lng),ke=Is(oe);let Pe=_e-Ns(re.lng);const We=ke-Is(ue);Pe>.5?Pe-=1:Pe<-.5&&(Pe+=1);let qe=0;Math.abs(Pe)>Math.abs(We)?qe=Pe>=0?1:3:(qe=We>=0?0:2,Ve(se,se,[T[4]*j,T[5]*j,T[6]*j],-Math.sin(Kt(We>=0?P.getSouth():P.getNorth()))*mt));const rt=R[qe],it=R[(qe+1)%4],ot=new ldt(rt,it,se),It=[zpe(ot,0)||rt[0],zpe(ot,1)||rt[1],zpe(ot,2)||rt[2]],wt=nv(x.zoom);if(wt>0){const At=function({x:St,y:rs,z:is},us,ws,hs,Ds){const ts=1/(1<.5?fr=-1:er<-.5&&(fr=1),vs=((vs+fr)*us-(hs*=us))*ws+hs,Ms=((Ms+fr)*us-hs)*ws+hs,Rs=(Rs*us-(Ds*=us))*ws+Ds,Ks=(Ks*us-Ds)*ws+Ds,[[vs,Ks,0],[Ms,Ks,0],[Ms,Rs,0],[vs,Rs,0]]}(h,c,x._pixelsPerMercatorPixel,_e,ke);for(let St=0;StMath.PI/2*1.01}const k3e=Kt(85),cdt=Math.cos(k3e),ddt=Math.sin(k3e),udt=b(),S3e=x=>{const c=[];return x.paint.get("circle-pitch-alignment")==="map"&&c.push("PITCH_WITH_MAP"),x.paint.get("circle-pitch-scale")==="map"&&c.push("SCALE_WITH_MAP"),c};function C3e(x,c,h,g,j,T,P,R,F){if(T&&x.queryGeometry.isAboveHorizon)return!1;T&&(F*=x.pixelToTileUnitsFactor);const H=x.tileID.canonical,Q=h.projection.upVectorScale(H,h.center.lat,h.worldSize).metersToTile;for(const se of c)for(const re of se){const oe=re.add(R),ue=j&&h.elevation?h.elevation.exaggeration()*j.getElevationAt(oe.x,oe.y,!0):0,_e=h.projection.projectTilePoint(oe.x,oe.y,H);if(ue>0){const qe=h.projection.upVector(H,oe.x,oe.y);_e.x+=qe[0]*Q*ue,_e.y+=qe[1]*Q*ue,_e.z+=qe[2]*Q*ue}const ke=T?oe:hdt(_e.x,_e.y,_e.z,g),Pe=T?x.tilespaceRays.map(qe=>pdt(qe,ue)):x.queryGeometry.screenGeometry,We=at([],[_e.x,_e.y,_e.z,1],g);if(!P&&T?F*=We[3]/h.cameraToCenterDistance:P&&!T&&(F*=h.cameraToCenterDistance/We[3]),T){const qe=ss((re.y/sr+H.y)/(1<x.width||j.height>x.height||h.x>x.width-j.width||h.y>x.height-j.height)throw new RangeError("out of range source coordinates for image copy");if(j.width>c.width||j.height>c.height||g.x>c.width-j.width||g.y>c.height-j.height)throw new RangeError("out of range destination coordinates for image copy");const F=x.data,H=c.data,Q=T===4&&R;for(let se=0;se{c[x.evaluationKey]=F;const H=x.expression.evaluate(c),Q=H?H.toNonPremultipliedRenderColor(null):null;Q&&(j.data[P+R+0]=Math.floor(255*Q.r),j.data[P+R+1]=Math.floor(255*Q.g),j.data[P+R+2]=Math.floor(255*Q.b),j.data[P+R+3]=Math.floor(255*Q.a))};if(x.clips)for(let P=0,R=0;P80*h){R=x[0],F=x[1];let Q=R,se=F;for(let re=h;reQ&&(Q=oe),ue>se&&(se=ue)}H=Math.max(Q-R,se-F),H=H!==0?32767/H:0}return tI(T,P,h,R,F,H,0),P}function O3e(x,c,h,g,j){let T;if(j===function(P,R,F,H){let Q=0;for(let se=R,re=F-H;se0)for(let P=c;P=c;P-=g)T=$3e(P/g|0,x[P],x[P+1],T);return T&&z3(T,T.next)&&(nI(T),T=T.next),T}function S2(x,c){if(!x)return x;c||(c=x);let h,g=x;do if(h=!1,g.steiner||!z3(g,g.next)&&Tc(g.prev,g,g.next)!==0)g=g.next;else{if(nI(g),g=c=g.prev,g===g.next)break;h=!0}while(h||g!==c);return c}function tI(x,c,h,g,j,T,P){if(!x)return;!P&&T&&function(F,H,Q,se){let re=F;do re.z===0&&(re.z=Hpe(re.x,re.y,H,Q,se)),re.prevZ=re.prev,re.nextZ=re.next,re=re.next;while(re!==F);re.prevZ.nextZ=null,re.prevZ=null,function(oe){let ue,_e=1;do{let ke,Pe=oe;oe=null;let We=null;for(ue=0;Pe;){ue++;let qe=Pe,rt=0;for(let ot=0;ot<_e&&(rt++,qe=qe.nextZ,qe);ot++);let it=_e;for(;rt>0||it>0&&qe;)rt!==0&&(it===0||!qe||Pe.z<=qe.z)?(ke=Pe,Pe=Pe.nextZ,rt--):(ke=qe,qe=qe.nextZ,it--),We?We.nextZ=ke:oe=ke,ke.prevZ=We,We=ke;Pe=qe}We.nextZ=null,_e*=2}while(ue>1)}(re)}(x,g,j,T);let R=x;for(;x.prev!==x.next;){const F=x.prev,H=x.next;if(T?_dt(x,g,j,T):vdt(x))c.push(F.i,x.i,H.i),nI(x),x=H.next,R=H.next;else if((x=H)===R){P?P===1?tI(x=bdt(S2(x),c),c,h,g,j,T,2):P===2&&wdt(x,c,h,g,j,T):tI(S2(x),c,h,g,j,T,1);break}}}function vdt(x){const c=x.prev,h=x,g=x.next;if(Tc(c,h,g)>=0)return!1;const j=c.x,T=h.x,P=g.x,R=c.y,F=h.y,H=g.y,Q=Math.min(j,T,P),se=Math.min(R,F,H),re=Math.max(j,T,P),oe=Math.max(R,F,H);let ue=g.next;for(;ue!==c;){if(ue.x>=Q&&ue.x<=re&&ue.y>=se&&ue.y<=oe&&sI(j,R,T,F,P,H,ue.x,ue.y)&&Tc(ue.prev,ue,ue.next)>=0)return!1;ue=ue.next}return!0}function _dt(x,c,h,g){const j=x.prev,T=x,P=x.next;if(Tc(j,T,P)>=0)return!1;const R=j.x,F=T.x,H=P.x,Q=j.y,se=T.y,re=P.y,oe=Math.min(R,F,H),ue=Math.min(Q,se,re),_e=Math.max(R,F,H),ke=Math.max(Q,se,re),Pe=Hpe(oe,ue,c,h,g),We=Hpe(_e,ke,c,h,g);let qe=x.prevZ,rt=x.nextZ;for(;qe&&qe.z>=Pe&&rt&&rt.z<=We;){if(qe.x>=oe&&qe.x<=_e&&qe.y>=ue&&qe.y<=ke&&qe!==j&&qe!==P&&sI(R,Q,F,se,H,re,qe.x,qe.y)&&Tc(qe.prev,qe,qe.next)>=0||(qe=qe.prevZ,rt.x>=oe&&rt.x<=_e&&rt.y>=ue&&rt.y<=ke&&rt!==j&&rt!==P&&sI(R,Q,F,se,H,re,rt.x,rt.y)&&Tc(rt.prev,rt,rt.next)>=0))return!1;rt=rt.nextZ}for(;qe&&qe.z>=Pe;){if(qe.x>=oe&&qe.x<=_e&&qe.y>=ue&&qe.y<=ke&&qe!==j&&qe!==P&&sI(R,Q,F,se,H,re,qe.x,qe.y)&&Tc(qe.prev,qe,qe.next)>=0)return!1;qe=qe.prevZ}for(;rt&&rt.z<=We;){if(rt.x>=oe&&rt.x<=_e&&rt.y>=ue&&rt.y<=ke&&rt!==j&&rt!==P&&sI(R,Q,F,se,H,re,rt.x,rt.y)&&Tc(rt.prev,rt,rt.next)>=0)return!1;rt=rt.nextZ}return!0}function bdt(x,c){let h=x;do{const g=h.prev,j=h.next.next;!z3(g,j)&&z3e(g,h,h.next,j)&&rI(g,j)&&rI(j,g)&&(c.push(g.i,h.i,j.i),nI(h),nI(h.next),h=x=j),h=h.next}while(h!==x);return S2(h)}function wdt(x,c,h,g,j,T){let P=x;do{let R=P.next.next;for(;R!==P.prev;){if(P.i!==R.i&&Cdt(P,R)){let F=B3e(P,R);return P=S2(P,P.next),F=S2(F,F.next),tI(P,c,h,g,j,T,0),void tI(F,c,h,g,j,T,0)}R=R.next}P=P.next}while(P!==x)}function jdt(x,c){let h=x.x-c.x;return h===0&&(h=x.y-c.y,h===0)&&(h=(x.next.y-x.y)/(x.next.x-x.x)-(c.next.y-c.y)/(c.next.x-c.x)),h}function Ndt(x,c){const h=function(j,T){let P=T;const R=j.x,F=j.y;let H,Q=-1/0;if(z3(j,P))return P;do{if(z3(j,P.next))return P.next;if(F<=P.y&&F>=P.next.y&&P.next.y!==P.y){const _e=P.x+(F-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(_e<=R&&_e>Q&&(Q=_e,H=P.x=P.x&&P.x>=re&&R!==P.x&&F3e(FH.x||P.x===H.x&&kdt(H,P)))&&(H=P,ue=_e)}P=P.next}while(P!==se);return H}(x,c);if(!h)return c;const g=B3e(h,x);return S2(g,g.next),S2(h,h.next)}function kdt(x,c){return Tc(x.prev,x,c.prev)<0&&Tc(c.next,x,x.next)<0}function Hpe(x,c,h,g,j){return(x=1431655765&((x=858993459&((x=252645135&((x=16711935&((x=(x-h)*j|0)|x<<8))|x<<4))|x<<2))|x<<1))|(c=1431655765&((c=858993459&((c=252645135&((c=16711935&((c=(c-g)*j|0)|c<<8))|c<<4))|c<<2))|c<<1))<<1}function Sdt(x){let c=x,h=x;do(c.x=(x-P)*(T-R)&&(x-P)*(g-R)>=(h-P)*(c-R)&&(h-P)*(T-R)>=(j-P)*(g-R)}function sI(x,c,h,g,j,T,P,R){return!(x===P&&c===R)&&F3e(x,c,h,g,j,T,P,R)}function Cdt(x,c){return x.next.i!==c.i&&x.prev.i!==c.i&&!function(h,g){let j=h;do{if(j.i!==h.i&&j.next.i!==h.i&&j.i!==g.i&&j.next.i!==g.i&&z3e(j,j.next,h,g))return!0;j=j.next}while(j!==h);return!1}(x,c)&&(rI(x,c)&&rI(c,x)&&function(h,g){let j=h,T=!1;const P=(h.x+g.x)/2,R=(h.y+g.y)/2;do j.y>R!=j.next.y>R&&j.next.y!==j.y&&P<(j.next.x-j.x)*(R-j.y)/(j.next.y-j.y)+j.x&&(T=!T),j=j.next;while(j!==h);return T}(x,c)&&(Tc(x.prev,x,c.prev)||Tc(x,c.prev,c))||z3(x,c)&&Tc(x.prev,x,x.next)>0&&Tc(c.prev,c,c.next)>0)}function Tc(x,c,h){return(c.y-x.y)*(h.x-c.x)-(c.x-x.x)*(h.y-c.y)}function z3(x,c){return x.x===c.x&&x.y===c.y}function z3e(x,c,h,g){const j=GF(Tc(x,c,h)),T=GF(Tc(x,c,g)),P=GF(Tc(h,g,x)),R=GF(Tc(h,g,c));return j!==T&&P!==R||!(j!==0||!HF(x,h,c))||!(T!==0||!HF(x,g,c))||!(P!==0||!HF(h,x,g))||!(R!==0||!HF(h,c,g))}function HF(x,c,h){return c.x<=Math.max(x.x,h.x)&&c.x>=Math.min(x.x,h.x)&&c.y<=Math.max(x.y,h.y)&&c.y>=Math.min(x.y,h.y)}function GF(x){return x>0?1:x<0?-1:0}function rI(x,c){return Tc(x.prev,x,x.next)<0?Tc(x,c,x.next)>=0&&Tc(x,x.prev,c)>=0:Tc(x,c,x.prev)<0||Tc(x,x.next,c)<0}function B3e(x,c){const h=Gpe(x.i,x.x,x.y),g=Gpe(c.i,c.x,c.y),j=x.next,T=c.prev;return x.next=c,c.prev=x,h.next=j,j.prev=h,g.next=h,h.prev=g,T.next=g,g.prev=T,g}function $3e(x,c,h,g){const j=Gpe(x,c,h);return g?(j.next=g.next,j.prev=g,g.next.prev=j,g.next=j):(j.prev=j,j.next=j),j}function nI(x){x.next.prev=x.prev,x.prev.next=x.next,x.prevZ&&(x.prevZ.nextZ=x.nextZ),x.nextZ&&(x.nextZ.prevZ=x.prevZ)}function Gpe(x,c,h){return{i:x,x:c,y:h,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function aI(x,c){const h=x.length;if(h<=1)return[x];const g=[];let j,T;for(let P=0;P1)for(let P=0;P=sr&&h>=sr}static evaluate(c){if(c.length===0)return new av;let h=[];for(const F of c)h.push(...F.portals);if(h.length===0)return new av;for(const F of h){const H=F.va,Q=F.vb;(av.isOnBorder(H.x,Q.x)||av.isOnBorder(H.y,Q.y))&&(F.type="border")}const g=h.filter(F=>F.type!=="unevaluated"),j=h.filter(F=>F.type==="unevaluated");if(j.length===0)return new av;j.sort((F,H)=>F.hash===H.hash?F.isTunnel===H.isTunnel?0:F.isTunnel?-1:1:F.hashF.hashT!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new Me(h,{zoom:g,lut:j},T=>T!=="fill-bridge-guard-rail-color")}addVertices(c,h){const g=this.unevalVertices.length;for(let j=0;j=T.min.x&&se.x<=T.max.x&&se.y>=T.min.y&&se.y<=T.max.y||re.x>=T.min.x&&re.x<=T.max.x&&re.y>=T.min.y&&re.y<=T.max.y||my(se,re,R))||this.isOnBorder(se.x,re.x)||this.isOnBorder(se.y,re.y))continue;const oe=sm.computeEdgeHash(this.unevalVertices[H],this.unevalVertices[Q]);let ue,_e=this.vertexHashLookup.get(sm.computePosHash(se));_e!=null?ue=_e.next:(_e=this.vertexHashLookup.get(sm.computePosHash(re)),ue=_e!=null?_e.prev:oe),this.unevalEdges.push({polygonIdx:c,a:H,b:Q,hash:oe,portalHash:ue,isTunnel:j,type:"unevaluated",featureInfo:P})}}addPortalCandidates(c,h,g,j,T){if(h.length!==0){this.vertexHashLookup.clear();for(const P of h){if(P.length===0)continue;const R=P[0];let F=sm.computeEdgeHash(R[R.length-2],R[R.length-1]);for(let H=0;H({vertexOffset:0,primitiveOffset:this.indexArray.length}),g=re=>{re.primitiveLength=this.indexArray.length-re.primitiveOffset},j=new Tdt(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(c.portals,this.unevalEdges);const T=h(),P=h(),R=h(),F=(re,oe)=>{re.sort((_e,ke)=>_e.type===oe&&ke.type!==oe?-1:_e.type!==oe&&ke.type===oe?1:0);const ue=re.findIndex(_e=>_e.type!==oe);return ue>=0?ue:re.length};let H=0;this.unevalEdges.length>0&&(H=F(this.unevalEdges,"none"),this.constructBridgeStructures(j,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:H},this.tileToMeters)),g(R);const Q=h(),se=h();if(this.unevalEdges.length>0){const re=this.unevalEdges.splice(H),oe=F(re,"tunnel")+H;this.unevalEdges.push(...re),this.constructTunnelStructures(j,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:H},{min:H,max:oe})}g(Q),j.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),g(se),j.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),g(P),j.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),g(T),this.maskSegments=wi.simpleSegment(0,se.primitiveOffset,0,se.primitiveLength),this.depthSegments=wi.simpleSegment(0,P.primitiveOffset,0,P.primitiveLength),this.renderableBridgeSegments=wi.simpleSegment(0,R.primitiveOffset,0,R.primitiveLength),this.renderableTunnelSegments=wi.simpleSegment(0,Q.primitiveOffset,0,Q.primitiveLength),this.shadowCasterSegments=wi.simpleSegment(0,T.primitiveOffset,0,T.primitiveLength)}update(c,h,g,j,T,P,R,F){this.bridgeProgramConfigurations.updatePaintArrays(c,h,T,g,j,P,R,F),this.tunnelProgramConfigurations.updatePaintArrays(c,h,T,g,j,P,R,F)}upload(c){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=c.createVertexBuffer(this.vertexPositions,gdt.members),this.vertexBufferNormal=c.createVertexBuffer(this.vertexNormals,ydt.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(c),this.tunnelProgramConfigurations.upload(c))}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy()}populatePaintArrays(c,h,g,j,T){const P=(R,F)=>{for(let H=0;Hie(ws,h[hs].x,h[hs].y,g[hs]*F),se=J(),re=J(),oe=J(),ue=J(),_e=J(),ke=(ws,hs)=>{const Ds=R.get(sm.computePosHash(h[hs])),ts=Ds.from,vs=Ds.to;if(!ts||!vs)return;Q(se,ts),Q(re,hs),Q(oe,vs),tt(ue),st(se,re)||(Ce(_e,re,se),ve(ue,_e)),st(oe,re)||(Ce(_e,oe,re),le(ue,ue,ve(_e,_e)));const Ms=Ct(ue);return Ms>0?Ne(ws,ue,1/Ms):void 0};let Pe=Number.POSITIVE_INFINITY;this.sortSubarray(j,T.min,T.max,(ws,hs)=>ws.featureInfo.featureIndex-hs.featureInfo.featureIndex);const We=J(),qe=J(),rt=J(),it=J(),ot=J(),It=J(),wt=J(),At=J(),kt=J(),St=[J(),J(),J(),J()],rs=[J(),J(),J(),J()],is=[{coord:new Xt(0,0),height:0},{coord:new Xt(0,0),height:0}],us=(ws,hs)=>ws>hs;for(let ws=T.min;wsPe.featureInfo.featureIndex-We.featureInfo.featureIndex;this.sortSubarray(j,T.min,T.max,F),this.sortSubarray(j,P.min,P.max,F);const H=Pe=>ve(Pe,Pe),Q=[{coord:new Xt(0,0),height:0},{coord:new Xt(0,0),height:0}],se=(Pe,We)=>PeR.hash===F.hash?F.polygonIdx-R.polygonIdx:F.hash>R.hash?1:-1);let g=0,j=0,T=0,P=h[g].polygonIdx;do j++,(j===h.length||h[g].hash!==h[j].hash)&&((j-g===1||h[j-1].polygonIdx!==P)&&(TH.portalHashQ.hash?R++:Q.hash>H.portalHash?F++:(H.type=Q.type,R++)}}}isOnBorder(c,h){return c<=0&&h<=0||c>=sr&&h>=sr}addFeatureSection(c,h,g,j){return c!==h&&(h=c,g.push({featureIndex:c,vertexStart:j.getVertexCount()}),j.clearVertexLookup()),h}sortSubarray(c,h,g,j){const T=c.slice(h,g);T.sort(j),c.splice(h,T.length,...T)}static computeEdgeHash(c,h){return(c.y===h.y&&c.x>h.x||c.y>h.y)&&([c,h]=[h,c]),BigInt(sm.computePosHash(c))<<32n|BigInt(sm.computePosHash(h))}static computePosHash(c){return((65535&c.x)<<16|65535&c.y)>>>0}}function Adt(x,c){return x>c?1:x0))return h;h=h.left}}return null}contains(c){for(var h=this._root,g=this._compare;h;){var j=g(c,h.key);if(j===0)return!0;h=j<0?h.left:h.right}return!1}remove(c){var h=this.find(c);if(!h)return!1;if(this.splay(h),h.left)if(h.right){var g=this.minNode(h.right);g.parent!==h&&(this.replace(g,g.right),g.right=h.right,g.right.parent=g),this.replace(h,g),g.left=h.left,g.left.parent=g}else this.replace(h,h.left);else this.replace(h,h.right);return this._size--,!0}removeNode(c){if(!c)return!1;if(this.splay(c),c.left)if(c.right){var h=this.minNode(c.right);h.parent!==c&&(this.replace(h,h.right),h.right=c.right,h.right.parent=h),this.replace(c,h),h.left=c.left,h.left.parent=h}else this.replace(c,c.left);else this.replace(c,c.right);return this._size--,!0}erase(c){var h=this.find(c);if(h){this.splay(h);var g=h.left,j=h.right,T=null;g&&(g.parent=null,T=this.maxNode(g),this.splay(T),this._root=T),j&&(g?T.right=j:this._root=j,j.parent=T),this._size--}}pop(){var c=this._root,h=null;if(c){for(;c.left;)c=c.left;h={key:c.key,data:c.data},this.remove(c.key)}return h}next(c){var h=c;if(h)if(h.right)for(h=h.right;h&&h.left;)h=h.left;else for(h=c.parent;h&&h.right===c;)c=h,h=h.parent;return h}prev(c){var h=c;if(h)if(h.left)for(h=h.left;h&&h.right;)h=h.right;else for(h=c.parent;h&&h.left===c;)c=h,h=h.parent;return h}forEach(c){for(var h=this._root,g=[],j=!1,T=0;!j;)h?(g.push(h),h=h.left):g.length>0?(c(h=g.pop(),T++),h=h.right):j=!0;return this}range(c,h,g,j){const T=[],P=this._compare;let R,F=this._root;for(;T.length!==0||F;)if(F)T.push(F),F=F.left;else{if(F=T.pop(),R=P(F.key,h),R>0)break;if(P(F.key,c)>=0&&g.call(j,F))return this;F=F.right}return this}keys(){for(var c=this._root,h=[],g=[],j=!1;!j;)c?(h.push(c),c=c.left):h.length>0?(c=h.pop(),g.push(c.key),c=c.right):j=!0;return g}values(){for(var c=this._root,h=[],g=[],j=!1;!j;)c?(h.push(c),c=c.left):h.length>0?(c=h.pop(),g.push(c.data),c=c.right):j=!0;return g}at(c){for(var h=this._root,g=[],j=!1,T=0;!j;)if(h)g.push(h),h=h.left;else if(g.length>0){if(h=g.pop(),T===c)return h;T++,h=h.right}else j=!0;return null}load(c=[],h=[],g=!1){if(this._size!==0)throw new Error("bulk-load: tree is not empty");const j=c.length;return g&&Xpe(c,h,0,j-1,this._compare),this._root=Ype(null,c,h,0,j),this._size=j,this}min(){var c=this.minNode(this._root);return c?c.key:null}max(){var c=this.maxNode(this._root);return c?c.key:null}isEmpty(){return this._root===null}get size(){return this._size}static createTree(c,h,g,j,T){return new Zpe(g,T).load(c,h,j)}}function Ype(x,c,h,g,j){const T=j-g;if(T>0){const P=g+Math.floor(T/2),R={key:c[P],data:h[P],parent:x};return R.left=Ype(R,c,h,g,P),R.right=Ype(R,c,h,P+1,j),R}return null}function Xpe(x,c,h,g,j){if(h>=g)return;const T=x[h+g>>1];let P=h-1,R=g+1;for(;;){do P++;while(j(x[P],T)<0);do R--;while(j(x[R],T)>0);if(P>=R)break;let F=x[P];x[P]=x[R],x[R]=F,F=c[P],c[P]=c[R],c[R]=F}Xpe(x,c,h,R,j),Xpe(x,c,R+1,g,j)}const U3e=11102230246251565e-32,bh=134217729,Edt=(3+8*U3e)*U3e;function Qpe(x,c,h,g,j){let T,P,R,F,H=c[0],Q=g[0],se=0,re=0;Q>H==Q>-H?(T=H,H=c[++se]):(T=Q,Q=g[++re]);let oe=0;if(seH==Q>-H?(P=H+T,R=T-(P-H),H=c[++se]):(P=Q+T,R=T-(P-Q),Q=g[++re]),T=P,R!==0&&(j[oe++]=R);seH==Q>-H?(P=T+H,F=P-T,R=T-(P-F)+(H-F),H=c[++se]):(P=T+Q,F=P-T,R=T-(P-F)+(Q-F),Q=g[++re]),T=P,R!==0&&(j[oe++]=R);for(;se0:(g[0]-c[0])*(h[1]-c[1])-(h[0]-c[0])*(g[1]-c[1])>0}isAbove(c){return!this.isBelow(c)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return this.resultTransition!==0}clone(){const c=new $3(this.point,this.left,this.otherEvent,this.isSubject,this.type);return c.contourId=this.contourId,c.resultTransition=this.resultTransition,c.prevInResult=this.prevInResult,c.isExteriorRing=this.isExteriorRing,c.inOut=this.inOut,c.otherInOut=this.otherInOut,c}}function xy(x,c){return x[0]===c[0]&&x[1]===c[1]}function Jpe(x,c,h){const g=function(j,T,P,R,F,H){const Q=(T-H)*(P-F),se=(j-F)*(R-H),re=Q-se;if(Q===0||se===0||Q>0!=se>0)return re;const oe=Math.abs(Q+se);return Math.abs(re)>=33306690738754716e-32*oe?re:-function(ue,_e,ke,Pe,We,qe,rt){let it,ot,It,wt,At,kt,St,rs,is,us,ws,hs,Ds,ts,vs,Ms,Rs,Ks;const fr=ue-We,er=ke-We,Js=_e-qe,Zs=Pe-qe;ts=fr*Zs,kt=bh*fr,St=kt-(kt-fr),rs=fr-St,kt=bh*Zs,is=kt-(kt-Zs),us=Zs-is,vs=rs*us-(ts-St*is-rs*is-St*us),Ms=Js*er,kt=bh*Js,St=kt-(kt-Js),rs=Js-St,kt=bh*er,is=kt-(kt-er),us=er-is,Rs=rs*us-(Ms-St*is-rs*is-St*us),ws=vs-Rs,At=vs-ws,B3[0]=vs-(ws+At)+(At-Rs),hs=ts+ws,At=hs-ts,Ds=ts-(hs-At)+(ws-At),ws=Ds-Ms,At=Ds-ws,B3[1]=Ds-(ws+At)+(At-Ms),Ks=hs+ws,At=Ks-hs,B3[2]=hs-(Ks-At)+(ws-At),B3[3]=Ks;let dr=function(ba,Sn){let ka=Sn[0];for(let Un=1;Un<4;Un++)ka+=Sn[Un];return ka}(0,B3),jr=22204460492503146e-32*rt;if(dr>=jr||-dr>=jr||(At=ue-fr,it=ue-(fr+At)+(At-We),At=ke-er,It=ke-(er+At)+(At-We),At=_e-Js,ot=_e-(Js+At)+(At-qe),At=Pe-Zs,wt=Pe-(Zs+At)+(At-qe),it===0&&ot===0&&It===0&&wt===0)||(jr=11093356479670487e-47*rt+Edt*Math.abs(dr),dr+=fr*wt+Zs*it-(Js*It+er*ot),dr>=jr||-dr>=jr))return dr;ts=it*Zs,kt=bh*it,St=kt-(kt-it),rs=it-St,kt=bh*Zs,is=kt-(kt-Zs),us=Zs-is,vs=rs*us-(ts-St*is-rs*is-St*us),Ms=ot*er,kt=bh*ot,St=kt-(kt-ot),rs=ot-St,kt=bh*er,is=kt-(kt-er),us=er-is,Rs=rs*us-(Ms-St*is-rs*is-St*us),ws=vs-Rs,At=vs-ws,rm[0]=vs-(ws+At)+(At-Rs),hs=ts+ws,At=hs-ts,Ds=ts-(hs-At)+(ws-At),ws=Ds-Ms,At=Ds-ws,rm[1]=Ds-(ws+At)+(At-Ms),Ks=hs+ws,At=Ks-hs,rm[2]=hs-(Ks-At)+(ws-At),rm[3]=Ks;const $r=Qpe(4,B3,4,rm,V3e);ts=fr*wt,kt=bh*fr,St=kt-(kt-fr),rs=fr-St,kt=bh*wt,is=kt-(kt-wt),us=wt-is,vs=rs*us-(ts-St*is-rs*is-St*us),Ms=Js*It,kt=bh*Js,St=kt-(kt-Js),rs=Js-St,kt=bh*It,is=kt-(kt-It),us=It-is,Rs=rs*us-(Ms-St*is-rs*is-St*us),ws=vs-Rs,At=vs-ws,rm[0]=vs-(ws+At)+(At-Rs),hs=ts+ws,At=hs-ts,Ds=ts-(hs-At)+(ws-At),ws=Ds-Ms,At=Ds-ws,rm[1]=Ds-(ws+At)+(At-Ms),Ks=hs+ws,At=Ks-hs,rm[2]=hs-(Ks-At)+(ws-At),rm[3]=Ks;const Pr=Qpe($r,V3e,4,rm,H3e);ts=it*wt,kt=bh*it,St=kt-(kt-it),rs=it-St,kt=bh*wt,is=kt-(kt-wt),us=wt-is,vs=rs*us-(ts-St*is-rs*is-St*us),Ms=ot*It,kt=bh*ot,St=kt-(kt-ot),rs=ot-St,kt=bh*It,is=kt-(kt-It),us=It-is,Rs=rs*us-(Ms-St*is-rs*is-St*us),ws=vs-Rs,At=vs-ws,rm[0]=vs-(ws+At)+(At-Rs),hs=ts+ws,At=hs-ts,Ds=ts-(hs-At)+(ws-At),ws=Ds-Ms,At=Ds-ws,rm[1]=Ds-(ws+At)+(At-Ms),Ks=hs+ws,At=Ks-hs,rm[2]=hs-(Ks-At)+(ws-At),rm[3]=Ks;const kn=Qpe(Pr,H3e,4,rm,G3e);return G3e[kn-1]}(j,T,P,R,F,H,oe)}(x[0],x[1],c[0],c[1],h[0],h[1]);return g>0?-1:g<0?1:0}function c_(x,c){const h=x.point,g=c.point;return h[0]>g[0]?1:h[0]g[1]?1:-1:function(j,T,P){return j.left!==T.left?j.left?1:-1:Jpe(P,j.otherEvent.point,T.otherEvent.point)!==0?j.isBelow(T.otherEvent.point)?-1:1:!j.isSubject&&T.isSubject?1:-1}(x,c,h)}function d_(x,c,h){const g=new $3(c,!1,x,x.isSubject),j=new $3(c,!0,x.otherEvent,x.isSubject);return xy(x.point,x.otherEvent.point)&&console.warn("what is that, a collapsed segment?",x),g.contourId=j.contourId=x.contourId,c_(j,x.otherEvent)>0&&(x.otherEvent.left=!0,j.left=!1),x.otherEvent.otherEvent=j,x.otherEvent=g,h.push(j),h.push(g),h}function WF(x,c){return x[0]*c[1]-x[1]*c[0]}function efe(x,c){return x[0]*c[0]+x[1]*c[1]}function tfe(x,c,h){const g=function(F,H,Q,se){const re=[H[0]-F[0],H[1]-F[1]],oe=[se[0]-Q[0],se[1]-Q[1]];function ue(It,wt,At){return[It[0]+wt*At[0],It[1]+wt*At[1]]}const _e=[Q[0]-F[0],Q[1]-F[1]];let ke=WF(re,oe),Pe=ke*ke;const We=efe(re,re);if(Pe>0){const It=WF(_e,oe)/ke;if(It<0||It>1)return null;const wt=WF(_e,re)/ke;return wt<0||wt>1?null:It===0||It===1?[ue(F,It,re)]:wt===0||wt===1?[ue(Q,wt,oe)]:[ue(F,It,re)]}if(ke=WF(_e,re),Pe=ke*ke,Pe>0)return null;const qe=efe(re,_e)/We,rt=qe+efe(re,oe)/We,it=Math.min(qe,rt),ot=Math.max(qe,rt);return it<=1&&ot>=0?it===1?[ue(F,it>0?it:0,re)]:ot===0?[ue(F,ot<1?ot:1,re)]:[ue(F,it>0?it:0,re),ue(F,ot<1?ot:1,re)]:null}(x.point,x.otherEvent.point,c.point,c.otherEvent.point),j=g?g.length:0;if(j===0||j===1&&(xy(x.point,c.point)||xy(x.otherEvent.point,c.otherEvent.point))||j===2&&x.isSubject===c.isSubject)return 0;if(j===1)return!xy(x.point,g[0])&&!xy(x.otherEvent.point,g[0])&&d_(x,g[0],h),!xy(c.point,g[0])&&!xy(c.otherEvent.point,g[0])&&d_(c,g[0],h),1;const T=[];let P=!1,R=!1;return xy(x.point,c.point)?P=!0:c_(x,c)===1?T.push(c,x):T.push(x,c),xy(x.otherEvent.point,c.otherEvent.point)?R=!0:c_(x.otherEvent,c.otherEvent)===1?T.push(c.otherEvent,x.otherEvent):T.push(x.otherEvent,c.otherEvent),P&&R||P?(c.type=1,x.type=c.inOut===x.inOut?2:3,P&&!R&&d_(T[1].otherEvent,T[0].point,h),2):R?(d_(T[0],T[1].point,h),3):T[0]!==T[3].otherEvent?(d_(T[0],T[1].point,h),d_(T[1],T[2].point,h),3):(d_(T[0],T[1].point,h),d_(T[3].otherEvent,T[2].point,h),3)}function Pdt(x,c){if(x===c)return 0;if(Jpe(x.point,x.otherEvent.point,c.point)!==0||Jpe(x.point,x.otherEvent.point,c.otherEvent.point)!==0)return xy(x.point,c.point)?x.isBelow(c.otherEvent.point)?-1:1:x.point[0]===c.point[0]?x.point[1](c.contourId??0)?1:-1}return c_(x,c)===1?1:-1}class Idt{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return this.holeOf==null}}function Ldt(x,c,h,g){let j,T=x+1,P=c[x].point;const R=c.length;for(Tg;)T--;return T}function Ddt(x,c,h){const g=new Idt;if(x.prevInResult!=null){const j=x.prevInResult,T=j.outputContourId;if(j.resultTransition>0){const P=c[T];if(P.holeOf!=null){const R=P.holeOf;c[R].holeIds.push(h),g.holeOf=R,g.depth=c[T].depth}else c[T].holeIds.push(h),g.holeOf=T,g.depth=c[T].depth+1}else g.holeOf=null,g.depth=c[T].depth}else g.holeOf=null,g.depth=0;return g}const K3e=Math.max,Z3e=Math.min;let KF=0;function Y3e(x,c,h,g,j,T){let P,R,F,H,Q,se;for(P=0,R=x.length-1;P0?se.left=!0:Q.left=!0;const re=F[0],oe=F[1];j[0]=Z3e(j[0],re),j[1]=Z3e(j[1],oe),j[2]=K3e(j[2],re),j[3]=K3e(j[3],oe),g.push(Q),g.push(se)}}const ZF=[];function X3e(x,c,h){let g=x,j=c;typeof x[0][0][0]=="number"&&(g=[x]),typeof c[0][0][0]=="number"&&(j=[c]);let T=function(re,oe,ue){let _e=null;return re.length*oe.length===0&&(ue===0?_e=ZF:ue===2?_e=re:(ue===1||ue===3)&&(_e=re.length===0?oe:re)),_e}(g,j,h);if(T)return T===ZF?null:T;const P=[1/0,1/0,-1/0,-1/0],R=[1/0,1/0,-1/0,-1/0],F=function(re,oe,ue,_e,ke){const Pe=new Ww(void 0,c_);let We,qe,rt,it,ot,It;for(rt=0,it=re.length;rt_e[2]||_e[0]>ue[2]||ue[1]>_e[3]||_e[1]>ue[3])&&(ke===0?Pe=ZF:ke===2?Pe=re:(ke===1||ke===3)&&(Pe=re.concat(oe))),Pe}(g,j,P,R,h),T)return T===ZF?null:T;const H=function(re,oe,ue,_e,ke,Pe){const We=new Zpe(Pdt),qe=[],rt=Math.min(_e[2],ke[2]);let it,ot,It;for(;re.length!==0;){let wt=re.pop();if(qe.push(wt),Pe===0&&wt.point[0]>rt||Pe===2&&wt.point[0]>_e[2])break;if(wt.left){ot=it=We.insert(wt),It=We.minNode(),it=it!==It?We.prev(it):null,ot=We.next(ot);const At=it?it.key:null;let kt;if(oI(wt,At,Pe),ot&&tfe(wt,ot.key,re)===2&&(oI(wt,At,Pe),oI(ot.key,wt,Pe)),it&&tfe(it.key,wt,re)===2){let St=it;St=St!==It?We.prev(St):null,kt=St?St.key:null,oI(At,kt,Pe),oI(wt,At,Pe)}}else wt=wt.otherEvent,ot=it=We.find(wt),it&&ot&&(it=it!==It?We.prev(it):null,ot=We.next(ot),We.remove(wt),ot&&it&&tfe(it.key,ot.key,re))}return qe}(F,0,0,P,R,h),Q=function(re){let oe,ue;const _e=function(We){let qe,rt,it,ot,It;const wt=[];for(rt=0,it=We.length;rt{ke[It]=!0,It<_e.length&&_e[It]&&(_e[It].outputContourId=We)};let it=oe,ot=oe;for(qe.points.push(_e[oe].point);rt(it),it=_e[it].otherPos,rt(it),qe.points.push(_e[it].point),it=Ldt(it,_e,ke,ot),!(it==ot||it>=_e.length)&&_e[it];);Pe.push(qe)}return Pe}(H),se=[];for(let re=0;re{P.push(new Xt(se,F+(se-R)/(H-R)*(Q-F)))}:(P,R,F,H,Q,se)=>{P.push(new Xt(R+(se-F)/(Q-F)*(H-R),se))};for(const P of x){const R=[];for(const F of P){if(F.length<=2)continue;const H=[];for(let re=0;rec&&T(H,oe,ue,_e,ke,c):Pe>h?We=c&&T(H,oe,ue,_e,ke,c),We>h&&Pe<=h&&T(H,oe,ue,_e,ke,h)}let Q=F[F.length-1];const se=g===0?Q.x:Q.y;se>=c&&se<=h&&H.push(Q),H.length&&(Q=H[H.length-1],H[0].x===Q.x&&H[0].y===Q.y||H.push(H[0]),R.push(H))}R.length&&j.push(R)}return j}function Rdt(x,c){const h=X3e(sfe(x),sfe([c]),0);return h==null?[]:Q3e(h)}function Odt(x,c,h=0){let j=sfe(x,65536);const T=[];for(;c.valid();c.next()){const[P,R]=c.get();let F=P.x*65536,H=P.y*65536,Q=R.x*65536,se=R.y*65536;const re=Q-F,oe=se-H,ue=Math.hypot(re,oe);if(ue===0)continue;F-=re*h,H-=oe*h,Q+=re*h,se+=oe*h;const _e=Math.trunc(oe/ue*3),ke=-Math.trunc(re/ue*3);T.push([[[F,H],[Q,se],[Q+_e,se+ke],[F+_e,H+ke],[F,H]]])}return T.length>0&&(j=X3e(j,T,2)),Q3e(j,1/65536,128)}function sfe(x,c=1){return[x.map(h=>h.map(g=>[g.x*c,g.y*c]))]}function Q3e(x,c=1,h){return x.map(g=>g.map((j,T)=>{const P=j.map(R=>{let F=R[0],H=R[1];return h&&(F=Math.round(F/h)*h,H=Math.round(H/h)*h),new Xt(F*c,H*c)._round()});return T>0&&P.reverse(),P}))}class rfe{constructor(c,h){this.layoutVertexArray=new yh,this.indexArray=new Ao,this.lineIndexArray=new Vm,this.triangleSegments=new wi,this.lineSegments=new wi,this.programConfigurations=new Me(c.layers,{zoom:c.zoom,lut:c.lut}),this.uploaded=!1,h&&(this.elevatedLayoutVertexArray=new Qh)}update(c,h,g,j,T,P,R,F){this.programConfigurations.updatePaintArrays(c,h,T,g,j,P,R,F)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,fdt.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.lineIndexBuffer=c.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,xdt.members))),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(c,h,g,j,T,P,R){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,h,g,j,T,P,void 0,R)}}class XF{constructor(c){this.zoom=c.zoom,this.pixelRatio=c.pixelRatio,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(h=>h.fqid),this.index=c.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=c.lut,this.bufferData=new rfe(c,!1),this.elevationBufferData=new rfe(c,!0),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.projection=c.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=c.sourceLayerIndex,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(c,h,g,j){this.hasPattern=Wpe("fill",this.layers,this.pixelRatio,h);const T=this.layers[0].layout.get("fill-sort-key"),P=[];for(const{feature:R,id:F,index:H,sourceLayerIndex:Q}of c){const se=this.layers[0]._featureFilter.needGeometry,re=qn(R,se);if(!this.layers[0]._featureFilter.filter(new Ga(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),re,g))continue;const oe=T?T.evaluate(re,{},g,h.availableImages):void 0,ue={id:F,properties:R.properties,type:R.type,sourceLayerIndex:Q,index:H,geometry:se?re.geometry:Ur(R,g,j),patterns:{},sortKey:oe};P.push(ue)}T&&P.sort((R,F)=>R.sortKey-F.sortKey);for(const R of P){const{geometry:F,index:H,sourceLayerIndex:Q}=R;if(this.hasPattern){const se=Kpe("fill",this.layers,R,this.zoom,this.pixelRatio,h);this.patternFeatures.push(se)}else this.addFeature(R,F,H,g,{},h.availableImages,h.brightness,h.elevationFeatures);h.featureIndex.insert(c[H].feature,F,H,Q,this.index)}}update(c,h,g,j,T,P,R){this.bufferData.update(c,h,g,j,T,P,R,this.worldview),this.elevationBufferData.update(c,h,g,j,T,P,R,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(c,h,g,j,T,P,R,this.worldview)}addFeatures(c,h,g,j,T,P){for(const R of this.patternFeatures)this.addFeature(R,R.geometry,R.index,h,g,j,P,c.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(c){this.bufferData.upload(c),this.elevationBufferData.upload(c),this.elevatedStructures&&this.elevatedStructures.upload(c)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(c,h,g,j,T,P=[],R,F){const H=aI(h,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(c,H,j,g,F):this.addGeometry(H,this.bufferData),this.bufferData.populatePaintArrays(c,g,T,P,j,R,this.worldview),this.elevationBufferData.populatePaintArrays(c,g,T,P,j,R,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(c,h,g,j,T){this.elevatedStructures&&(this.elevatedStructures.construct(c),this.elevatedStructures.populatePaintArrays(h,g,j,T,this.worldview))}addElevatedRoadFeature(c,h,g,j,T){const P=new Array,R=Ci.getElevationFeature(c,T);if(!R)return void this.addGeometry(h,this.bufferData);{const H=this.clipPolygonsToTile(h,1);H.length>0&&P.push({polygons:H,elevationFeature:R,elevationTileID:g})}const F={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(c,{},g),featureIndex:j};for(const H of P)if(H.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new sm(H.elevationTileID,this.layers,this.zoom,this.lut));const se=H.elevationFeature.isTunnel();let re=0;c.properties.hasOwnProperty(Ni)&&(re=+c.properties[Ni]),this.elevatedStructures.addPortalCandidates(H.elevationFeature.id,H.polygons,se,H.elevationFeature,re)}H.elevationFeature.constantHeight==null&&(H.polygons=this.prepareElevatedPolygons(H.polygons,H.elevationFeature,H.elevationTileID));const Q=new Pi(g,H.elevationTileID);this.addElevatedGeometry(H.polygons,Q,H.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,j,F)}}addElevatedGeometry(c,h,g,j,T,P){const R={elevation:g,elevationSampler:h,bias:j,index:T,featureInfo:P},[F,H]=this.addGeometry(c,this.elevationBufferData,R);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:F,max:H}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,F),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,H))}addGeometry(c,h,g){let j=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,P=null;g&&(P=g.elevationSampler.constantElevation(g.elevation,g.bias),P!=null&&(j=P,T=P));const R=(F,H,Q)=>{if(g!=null)if(H.push(F),P!=null)h.elevatedLayoutVertexArray.emplaceBack(P),Q.push(P);else{const se=g.elevationSampler.pointElevation(F,g.elevation,g.bias);h.elevatedLayoutVertexArray.emplaceBack(se),Q.push(se),j=Math.min(j,se),T=Math.max(T,se)}};for(const F of c){let H=0;for(const qe of F)H+=qe.length;const Q=h.triangleSegments.prepareSegment(H,h.layoutVertexArray,h.indexArray),se=Q.vertexLength,re=[],oe=[],ue=[],_e=[],ke=[],Pe=h.layoutVertexArray.length;for(const qe of F){if(qe.length===0)continue;qe!==F[0]&&oe.push(re.length/2);const rt=h.lineSegments.prepareSegment(qe.length,h.layoutVertexArray,h.lineIndexArray),it=rt.vertexLength;g&&ke.push(h.layoutVertexArray.length-Pe),R(qe[0],ue,_e),h.layoutVertexArray.emplaceBack(qe[0].x,qe[0].y),h.lineIndexArray.emplaceBack(it+qe.length-1,it),re.push(qe[0].x),re.push(qe[0].y);for(let ot=1;ot0&&g&&this.elevationMode==="hd-road-base"){const qe=g.elevation.isTunnel(),rt=g.elevation.safeArea,it=this.elevatedStructures.addVertices(ue,_e);this.elevatedStructures.addTriangles(We,it,qe);const ot=ke.length;if(ot>0){for(let It=0;It=g&&oe.max.x<=T&&oe.min.y>=j&&oe.max.y<=P?F:H).push(re)}if(F.length===c.length)return c;const Q=[new Xt(g,j),new Xt(T,j),new Xt(T,P),new Xt(g,P),new Xt(g,j)],se=F;for(const re of H)se.push(...Rdt(re,Q));return se}}let J3e,e5e,t5e,s5e;gr(XF,"FillBucket",{omit:["layers","patternFeatures"]}),gr(rfe,"FillBufferData"),gr(sm,"ElevatedStructures");class QF{constructor(c,h,g,j){if(this.triangleCount=h.length/3,this.min=new Xt(0,0),this.max=new Xt(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||c.length===0)return;const[T,P]=[c[0].clone(),c[0].clone()];for(let se=1;sese.cellIdx-re.cellIdx||se.triIdx-re.triIdx);let Q=0;for(;Qthis.max.x||this.min.x>c.x||c.y>this.max.y||this.min.y>c.y)return;const g=gy(c.x-this.min.x,this.xScale,this.cellsX),j=gy(c.y-this.min.y,this.yScale,this.cellsY),T=this.cells[j*this.cellsX+g];if(T){this._lazyInitLookup();for(let P=0;Pthis.max.x||this.min.x>h.x||c.y>this.max.y||this.min.y>h.y)return;this._lazyInitLookup();const j=gy(c.x-this.min.x,this.xScale,this.cellsX),T=gy(h.x-this.min.x,this.xScale,this.cellsX),P=gy(c.y-this.min.y,this.yScale,this.cellsY),R=gy(h.y-this.min.y,this.yScale,this.cellsY);for(let F=P;F<=R;F++)for(let H=j;H<=T;H++){const Q=this.cells[F*this.cellsX+H];if(Q)for(let se=0;seh.fqid),this.index=c.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.footprints=[],this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){for(const g of this.footprints)h.push({footprint:g,id:c})}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(c,h,g,j){const T=[];for(const{feature:P,id:R,index:F,sourceLayerIndex:H}of c){const Q=this.layers[0]._featureFilter.needGeometry,se=qn(P,Q);if(!this.layers[0]._featureFilter.filter(new Ga(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),se,g))continue;const re={id:R,properties:P.properties,type:P.type,sourceLayerIndex:H,index:F,geometry:Q?se.geometry:Ur(P,g,j),patterns:{}};T.push(re)}for(const P of T){const{geometry:R,index:F,sourceLayerIndex:H}=P;this.addFeature(P,R,F,g,{},h.availableImages,h.brightness),h.featureIndex.insert(c[F].feature,R,F,H,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(c){}update(c,h,g,j,T,P,R){}destroy(){}addFeature(c,h,g,j,T,P=[],R){for(const F of aI(h,2)){const H=[],Q=[],se=[],re=new Xt(1/0,1/0),oe=new Xt(-1/0,-1/0);for(const ke of F)if(ke.length!==0){ke!==F[0]&&se.push(Q.length/2);for(let Pe=0;Pec.max.x||x.max.xc.max.y||x.max.ynew Xt((F.x+T.x*sr)*R-P.x*sr,(F.y+T.y*sr)*R-P.y*sr))}return afe(h,j,x.indices,0,x.indices.length,0,0)}function l5e(x,c,h,g){const j=Math.pow(2,g.z-h.z);return new Xt((x+h.x*sr)*j-g.x*sr,(c+h.y*sr)*j-g.y*sr)}function c5e(x,c){const h=[];c.grid.queryPoint(x,h);const g=c.indices,j=c.vertices;for(let T=0;T0&&(g.length>1&&h.push(g),g=[])}return g.length>1&&h.push(g),h}const ofe=ln.types,Kdt=["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"],Zdt=["fill-extrusion-flood-light-ground-radius"],Ydt=Math.pow(2,13),Xdt=Math.pow(2,15)-1,s7=new Xt(0,1),iv=2147483648,r7=1073741824;function cI(x,c,h,g,j,T,P,R){x.emplaceBack((c<<1)+P,(h<<1)+T,(Math.floor(g*Ydt)<<1)+j,Math.round(R))}function dI(x,c,h){x.emplaceBack(c.x*sr,c.y*sr,h?1:0)}function n7(x,c,h,g,j,T){x.emplaceBack(c.x,c.y,(h.x<<1)+g,(h.y<<1)+j,T)}function uI(x,c,h){x.emplaceBack(c.x,c.y,c.z,h[0]*16384,h[1]*16384,h[2]*16384)}class u5e{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class lfe{constructor(){this.centroidXY=new Xt(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 Xt(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Xt(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new Xt(0,0)}span(){return new Xt(this.max.x-this.min.x,this.max.y-this.min.y)}}class cfe{constructor(){this.acc=new Xt(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(c,h){c.min.x===Number.MAX_VALUE&&(c.min.x=c.max.x=h.x,c.min.y=c.max.y=h.y)}appendEdge(c,h,g){this.accCount++,this.acc._add(h);let j=!!this.borders;h.xc.max.x&&(c.max.x=h.x,j=!0),h.yc.max.y&&(c.max.y=h.y,j=!0),((h.x===0||h.x===sr)&&h.x===g.x)!=((h.y===0||h.y===sr)&&h.y===g.y)&&this.processBorderOverlap(h,g),j&&this.checkBorderIntersection(h,g)}checkBorderIntersection(c,h){h.x<0!=c.x<0&&this.addBorderIntersection(0,en(h.y,c.y,(0-h.x)/(c.x-h.x))),h.x>sr!=c.x>sr&&this.addBorderIntersection(1,en(h.y,c.y,(sr-h.x)/(c.x-h.x))),h.y<0!=c.y<0&&this.addBorderIntersection(2,en(h.x,c.x,(0-h.y)/(c.y-h.y))),h.y>sr!=c.y>sr&&this.addBorderIntersection(3,en(h.x,c.x,(sr-h.y)/(c.y-h.y)))}addBorderIntersection(c,h){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 g=this.borders[c];hg[1]&&(g[1]=h)}processBorderOverlap(c,h){if(c.x===h.x){if(c.y===h.y)return;const g=c.x===0?0:1;this.addBorderIntersection(g,h.y),this.addBorderIntersection(g,c.y)}else{const g=c.y===0?2:3;this.addBorderIntersection(g,h.x),this.addBorderIntersection(g,c.x)}}centroid(){return this.accCount===0?new Xt(0,0):new Xt(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((c,h)=>c+ +(h[0]!==Number.MAX_VALUE),0):0}}function h5e(x,c){const h=x.add(c)._unit(),g=De(x.x*h.x+x.y*h.y,-1,1);var j,T,P;return P=Math.acos(g),Math.min(4,Math.max(-4,Math.tan(P)))/4*Xdt*((j=x).x*(T=c).y-j.y*T.x<0?-1:1)}const Qdt=[x=>x.x<0,x=>x.x>sr,x=>x.y<0,x=>x.y>sr];function Jdt(x,c,h,g){const j=[4];if(g===0)return j;h._mult(g);const T=x.sub(h),P=c.sub(h),R=[x,c,T,P];for(let F=0;F<4;F++)for(const H of R)if(Qdt[F](H)){j.push(F);break}return j}class dfe{constructor(c){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new OP,this.indexArray=new Ao,this.programConfigurations=new Me(c.layers,{zoom:c.zoom,lut:c.lut},h=>Zdt.includes(h)),this._segments=new wi,this.hiddenByLandmarkVertexArray=new I3,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new wi}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(c,h,g,j=!1){const T=c.length;if(T>2){let P=Math.max(0,this._segments.get().length-1);const R=this._segments._prepareSegment(4*T,this.vertexArray.length,2*this._segmentToGroundQuads[P].length);let F;P!==this._segments.get().length-1&&(P++,this._segmentToGroundQuads[P]=[],this._segmentToRegionTriCounts[P]=[0,0,0,0,0]);{const H=c[0],Q=c[1];F=h5e(H.sub(c[T-1])._perp()._unit(),Q.sub(H)._perp()._unit())}for(let H=0;Hj.region-T.region);for(let g=0;gF+H,0);let R=0;for(let F=0;F<=4;F++){const H=P[F];if(H!==0){let Q=this.regionSegments[F];Q||(Q=this.regionSegments[F]=new wi);const se={vertexOffset:T.vertexOffset,primitiveOffset:T.primitiveOffset+R,vertexLength:T.vertexLength,primitiveLength:H};Q.get().push(se)}R+=H}for(let F=0;F0?this.hiddenByLandmarkVertexBuffer=c.createVertexBuffer(this.hiddenByLandmarkVertexArray,Udt.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let c=0;c<=4;c++){const h=this.regionSegments[c];h&&h.destroy()}}}}class a7{constructor(c){this.zoom=c.zoom,this.canonical=c.canonical,this.overscaling=c.overscaling,this.layers=c.layers,this.pixelRatio=c.pixelRatio,this.layerIds=this.layers.map(h=>h.fqid),this.index=c.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=c.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ao,this.footprintVertices=new yh,this.footprintSegments=[],this.layoutVertexArray=new RP,this.centroidVertexArray=new FF,this.wallVertexArray=new ZP,this.indexArray=new Ao,this.programConfigurations=new Me(c.layers,{zoom:c.zoom,lut:c.lut},h=>Kdt.includes(h)),this.segments=new wi,this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.groundEffect=new dfe(c),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(c,h,g,j){this.features=[],this.hasPattern=Wpe("fill-extrusion",this.layers,this.pixelRatio,h),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=Ts(g),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:T,id:P,index:R,sourceLayerIndex:F}of c){const H=this.layers[0]._featureFilter.needGeometry,Q=qn(T,H);if(!this.layers[0]._featureFilter.filter(new Ga(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),Q,g))continue;const se={id:P,sourceLayerIndex:F,index:R,geometry:H?Q.geometry:Ur(T,g,j),properties:T.properties,type:T.type,patterns:{}},re=this.layoutVertexArray.length,oe=ofe[se.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:T.id,feature:Kpe("fill-extrusion",this.layers,se,this.zoom,this.pixelRatio,h)});else if(this.wallMode)for(const ue of se.geometry)for(const _e of d5e(ue,oe))this.addFeature(T.id,se,[_e],R,g,{},h.availableImages,j,h.brightness);else this.addFeature(T.id,se,se.geometry,R,g,{},h.availableImages,j,h.brightness);h.featureIndex.insert(T,se.geometry,R,F,this.index,re)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(c,h,g,j,T,P){for(const{featureId:R,feature:F}of this.features){const H=ofe[F.type]==="Polygon",{geometry:Q}=F;if(this.wallMode)for(const se of Q)for(const re of d5e(se,H))this.addFeature(R,F,[re],F.index,h,g,j,T,P);else this.addFeature(R,F,Q,F.index,h,g,j,T,P)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(c,h,g,j,T,P,R){this.programConfigurations.updatePaintArrays(c,h,T,g,j,P,R,this.worldview),this.groundEffect.update(c,h,T,g,j,P,R,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,Hdt),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.wallVertexBuffer=c.createVertexBuffer(this.wallVertexArray,qdt.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=c.createVertexBuffer(this.layoutVertexExtArray,Vdt.members,!0)),this.groundEffect.upload(c)),this.groundEffect.uploadPaintProperties(c),this.programConfigurations.upload(c),this.uploaded=!0}uploadCentroid(c){this.groundEffect.uploadHiddenByLandmark(c),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=c.createVertexBuffer(this.centroidVertexArray,$dt.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(c,h,g,j,T,P,R,F,H){const Q=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(h,{})/this.tileToMeter,se=[new Xt(0,0),new Xt(sr,sr)],re=F.projection,oe=re.name==="globe",ue=this.wallMode||ofe[h.type]==="Polygon",_e=new cfe;_e.centroidDataIndex=this.centroidData.length;const ke=new lfe;ke.buildingId=c,h.properties&&h.properties.hasOwnProperty("building_id")&&(ke.buildingId=Number(h.properties.building_id)),_e.buildingId=ke.buildingId;const Pe=this.layers[0].paint.get("fill-extrusion-base").evaluate(h,{},T)<=0,We=this.layers[0].paint.get("fill-extrusion-height").evaluate(h,{},T);let qe;if(ke.height=We,ke.vertexArrayOffset=this.layoutVertexArray.length,ke.groundVertexArrayOffset=this.groundEffect.vertexArray.length,oe&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new C3),this.wallMode){if(oe)return void zr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(g.length!==1)return;qe=function(kt){const St=kt[0].x===kt[kt.length-1].x&&kt[0].y===kt[kt.length-1].y;(function(Js){let Zs=0;const dr=Js.length;for(let jr=0;jr=0})(kt)||(kt=kt.reverse());const is={geometry:[],joinNormals:[],indices:[]},us=[],ws=[],hs=[];let Ds=kt.length;for(;Ds>=2&&kt[Ds-1].equals(kt[Ds-2]);)Ds--;if(Ds<(St?3:2))return is;let ts,vs,Ms,Rs,Ks,fr=0;for(;fr0;let Pr="miter";const kn=2;Pr==="miter"&&jr>kn&&(Pr="bevel"),Pr==="bevel"&&(jr>100&&(Pr="flipbevel"),jr{const Wa=new Xt(Sn.x,Sn.y),Ia=new Xt(Sn.x,Sn.y);Wa.x+=ka.x*po,Wa.y+=ka.y*po,Ia.x-=ka.x*Math.max(Un,1),Ia.y-=ka.y*Math.max(Un,1),hs.push(ka),us.push(Wa),ws.push(Ia)};if(Pr==="miter")Zs._mult(jr),ba(ts,Zs,0,0);else if(Pr==="flipbevel")Zs=Ks.mult(-1),ba(ts,Zs,0,0),ba(ts,Zs.mult(-1),0,0);else{const Sn=-Math.sqrt(jr*jr-1),ka=$r?Sn:0,Un=$r?0:Sn;vs&&ba(ts,Rs,ka,Un),Ms&&ba(ts,Ks,ka,Un)}}is.geometry=[...us,...ws.reverse(),us[0]],is.joinNormals=[...hs,...hs.reverse(),hs[hs.length-1]];const er=is.geometry.length-1;for(let Js=0;Jskt<(St.length-1)/2||kt===St.length-1,it=this.wallMode?[g]:aI(g,500);for(let kt=it.length-1;kt>=0;kt--){const St=it[kt];(St.length===0||tut(St[0]))&&it.splice(kt,1)}let ot;if(oe)ot=v5e(it,se,T);else{ot=[];for(const kt of it)ot.push({polygon:kt,bounds:se})}const It=ue?this.edgeRadius:0,wt=It>0&&this.zoom<17,At=(kt,St)=>{if(kt.length===0)return!1;const rs=kt[kt.length-1];return St.x===rs.x&&St.y===rs.y};for(const{polygon:kt,bounds:St}of ot){let rs=0,is=0;for(const Ds of kt)ue&&!Ds[0].equals(Ds[Ds.length-1])&&Ds.push(Ds[0]),is+=ue?Ds.length-1:Ds.length;const us=this.segments.prepareSegment((ue?5:4)*is,this.layoutVertexArray,this.indexArray);ke.footprintSegIdx<0&&(ke.footprintSegIdx=this.footprintSegments.length),ke.polygonSegIdx<0&&(ke.polygonSegIdx=this.polygonSegments.length);const ws={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},hs=new u5e;if(hs.vertexOffset=this.footprintVertices.length,hs.indexOffset=3*this.footprintIndices.length,hs.ringIndices=[],ue){const Ds=[],ts=[];rs=us.vertexLength;for(let Ms=0;Ms4&&x5e(ts[ts.length-2],ts[0],ts[1]),Ms=It?eut(ts[ts.length-2],ts[0],ts[1],It):0;const Rs=[];let Ks,fr,er;fr=ts[1].sub(ts[0])._perp()._unit();let Js=!0;for(let Zs=1,dr=0;Zs0?1:0,ka=jr.dist($r);if(dr+ka>32768&&(dr=0),It){er=Pr.sub($r)._perp()._unit();let Ia=p5e(jr,$r,Pr,m5e(fr,er),It);isNaN(Ia)&&(Ia=0);const ki=$r.sub(jr)._unit();jr=jr.add(ki.mult(Ms))._round(),$r=$r.add(ki.mult(-Ia))._round(),Ms=Ia,fr=er,Pe&&this.zoom>=17&&(At(Rs,jr)||Rs.push(jr),At(Rs,$r)||Rs.push($r))}const Un=us.vertexLength,po=ts.length>4&&x5e(jr,$r,Pr);let Wa=g5e(dr,vs,Js);if(cI(this.layoutVertexArray,jr.x,jr.y,ba,Sn,0,0,Wa),cI(this.layoutVertexArray,jr.x,jr.y,ba,Sn,0,1,Wa),this.wallMode){const Ia=rt(Zs-1,ts),ki=qe.joinNormals[Zs-1];dI(this.wallVertexArray,ki,Ia),dI(this.wallVertexArray,ki,Ia)}if(dr+=ka,Wa=g5e(dr,po,!Js),vs=po,cI(this.layoutVertexArray,$r.x,$r.y,ba,Sn,0,0,Wa),cI(this.layoutVertexArray,$r.x,$r.y,ba,Sn,0,1,Wa),this.wallMode){const Ia=rt(Zs,ts),ki=qe.joinNormals[Zs];dI(this.wallVertexArray,ki,Ia),dI(this.wallVertexArray,ki,Ia)}if(us.vertexLength+=4,this.indexArray.emplaceBack(Un+0,Un+1,Un+2),this.indexArray.emplaceBack(Un+1,Un+3,Un+2),us.primitiveLength+=2,It){const Ia=rs+(Zs===1?ts.length-2:Zs-2),ki=Zs===1?rs:Ia+1;if(this.indexArray.emplaceBack(Un+1,Ia,Un+3),this.indexArray.emplaceBack(Ia,ki,Un+3),us.primitiveLength+=2,Ks===void 0&&(Ks=Un),!ufe(Pr,ts[Zs],St)){const io=Zs===ts.length-1?Ks:us.vertexLength;this.indexArray.emplaceBack(Un+2,Un+3,io),this.indexArray.emplaceBack(Un+3,io+1,io),this.indexArray.emplaceBack(Un+3,ki,io+1),us.primitiveLength+=3}Js=!Js}if(oe){const Ia=this.layoutVertexExtArray,ki=re.projectTilePoint(jr.x,jr.y,T),io=re.projectTilePoint($r.x,$r.y,T),oc=re.upVector(T,jr.x,jr.y),oo=re.upVector(T,$r.x,$r.y);uI(Ia,ki,oc),uI(Ia,ki,oc),uI(Ia,io,oo),uI(Ia,io,oo)}}ue&&(rs+=ts.length-1),Pe&&It&&this.zoom>=17&&(Rs.length!==0&&At(Rs,Rs[0])&&Rs.pop(),this.groundEffect.addData(Rs,St,Q,It>0))}this.footprintSegments.push(hs),ws.triangleCount=this.indexArray.length-ws.triangleArrayOffset,this.polygonSegments.push(ws),++ke.footprintSegLen,++ke.polygonSegLen}if(ke.vertexCount=this.layoutVertexArray.length-ke.vertexArrayOffset,ke.groundVertexCount=this.groundEffect.vertexArray.length-ke.groundVertexArrayOffset,ke.vertexCount!==0){if(ke.centroidXY=_e.borders?s7:this.encodeCentroid(_e,ke),h.properties&&h.properties.hasOwnProperty("building_id")){const kt=ke.buildingId;let St=this.buildingGroups.get(kt);St||(St={accX:0,accY:0,accCount:0,mergedMin:new Xt(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new Xt(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(kt,St)),St.accX+=_e.acc.x,St.accY+=_e.acc.y,St.accCount+=_e.accCount,St.mergedMin.x=Math.min(St.mergedMin.x,ke.min.x),St.mergedMin.y=Math.min(St.mergedMin.y,ke.min.y),St.mergedMax.x=Math.max(St.mergedMax.x,ke.max.x),St.mergedMax.y=Math.max(St.mergedMax.y,ke.max.y),St.partIndices.push(this.centroidData.length)}if(this.centroidData.push(ke),_e.borders){this.featuresOnBorder.push(_e);const kt=this.featuresOnBorder.length-1;for(let St=0;St<_e.borders.length;St++)_e.borders[St][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[St].push(kt)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,h,j,P,R,T,H,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(h,j,P,R,T,H,this.worldview),this.maxHeight=Math.max(this.maxHeight,We)}}_finalizeBuildingGroups(){for(const[,c]of this.buildingGroups){if(c.partIndices.length===0)continue;const h=new cfe;h.acc=new Xt(c.accX,c.accY),h.accCount=c.accCount;const g=new lfe;g.min=c.mergedMin,g.max=c.mergedMax;const j=this.encodeCentroid(h,g),T=h.centroid();for(const P of c.partIndices){const R=this.centroidData[P];R.centroidXY.x===s7.x&&R.centroidXY.y===s7.y||(R.centroidXY=j),R.min=c.mergedMin,R.max=c.mergedMax,R.groupCentroidPos=T}}this.buildingGroups.clear()}sortBorders(){for(let c=0;cthis.featuresOnBorder[h].borders[c][0]-this.featuresOnBorder[g].borders[c][0])}splitToSubtiles(){const c=[];for(let R=0;Rsr),Q=2*H+(+(F.min.x+F.max.x>sr)^H);for(let se=0;seR.triangleSegmentIdx===F.triangleSegmentIdx?R.subtile-F.subtile:R.triangleSegmentIdx-F.triangleSegmentIdx);let g=0,j=0,T=0;for(const R of c){if(R.triangleSegmentIdx!==g)break;T++}const P=c.length;for(;j!==c.length;){g=c[j].triangleSegmentIdx;let R=0,F=j,H=j;for(let Q=F;Q0&&this.triangleSubSegments.push({segment:oe,min:se,max:re}),F=H;for(let ue=F;ue[_e[0]*(1-Pe[0])+ke[0]*Pe[0],_e[1]*(1-Pe[1])+ke[1]*Pe[1]],oe=[],ue=[];for(const _e of this.triangleSubSegments){oe[0]=_e.min.x/sr,oe[1]=_e.min.y/sr,ue[0]=_e.max.x/sr,ue[1]=_e.max.y/sr;const ke=re(Q,se,oe),Pe=re(Q,se,ue);if(new Ja([ke[0],ke[1],T],[Pe[0],Pe[1],P]).intersectsPrecise(g)===0){H&&(j.segments.push(H),H=void 0);continue}const We=_e.segment;H&&H.vertexOffset!==We.vertexOffset&&(j.segments.push(H),H=void 0),H?(H.vertexLength+=We.vertexLength,H.primitiveLength+=We.primitiveLength):H={vertexOffset:We.vertexOffset,primitiveLength:We.primitiveLength,vertexLength:We.vertexLength,primitiveOffset:We.primitiveOffset,sortKey:void 0,vaos:{}}}return H&&j.segments.push(H),j}encodeCentroid(c,h){const g=c.centroid(),j=h.span(),T=Math.min(7,Math.round(j.x*this.tileToMeter/10)),P=Math.min(6,Math.round(j.y*this.tileToMeter/10));return new Xt(De(g.x,1,8191)<<3|T,De(g.y,1,8191)<<3|P)}encodeBorderCentroid(c){if(!c.borders)return new Xt(0,0);const h=c.borders,g=Number.MAX_VALUE;if(h[0][0]!==g||h[1][0]!==g){const j=h[0][0]!==g?0:1;return new Xt(6|(h[0][0]!==g?0:65528),(h[j][0]+h[j][1])/2<<3|6)}{const j=h[2][0]!==g?2:3;return new Xt((h[j][0]+h[j][1])/2<<3|6,6|(h[2][0]!==g?0:65528))}}showCentroid(c){const h=this.centroidData[c.centroidDataIndex];if(h.flags&=iv,h.groupCentroidPos.x!==0||h.groupCentroidPos.y!==0){const g=h.span(),j=Math.min(7,Math.round(g.x*this.tileToMeter/10)),T=Math.min(6,Math.round(g.y*this.tileToMeter/10));h.centroidXY=new Xt(De(h.groupCentroidPos.x,1,8191)<<3|j,De(h.groupCentroidPos.y,1,8191)<<3|T)}else h.centroidXY=new Xt(0,0);this.writeCentroidToBuffer(h)}writeCentroidToBuffer(c){this.groundEffect.updateHiddenByLandmark(c);const h=c.vertexArrayOffset,g=c.vertexCount+c.vertexArrayOffset,j=-1073741824&c.flags?s7:c.centroidXY,T=this.centroidVertexArray.geta_centroid_pos0(h);if(this.centroidVertexArray.geta_centroid_pos1(h)!==j.y||T!==j.x){for(let P=h;PF.max.x||F.min.x>P.max.x||P.min.y>F.max.y||F.min.y>P.max.y||P.footprint.buildingIds.has(F.buildingId)&&(F.flags|=P.clipMask!==t7.None?-1073741824:iv);else for(const F of this.centroidData)if(!(F.flags&iv||F.flags&r7||P.min.x>F.max.x||F.min.x>P.max.x||P.min.y>F.max.y||F.min.y>P.max.y))for(let H=0;Hh!=oe>h&&c<(this.footprintVertices.int16[2*(Q+P.vertexOffset)+0]-se)*(h-re)/(oe-re)+se&&(j=!j)}R=F}}return j}getHeightAtTileCoord(c,h){let g=Number.NEGATIVE_INFINITY,j=!0;const T=4*(c+sr)*sr+(h+sr);if(this.partLookup.hasOwnProperty(T)){const P=this.partLookup[T];return P?{height:P.height,hidden:!!(P.flags&iv)}:void 0}for(const P of this.centroidData)c>P.max.x||P.min.x>c||h>P.max.y||P.min.y>h||P.height<=g||this.footprintContainsPoint(c,h,P)&&(g=P.height,this.partLookup[T]=P,j=!!(P.flags&iv));if(g!==Number.NEGATIVE_INFINITY)return{height:g,hidden:j};this.partLookup[T]=void 0}}function m5e(x,c){const h=x.add(c)._unit();return x.x*h.x+x.y*h.y}function eut(x,c,h,g){const j=c.sub(x)._perp()._unit(),T=h.sub(c)._perp()._unit();return p5e(x,c,h,m5e(j,T),g)}function p5e(x,c,h,g,j){const T=Math.sqrt(1-g*g);return Math.min(x.dist(c)/3,c.dist(h)/3,j*T/g)}function ufe(x,c,h){return x.xh[1].x&&c.x>h[1].x||x.yh[1].y&&c.y>h[1].y}function f5e(x,c){return x.xc[1].x||x.yc[1].y}function tut(x){return x.every(c=>c.x<=0)||x.every(c=>c.x>=sr)||x.every(c=>c.y<=0)||x.every(c=>c.y>=sr)}function x5e(x,c,h){if(x.x<0||x.x>=sr||c.x<0||c.x>=sr||h.x<0||h.x>=sr)return!1;const g=h.sub(c),j=g.perp(),T=x.sub(c);return(g.x*T.x+g.y*T.y)/Math.sqrt((g.x*g.x+g.y*g.y)*(T.x*T.x+T.y*T.y))>-.866&&j.x*T.x+j.y*T.y<0}function g5e(x,c,h){const g=c?2|x:-3&x;return h?1|g:-2&g}function y5e(){const x=Math.PI/32,c=Math.tan(x),h=Tt;return h*Math.sqrt(1+2*c*c)-h}function v5e(x,c,h){const g=1<{for(const wt of ot)ue.push({polygon:wt,bounds:It})},ke=Math.ceil(Math.log2(Q)),Pe=Math.ceil(Math.log2(se)),We=ke-Pe,qe=[];for(let ot=0;ot0?0:1);for(let ot=0;otIt+1?it.push({polygons:us,bounds:hs,depth:It+1}):_e(us,hs)}if(ws.length){const hs=[new Xt(wt===0?is:At.x,wt===1?is:At.y),kt];qe.length>It+1?it.push({polygons:ws,bounds:hs,depth:It+1}):_e(ws,hs)}}return ue}(x,c,Math.ceil((T-j)/11.25),Math.ceil((P-R)/11.25),1,(F,H,Q)=>{if(F===0)return .5*(H+Q);{const se=ss((h.y+H/sr)/g);return(Is(.5*(ss((h.y+Q/sr)/g)+se))*g-h.y)*sr}})}function sut(x,c,h,g,j,T){const P=Math.pow(2,g.z-j.z);for(let R=0;R=F[P]&&(R=c,F=x),R[P]j&&j5e(R,F,P,j),R[P]T&&j5e(F,R,P,T)}}function i7(x,c,h,g,j,T){const P=[];for(let R=0;R=g&&ue.x>=g||(oe.x>=g?oe=new Xt(g,oe.y+(g-oe.x)/(ue.x-oe.x)*(ue.y-oe.y))._round():ue.x>=g&&(ue=new Xt(g,oe.y+(g-oe.x)/(ue.x-oe.x)*(ue.y-oe.y))._round()),oe.y>=j&&ue.y>=j||(oe.y>=j?oe=new Xt(oe.x+(j-oe.y)/(ue.y-oe.y)*(ue.x-oe.x),j)._round():ue.y>=j&&(ue=new Xt(oe.x+(j-oe.y)/(ue.y-oe.y)*(ue.x-oe.x),j)._round()),H&&oe.equals(H[H.length-1])||(H=[oe],P.push(H),T&&T.push({progress:{min:ke+k5e(Pe,We,oe)*_e,max:1},parentIndex:R,prevPoint:Pe,nextPoint:We})),H.push(ue),T&&(T[T.length-1].progress.max=ke+k5e(Pe,We,ue)*_e,T[T.length-1].nextPoint=We)))))}if(T&&se>0)for(let re=Q;reH.t-Q.t);let P=0,R=0,F=[];for(g.push(F);P!==x.length;){if(R===T.length){for(;P!==x.length;)F.length!==0&&F[F.length-1].equals(x[P])||F.push(x[P]),P++;break}T[R].t<=P?(F.length!==0&&F[F.length-1].equals(T[R].point)||F.push(T[R].point),Math.trunc(T[R].t),R++):(F.length!==0&&F[F.length-1].equals(x[P])||F.push(x[P]),P++)}}function k5e(x,c,h){return x.x!==c.x?(h.x-x.x)/(c.x-x.x):x.y!==c.y?(h.y-x.y)/(c.y-x.y):0}function hI(x,c){return x.x*c.x+x.y*c.y}function S5e(x,c){if(x.length===1){let h=0;const g=c[h++];let j;for(;!j||g.equals(j);)if(j=c[h++],!j)return 1/0;for(;h{is[0]=us,is[1]=ws,is[2]=hs,is[3]=1},rs=y5e();oe>0&&(oe+=rs),ue+=rs;for(const is of re){const us=[],ws=[];for(const hs of is){const Ds=hs.x+_e.x,ts=hs.y+_e.y,vs=se.projection.projectTilePoint(Ds,ts,it),Ms=se.projection.upVector(it,hs.x,hs.y);let Rs=oe,Ks=ue;if(Pe){const fr=T5e(Ds,ts,oe,ue,Pe,We,qe,rt);Rs+=fr.base,Ks+=fr.top}oe!==0?St(At,vs.x+Ms[0]*wt*Rs,vs.y+Ms[1]*wt*Rs,vs.z+Ms[2]*wt*Rs):St(At,vs.x,vs.y,vs.z),St(kt,vs.x+Ms[0]*wt*Ks,vs.y+Ms[1]*wt*Ks,vs.z+Ms[2]*wt*Ks),ct(At,At,ke),ct(kt,kt,ke),us.push(new C2(At[0],At[1],At[2])),ws.push(new C2(kt[0],kt[1],kt[2]))}ot.push(us),It.push(ws)}return[ot,It]}(x,c,h,g,j,T,P,R,F,H,Q):P?function(se,re,oe,ue,_e,ke,Pe,We,qe){const rt=[],it=[],ot=[0,0,0,1];for(const It of se){const wt=[],At=[];for(const kt of It){const St=kt.x+ue.x,rs=kt.y+ue.y,is=T5e(St,rs,re,oe,ke,Pe,We,qe);ot[0]=St,ot[1]=rs,ot[2]=is.base,ot[3]=1,at(ot,ot,_e),ot[3]=Math.max(ot[3],1e-5);const us=new C2(ot[0]/ot[3],ot[1]/ot[3],ot[2]/ot[3]);ot[0]=St,ot[1]=rs,ot[2]=is.top,ot[3]=1,at(ot,ot,_e),ot[3]=Math.max(ot[3],1e-5);const ws=new C2(ot[0]/ot[3],ot[1]/ot[3],ot[2]/ot[3]);wt.push(us),At.push(ws)}rt.push(wt),it.push(At)}return[rt,it]}(c,h,g,j,T,P,R,F,H):function(se,re,oe,ue,_e){const ke=[],Pe=[],We=_e[8]*re,qe=_e[9]*re,rt=_e[10]*re,it=_e[11]*re,ot=_e[8]*oe,It=_e[9]*oe,wt=_e[10]*oe,At=_e[11]*oe;for(const kt of se){const St=[],rs=[];for(const is of kt){const us=is.x+ue.x,ws=is.y+ue.y,hs=_e[0]*us+_e[4]*ws+_e[12],Ds=_e[1]*us+_e[5]*ws+_e[13],ts=_e[2]*us+_e[6]*ws+_e[14],vs=_e[3]*us+_e[7]*ws+_e[15],Ms=hs+We,Rs=Ds+qe,Ks=ts+rt,fr=Math.max(vs+it,1e-5),er=hs+ot,Js=Ds+It,Zs=ts+wt,dr=Math.max(vs+At,1e-5);St.push(new C2(Ms/fr,Rs/fr,Ks/fr)),rs.push(new C2(er/dr,Js/dr,Zs/dr))}ke.push(St),Pe.push(rs)}return[ke,Pe]}(c,h,g,j,T)}function T5e(x,c,h,g,j,T,P,R){const F=P*j.getElevationAt(x,c,!0,!0),H=T[0]!==0,Q=H?T[1]===0?P*(T[0]/7-450):P*function(se,re,oe){const ue=Math.floor(re[0]/8),_e=Math.floor(re[1]/8),ke=10*(re[0]-8*ue),Pe=10*(re[1]-8*_e),We=se.getElevationAt(ue,_e,!0,!0),qe=se.getMeterToDEM(oe),rt=Math.floor(.5*(ke*qe-1)),it=Math.floor(.5*(Pe*qe-1)),ot=se.tileCoordToPixel(ue,_e),It=2*rt+1,wt=2*it+1,At=function(ws,hs,Ds,ts,vs){return[ws.getElevationAtPixel(hs,Ds,!0),ws.getElevationAtPixel(hs+vs,Ds,!0),ws.getElevationAtPixel(hs,Ds+vs,!0),ws.getElevationAtPixel(hs+ts,Ds+vs,!0)]}(se,ot.x-rt,ot.y-it,It,wt),kt=Math.abs(At[0]-At[1]),St=Math.abs(At[2]-At[3]),rs=Math.abs(At[0]-At[2])+Math.abs(At[1]-At[3]),is=Math.min(.25,.5*qe*(kt+St)/It),us=Math.min(.25,.5*qe*rs/wt);return We+Math.max(is*ke,us*Pe)}(j,T,R):F;return{base:F+(h===0?-1:h),top:H?Math.max(Q+g,F+h+2):F+g}}const hfe=4096;class nut{constructor(c){this.module=c,this.memoryStack=this.module.malloc(hfe),this.memoryStackNextFree=this.memoryStack}createIntArray(c){const h=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>hfe?-1:(new Int32Array(this.module.heap32.buffer,h,c.length).set(c),h)}createFloatArray(c){const h=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>hfe?-1:(new Float32Array(this.module.heapF32.buffer,h,c.length).set(c),h)}readStringBuffer(c){let h="";for(;this.module.heapU8[c]!==0;)h+=String.fromCharCode(this.module.heapU8[c]),++c;return h}setStyle(c){const h=c.normalScale;this.module.setStyle(h[0],h[1],h[2],c.tileToMeters)}setAOOptions(c,h){this.module.setAOOptions(c?1:0,h)}setMetricOptions(c,h){this.module.setMetricOptions(c?1:0,h)}setStructuralOptions(c){this.module.setStructuralOptions(c?1:0)}setFacadeOptions(c,h){this.module.setFacadeOptions(c,h?1:0)}setFauxFacadeOptions(c,h,g){this.module.setFauxFacadeOptions(c?1:0,h?1:0,g)}setFacadeClassifierOptions(c){this.module.setFacadeClassifierOptions(c)}generateMesh(c,h){this.memoryStackNextFree=this.memoryStack;for(const R of c){const F=this.createIntArray(R.ringIndices),H=this.createFloatArray(R.coordinates);if(F===-1||H===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(R.id,R.sourceId,R.minHeight,R.height,R.roofType,H,F,R.ringIndices.length-1)}for(const R of h){let F;F=R.entrances?JSON.parse(R.entrances):[];const H=this.createFloatArray(F),Q=this.createFloatArray(R.coordinates);if(H===-1||Q===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(R.sourceId,R.crossPerc,R.distanceToRoad,H,F.length,Q,R.coordinates.length)}if(!this.module.generateMesh()){const R=this.module.getLastError();return this.readStringBuffer(R)}const g=this.module.getMeshCount(),j=new Array(g);for(let R=0;R>2)-3,ke=oe[ue++]>>2;if(ue++,j.json=JSON.parse(z5e.decode(oe.subarray(ue,ue+ke))),ue+=ke,ue<_e){const Pe=oe[ue++];ue++;const We=c+(ue<<2);j.buffers[0]=x.slice(We,We+Pe)}}else j.json=JSON.parse(z5e.decode(new Uint8Array(x,c)));const{buffers:T,images:P,meshes:R,extensionsUsed:F,bufferViews:H}=j.json;if(T){const oe=[];for(let ue=0;ue>>0,Math.ceil(1.2*rt)),ot=Math.ceil((it-rt)/65536);try{return _e.grow(ot),ke(),!0}catch{return!1}},b:Pe}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(oe,We):oe.then(qe=>qe.arrayBuffer()).then(qe=>WebAssembly.instantiate(qe,We))).then(qe=>{const{Rb:rt,Qb:it,P:ot,T:It,X:wt,Ja:At,La:kt,Qa:St,Va:rs,Wa:is,eb:us,jb:ws,f:hs,e:Ds,yb:ts,zb:vs,Ab:Ms,Bb:Rs,Db:Ks,Gb:fr}=qe.instance.exports;_e=Ds;const er=(()=>{let Js=0,Zs=0,dr=0,jr=0;return $r=>{dr&&(rt(jr),rt(Js),Zs+=dr,dr=Js=0),Js||(Zs+=128,Js=it(Zs));const Pr=$r.length+7&-8;let kn=Js;Pr>=Zs&&(dr=Pr,kn=jr=it(Pr));for(let ba=0;ba<$r.length;ba++)ue[kn+ba]=$r[ba];return kn}})();return ke(),hs(),{memory:Ds,_free:rt,_malloc:it,Mesh:class{constructor(){this.ptr=ot()}destroy(){It(this.ptr)}},Decoder:class{constructor(){this.ptr=At()}destroy(){ws(this.ptr)}DecodeArrayToMesh(Js,Zs,dr){const jr=er(Js),$r=kt(this.ptr,jr,Zs,dr.ptr);return!!wt($r)}GetAttributeByUniqueId(Js,Zs){return{ptr:St(this.ptr,Js.ptr,Zs)}}GetTrianglesUInt16Array(Js,Zs,dr){rs(this.ptr,Js.ptr,Zs,dr)}GetTrianglesUInt32Array(Js,Zs,dr){is(this.ptr,Js.ptr,Zs,dr)}GetAttributeDataArrayForAllPoints(Js,Zs,dr,jr,$r){us(this.ptr,Js.ptr,Zs.ptr,dr,jr,$r)}},DT_INT8:ts(),DT_UINT8:vs(),DT_INT16:Ms(),DT_UINT16:Rs(),DT_UINT32:Ks(),DT_FLOAT32:fr()}})}(fetch(Jo())),mI.then(oe=>{rg=oe,mI=void 0}))}()),re&&Q.push(function(){if(mfe)return;const oe=function(ue){let _e;const ke=WebAssembly.instantiateStreaming(ue,{}).then(qe=>{_e=qe.instance,_e.exports.__wasm_call_ctors()}),Pe={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},We={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:ke,supported:!0,decodeGltfBuffer(qe,rt,it,ot,It,wt){(function(At,kt,St,rs,is,us,ws){const hs=At.exports.sbrk,Ds=rs+3&-4,ts=hs(Ds*is),vs=hs(us.length),Ms=new Uint8Array(At.exports.memory.buffer);Ms.set(us,vs);const Rs=kt(ts,rs,is,vs,us.length);if(Rs===0&&ws&&ws(ts,Ds,is),St.set(Ms.subarray(ts,ts+rs*is)),hs(ts-hs(0)),Rs!==0)throw new Error(`Malformed buffer data: ${Rs}`)})(_e,_e.exports[We[It]],qe,rt,it,ot,_e.exports[Pe[wt]])}}}(fetch(Cc()));return oe.ready.then(()=>{mfe=oe})}()),P)for(let oe=0;oe{const R=Hx(g,(F,H)=>{F?P(F):T(H)});j&&j.addEventListener("abort",()=>{R.cancel(),P(new DOMException("Aborted","AbortError"))},{once:!0})})}({url:x,type:"arrayBuffer"},c);return q5e(h,0,x,c)}function ffe(x){switch(x){case WebGL2RenderingContext.RGBA8:case WebGL2RenderingContext.RGBA16F: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 xfe(x){switch(x){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.HALF_FLOAT;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 yy{constructor(c,h,g,j){this.context=c,this.format=g,this.useMipmap=j&&j.useMipmap,this.texture=c.gl.createTexture(),this.update(h,{premultiply:j&&j.premultiply})}update(c,h){const g=c&&c instanceof HTMLVideoElement&&c.width===0?c.videoWidth:c.width,j=c&&c instanceof HTMLVideoElement&&c.height===0?c.videoHeight:c.height,{context:T}=this,{gl:P}=T,{x:R,y:F}=h&&h.position?h.position:{x:0,y:0},H=R+g,Q=F+j;this.size&&(this.size[0]!==H||this.size[1]!==Q)&&(!h||h.recreateWhenResize===void 0||h.recreateWhenResize)&&(P.bindTexture(P.TEXTURE_2D,null),P.deleteTexture(this.texture),this.texture=P.createTexture(),this.size=null),P.bindTexture(P.TEXTURE_2D,this.texture),T.pixelStoreUnpackFlipY.set(!1),T.pixelStoreUnpack.set(1),T.pixelStoreUnpackPremultiplyAlpha.set(this.format===P.RGBA8&&(!h||h.premultiply!==!1));const se=c instanceof HTMLImageElement||c instanceof HTMLCanvasElement||c instanceof HTMLVideoElement||c instanceof ImageData||ImageBitmap&&c instanceof ImageBitmap;if(!this.size&&H>0&&Q>0){const re=this.useMipmap?Math.floor(Math.log2(Math.max(H,Q)))+1:1;P.texStorage2D(P.TEXTURE_2D,re,this.format,H,Q),this.size=[H,Q]}this.size&&(se?P.texSubImage2D(P.TEXTURE_2D,0,R,F,ffe(this.format),xfe(this.format),c):"data"in c&&c.data&&P.texSubImage2D(P.TEXTURE_2D,0,R,F,g,j,ffe(this.format),xfe(this.format),c.data)),this.useMipmap&&P.generateMipmap(P.TEXTURE_2D)}bind(c,h,g=!1){const{context:j}=this,{gl:T}=j;T.bindTexture(T.TEXTURE_2D,this.texture),c!==this.minFilter&&(T.texParameteri(T.TEXTURE_2D,T.TEXTURE_MAG_FILTER,c),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_MIN_FILTER,this.useMipmap&&!g?c===T.NEAREST?T.NEAREST_MIPMAP_NEAREST:T.LINEAR_MIPMAP_LINEAR:c),this.minFilter=c),h!==this.wrapS&&(T.texParameteri(T.TEXTURE_2D,T.TEXTURE_WRAP_S,h),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_WRAP_T,h),this.wrapS=h)}bindExtraParam(c,h,g,j,T){const{context:P}=this,{gl:R}=P;R.bindTexture(R.TEXTURE_2D,this.texture),h!==this.magFilter&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MAG_FILTER,h),this.magFilter=h),c!==this.minFilter&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MIN_FILTER,this.useMipmap?c===R.NEAREST?R.NEAREST_MIPMAP_NEAREST:R.LINEAR_MIPMAP_LINEAR:c),this.minFilter=c),g!==this.wrapS&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_WRAP_S,g),this.wrapS=g),j!==this.wrapT&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_WRAP_T,j),this.wrapT=j),T!==this.compareMode&&(T?(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_MODE,R.COMPARE_REF_TO_TEXTURE),R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_FUNC,T)):R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_MODE,R.NONE),this.compareMode=T)}destroy(){const{gl:c}=this.context;c.deleteTexture(this.texture),this.texture=null}}class fI{constructor(c,h){this.context=c,this.texture=h}bind(c,h){const{context:g}=this,{gl:j}=g;j.bindTexture(j.TEXTURE_2D,this.texture),c!==this.minFilter&&(j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MAG_FILTER,c),j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MIN_FILTER,c),this.minFilter=c),h!==this.wrapS&&(j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_S,h),j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_T,h),this.wrapS=h)}}const uut=ia([{name:"a_pos_3f",components:3,type:"Float32"}]),hut=ia([{name:"a_color_3f",components:3,type:"Float32"}]),mut=ia([{name:"a_color_4f",components:4,type:"Float32"}]),put=ia([{name:"a_uv_2f",components:2,type:"Float32"}]),fut=ia([{name:"a_normal_3f",components:3,type:"Float32"}]),xut=ia([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),gut=ia([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function V5e(x,c){const h=d7(x.projection,x.zoom,x.width,x.height),g=function(T,P,R,F,H){const Q=new qt(R.lng-180*u_,R.lat),se=new qt(R.lng+180*u_,R.lat),re=T.project(Q.lng,Q.lat),oe=T.project(se.lng,se.lat),ue=-Math.atan2(oe.y-re.y,oe.x-re.x),_e=wr.fromLngLat(R);_e.y=De(_e.y,-1+u_,1-u_);const ke=_e.toLngLat(),Pe=T.project(ke.lng,ke.lat),We=wr.fromLngLat(ke);We.x+=u_;const qe=We.toLngLat(),rt=T.project(qe.lng,qe.lat),it=G5e(rt.x-Pe.x,rt.y-Pe.y,ue),ot=wr.fromLngLat(ke);ot.y+=u_;const It=ot.toLngLat(),wt=T.project(It.lng,It.lat),At=G5e(wt.x-Pe.x,wt.y-Pe.y,ue),kt=Math.abs(it.x)/Math.abs(At.y),St=w([]);U(St,St,-ue*(1-(H?0:F)));const rs=w([]);return I(rs,rs,[1,1-(1-kt)*F,1]),rs[4]=-At.x/At.y*F,U(rs,rs,ue),C(rs,St,rs),rs}(x.projection,0,x.center,h,c),j=H5e(x);return I(g,g,[j,j,1]),g}function H5e(x){const c=x.projection,h=d7(x.projection,x.zoom,x.width,x.height),g=gfe(c,x.center),j=gfe(c,qt.convert(c.center));return Math.pow(2,g*h+(1-h)*j)}function d7(x,c,h,g,j=1/0){const T=x.range;if(!T)return 0;const P=Math.min(j,Math.max(h,g)),R=Math.log2(P/1024);return Ze(T[0]+R,T[1]+R,c)}const u_=1/4e4;function gfe(x,c){const h=De(c.lat,-85.051129,ds),g=new qt(c.lng-180*u_,h),j=new qt(c.lng+180*u_,h),T=x.project(g.lng,h),P=x.project(j.lng,h),R=wr.fromLngLat(g),F=wr.fromLngLat(j),H=P.x-T.x,Q=P.y-T.y,se=F.x-R.x,re=F.y-R.y,oe=Math.sqrt((se*se+re*re)/(H*H+Q*Q));return Math.log2(oe)}function G5e(x,c,h){const g=Math.cos(h),j=Math.sin(h);return{x:x*g-c*j,y:x*j+c*g}}function W5e(x,c,h){w(x),U(x,x,Kt(c[2])),L(x,x,Kt(c[0])),O(x,x,Kt(c[1])),I(x,x,h),C(x,x,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function u7(x,c,h,g,j,T,P,R){const F=[h[0]-c[0],h[1]-c[1],0],H=[g[0]-c[0],g[1]-c[1],0];if(ce(F)<1e-12||ce(H)<1e-12)return He(x);const Q=Ue([],F,H);ve(Q,Q),fe(H,g,c),F[2]=(T-j)*R,H[2]=(P-j)*R;const se=F;return Ue(se,F,H),ve(se,se),Ar(x,Q,se)}function h7(x,c,h=!1){const g=nv(c.zoom),j=function(T,P,R){const F=P.worldSize,H=[T[12],T[13],T[14]],Q=ss(H[1]/F),se=Ut(H[0]/F),re=w([]),oe=Zt(1,Q)*F,ue=Zt(1,0)*F*Gs(Q,P.zoom),_e=1/qpe(F);let ke=ue*_e;if(R){const rt=d7(P.projection,P.zoom,P.width,P.height,1024);ke=_e*P.projection.pixelSpaceConversion(P.center.lat,F,rt)}const Pe=vt(Q,se);le(Pe,Pe,Ne([],ve([],Pe),oe*ke*H[2]));const We=function(rt){const it=[rt[0],rt[1],rt[2]];let ot=[0,1,0];const It=Ue([],ot,it);return Ue(ot,it,It),ze(ot)===0&&(ot=[0,1,0],Ue(It,it,ot)),ve(It,It),ve(ot,ot),ve(it,it),[It[0],It[1],It[2],0,ot[0],ot[1],ot[2],0,it[0],it[1],it[2],0,rt[0],rt[1],rt[2],1]}(Pe);I(re,re,[ke,ke,ke*oe]),A(re,re,[-H[0],-H[1],-H[2]]);const qe=C([],P.globeMatrix,We);return C(qe,qe,re),C(qe,qe,T),qe}(x,c,h);if(g>0){const T=function(P,R){const F=R.worldSize,H=Zt(1,0)*F*Gs(R.center.lat,R.zoom)/qpe(F),Q=Zt(1,R.center.lat)*F,se=w([]);O(se,se,Kt(R.center.lng)),L(se,se,Kt(R.center.lat)),A(se,se,[0,0,mt]),I(se,se,[H,H,H*Q]);const re=R.point;return A(se,se,[-re.x,-re.y,0]),C(se,se,P),C(se,R.globeMatrix,se)}(x,c);return function(P,R,F){const H=(ue,_e,ke)=>{const Pe=ce(ue),We=ce(_e),qe=rv(ue,_e,ke);return Ne(qe,qe,1/ce(qe)*en(Pe,We,ke))},Q=H([P[0],P[1],P[2]],[R[0],R[1],R[2]],F),se=H([P[4],P[5],P[6]],[R[4],R[5],R[6]],F),re=H([P[8],P[9],P[10]],[R[8],R[9],R[10]],F),oe=rv([P[12],P[13],P[14]],[R[12],R[13],R[14]],F);return[Q[0],Q[1],Q[2],0,se[0],se[1],se[2],0,re[0],re[1],re[2],0,oe[0],oe[1],oe[2],1]}(j,T,g)}return j}function yfe(x,c,h,g){const j=Ja.projectAabbCorners(g,h);let T=Number.MAX_VALUE;for(let R=0;R0||ke===0&&ue[0]*_e[0]+ue[1]*_e[1]>=0&&ue[0]*ue[0]+ue[1]*ue[1]>_e[0]*_e[0]+_e[1]*_e[1])&&(Q=oe)}se=Q}while(se!==H);return F.length>0&&F.push(F[0]),F}(j);if(Fo(x,P))return T}const M2=64,U3={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function m7(x,c,h,g,j,T,P,R,F,H=!1){const Q=h.zoom,se=h.project(g),re=Gs(g.lat,Q),oe=1/re;w(x),A(x,x,[se.x+P[0]*oe,se.y+P[1]*oe,P[2]]);let ue=1,_e=1;const ke=h.worldSize;if(H){if(h.projection.name==="mercator"){let rt=0;h.elevation&&(rt=h.elevation.getAtPointOrZero(new wr(se.x/ke,se.y/ke),0));const it=at([],[se.x,se.y,rt,1],h.projMatrix)[3]/h.cameraToCenterDistance;ue=it,_e=it*Gs(h.center.lat,Q)}else if(h.projection.name==="globe"){const rt=h7(x,h),it=[0,0,0,1];at(it,it,C([],h.projMatrix,rt));const ot=it[3]/h.cameraToCenterDistance,It=nv(Q),wt=h.projection.pixelsPerMeter(g.lat,ke)*Gs(g.lat,Q),At=h.projection.pixelsPerMeter(h.center.lat,ke)*Gs(h.center.lat,Q);ue=ot/en(wt,Qs(h.center.lat),It),_e=ot*re/wt,ue*=At,_e*=At}}else ue=oe;I(x,x,[ue,ue,_e]);const Pe=[...x],We=c.orientation,qe=[];if(W5e(qe,[We[0]+(j?j[0]:0),We[1]+(j?j[1]:0),We[2]+(j?j[2]:0)],T),C(x,Pe,qe),R&&h.elevation){let rt=0;const it=[];if(F&&h.elevation){rt=function(It,wt,At,kt,St){const rs=wt.elevation;if(!rs)return 0;const is=Ja.projectAabbCorners(At,kt),us=Zt(1,St.lat)*wt.worldSize,ws=function(Zs,dr){const jr=[0,0,1],$r=[{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 Pr of $r){const kn=Zs[Pr.corners[0]],ba=Zs[Pr.corners[1]],Sn=Zs[Pr.corners[2]],ka=[ba[0]-kn[0],ba[1]-kn[1],dr*(ba[2]-kn[2])],Un=Ue(ka,ka,[Sn[0]-kn[0],Sn[1]-kn[1],dr*(Sn[2]-kn[2])]);ve(Un,Un),Pr.dotProductWithUp=Re(Un,jr)}return $r.sort((Pr,kn)=>Pr.dotProductWithUp-kn.dotProductWithUp),$r[0].corners}(is,us),hs=is[ws[0]],Ds=is[ws[1]],ts=is[ws[2]],vs=is[ws[3]],Ms=rs.getAtPointOrZero(new wr(hs[0]/wt.worldSize,hs[1]/wt.worldSize),0),Rs=rs.getAtPointOrZero(new wr(Ds[0]/wt.worldSize,Ds[1]/wt.worldSize),0),Ks=rs.getAtPointOrZero(new wr(ts[0]/wt.worldSize,ts[1]/wt.worldSize),0),fr=rs.getAtPointOrZero(new wr(vs[0]/wt.worldSize,vs[1]/wt.worldSize),0),er=(Ms+fr)/2,Js=(Rs+Ks)/2;return er>Js?Rs=c.gl.NEAREST_MIPMAP_NEAREST}),x.uploaded=!0,x.image=null)}function yut(x,c,h){x.indexBuffer=c.createIndexBuffer(x.indexArray,!1,!0),x.vertexBuffer=c.createVertexBuffer(x.vertexArray,uut.members,!1,!0),x.normalArray&&(x.normalBuffer=c.createVertexBuffer(x.normalArray,fut.members,!1,!0)),x.texcoordArray&&(x.texcoordBuffer=c.createVertexBuffer(x.texcoordArray,put.members,!1,!0)),x.colorArray&&(x.colorBuffer=c.createVertexBuffer(x.colorArray,(x.colorArray.bytesPerElement===12?hut:mut).members,!1,!0)),x.featureArray&&(x.pbrBuffer=c.createVertexBuffer(x.featureArray,gut.members,!0)),x.segments=wi.simpleSegment(0,0,x.vertexArray.length,x.indexArray.length);const g=x.material;g.pbrMetallicRoughness.baseColorTexture&&xI(g.pbrMetallicRoughness.baseColorTexture,c),g.pbrMetallicRoughness.metallicRoughnessTexture&&xI(g.pbrMetallicRoughness.metallicRoughnessTexture,c),g.normalTexture&&xI(g.normalTexture,c),g.occlusionTexture&&xI(g.occlusionTexture,c,h),g.emissionTexture&&xI(g.emissionTexture,c)}function vfe(x,c,h){if(x.meshes)for(const g of x.meshes)yut(g,c,h);if(x.children)for(const g of x.children)vfe(g,c,h)}function p7(x){if(x.meshes)for(const c of x.meshes)c.indexArray.destroy(),c.vertexArray.destroy(),c.colorArray&&c.colorArray.destroy(),c.normalArray&&c.normalArray.destroy(),c.texcoordArray&&c.texcoordArray.destroy(),c.featureArray&&c.featureArray.destroy();if(x.children)for(const c of x.children)p7(c)}function vut(x){x.pbrMetallicRoughness.baseColorTexture&&x.pbrMetallicRoughness.baseColorTexture.gfxTexture&&x.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),x.pbrMetallicRoughness.metallicRoughnessTexture&&x.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&x.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),x.normalTexture&&x.normalTexture.gfxTexture&&x.normalTexture.gfxTexture.destroy(),x.emissionTexture&&x.emissionTexture.gfxTexture&&x.emissionTexture.gfxTexture.destroy(),x.occlusionTexture&&x.occlusionTexture.gfxTexture&&x.occlusionTexture.gfxTexture.destroy()}function _fe(x){if(x.meshes)for(const c of x.meshes)c.vertexBuffer&&(c.vertexBuffer.destroy(),c.indexBuffer.destroy(),c.normalBuffer&&c.normalBuffer.destroy(),c.texcoordBuffer&&c.texcoordBuffer.destroy(),c.colorBuffer&&c.colorBuffer.destroy(),c.pbrBuffer&&c.pbrBuffer.destroy(),c.segments.destroy(),c.material&&vut(c.material));if(x.footprintDebugMesh&&(x.footprintDebugMesh.vertexBuffer.destroy(),x.footprintDebugMesh.indexBuffer.destroy(),x.footprintDebugMesh.segments.destroy()),x.children)for(const c of x.children)_fe(c)}function T2(x,c){const h=x.json.bufferViews[c.bufferView],g=l7[c.componentType];return new g(x.buffers[h.buffer],(c.byteOffset||0)+(h.byteOffset||0),c.count*(h.byteStride&&h.byteStride!==pI[c.type]*g.BYTES_PER_ELEMENT?h.byteStride/g.BYTES_PER_ELEMENT:pI[c.type]))}function bfe(x,c,h,g){const j=l7[c.componentType],T=function(Q){switch(Q){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(j),P=x.json.bufferViews[c.bufferView],R=P.byteStride?P.byteStride/j.BYTES_PER_ELEMENT:pI[c.type],F=h.float32,H=F.length/h.capacity;for(let Q=0,se=0;Q0){for(let ke=0;ke<_e;ke++){const Pe=3*re[ke];ue[0]+=oe[Pe],ue[1]+=oe[Pe+1],ue[2]+=oe[Pe+2]}ue[0]/=_e,ue[1]/=_e,ue[2]/=_e}return ue}(F,Q),j.COLOR_0!==void 0){const re=c.json.accessors[j.COLOR_0],oe=pI[re.type],ue=T2(c,re);T.colorArray=oe===3?new Um:new tg,T.colorArray.resize(re.count),bfe(c,re,T.colorArray,ue)}if(j.NORMAL!==void 0){T.normalArray=new Um;const re=c.json.accessors[j.NORMAL];T.normalArray.resize(re.count);const oe=T2(c,re);bfe(c,re,T.normalArray,oe)}if(j.TEXCOORD_0!==void 0&&h.length>0){T.texcoordArray=new J0;const re=c.json.accessors[j.TEXCOORD_0];T.texcoordArray.resize(re.count);const oe=T2(c,re);bfe(c,re,T.texcoordArray,oe)}if(j._FEATURE_ID_RGBA4444!==void 0){const re=c.json.accessors[j._FEATURE_ID_RGBA4444];c.json.extensionsUsed&&c.json.extensionsUsed.includes("EXT_meshopt_compression")&&(T.featureData=T2(c,re))}j._FEATURE_RGBA4444!==void 0&&(T.featureData=new Uint32Array(T2(c,c.json.accessors[j._FEATURE_RGBA4444]).buffer));const se=x.material;return T.material=function(re,oe){const{emissiveFactor:ue=[0,0,0],alphaMode:_e="OPAQUE",alphaCutoff:ke=.5,normalTexture:Pe,occlusionTexture:We,emissiveTexture:qe,doubleSided:rt,name:it}=re,{baseColorFactor:ot=[1,1,1,1],metallicFactor:It=1,roughnessFactor:wt=1,baseColorTexture:At,metallicRoughnessTexture:kt}=re.pbrMetallicRoughness||{},St=We?oe[We.index]:void 0;if(We&&We.extensions&&We.extensions.KHR_texture_transform&&St){const rs=We.extensions.KHR_texture_transform;St.offsetScale=[rs.offset[0],rs.offset[1],rs.scale[0],rs.scale[1]]}return{name:it,pbrMetallicRoughness:{baseColorFactor:new la(...ot),metallicFactor:It,roughnessFactor:wt,baseColorTexture:At?oe[At.index]:void 0,metallicRoughnessTexture:kt?oe[kt.index]:void 0},doubleSided:rt,emissiveFactor:new la(...ue),alphaMode:_e,alphaCutoff:ke,normalTexture:Pe?oe[Pe.index]:void 0,occlusionTexture:St,emissionTexture:qe?oe[qe.index]:void 0,defined:re.defined===void 0}}(se!==void 0?c.json.materials[se]:{defined:!1},h),T}function Z5e(x,c,h){const{matrix:g,rotation:j,translation:T,scale:P,mesh:R,extras:F,children:H,name:Q}=x,se={};if(se.name=Q,se.localMatrix=g||function(re,oe,ue,_e){var ke=oe[0],Pe=oe[1],We=oe[2],qe=oe[3],rt=ke+ke,it=Pe+Pe,ot=We+We,It=ke*rt,wt=ke*it,At=ke*ot,kt=Pe*it,St=Pe*ot,rs=We*ot,is=qe*rt,us=qe*it,ws=qe*ot,hs=_e[0],Ds=_e[1],ts=_e[2];return re[0]=(1-(kt+rs))*hs,re[1]=(wt+ws)*hs,re[2]=(At-us)*hs,re[3]=0,re[4]=(wt-ws)*Ds,re[5]=(1-(It+rs))*Ds,re[6]=(St+is)*Ds,re[7]=0,re[8]=(At+us)*ts,re[9]=(St-is)*ts,re[10]=(1-(It+kt))*ts,re[11]=0,re[12]=ue[0],re[13]=ue[1],re[14]=ue[2],re[15]=1,re}([],j||[0,0,0,1],T||[0,0,0],P||[1,1,1]),se.globalMatrix=N(se.localMatrix),R!==void 0){se.meshes=h[R];const re=se.anchor=[0,0];for(const oe of se.meshes){const{min:ue,max:_e}=oe.aabb;re[0]+=ue[0]+_e[0],re[1]+=ue[1]+_e[1]}re[0]=Math.floor(re[0]/se.meshes.length/2),re[1]=Math.floor(re[1]/se.meshes.length/2)}if(F&&(F.id&&(se.id=F.id),F.lights&&(se.lights=function(re){if(!re.length)return[];const oe=function(We){const qe=atob(We),rt=new Uint8Array(qe.length);for(let it=0;it1&&g[g.length-1].equals(g[0])&&g.pop();let j=0;for(let P=0;P0&&g.reverse();const T=F3(g.flatMap(P=>[P.x,P.y]),[]);return T.length===0?null:{vertices:g,indices:T}}function jut(x,c){const h=[],g=[];let j=0;const T=[];for(const P of x){j=h.length;const R=P.vertexArray.float32,F=P.indexArray.uint16;for(let H=0;H0&&([g[P+1],g[P+2]]=[g[P+2],g[P+1]])}return{vertices:h,indices:g}}function wfe(x){const c=function(F,H){const Q=[],se=WebGL2RenderingContext;if(F.json.textures)for(const re of F.json.textures){const oe={magFilter:se.LINEAR,minFilter:se.NEAREST,wrapS:se.REPEAT,wrapT:se.REPEAT};re.sampler!==void 0&&Object.assign(oe,F.json.samplers[re.sampler]),Q.push({image:H[re.source],sampler:oe,uploaded:!1})}return Q}(x,x.images),h=function(F,H){const Q=[];for(const se of F.json.meshes){const re=[];for(const oe of se.primitives)re.push(_ut(oe,F,H));Q.push(re)}return Q}(x,c),{scenes:g,scene:j,nodes:T}=x.json,P=g?g[j||0].nodes:[...T.keys()],R=[];for(const F of P)R.push(Z5e(T[F],x,h));return function(F,H,Q){const se={},re=new Set;for(let oe=0;oe0){const oe=Array.from(re.values()).sort((ue,_e)=>ue-_e);for(let ue=oe.length-1;ue>=0;ue--)F.splice(oe[ue],1)}}(R,P,x.json.nodes),R}function Nut(x){x.heightmap=new Float32Array(4096),x.heightmap.fill(-1);const c=x.vertexArray.float32,h=x.aabb.min[0]-1,g=x.aabb.min[1]-1,j=M2/(x.aabb.max[0]-h+2),T=M2/(x.aabb.max[1]-g+2);for(let P=0;Px.heightmap[H*M2+F]&&(x.heightmap[H*M2+F]=R)}}function Y5e(x,c,h,g,j){h.reserve(h.length+4*x.length),g.reserve(g.length+10*x.length),j.reserve(j.length+10*x.length);let T=g.length;for(const P of x){const R=Math.min(10,Math.max(4,1.3*P.height))*c,F=[-P.normal[1],P.normal[0],0],H=Math.min(.29,.1*P.width/P.depth),Q=P.width-2*P.depth*c*(H+.01),se=Ve([],P.pos,F,Q/2),re=Ve([],P.pos,F,-Q/2),oe=[se[0],se[1],se[2]+P.height],ue=[re[0],re[1],re[2]+P.height],_e=Ve([],P.normal,F,H);Ne(_e,_e,R);const ke=Ve([],P.normal,F,-H);Ne(ke,ke,R),le(_e,se,_e),le(ke,re,ke),se[2]+=.1,re[2]+=.1,g.emplaceBack(_e[0],_e[1],_e[2]),g.emplaceBack(ke[0],ke[1],ke[2]),g.emplaceBack(se[0],se[1],se[2]),g.emplaceBack(re[0],re[1],re[2]),g.emplaceBack(oe[0],oe[1],oe[2]),g.emplaceBack(ue[0],ue[1],ue[2]),g.emplaceBack(se[0],se[1],se[2]),g.emplaceBack(re[0],re[1],re[2]),g.emplaceBack(_e[0],_e[1],_e[2]),g.emplaceBack(ke[0],ke[1],ke[2]);const Pe=Q/R/2;j.emplaceBack(-Pe-H,-1,Pe,.8),j.emplaceBack(Pe+H,-1,Pe,.8),j.emplaceBack(-Pe,0,Pe,1.3),j.emplaceBack(Pe,0,Pe,1.3),j.emplaceBack(Pe+H,-.8,Pe,.7),j.emplaceBack(Pe+H,-.8,Pe,.7),j.emplaceBack(0,0,Pe,1.3),j.emplaceBack(0,0,Pe,1.3),j.emplaceBack(Pe+H,-1.2,Pe,.8),j.emplaceBack(Pe+H,-1.2,Pe,.8),h.emplaceBack(6+T,4+T,8+T),h.emplaceBack(7+T,9+T,5+T),h.emplaceBack(0+T,1+T,2+T),h.emplaceBack(1+T,3+T,2+T),T+=10}}function kut(x,c){const h={};h.indexArray=new Ao,h.vertexArray=new Um,h.colorArray=new tg,Y5e(x,c,h.indexArray,h.vertexArray,h.colorArray);const g={defined:!0};g.emissiveFactor=la.black;const j={};return j.baseColorFactor=la.white,g.pbrMetallicRoughness=j,h.material=g,h.aabb=new Ja([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),h}const X5e=ia([{name:"a_pos_3f",components:3,type:"Float32"}]),Sut=ia([{name:"a_normal_3",components:3,type:"Int16"}]),Cut=ia([{name:"a_centroid_3",components:3,type:"Int16"}]),Q5e=ia([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),Mut=ia([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Tut=ia([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Aut=ia([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Eut=ia([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),Put=ia([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),J5e=ln.types,f7=32767;function Iut(x,c){const h=sr+c;for(const g of x)for(const j of g)if(j.x<-c||j.x>h||j.y<-c||j.y>h)return!1;return!0}function Lut(x){switch(x){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${x}`)}}class jfe{constructor(){this.layoutVertexArray=new Um,this.layoutAttenuationArray=new tg,this.layoutColorArray=new Vm,this.indexArray=new Ao,this.indexArrayForConflation=new Ao,this.segmentsBucket=new wi}}class Nfe{constructor(c){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new wi,this.entranceBloom=new jfe;const h=66560;this.layoutVertexArray=new Um,this.layoutVertexArray.reserve(h),this.layoutNormalArray=new zf,this.layoutNormalArray.reserve(h),this.layoutCentroidArray=new zf,this.layoutCentroidArray.reserve(h),this.layoutColorArray=new Vm,this.layoutColorArray.reserve(h),this.layoutFloodLightDataArray=new P3,this.layoutFloodLightDataArray.reserve(h),this.layoutAOArray=new I3,this.layoutAOArray.reserve(h),this.indexArray=new Ao,this.indexArray.reserve(66560),this.indexArrayForConflation=new Ao,this.segmentsBucket=new wi,this.entranceBloom=new jfe,c&&(this.layoutFacadePaintArray=new Vm,this.layoutFacadeDataArray=new n_,this.layoutFacadeVerticalRangeArray=new Vm)}reserve(c,h,g){this.layoutVertexArray.reserveForAdditional(c),this.layoutCentroidArray.reserveForAdditional(c),this.layoutFloodLightDataArray.reserveForAdditional(c),this.layoutNormalArray.reserveForAdditional(c),this.layoutAOArray.reserveForAdditional(c),this.layoutColorArray.reserveForAdditional(c),this.indexArray.reserveForAdditional(h),g&&(this.layoutFacadePaintArray.reserveForAdditional(c),this.layoutFacadeDataArray.reserveForAdditional(c),this.layoutFacadeVerticalRangeArray.reserveForAdditional(c))}}class eMe{constructor(c){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new J0,this.footprintsIndices=new ev,this.footprintsMin=new Xt(1/0,1/0),this.footprintsMax=new Xt(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Nfe(!1),this.buildingWithFacade=new Nfe(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=c.zoom,this.canonical=c.canonical,this.layers=c.layers,this.layerIds=this.layers.map(h=>h.fqid),this.index=c.index,this.hasPattern=!1,this.worldview=c.worldview,this.lut=c.lut,this.programConfigurations=new Me(c.layers,{zoom:c.zoom,lut:c.lut}),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.projection=c.projection,this.groundEffect=new dfe(c),this.groundEffect.groundRadiusArray=new Qh,this.hasAppearances=null}updateFootprints(c,h){const g=new QF([],[],1),j={vertices:[],indices:new Uint32Array(0),grid:g,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};h.push({footprint:j,id:c})}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}prepare(){return function(){if(o7!=null||A5e!=null)return null;if(q3!=null)return q3;const c=fetch(Bl());return q3=function(h){let g,j,T,P,R;function F(){g=new Uint8Array(R.buffer),j=new Int16Array(R.buffer),T=new Int32Array(R.buffer),P=new Float32Array(R.buffer)}function H(){throw new Error("Unexpected BuildingGen error.")}const Q=()=>{},se={a:{a:H,f:function(re){const oe=g.length,ue=Math.max(re>>>0,Math.ceil(1.2*oe)),_e=Math.ceil((ue-oe)/65536);try{return R.grow(_e),F(),!0}catch{return!1}},g:H,b:Q,c:Q,d:Q,e:Q}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(h,se):h.then(re=>re.arrayBuffer()).then(re=>WebAssembly.instantiate(re,se))).then(re=>{const oe=re.instance.exports;return(0,oe.g)(),R=oe.f,F(),new nut({setStyle:oe.h,setAOOptions:oe.i,setMetricOptions:oe.j,setStructuralOptions:oe.k,setFacadeOptions:oe.l,setFauxFacadeOptions:oe.m,setFacadeClassifierOptions:oe.n,addFeature:oe.o,addFacade:oe.p,generateMesh:oe.q,getLastError:oe.r,getOuterRingLength:oe.s,getMeshCount:oe.t,getPositionsPtr:oe.u,getPositionsLength:oe.v,getNormalsPtr:oe.w,getNormalsLength:oe.x,getAOPtr:oe.y,getAOLength:oe.z,getUVPtr:oe.A,getUVLength:oe.B,getFauxFacadePtr:oe.C,getFauxFacadeLength:oe.D,getIndicesPtr:oe.E,getIndicesLength:oe.F,getBuildingPart:oe.G,getRingCount:oe.H,getRingPtr:oe.I,getRingLength:oe.J,malloc:oe.K,free:oe.L,heapU8:g,heap16:j,heap32:T,heapF32:P})})}(c).then(h=>(q3=null,o7=h,o7)).catch(h=>{zr("Could not load building-gen"),q3=null,A5e=h instanceof Error?h:new Error("Unknown error")}),q3}()}populate(c,h,g,j){const T=aut();if(!T)return;const P=Ts(g);this.tileToMeter=P,this.brightness=h.brightness,T.setStyle({normalScale:[1,-1,P],tileToMeters:P}),T.setAOOptions(!1,.3),T.setMetricOptions(!1,16),T.setStructuralOptions(!0),T.setFacadeClassifierOptions(3);const R=new Map,F=new Map;let H=0;for(const{feature:Pe}of c){if(J5e[Pe.type]!=="LineString"){R.set(Pe.id,Pe.properties.source_id);continue}const We=this.layers[0]._featureFilter.needGeometry;if(We&&!this.layers[0]._featureFilter.filter(new Ga(this.zoom),Pe,g))continue;const qe=qn(Pe,We);if(!We&&!this.layers[0]._featureFilter.filter(new Ga(this.zoom),qe,g))continue;const rt=We?qe.geometry:Ur(Pe,g,j),it=[];for(const At of rt)for(const kt of At)it.push(kt.x),it.push(kt.y);const ot={coordinates:it,crossPerc:Pe.properties.cross_perc,distanceToRoad:Pe.properties.distance_to_road,entrances:Pe.properties.entrances,sourceId:0},It=Pe.properties.source_id;let wt=F.get(It);wt||(wt=[],F.set(It,wt)),wt.push(ot),++H}this.maxHeight=0;const Q=new Array,se=new Set,re=Pe=>{Pe!=null&&se.add(Pe)},oe=(Pe,We)=>{Pe!=null&&Q.push({buildingId:Pe,footprintIndex:We})},ue=64*(c.length-H),_e=ue/2;this.buildingWithFacade.reserve(ue,_e,!0),this.buildingWithoutFacade.reserve(2*ue,2*_e,!1),this.footprintsIndices.reserve(16*(c.length-H)),this.footprintsVertices.reserve(8*(c.length-H));for(const{feature:Pe,id:We,index:qe,sourceLayerIndex:rt}of c){if(J5e[Pe.type]==="LineString")continue;const it=this.layers[0]._featureFilter.needGeometry;if(it&&!this.layers[0]._featureFilter.filter(new Ga(this.zoom),Pe,g))continue;let ot=null;if(Pe.properties&&Pe.properties.hasOwnProperty("building_id")&&(ot=Number(Pe.properties.building_id),se.has(ot)))continue;const It=qn(Pe,it);if(!it&&!this.layers[0]._featureFilter.filter(new Ga(this.zoom),It,g))continue;const wt=it?It.geometry:Ur(Pe,g,j),At=aI(wt,500);let kt=!1;for(const Jn of At)if(Jn.length!==1){kt=!0;break}if(kt){re(ot);continue}if(!Iut(wt,163)){re(ot);continue}const St=this.layers[0],rs=Lut(St.layout.get("building-roof-shape").evaluate(Pe,{},g)),is=St.layout.get("building-base").evaluate(Pe,{},g),us=St.layout.get("building-height").evaluate(Pe,{},g),ws=St.layout.get("building-flood-light-ground-radius").evaluate(Pe,{},g),hs=St.paint.get("building-ambient-occlusion-intensity"),Ds=ws/this.tileToMeter;Pe.properties["building-part"]="roof";const ts=St.paint.get("building-color").evaluate(Pe,{},this.canonical).toPremultipliedRenderColor(this.lut),vs=St.paint.get("building-emissive-strength").evaluate(Pe,{},this.canonical);Pe.properties["building-part"]="wall";const Ms=St.paint.get("building-color").evaluate(Pe,{},this.canonical).toPremultipliedRenderColor(this.lut),Rs=St.paint.get("building-emissive-strength").evaluate(Pe,{},this.canonical);Pe.properties["building-part"]="window";const Ks=St.paint.get("building-color").evaluate(Pe,{},this.canonical).toPremultipliedRenderColor(this.lut),fr=St.paint.get("building-emissive-strength").evaluate(Pe,{},this.canonical);Pe.properties["building-part"]="door";const er=St.paint.get("building-color").evaluate(Pe,{},this.canonical).toPremultipliedRenderColor(this.lut),Js=St.paint.get("building-emissive-strength").evaluate(Pe,{},this.canonical);let Zs=St.layout.get("building-flood-light-wall-radius").evaluate(Pe,{},g);Zs=De(Zs,0,2048);const dr=Zs/2048*f7,jr=R.get(We),$r=F.get(jr)||[],Pr=$r.length!==0&&St.layout.get("building-facade").evaluate(Pe,{},g);T.setFacadeOptions(4,!0),T.setFauxFacadeOptions(Pr,!1,1);let kn=0,ba=0,Sn=0,ka=0,Un=0,po=0,Wa=0,Ia=0,ki=0,io=0,oc=0;if(Pr){let Jn=Math.round(St.layout.get("building-facade-floors").evaluate(Pe,{},g));if(is===0){Jn=Math.max(1,Jn-($r.length>0?1:0));let Io=4;if(us>100){const Ul=[10,13,15];Io=Ul[Pe.id?Pe.id%Ul.length:0]}else us<=10&&(Io=3);T.setFacadeOptions(Io,!0),Un=(us<15?1.3:1.61803)*Io/P}else Un=is/P;po=us/P,Un=Math.min(Un,po),Sn=St.layout.get("building-facade-unit-width").evaluate(Pe,{},g)/P,ka=(po-Un)/Jn,T.setFauxFacadeOptions(!0,!0,Sn);const Pc=St.layout.get("building-facade-window").evaluate(Pe,{},g);kn=Pc[0],ba=Pc[1],Wa=Math.floor(65535*Math.min(1,Un/sr)),Ia=Math.floor(65535*Math.min(1,po/sr)),ki=Math.floor(255*kn)<<8|Math.floor(255*ba),io=Math.floor(65535*Math.min(1,Sn/sr)),oc=Math.floor(65535*Math.min(1,ka/sr))}const oo=Array(At.length),Eo={x:1/0,y:1/0},el={x:-1/0,y:-1/0},Po={x:0,y:0};let ld=0;for(let Jn=0;Jn0){const Io=[],Ul=Array(Pc.length+1);Ul[0]=0;for(let Op=0;Opsr||Eo.y<0||el.y>sr)&&this.featuresOnBorder.push({featureId:Pe.id,footprintIndex:this.footprints.length});{const Jn=F3(dv,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Jn.length),this.footprintsIndices.uint16.set(Jn,s5),this.buildingIds.add(ot??Pe.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Dp.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Dp.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Rp.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Rp.y);const Pc={footprintVertexOffset:cv,footprintVertexLength:this.footprintsVertices.length-cv,footprintIndexOffset:s5,footprintIndexLength:this.footprintsIndices.length-s5,min:Dp,max:Rp,hiddenFlags:0,indicesOffset:V7,indicesLength:pxe,bloomIndicesOffset:cd,bloomIndicesLength:fo,groundEffectVertexOffset:R2,groundEffectVertexLength:r5,hasFauxFacade:Pr,height:t5,promoteId:We,feature:It,parts:Ac,buildingBloom:Nu},Io=this.footprints.length;Pe.id!==void 0&&this.featureFootprintLookup.set(Pe.id,Io),oe(ot,Io),this.footprints.push(Pc)}this.programConfigurations.populatePaintArrays(Wn.layoutVertexArray.length,Pe,qe,{},h.availableImages,g,h.brightness),this.groundEffect.addPaintPropertiesData(Pe,qe,{},h.availableImages,g,h.brightness),h.featureIndex.insert(Pe,wt,qe,rt,this.index,Xd)}Q.forEach(({buildingId:Pe,footprintIndex:We})=>{se.has(Pe)&&(this.footprints[We].hiddenFlags|=4)});const ke=new Set;this.buildingIds.forEach((Pe,We,qe)=>{se.has(Pe)||ke.add(Pe)}),this.buildingIds=ke,this.groundEffect.prepareBorderSegments()}update(c,h,g,j,T,P,R){this.programConfigurations.updatePaintArrays(c,h,T,g,j,P,R),this.groundEffect.update(c,h,T,g,j,P,R),this.evaluate(this.layers[0],c),this.colorBufferUploaded=!1}isEmpty(){return this.buildingWithoutFacade.layoutVertexArray.length===0&&this.buildingWithFacade.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(c){const h=g=>{g.layoutVertexBuffer=c.createVertexBuffer(g.layoutVertexArray,X5e.members),g.layoutNormalBuffer=c.createVertexBuffer(g.layoutNormalArray,Sut.members),g.layoutCentroidBuffer=c.createVertexBuffer(g.layoutCentroidArray,Cut.members),g.layoutFloodLightDataBuffer=c.createVertexBuffer(g.layoutFloodLightDataArray,Put.members),g.layoutFacadeDataArray&&g.layoutFacadeDataArray.length&&(g.layoutFacadeDataBuffer=c.createVertexBuffer(g.layoutFacadeDataArray,Tut.members)),g.layoutFacadeVerticalRangeArray&&g.layoutFacadeVerticalRangeArray.length&&(g.layoutFacadeVerticalRangeBuffer=c.createVertexBuffer(g.layoutFacadeVerticalRangeArray,Aut.members)),g.entranceBloom.layoutVertexArray.length&&(g.entranceBloom.layoutVertexBuffer=c.createVertexBuffer(g.entranceBloom.layoutVertexArray,X5e.members),g.entranceBloom.layoutAttenuationBuffer=c.createVertexBuffer(g.entranceBloom.layoutAttenuationArray,Eut.members)),this.uploadUpdatedColorBuffer(c),this.uploadUpdatedIndexBuffer(c)};this.uploaded||(h(this.buildingWithoutFacade),h(this.buildingWithFacade),this.groundEffect.upload(c)),this.groundEffect.uploadPaintProperties(c),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){const c=h=>{h.layoutVertexBuffer&&(h.layoutVertexBuffer.destroy(),h.layoutNormalBuffer.destroy(),h.layoutColorBuffer.destroy(),h.segmentsBucket.destroy(),h.indexBuffer&&h.indexBuffer.destroy(),h.entranceBloom.layoutVertexBuffer&&(h.entranceBloom.layoutVertexBuffer.destroy(),h.entranceBloom.layoutColorBuffer.destroy(),h.entranceBloom.layoutAttenuationBuffer.destroy(),h.entranceBloom.indexBuffer.destroy(),h.entranceBloom.segmentsBucket.destroy()))};c(this.buildingWithoutFacade),c(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(c,h,g=!0){let j=!1;const T=g?h:0,P=0|(g?-1:~h);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const R of c){const F=this.footprints[R],H=F.hiddenFlags&P|T;F.hiddenFlags!==H&&(F.hiddenFlags=H,j=!0,this.groundEffect.updateHiddenByLandmarkRange(F.groundEffectVertexOffset,F.groundEffectVertexLength,F.hiddenFlags!==0))}return j&&(this.indexArrayForConflationUploaded=!1),j}uploadUpdatedIndexBuffer(c){if(this.groundEffect.uploadHiddenByLandmark(c),this.indexArrayForConflationUploaded)return;const h=j=>{j.indexArray.length!==0&&(j.indexArrayForConflation.resize(j.indexArray.length),j.indexArrayForConflation.uint16.set(j.indexArray.uint16),j.entranceBloom.indexArrayForConflation.resize(j.entranceBloom.indexArray.length),j.entranceBloom.indexArrayForConflation.uint16.set(j.entranceBloom.indexArray.uint16))};h(this.buildingWithoutFacade),h(this.buildingWithFacade);for(const j of this.footprints){const T=j.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,P=j.indicesOffset+j.indicesLength;if(j.hiddenFlags!==0){for(let F=j.indicesOffset;F{j.indexArray.length!==0&&(j.indexBuffer?j.indexBuffer.updateData(j.indexArrayForConflation):j.indexBuffer=c.createIndexBuffer(j.indexArrayForConflation,!0),j.entranceBloom.indexBuffer?j.entranceBloom.indexBuffer.updateData(j.entranceBloom.indexArrayForConflation):j.entranceBloom.indexBuffer=c.createIndexBuffer(j.entranceBloom.indexArrayForConflation,!0))};g(this.buildingWithoutFacade),g(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(c){const h=g=>{g.layoutColorBuffer?g.layoutColorBuffer.updateData(g.layoutColorArray):g.layoutColorBuffer=c.createVertexBuffer(g.layoutColorArray,Q5e.members,!0),g.layoutFacadePaintArray&&(g.layoutFacadePaintBuffer?g.layoutFacadePaintBuffer.updateData(g.layoutFacadePaintArray):g.layoutFacadePaintBuffer=c.createVertexBuffer(g.layoutFacadePaintArray,Mut.members,!0)),g.entranceBloom.layoutColorBuffer?g.entranceBloom.layoutColorBuffer.updateData(g.entranceBloom.layoutColorArray):g.entranceBloom.layoutColorBuffer=c.createVertexBuffer(g.entranceBloom.layoutColorArray,Q5e.members,!0)};h(this.buildingWithoutFacade),h(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(c,h){const g=c.paint.get("building-ambient-occlusion-intensity");for(const j of this.footprints){if(4&j.hiddenFlags)continue;const T=h[j.promoteId],P=j.feature;P.properties["building-part"]="roof";const R=c.paint.get("building-color").evaluate(P,T,this.canonical).toPremultipliedRenderColor(this.lut),F=c.paint.get("building-emissive-strength").evaluate(P,T,this.canonical);P.properties["building-part"]="wall";const H=c.paint.get("building-color").evaluate(P,T,this.canonical).toPremultipliedRenderColor(this.lut),Q=c.paint.get("building-emissive-strength").evaluate(P,T,this.canonical);P.properties["building-part"]="window";const se=c.paint.get("building-color").evaluate(P,T,this.canonical).toPremultipliedRenderColor(this.lut),re=c.paint.get("building-emissive-strength").evaluate(P,T,this.canonical);P.properties["building-part"]="door";const oe=c.paint.get("building-color").evaluate(P,T,this.canonical).toPremultipliedRenderColor(this.lut),ue=c.paint.get("building-emissive-strength").evaluate(P,T,this.canonical),_e=j.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Pe of j.parts){let We,qe=R;Pe.part===1?(qe=R,We=F):Pe.part===0?(qe=H,We=Q):Pe.part===2?(qe=se,We=re):Pe.part===3&&(qe=oe,We=ue),We=De(We,0,1);for(let rt=0;rtP.max.x||F.max.xP.max.y||F.max.yR.max.x||R.min.x>c||h>R.max.y||R.min.y>h||R.height<=g||Dut(P,this.footprintsVertices.float32.subarray(2*R.footprintVertexOffset,2*(R.footprintVertexOffset+R.footprintVertexLength)),this.footprintsIndices.uint16.subarray(R.footprintIndexOffset,R.footprintIndexOffset+R.footprintIndexLength))&&(g=R.height,this.footprintLookup[T]=R,j=R.hiddenFlags!==0);if(g!==Number.NEGATIVE_INFINITY)return{height:g,hidden:j};this.footprintLookup[T]=void 0}}function Dut(x,c,h){for(let g=0;g1&&(F=c[++R]);const Q=Math.abs(H-F.left),se=Math.abs(H-F.right),re=Math.min(Q,se);let oe;const ue=T/g*(j+1);if(F.isDash){const _e=j-Math.abs(ue);oe=Math.sqrt(re*re+_e*_e)}else oe=j-Math.sqrt(re*re+ue*ue);this.image.data[P+H]=Math.max(0,Math.min(255,oe+128))}}}addRegularDash(c,h){for(let F=c.length-1;F>=0;--F){const H=c[F],Q=c[F+1];H.zeroLength?c.splice(F,1):Q&&Q.isDash===H.isDash&&(Q.left=H.left,c.splice(F,1))}const g=c[0],j=c[c.length-1];g.isDash===j.isDash&&(g.left=j.left-this.width,j.right=g.right+this.width);const T=this.width*this.nextRow;let P=0,R=c[P];for(let F=0;F1&&(R=c[++P]);const H=Math.abs(F-R.left),Q=Math.abs(F-R.right),se=Math.min(H,Q);this.image.data[T+F]=Math.max(0,Math.min(255,(R.isDash?se:-se)+h+128))}}addDash(c,h){const g=this.getKey(c,h);if(this.positions[g])return this.positions[g];const j=h==="round",T=j?7:0,P=2*T+1;if(this.nextRow+P>this.height)return zr("LineAtlas out of space"),null;c.length===0&&c.push(1);let R=0;for(let se=0;seh.fqid),this.index=c.index,this.projection=c.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(h=>{this.gradients[h.id]={}}),this.layoutVertexArray=new p2,this.layoutVertexArray2=new Um,this.patternVertexArray=new Um,this.indexArray=new Ao,this.programConfigurations=new Me(c.layers,{zoom:c.zoom,lut:c.lut}),this.segments=new wi,this.maxLineLength=0,this.zOffsetVertexArray=new Um,this.elevationGroundScaleVertexArray=new Qh,this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.tessellationStep=c.tessellationStep?c.tessellationStep:128,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(c,h,g,j){this.hasPattern=Wpe("line",this.layers,this.pixelRatio,h);const T=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Ts(g);const P=this.layers[0].layout.get("line-elevation-reference");if(P==="hd-road-markup")this.elevationType="road";else{const re=this.layers[0].layout.get("line-z-offset"),oe=re.isConstant()&&!re.constantOr(0);this.elevationType=P!=="sea"&&P!=="ground"&&oe?"none":"offset",this.elevationType==="offset"&&P==="none"&&zr(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference=P==="sea"}const R=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&R!==void 0;const F=[];for(const{feature:re,id:oe,index:ue,sourceLayerIndex:_e}of c){const ke=this.layers[0]._featureFilter.needGeometry,Pe=qn(re,ke);if(!this.layers[0]._featureFilter.filter(new Ga(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),Pe,g))continue;const We=T?T.evaluate(Pe,{},g):void 0,qe={id:oe,properties:re.properties,type:re.type,sourceLayerIndex:_e,index:ue,geometry:ke?Pe.geometry:Ur(re,g,j),patterns:{},sortKey:We};F.push(qe)}T&&F.sort((re,oe)=>re.sortKey-oe.sortKey);const{lineAtlas:H,featureIndex:Q}=h,se=this.addConstantDashes(H);for(const re of F){const{geometry:oe,index:ue,sourceLayerIndex:_e}=re;if(se&&this.addFeatureDashes(re,H),this.hasPattern){const ke=Kpe("line",this.layers,re,this.zoom,this.pixelRatio,h);this.patternFeatures.push(ke)}else this.addFeature(re,oe,ue,g,H.positions,h.availableImages,h.brightness,h.elevationFeatures);Q.insert(c[ue].feature,oe,ue,_e,this.index)}}addConstantDashes(c){let h=!1;for(const g of this.layers){const j=g.paint.get("line-dasharray").value,T=g.layout.get("line-cap").value;if(j.kind!=="constant"||T.kind!=="constant")h=!0;else{const P=T.value,R=j.value;if(!R)continue;c.addDash(R,P)}}return h}addFeatureDashes(c,h){const g=this.zoom;for(const j of this.layers){const T=j.paint.get("line-dasharray").value,P=j.layout.get("line-cap").value;if(T.kind==="constant"&&P.kind==="constant")continue;let R,F;if(T.kind==="constant"){if(R=T.value,!R)continue}else R=T.evaluate({zoom:g},c);F=P.kind==="constant"?P.value:P.evaluate({zoom:g},c),h.addDash(R,F),c.patterns[j.id]=[h.getKey(R,F)]}}update(c,h,g,j,T,P,R,F,H){this.programConfigurations.updatePaintArrays(c,h,T,g,j,P,R,H)}addFeatures(c,h,g,j,T,P){for(const R of this.patternFeatures)this.addFeature(R,R.geometry,R.index,h,g,j,P,c.elevationFeatures)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=c.createVertexBuffer(this.layoutVertexArray2,qut)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=c.createVertexBuffer(this.patternVertexArray,Vut)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,Fut.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=c.createVertexBuffer(this.elevationGroundScaleVertexArray,zut.members,!0)),this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,But),this.indexBuffer=c.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(c,h){let g,j;if(h&&h>0?(g=`mapbox_clip_start_${h}`,j=`mapbox_clip_end_${h}`):(g="mapbox_clip_start",j="mapbox_clip_end"),c.properties&&c.properties.hasOwnProperty(g)&&c.properties.hasOwnProperty(j))return{start:+c.properties[g],end:+c.properties[j]}}addFeature(c,h,g,j,T,P,R,F){const H=this.layers[0].layout,Q=H.get("line-join").evaluate(c,{}),se=H.get("line-cap").evaluate(c,{}),re=H.get("line-miter-limit"),oe=H.get("line-round-limit");this.lineClips=this.lineFeatureClips(c),this.lineFeature=c;const ue=!(!c.properties||!c.properties.hasOwnProperty("mapbox_line_metrics"))&&c.properties.mapbox_line_metrics;this.zOffsetValue=H.get("line-z-offset").value;const _e=this.layers[0].paint.get("line-width").value;if(_e.kind!=="constant"&&_e.isLineProgressConstant===!1&&(this.variableWidthValue=_e),this.isSeaLevelReference){const ke=H.get("line-elevation-ground-scale").value;ke.kind==="constant"&&ke.value===0||(this.elevationGroundScaleValue=ke)}if(this.elevationType==="road"){const ke=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(c,h,j,F,Q,se,re,oe)){const[Pe,We]=this.clipRuntimeLinesToTile(h,1);for(let qe=0;qe0?it.parentIndex:null)}this.fillNonElevatedRoadSegment(ke)}}else for(let ke=0;ke0?ke:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,g,T,P,j,R,void 0,this.worldview)}computeSegNextDir(c,h){return c.nextPoint.sub(h.at(-2)).unit()}computeSegPrevDir(c,h){return h[1].sub(c.prevPoint).unit()}clipLinesToTile(c,h){return i7(c,-h,-h,sr+h,sr+h)}clipRuntimeLinesToTile(c,h){const g=[];return[i7(c,-h,-h,sr+h,sr+h,g),g]}addElevatedRoadFeature(c,h,g,j,T,P,R,F){const H=[],Q=Ci.getElevationFeature(c,j);if(Q){const se=this.clipLinesToTile(h,1),re=this.prepareElevatedLines(se,Q,g);for(const oe of re)H.push({geometry:oe,elevation:Q,elevationTileID:g,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(H.length===0)return!1;for(const se of H){const re=this.layoutVertexArray.length;this.addLine(se.geometry,c,g,T,P,R,F);const oe=new Pi(g,se.elevationTileID);if(se.elevation)for(let ue=re;ue>1,this.layoutVertexArray.int16[6*ue+1]>>1),ke=oe.pointElevation(_e,se.elevation,.05);this.updateHeightRange(ke),this.zOffsetVertexArray.emplaceBack(ke,0,0)}else this.fillNonElevatedRoadSegment(re)}return!0}prepareElevatedLines(c,h,g){if(h.constantHeight!=null)return c;const j=[],T=1/Ts(g);for(const P of c)rut(P,new em(h,T),0,j);return j}fillNonElevatedRoadSegment(c){for(let h=c;h0,re=F&&F.progress.max<1;if(this.lineClips){let At={min:this.lineClips.start,max:this.lineClips.end},kt=1;if(F){const is=this.lineClips.end-this.lineClips.start;At=function(us,ws,hs){return{min:Bi(us.min,ws,hs),max:Bi(us.max,ws,hs)}}(F.progress,{min:0,max:1},At),is>0&&(kt=(At.max-At.min)/is)}const St=+h.properties.mapbox_clip_feature_len,rs=+h.properties.mapbox_clip_seg_len;if(Number.isNaN(St)||Number.isNaN(rs)){for(let us=0;us=2&&c[ue-1].equals(c[ue-2]);)ue--;let _e=0;for(;_e0,vs=this.overscaling<=16?122880/(512*this.overscaling):0;if(kt&&St==="round"){if(wsP&&(St="bevel"),St==="bevel"&&(ws>2&&(St="flipbevel"),ws2*vs){const Ks=Pe.sub(Pe.sub(We)._mult(vs/Ms)._round());this.updateDistance(We,Ks),this.addCurrentVertex(Ks,rt,0,0,ke,wt),We=Ks}this.updateDistance(We,Pe),is._mult(ws),this.addCurrentVertex(Pe,is,0,0,ke,wt);const Rs=Pe.dist(qe);if(Rs>2*vs){const Ks=Pe.add(qe.sub(Pe)._mult(vs/Rs)._round());this.updateDistance(Pe,Ks),this.addCurrentVertex(Ks,it,0,0,ke,wt),Pe=Ks}}else is._mult(ws),this.addCurrentVertex(Pe,is,0,0,ke,wt);else if(St==="flipbevel"){if(ws>100)is=it.mult(-1);else{const Ms=ws*rt.add(it).mag()/rt.sub(it).mag();is._perp()._mult(Ms*(ts?-1:1))}this.addCurrentVertex(Pe,is,0,0,ke,wt),this.addCurrentVertex(Pe,is.mult(-1),0,0,ke,wt)}else if(St==="bevel"||St==="fakeround"){const Ms=Pe.dist(We);let Rs=1;if(this.elevationType==="offset"&&St==="bevel"&&this.currentLineJoinType!=="round"&&!this.patternJoinNone&&wt!=null&&We&&qe){const dr=4*vs;Ms1){this.lineSoFar=c.w;const _e=(h.x-c.x)/se,ke=(h.y-c.y)/se,Pe=(h.z-c.z)/se,We=(h.w-c.w)/se,qe=h.x-c.x,rt=h.y-c.y,it=Math.sqrt(qe*qe+rt*rt);if(it===0)return;const ot=-rt/it,It=qe/it,wt=ot,At=It,kt=-ot,St=-It;for(let rs=1;rs=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,Q),F.primitiveLength++),P?this.e2=Q:this.e1=Q,H!=null&&this.zOffsetVertexArray.emplaceBack(H.zOffset,H.variableWidth,H.variableWidth),this.elevationGroundScaleValue){const se=H?H.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(se)}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(c,h){this.prevDistance=this.distance,this.distance+=c.dist(h),this.updateScaledDistance()}}function kfe(x,c,h){return x.xh||x.yh}let nMe,aMe;function iMe(x,c,h){return c*(sr/(x.tileSize*Math.pow(2,h-x.tileID.overscaledZ)))}gr(x7,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const oMe=(x,c,h)=>(1-h)*x+h*c;function lMe(x,c){return 1/iMe(x,1,c.tileZoom)}function cMe(x,c,h,g){return x.translatePosMatrix(g||c.tileID.projMatrix,c,h.paint.get("line-translate"),h.paint.get("line-translate-anchor"))}const dMe=x=>{const c=[];uMe(x)&&c.push("RENDER_LINE_DASH"),x.paint.get("line-gradient")&&c.push("RENDER_LINE_GRADIENT"),x.paint.get("line-blend-mode")==="multiply"&&c.push("LINE_BLEND_MULTIPLY");const h=x.paint.get("line-trim-offset");h[0]===0&&h[1]===0||c.push("RENDER_LINE_TRIM_OFFSET"),x.paint.get("line-border-width").constantOr(1)!==0&&c.push("RENDER_LINE_BORDER");const g=x.layout.get("line-join").constantOr("miter")==="none",j=!!x.paint.get("line-pattern").constantOr(1);return g&&j&&c.push("LINE_JOIN_NONE"),c};function uMe(x){const c=x.paint.get("line-dasharray").value;return c.kind!=="constant"||c.value}let Sfe;const hMe=()=>Sfe||(Sfe={layout:nMe||(nMe=new Xi({"line-cap":new Hs(Ht.layout_line["line-cap"]),"line-join":new Hs(Ht.layout_line["line-join"]),"line-miter-limit":new Ys(Ht.layout_line["line-miter-limit"]),"line-round-limit":new Ys(Ht.layout_line["line-round-limit"]),"line-sort-key":new Hs(Ht.layout_line["line-sort-key"]),"line-z-offset":new Hs(Ht.layout_line["line-z-offset"]),"line-elevation-reference":new Ys(Ht.layout_line["line-elevation-reference"]),"line-cross-slope":new Ys(Ht.layout_line["line-cross-slope"]),visibility:new Ys(Ht.layout_line.visibility),"line-width-unit":new Ys(Ht.layout_line["line-width-unit"]),"line-elevation-ground-scale":new Hs(Ht.layout_line["line-elevation-ground-scale"])})),paint:aMe||(aMe=new Xi({"line-opacity":new Hs(Ht.paint_line["line-opacity"]),"line-color":new Hs(Ht.paint_line["line-color"]),"line-translate":new Ys(Ht.paint_line["line-translate"]),"line-translate-anchor":new Ys(Ht.paint_line["line-translate-anchor"]),"line-width":new Hs(Ht.paint_line["line-width"]),"line-gap-width":new Hs(Ht.paint_line["line-gap-width"]),"line-offset":new Hs(Ht.paint_line["line-offset"]),"line-blur":new Hs(Ht.paint_line["line-blur"]),"line-dasharray":new Hs(Ht.paint_line["line-dasharray"]),"line-pattern":new Hs(Ht.paint_line["line-pattern"]),"line-pattern-cross-fade":new Ys(Ht.paint_line["line-pattern-cross-fade"]),"line-gradient":new s_(Ht.paint_line["line-gradient"]),"line-trim-offset":new Ys(Ht.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ys(Ht.paint_line["line-trim-fade-range"]),"line-trim-color":new Ys(Ht.paint_line["line-trim-color"]),"line-emissive-strength":new Hs(Ht.paint_line["line-emissive-strength"]),"line-border-width":new Hs(Ht.paint_line["line-border-width"]),"line-border-color":new Hs(Ht.paint_line["line-border-color"]),"line-occlusion-opacity":new Ys(Ht.paint_line["line-occlusion-opacity"]),"line-blend-mode":new Ys(Ht.paint_line["line-blend-mode"]),"line-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"})}))},Sfe);class Kut extends Hs{possiblyEvaluate(c,h){return h=new Ga(Math.floor(h.zoom),{now:h.now,fadeDuration:h.fadeDuration,transition:h.transition,worldview:h.worldview}),super.possiblyEvaluate(c,h)}evaluate(c,h,g,j){return h=Object.assign({},h,{zoom:Math.floor(h.zoom)}),super.evaluate(c,h,g,j)}}let gI;function mMe(x,c){return c>0?c+2*x:x}const Zut=ia([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Yut=ia([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Xut=ia([{name:"a_projected_pos",components:4,type:"Float32"}],4);ia([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Qut=ia([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Jut=ia([{name:"a_feature_index",components:1,type:"Float32"}],4),eht=ia([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),tht=ia([{name:"a_texb",components:2,type:"Uint16"}]),sht=ia([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),rht=ia([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ia([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const pMe=ia([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),nht=ia([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ia([{name:"triangle",components:3,type:"Uint16"}]),ia([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),ia([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}]),ia([{type:"Float32",name:"offsetX"}]),ia([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const Cfe=class $ie{constructor(c=null,h=0,g=4096){this.batchIndex=h,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=c||null,this.propsDwords=g,this.totalBytes=4*this.propsDwords,this.headerData=new Uint32Array($ie.HEADER_DWORDS),this.propertiesData=new Float32Array(this.propsDwords),this.blockIndicesData=new Uint32Array(this.propsDwords);for(let j=0;jc.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${c.maxUniformBlockSize}`);if(this.headerBuffer=h.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(h.bindBuffer(h.UNIFORM_BUFFER,this.headerBuffer),h.bufferData(h.UNIFORM_BUFFER,$ie.HEADER_BYTES,h.DYNAMIC_DRAW),this.propertiesBuffer=h.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(h.bindBuffer(h.UNIFORM_BUFFER,this.propertiesBuffer),h.bufferData(h.UNIFORM_BUFFER,this.totalBytes,h.DYNAMIC_DRAW),this.blockIndicesBuffer=h.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");h.bindBuffer(h.UNIFORM_BUFFER,this.blockIndicesBuffer),h.bufferData(h.UNIFORM_BUFFER,this.totalBytes,h.DYNAMIC_DRAW),h.bindBuffer(h.UNIFORM_BUFFER,null)}writeHeader(c){const h=this.headerData;h[0]=c.dataDrivenMask,h[1]=c.zoomDependentMask,h[2]=c.dataDrivenBlockSizeVec4,h[3]=c.offsets[0],h[4]=c.offsets[1],h[5]=c.offsets[2],h[6]=c.offsets[3],h[7]=c.offsets[4],h[8]=c.offsets[5],h[9]=c.offsets[6],h[10]=c.offsets[7],h[11]=c.offsets[8]}writeDataDrivenBlock(c,h,g){const j=4*g.dataDrivenBlockSizeVec4;if(j===0)return;const T=h*j;if(T+j>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${h} exceeds propertiesData capacity`);for(let P=0;P<9;P++)g.dataDrivenMask&1<{if(!R)return;const H=g.getUniformBlockIndex(h,P);H!==g.INVALID_INDEX&&(g.uniformBlockBinding(h,H,F),g.bindBufferBase(g.UNIFORM_BUFFER,F,R))},T=3*this.batchIndex;j("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,T),j("SymbolPaintPropertiesUniform",this.propertiesBuffer,T+1),j("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,T+2)}destroy(){if(this.context){const c=this.context.gl;this.headerBuffer&&(c.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(c.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(c.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null)}}};Cfe.HEADER_DWORDS=12,Cfe.HEADER_BYTES=48;let Mfe=Cfe;function Tfe(x,c,h,g){return[L3(255*x,255*c),L3(255*h,255*g)]}function fMe(x,c,h,g,j,T,P,R){return!!x&&(x.kind==="constant"?x.value==="none":x.kind==="composite"||x.kind==="source"?x.evaluate({zoom:0,brightness:T,worldview:R},c,h,j,g,P)==="none":typeof x=="string"&&x==="none")}gr(Mfe,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});class Afe{constructor(c,h,g,j,T="",P,R){this.layer=c,this.zoom=h,this.lut=g,this.isText=j,this.propDefs=this._getPropDefs(),this.worldview=T,this.maxUniformBufferBindings=P||24,this.uboSizeDwords=R||4096,this.featureVertexRangesFromId=new Map,this.allFeatures=[],this.ubos=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex=new Map,this.canDeduplicate=this._checkIfAllPropertiesAreConstant(c,j),this.cachedParams=null,this.cachedParamsNext=null,this.cachedBrightness=void 0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.activeAppearanceByVtIndex=new Map}_getPropDefs(){const c=this.isText?"text":"icon";return[{name:`${c}-color`,useThemeName:`${c}-color-use-theme`,isColor:!0},{name:`${c}-halo-color`,useThemeName:`${c}-halo-color-use-theme`,isColor:!0},{name:`${c}-opacity`,useThemeName:null,isColor:!1},{name:`${c}-halo-width`,useThemeName:null,isColor:!1},{name:`${c}-halo-blur`,useThemeName:null,isColor:!1},{name:`${c}-emissive-strength`,useThemeName:null,isColor:!1},{name:`${c}-occlusion-opacity`,useThemeName:null,isColor:!1},{name:"symbol-z-offset",useThemeName:null,isColor:!1},{name:`${c}-translate`,useThemeName:null,isColor:!1,isVec2:!0}]}buildHeader(){const c=this.layer.paint,h=this.propDefs;let g=0,j=0,T=0,P=0;const R=[0,0,0,0,0,0,0,0,0];for(let F=0;F<9;F++){const{name:H,isColor:Q,isVec2:se}=h[F],re=c.get(H),oe=!(!re||typeof re.isConstant!="function"||re.isConstant()),ue=this._appearancesHavePaintProperties(H),_e=oe||ue,ke=!(!re||!re.value||re.value.kind!=="composite"),Pe=this.layer._transitionablePaint._values[H],We=!_e&&(Pe&&Pe.value&&Pe.value.expression&&Pe.value.expression.kind)==="camera";_e?(g|=1<h.hasPaintProperty(c):this.isText?h=>h.hasTextPaintProperties():h=>h.hasIconPaintProperties())}_checkIfAllPropertiesAreConstant(c,h){const g=c.paint,j=h?"text":"icon",T=[`${j}-color`,`${j}-halo-color`,`${j}-opacity`,`${j}-halo-width`,`${j}-halo-blur`,`${j}-emissive-strength`,`${j}-occlusion-opacity`,"symbol-z-offset",`${j}-translate`];for(const P of T){const R=g.get(P);if(R&&typeof R=="object"&&"isConstant"in R&&!R.isConstant())return!1}return!this._appearancesHavePaintProperties()}_hashDataDrivenValues(c,h){if(h.dataDrivenMask===0)return"";const g=[];for(let j=0;j<9;j++){if(!(h.dataDrivenMask&1<=ue){zr(`Too many symbol features: batch ${re} requires binding points up to ${3*re+2}, device limit ${ue}. Some features will render incorrectly.`);const ke={batchIndex:0,localFeatureIndex:0,vtFeatureIndex:h,featureId:F};return this.allFeatures.push(ke),F!=null&&(this.featureVertexRangesFromId.has(F)||this.featureVertexRangesFromId.set(F,[]),this.featureVertexRangesFromId.get(F).push(ke)),0}this.ubos[re]||(this.ubos[re]=new Mfe(R,re,this.uboSizeDwords),this.ubos[re].writeHeader(H)),this.ubos[re].writeDataDrivenBlock(Q,oe,H);const _e={batchIndex:re,localFeatureIndex:oe,vtFeatureIndex:h,featureId:F};return this.allFeatures.push(_e),F!=null&&(this.featureVertexRangesFromId.has(F)||this.featureVertexRangesFromId.set(F,[]),this.featureVertexRangesFromId.get(F).push(_e)),oe}updateFeatures(c,h,g,j,T,P,R){if(this.layer=h,this.cachedConstantUniforms=null,!this.cachedHeader)return;const F=this.cachedHeader;for(const H of c){const Q=this.featureVertexRangesFromId.get(H);if(!Q)continue;const se=P[H]||{};for(const re of Q){if(!g)continue;const oe=g.feature(re.vtFeatureIndex);if(!oe)continue;const ue={type:oe.type,id:H,properties:oe.properties||{},geometry:[]},_e=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(re.vtFeatureIndex):void 0,ke=this.evaluateAllProperties(ue,se,j,T,R,void 0,_e);this.ubos[re.batchIndex]&&this.ubos[re.batchIndex].writeDataDrivenBlock(ke,re.localFeatureIndex,F)}}}updateDynamicExpressions(c,h,g,j,T,P){if(this.layer=c,this.cachedConstantUniforms=null,!this.cachedHeader)return;const R=this.cachedHeader;for(const F of this.allFeatures){if(!h)continue;const H=h.feature(F.vtFeatureIndex);if(!H)continue;const Q=F.featureId!=null&&T[F.featureId]||{},se={type:H.type,id:F.featureId,properties:H.properties||{},geometry:[]},re=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(F.vtFeatureIndex):void 0,oe=this.evaluateAllProperties(se,Q,g,j,P,void 0,re);this.ubos[F.batchIndex]&&this.ubos[F.batchIndex].writeDataDrivenBlock(oe,F.localFeatureIndex,R)}}updateFeaturePaintForAppearance(c,h,g,j,T,P,R){if(!this.layer||(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(c,R||null),!this.cachedHeader))return!1;const F=this.cachedHeader;if(F.dataDrivenMask===0)return!1;let H=!1;for(const Q of this.allFeatures){if(Q.vtFeatureIndex!==c)continue;const se=this.evaluateAllProperties(h,g,j,T,P,void 0,R);this.ubos[Q.batchIndex]&&(this.ubos[Q.batchIndex].writeDataDrivenBlock(se,Q.localFeatureIndex,F),H=!0)}return H}getConstantUniformValues(c,h){const g=this.cachedHeader,j=!(!g||!g.cameraMask);if(this.cachedConstantUniforms&&this.cachedConstantBrightness===h&&(!j||this.cachedConstantRenderZoom===c))return this.cachedConstantUniforms;const T=this.layer.paint,P=this.propDefs,R=j?new Ga(c,{brightness:h,worldview:this.worldview}):null,F={type:1,id:void 0,properties:{},geometry:[]},H=re=>{const oe=P[re],ue=T.get(oe.name);if(!ue)return[0,0,0,1];const _e=oe.useThemeName?T.get(oe.useThemeName):void 0,ke=fMe(_e&&typeof _e!="string"?_e.value:void 0,F,{},[],void 0,h,void 0,this.worldview)?null:this.lut;let Pe;Pe=g&&g.cameraMask&1<{const ue=T.get(P[re].name);if(!ue)return oe;if(g&&g.cameraMask&1<{g.text=function(j,T,P){const R=T.layout.get("text-transform").evaluate(P,{});return R==="uppercase"?j=j.toLocaleUpperCase():R==="lowercase"&&(j=j.toLocaleLowerCase()),Qx.applyArabicShaping&&(j=Qx.applyArabicShaping(j)),j}(g.text,c,h)}),x}const yI={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function iht(x){return x==="︶"||x==="﹈"||x==="︸"||x==="﹄"||x==="﹂"||x==="︾"||x==="︼"||x==="︺"||x==="︘"||x==="﹀"||x==="︐"||x==="︓"||x==="︔"||x==="`"||x===" ̄"||x==="︑"||x==="︒"}function oht(x){return x==="︵"||x==="﹇"||x==="︷"||x==="﹃"||x==="﹁"||x==="︽"||x==="︻"||x==="︹"||x==="︗"||x==="︿"}const Efe=4294967296,xMe=1/Efe,gMe=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let g7=class{constructor(x=new Uint8Array(16)){this.buf=ArrayBuffer.isView(x)?x:new Uint8Array(x),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(x,c,h=this.length){for(;this.pos>3,T=this.pos;this.type=7&g,x(j,c,this),this.pos===T&&this.skip(g)}return c}readMessage(x,c){return this.readFields(x,c,this.readVarint()+this.pos)}readFixed32(){const x=this.dataView.getUint32(this.pos,!0);return this.pos+=4,x}readSFixed32(){const x=this.dataView.getInt32(this.pos,!0);return this.pos+=4,x}readFixed64(){const x=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Efe;return this.pos+=8,x}readSFixed64(){const x=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Efe;return this.pos+=8,x}readFloat(){const x=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,x}readDouble(){const x=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,x}readVarint(x){const c=this.buf;let h,g;return g=c[this.pos++],h=127&g,g<128?h:(g=c[this.pos++],h|=(127&g)<<7,g<128?h:(g=c[this.pos++],h|=(127&g)<<14,g<128?h:(g=c[this.pos++],h|=(127&g)<<21,g<128?h:(g=c[this.pos],h|=(15&g)<<28,function(j,T,P){const R=P.buf;let F,H;if(H=R[P.pos++],F=(112&H)>>4,H<128||(H=R[P.pos++],F|=(127&H)<<3,H<128)||(H=R[P.pos++],F|=(127&H)<<10,H<128)||(H=R[P.pos++],F|=(127&H)<<17,H<128)||(H=R[P.pos++],F|=(127&H)<<24,H<128)||(H=R[P.pos++],F|=(1&H)<<31,H<128))return V3(j,F,T);throw new Error("Expected varint not more than 10 bytes")}(h,x,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const x=this.readVarint();return x%2==1?(x+1)/-2:x/2}readBoolean(){return!!this.readVarint()}readString(){const x=this.readVarint()+this.pos,c=this.pos;return this.pos=x,x-c>=12&&gMe?gMe.decode(this.buf.subarray(c,x)):function(h,g,j){let T="",P=g;for(;P239?4:R>223?3:R>191?2:1;if(P+re>j)break;re===1?R<128&&(se=R):re===2?(F=h[P+1],(192&F)==128&&(se=(31&R)<<6|63&F,se<=127&&(se=null))):re===3?(F=h[P+1],H=h[P+2],(192&F)==128&&(192&H)==128&&(se=(15&R)<<12|(63&F)<<6|63&H,(se<=2047||se>=55296&&se<=57343)&&(se=null))):re===4&&(F=h[P+1],H=h[P+2],Q=h[P+3],(192&F)==128&&(192&H)==128&&(192&Q)==128&&(se=(15&R)<<18|(63&F)<<12|(63&H)<<6|63&Q,(se<=65535||se>=1114112)&&(se=null))),se===null?(se=65533,re=1):se>65535&&(se-=65536,T+=String.fromCharCode(se>>>10&1023|55296),se=56320|1023&se),T+=String.fromCharCode(se),P+=re}return T}(this.buf,c,x)}readBytes(){const x=this.readVarint()+this.pos,c=this.buf.subarray(this.pos,x);return this.pos=x,c}readPackedVarint(x=[],c){const h=this.readPackedEnd();for(;this.pos127;);else if(c===2)this.pos=this.readVarint()+this.pos;else if(c===5)this.pos+=4;else{if(c!==1)throw new Error(`Unimplemented type: ${c}`);this.pos+=8}}writeTag(x,c){this.writeVarint(x<<3|c)}realloc(x){let c=this.length||16;for(;c268435455||x<0?function(c,h){let g,j;if(c>=0?(g=c%4294967296|0,j=c/4294967296|0):(g=~(-c%4294967296),j=~(-c/4294967296),4294967295^g?g=g+1|0:(g=0,j=j+1|0)),c>=18446744073709552e3||c<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");h.realloc(10),function(T,P,R){R.buf[R.pos++]=127&T|128,T>>>=7,R.buf[R.pos++]=127&T|128,T>>>=7,R.buf[R.pos++]=127&T|128,T>>>=7,R.buf[R.pos++]=127&T|128,R.buf[R.pos]=127&(T>>>=7)}(g,0,h),function(T,P){const R=(7&T)<<4;P.buf[P.pos++]|=R|((T>>>=3)?128:0),T&&(P.buf[P.pos++]=127&T|((T>>>=7)?128:0),T&&(P.buf[P.pos++]=127&T|((T>>>=7)?128:0),T&&(P.buf[P.pos++]=127&T|((T>>>=7)?128:0),T&&(P.buf[P.pos++]=127&T|((T>>>=7)?128:0),T&&(P.buf[P.pos++]=127&T)))))}(j,h)}(x,this):(this.realloc(4),this.buf[this.pos++]=127&x|(x>127?128:0),x<=127||(this.buf[this.pos++]=127&(x>>>=7)|(x>127?128:0),x<=127||(this.buf[this.pos++]=127&(x>>>=7)|(x>127?128:0),x<=127||(this.buf[this.pos++]=x>>>7&127))))}writeSVarint(x){this.writeVarint(x<0?2*-x-1:2*x)}writeBoolean(x){this.writeVarint(+x)}writeString(x){x=String(x),this.realloc(4*x.length),this.pos++;const c=this.pos;this.pos=function(g,j,T){for(let P,R,F=0;F55295&&P<57344){if(!R){P>56319||F+1===j.length?(g[T++]=239,g[T++]=191,g[T++]=189):R=P;continue}if(P<56320){g[T++]=239,g[T++]=191,g[T++]=189,R=P;continue}P=R-55296<<10|P-56320|65536,R=null}else R&&(g[T++]=239,g[T++]=191,g[T++]=189,R=null);P<128?g[T++]=P:(P<2048?g[T++]=P>>6|192:(P<65536?g[T++]=P>>12|224:(g[T++]=P>>18|240,g[T++]=P>>12&63|128),g[T++]=P>>6&63|128),g[T++]=63&P|128)}return T}(this.buf,x,this.pos);const h=this.pos-c;h>=128&&yMe(c,h,this),this.pos=c-1,this.writeVarint(h),this.pos+=h}writeFloat(x){this.realloc(4),this.dataView.setFloat32(this.pos,x,!0),this.pos+=4}writeDouble(x){this.realloc(8),this.dataView.setFloat64(this.pos,x,!0),this.pos+=8}writeBytes(x){const c=x.length;this.writeVarint(c),this.realloc(c);for(let h=0;h=128&&yMe(h,g,this),this.pos=h-1,this.writeVarint(g),this.pos+=g}writeMessage(x,c,h){this.writeTag(x,2),this.writeRawMessage(c,h)}writePackedVarint(x,c){c.length&&this.writeMessage(x,lht,c)}writePackedSVarint(x,c){c.length&&this.writeMessage(x,cht,c)}writePackedBoolean(x,c){c.length&&this.writeMessage(x,hht,c)}writePackedFloat(x,c){c.length&&this.writeMessage(x,dht,c)}writePackedDouble(x,c){c.length&&this.writeMessage(x,uht,c)}writePackedFixed32(x,c){c.length&&this.writeMessage(x,mht,c)}writePackedSFixed32(x,c){c.length&&this.writeMessage(x,pht,c)}writePackedFixed64(x,c){c.length&&this.writeMessage(x,fht,c)}writePackedSFixed64(x,c){c.length&&this.writeMessage(x,xht,c)}writeBytesField(x,c){this.writeTag(x,2),this.writeBytes(c)}writeFixed32Field(x,c){this.writeTag(x,5),this.writeFixed32(c)}writeSFixed32Field(x,c){this.writeTag(x,5),this.writeSFixed32(c)}writeFixed64Field(x,c){this.writeTag(x,1),this.writeFixed64(c)}writeSFixed64Field(x,c){this.writeTag(x,1),this.writeSFixed64(c)}writeVarintField(x,c){this.writeTag(x,0),this.writeVarint(c)}writeSVarintField(x,c){this.writeTag(x,0),this.writeSVarint(c)}writeStringField(x,c){this.writeTag(x,2),this.writeString(c)}writeFloatField(x,c){this.writeTag(x,5),this.writeFloat(c)}writeDoubleField(x,c){this.writeTag(x,1),this.writeDouble(c)}writeBooleanField(x,c){this.writeVarintField(x,+c)}};function V3(x,c,h){return h?4294967296*c+(x>>>0):4294967296*(c>>>0)+(x>>>0)}function yMe(x,c,h){const g=c<=16383?1:c<=2097151?2:c<=268435455?3:Math.floor(Math.log(c)/(7*Math.LN2));h.realloc(g);for(let j=h.pos-1;j>=x;j--)h.buf[j+g]=h.buf[j]}function lht(x,c){for(let h=0;h=0&&g>=c&&y7[this.text.charCodeAt(g)];g--)h--;this.text=this.text.substring(c,h),this.sectionIndex=this.sectionIndex.slice(c,h)}substring(c,h){const g=new H3;return g.text=this.text.substring(c,h),g.sectionIndex=this.sectionIndex.slice(c,h),g.sections=this.sections,g}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((c,h)=>Math.max(c,this.sections[h].scale),0)}addTextSection(c,h){this.text+=c.text,this.sections.push(vI.forText(c.scale,c.fontStack||h));const g=this.sections.length-1;for(let j=0;j=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Pfe(x,c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e=1,ke=1){const Pe=H3.fromFeature(x,j,_e,ke);se===nm.vertical&&Pe.verticalizePunctuation(re);let We=[];const qe=function(wt,At,kt,St,rs,is,us=1){if(!wt)return[];const ws=[],hs=function(vs,Ms,Rs,Ks,fr,er,Js=1){let Zs=0;for(let dr=0;dr=0;let ts=0;for(let vs=0;vs0&&Xd>Un&&(Un=Xd)}else{const Ac=kt[io.fontStack];if(!Ac)continue;Ac[oo]&&(Po=Ac[oo]);const Nu=At[io.fontStack];if(!Nu)continue;const cd=Nu.glyphs[oo];if(!cd)continue;if(el=cd.metrics,lc=oo!==8203?ic:0,Js){const fo=Nu.ascender!==void 0?Math.abs(Nu.ascender):0,Xd=Nu.descender!==void 0?Math.abs(Nu.descender):0,Ec=(fo+Xd)*Eo;po-h/2;){if(P--,P<0)return!1;R-=x[P].dist(T),T=x[P]}R+=x[P].dist(x[P+1]),P++;const F=[];let H=0;for(;Rg;)H-=F.shift().angleDelta;if(H>j)return!1;P++,R+=Q.dist(se)}return!0}function MMe(x){let c=0;for(let h=0;hH){const ue=(H-F)/oe,_e=en(se.x,re.x,ue),ke=en(se.y,re.y,ue),Pe=new lv(_e,ke,0,re.angleTo(se),Q);return!P||CMe(x,Pe,R,P,c)?Pe:void 0}F+=oe}}function jht(x,c,h,g,j,T,P,R,F){const H=TMe(g,T,P),Q=AMe(g,j),se=Q*P,re=x[0].x===0||x[0].x===F||x[0].y===0||x[0].y===F;return c-se=0&&rt=0&&it=0&&re+H<=Q){const ot=new lv(rt,it,0,We,ue);g&&!CMe(x,ot,T,g,j)||oe.push(ot)}}se+=Pe}return R||oe.length||P||(oe=EMe(x,se/2,h,g,j,T,P,!0,F)),oe}function PMe(x){let c=0,h=0;for(const P of x)c+=P.w*P.h,h=Math.max(h,P.w);x.sort((P,R)=>R.h-P.h);const g=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(c/.95)),h),h:1/0}];let j=0,T=0;for(const P of x)for(let R=g.length-1;R>=0;R--){const F=g[R];if(!(P.w>F.w||P.h>F.h)){if(P.x=F.x,P.y=F.y,T=Math.max(T,P.y+P.h),j=Math.max(j,P.x+P.w),P.w===F.w&&P.h===F.h){const H=g.pop();H&&Rc.id?1:x.versionc.version?1:x.sxc.sx?1:x.syc.sy?1:0}function Ofe(x){let c=0;for(let h=0;h0,IMe(c,g,this.iconDescriptors,T),IMe(h,g,this.patternDescriptors,T),this.iconDescriptors.sort(_7),this.patternDescriptors.sort(_7);let P=0;const R=j?j.data:"";R&&(P=ng(P,Ofe(R))),P=ng(P,1);for(const F of this.iconDescriptors)P=ng(P,Ofe(F.id)),P=ng(P,F.version),P=ng(P,F.sx),P=ng(P,F.sy);P=ng(P,1);for(const F of this.patternDescriptors)P=ng(P,Ofe(F.id)),P=ng(P,F.version),P=ng(P,F.sx),P=ng(P,F.sy);this.hash=P}subsetOf(c){return this.isSubsetArray(this.iconDescriptors,c.iconDescriptors,_7)&&this.isSubsetArray(this.patternDescriptors,c.patternDescriptors,_7)}isSubsetArray(c,h,g){let j=0,T=0;if(c.length>h.length)return!1;for(;j{const P=j.variant.id.toString().localeCompare(T.variant.id.toString());return P!==0?P:j.variant.sx!==T.variant.sx?j.variant.sx-T.variant.sx:j.variant.sy!==T.variant.sy?j.variant.sy-T.variant.sy:0});const g=new Map;for(const j of h)g.set(j.key,j.value);return g}class LMe{constructor(c){this.sourceAtlasHash=c}}class DMe{constructor(c,h,g,j){const T=new Map,P=new Map;this.haveRenderCallbacks=[];const R=[],F=j!==void 0,H=F?new Map:void 0,Q=F?Bfe(c,H):c,se=F?Bfe(h,H):h;this.addImages(Q,T,1,R),this.addImages(se,P,2,R);const{w:re,h:oe}=PMe(R),ue=new Md({width:re||1,height:oe||1});for(const[_e,ke]of Q.entries()){const Pe=T.get(_e).paddedRect;Md.copy(ke.data,ue,{x:0,y:0},{x:Pe.x+1,y:Pe.y+1},ke.data,null,ke.sdf)}for(const[_e,ke]of se.entries()){const Pe=P.get(_e),We=Pe.paddedRect;let qe=Pe.padding;const rt=We.x+qe,it=We.y+qe,ot=ke.data.width,It=ke.data.height;qe=qe>1?qe-1:qe,Md.copy(ke.data,ue,{x:0,y:0},{x:rt,y:it},ke.data,g),Md.copy(ke.data,ue,{x:0,y:It-qe},{x:rt,y:it-qe},{width:ot,height:qe},g),Md.copy(ke.data,ue,{x:0,y:0},{x:rt,y:it+It},{width:ot,height:qe},g),Md.copy(ke.data,ue,{x:ot-qe,y:0},{x:rt-qe,y:it},{width:qe,height:It},g),Md.copy(ke.data,ue,{x:0,y:0},{x:rt+ot,y:it},{width:qe,height:It},g),Md.copy(ke.data,ue,{x:ot-qe,y:It-qe},{x:rt-qe,y:it-qe},{width:qe,height:qe},g),Md.copy(ke.data,ue,{x:0,y:It-qe},{x:rt+ot,y:it-qe},{width:qe,height:qe},g),Md.copy(ke.data,ue,{x:0,y:0},{x:rt+ot,y:it+It},{width:qe,height:qe},g),Md.copy(ke.data,ue,{x:ot-qe,y:0},{x:rt-qe,y:it+It},{width:qe,height:qe},g)}this.lut=g,this.image=ue,this.iconPositions=T,this.patternPositions=P,F&&(this.contentDescriptor=new Ffe(Q,se,j,g,H))}addImages(c,h,g,j){for(const[T,P]of c.entries()){const{bin:R,imagePosition:F,imageVariant:H}=zfe(T,P,g);h.set(T,F),j.push(R),P.hasRenderCallback&&this.haveRenderCallbacks.push(H.id)}}patchUpdatedImages(c,h,g,j){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(T=>c.hasImage(T,g)),c.dispatchRenderCallbacks(this.haveRenderCallbacks,g);for(const T of c.getUpdatedImages(g)){for(const P of this.iconPositions.keys()){const R=$m.parse(P);if(Bn.isEqual(R.id,T)){const F=c.getImage(T,g);this.patchUpdatedImage(this.iconPositions.get(P),F,h,null)}}for(const P of this.patternPositions.keys()){const R=$m.parse(P);if(Bn.isEqual(R.id,T)){const F=c.getImage(T,g);this.patchUpdatedImage(this.patternPositions.get(P),F,h,j||this.lut)}}}}patchUpdatedImage(c,h,g,j=null){if(!c||!h||c.version===h.version)return;c.version=h.version;const[T,P]=c.tl,R=c.sdf;if(this.lut||R){const F={width:h.data.width,height:h.data.height},H=new Md(F);Md.copy(h.data,H,{x:0,y:0},{x:0,y:0},F,j,R),g.update(H,{position:{x:T,y:P},recreateWhenResize:!1})}else g.update(h.data,{position:{x:T,y:P},recreateWhenResize:!1})}}gr(_I,"ImagePosition"),gr(DMe,"ImageAtlas",{omit:["lut"]}),gr(LMe,"ImageAtlasReference");class bI{constructor(c){this.pendingRequests=new Map,this.cachedRanges=new Map,this.useServerFontComposition=!c||c.useServerFontComposition===void 0||c.useServerFontComposition}loadGlyphRange(c,h,g,j,T){if(this.useServerFontComposition)return void bI.loadGlyphRange(c,h,g,j,T);const P=c.split(",").map(R=>R.trim()).filter(R=>R.length>0);P.length!==0?P.length!==1?this._loadMultipleFonts(P,h,g,j,T):this._loadFont(P[0],h,g,j,T):T(new Error("Empty fontstack"))}_loadMultipleFonts(c,h,g,j,T){const P=c.map(()=>null),R={completed:0,firstError:null,callbackCalled:!1},F=(H,Q,se)=>{if(!R.callbackCalled&&(Q&&!R.firstError&&(R.firstError=Q),se&&(P[H]=se),R.completed++,R.completed===c.length)){R.callbackCalled=!0;const re=P.filter(ue=>ue!==null);if(re.length===0)return void T(R.firstError||new Error("All fonts failed to load"));const oe=this._composeGlyphs(re);T(null,oe)}};for(let H=0;H{F(H,Q,se)})}_loadFont(c,h,g,j,T){const P=`${c}:${h}`;if(this.cachedRanges.has(P)){const F=this.cachedRanges.get(P);return void Gd.frame(()=>T(null,F))}const R=this.pendingRequests.get(P);R?R.push(T):(this.pendingRequests.set(P,[T]),bI.loadGlyphRange(c,h,g,j,(F,H)=>{F||this.cachedRanges.set(P,H||null);const Q=this.pendingRequests.get(P);if(this.pendingRequests.delete(P),Q)for(const se of Q)se(F,H)}))}_composeGlyphs(c){const h={};let g,j;for(const T of c)if(g===void 0&&T.ascender!==void 0&&(g=T.ascender),j===void 0&&T.descender!==void 0&&(j=T.descender),T.glyphs)for(const P in T.glyphs)h[P]===void 0&&(h[P]=T.glyphs[P]);return{glyphs:h,ascender:g,descender:j}}}bI.loadGlyphRange=function(x,c,h,g,j){const T=256*c,P=T+255,R=g.transformRequest(g.normalizeGlyphsURL(h).replace("{fontstack}",x).replace("{range}",`${T}-${P}`),Pf.Glyphs);If(R,(F,H)=>{if(F)j(F);else if(H){const Q={},se=function(re){return new g7(re).readFields(ght,{})}(H);for(const re of se.glyphs)Q[re.id]=re;j(null,{glyphs:Q,ascender:se.ascender,descender:se.descender})}})};const wI=1e20;function RMe(x,c,h,g,j,T,P,R,F){for(let H=c;H-1);F++,T[F]=R,P[F]=H,P[F+1]=wI}for(let R=0,F=0;R{if(P){j.ascender=P.ascender,j.descender=P.descender;for(const R in P.glyphs)this._doesCharSupportLocalGlyph(+R)||(j.glyphs[+R]=P.glyphs[+R]);j.ranges[h]=!0}for(const R of j.requests[h]||[])R(T,P);delete j.requests[h]}))}getGlyphs(c,h){const g=[],j=this.url||oa.GLYPHS_URL;for(const T in c)for(const P of c[T])g.push({stack:T,id:P});_t(g,({stack:T,id:P},R)=>{let F=this.entries[T];F||(F=this.entries[T]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let H=F.glyphs[P];if(H!==void 0)return void R(null,{stack:T,id:P,glyph:H});if(H=this._tinySDF(F,T,P),H)return F.glyphs[P]=H,void R(null,{stack:T,id:P,glyph:H});const Q=Math.floor(P/256);if(256*Q>65535)return zr("glyphs > 65535 not supported"),void R(null,{stack:T,id:P,glyph:H});if(F.ranges[Q])return void R(null,{stack:T,id:P,glyph:H});let se=F.requests[Q];se||(se=F.requests[Q]=[],this.glyphLoader.loadGlyphRange(T,Q,j,this.requestManager,(re,oe)=>{if(oe){F.ascender=oe.ascender,F.descender=oe.descender;for(const ue in oe.glyphs)this._doesCharSupportLocalGlyph(+ue)||(F.glyphs[+ue]=oe.glyphs[+ue]);F.ranges[Q]=!0}for(const ue of se)ue(re,oe);delete F.requests[Q]})),se.push((re,oe)=>{re?R(re):oe&&R(null,{stack:T,id:P,glyph:oe.glyphs[P]||null})})},(T,P)=>{if(T)h(T);else if(P){const R={};for(const{stack:F,id:H,glyph:Q}of P)R[F]===void 0&&(R[F]={}),R[F].glyphs===void 0&&(R[F].glyphs={}),R[F].glyphs[H]=Q&&{id:Q.id,bitmap:Q.bitmap.clone(),metrics:Q.metrics},R[F].ascender=this.entries[F].ascender,R[F].descender=this.entries[F].descender;h(null,R)}})}_doesCharSupportLocalGlyph(c){return this.localGlyphMode!==$fe.none&&(this.localGlyphMode===$fe.all?!!this.localFontFamily:!!this.localFontFamily&&(g3(c)||fP(c)||c2(c)||K0(c)||l2(c)||mP(c)||(h=c)>=131072&&h<=173791||(g=>g>=66736&&g<=66815)(c)));var h}_tinySDF(c,h,g){const j=this.localFontFamily;if(!j||!this._doesCharSupportLocalGlyph(g))return;let T=c.tinySDF;if(!T){let ke="400";/bold/i.test(h)?ke="900":/medium/i.test(h)?ke="500":/light/i.test(h)&&(ke="200"),T=c.tinySDF=new b7.TinySDF({fontFamily:j,fontWeight:ke,fontSize:48,buffer:6,radius:16}),T.fontWeight=ke}const P=T.fontWeight;if(this.localGlyphs[P][g])return this.localGlyphs[P][g];const R=String.fromCodePoint(g),{data:F,width:H,height:Q,glyphWidth:se,glyphHeight:re,glyphLeft:oe,glyphTop:ue,glyphAdvance:_e}=T.draw(R);return this.localGlyphs[P][g]={id:g,bitmap:new l_({width:H,height:Q},F),metrics:{width:se/2,height:re/2,left:oe/2,top:ue/2-27,advance:_e/2,localGlyph:!0}}}}function FMe(x,c){return x+c[1]-c[0]}function qfe(x,c,h,g,j=1){const T=[],P=x.imagePrimary,R=P.pixelRatio,F=P.paddedRect.w-2,H=P.paddedRect.h-2,Q=(x.right-x.left)*j,se=(x.bottom-x.top)*j,re=P.stretchX||[[0,F]],oe=P.stretchY||[[0,H]],ue=re.reduce(FMe,0),_e=oe.reduce(FMe,0),ke=F-ue,Pe=H-_e;let We=0,qe=ue,rt=0,it=_e,ot=0,It=ke,wt=0,At=Pe;if(P.content&&g){const St=P.content;We=w7(re,0,St[0]),rt=w7(oe,0,St[1]),qe=w7(re,St[0],St[2]),it=w7(oe,St[1],St[3]),ot=St[0]-We,wt=St[1]-rt,It=St[2]-St[0]-qe,At=St[3]-St[1]-it}const kt=(St,rs,is,us)=>{const ws=j7(St.stretch-We,qe,Q,x.left*j),hs=N7(St.fixed-ot,It,St.stretch,ue),Ds=j7(rs.stretch-rt,it,se,x.top*j),ts=N7(rs.fixed-wt,At,rs.stretch,_e),vs=j7(is.stretch-We,qe,Q,x.left*j),Ms=N7(is.fixed-ot,It,is.stretch,ue),Rs=j7(us.stretch-rt,it,se,x.top*j),Ks=N7(us.fixed-wt,At,us.stretch,_e),fr=new Xt(ws,Ds),er=new Xt(vs,Ds),Js=new Xt(vs,Rs),Zs=new Xt(ws,Rs),dr=new Xt(hs/R,ts/R),jr=new Xt(Ms/R,Ks/R),$r=c*Math.PI/180;if($r){const Un=Math.sin($r),po=Math.cos($r),Wa=[po,-Un,Un,po];fr._matMult(Wa),er._matMult(Wa),Zs._matMult(Wa),Js._matMult(Wa)}const Pr=St.stretch+St.fixed,kn=is.stretch+is.fixed,ba=rs.stretch+rs.fixed,Sn=us.stretch+us.fixed,ka=x.imageSecondary;return{tl:fr,tr:er,bl:Zs,br:Js,texPrimary:{x:P.paddedRect.x+1+Pr,y:P.paddedRect.y+1+ba,w:kn-Pr,h:Sn-ba},texSecondary:ka?{x:ka.paddedRect.x+1+Pr,y:ka.paddedRect.y+1+ba,w:kn-Pr,h:Sn-ba}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:dr,pixelOffsetBR:jr,minFontScaleX:It/R/Q,minFontScaleY:At/R/se,isSDF:h}};if(P.stretchX||P.stretchY){const St=zMe(re,ke,ue),rs=zMe(oe,Pe,_e);for(let is=0;is0?[We,-qe]:rt<0?[-We,qe]:We===0?[qe,We]:[qe,-We]}(h);let oe=Math.abs(c.top-c.bottom);for(const Pe of c.positionedLines)oe-=Pe.lineOffset;const ue=c.positionedLines.length,_e=oe/ue;let ke=c.top-h[1];for(let Pe=0;PeT)&&(T=ue.x),(!oe||ue.y>P)&&(P=ue.y)}const F=Math.min(T-g,P-j);let H=F/2;const Q=new Ww([],Cht);if(F===0)return new Xt(g,j);for(let oe=g;oese.d||!se.d)&&(se=oe,h&&console.log("found best %d after %d probes",Math.round(1e4*oe.d)/1e4,re)),oe.max-se.d<=c||(H=oe.h/2,Q.push(new W3(oe.p.x-H,oe.p.y-H,H,x)),Q.push(new W3(oe.p.x+H,oe.p.y-H,H,x)),Q.push(new W3(oe.p.x-H,oe.p.y+H,H,x)),Q.push(new W3(oe.p.x+H,oe.p.y+H,H,x)),re+=4)}return h&&(console.log(`num probes: ${re}`),console.log(`best distance: ${se.d}`)),se.p}function Cht(x,c){return c.max-x.max}b7.TinySDF=class{constructor({fontSize:x=24,buffer:c=3,radius:h=8,cutoff:g=.25,fontFamily:j="sans-serif",fontWeight:T="normal",fontStyle:P="normal",lang:R=null}={}){this.buffer=c,this.cutoff=g,this.radius=h,this.lang=R;const F=this.size=x+4*c,H=this._createCanvas(F),Q=this.ctx=H.getContext("2d",{willReadFrequently:!0});Q.font=`${P} ${T} ${x}px ${j}`,Q.textBaseline="alphabetic",Q.textAlign="left",Q.fillStyle="black",this.gridOuter=new Float64Array(F*F),this.gridInner=new Float64Array(F*F),this.f=new Float64Array(F),this.z=new Float64Array(F+1),this.v=new Uint16Array(F)}_createCanvas(x){const c=document.createElement("canvas");return c.width=c.height=x,c}draw(x){const{width:c,actualBoundingBoxAscent:h,actualBoundingBoxDescent:g,actualBoundingBoxLeft:j,actualBoundingBoxRight:T}=this.ctx.measureText(x),P=Math.ceil(h),R=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(T-j))),F=Math.min(this.size-this.buffer,P+Math.ceil(g)),H=R+2*this.buffer,Q=F+2*this.buffer,se=Math.max(H*Q,0),re=new Uint8ClampedArray(se),oe={data:re,width:H,height:Q,glyphWidth:R,glyphHeight:F,glyphTop:P,glyphLeft:0,glyphAdvance:c};if(R===0||F===0)return oe;const{ctx:ue,buffer:_e,gridInner:ke,gridOuter:Pe}=this;this.lang&&(ue.lang=this.lang),ue.clearRect(_e,_e,R,F),ue.fillText(x,_e,_e+P);const We=ue.getImageData(_e,_e,R,F);Pe.fill(wI,0,se),ke.fill(0,0,se);for(let qe=0;qe0?It*It:0,ke[ot]=It<0?It*It:0}}RMe(Pe,0,0,H,Q,H,this.f,this.v,this.z),RMe(ke,_e,_e,R,F,H,this.f,this.v,this.z);for(let qe=0;qeT.y!=_e.y>T.y&&T.x<(_e.x-ue.x)*(T.y-ue.y)/(_e.y-ue.y)+ue.x&&(R=!R),F=Math.min(F,$f(T,ue,_e))}}return(R?1:-1)*Math.sqrt(F)}(this.p,j),this.max=this.d+this.h*Math.SQRT2}}const Mht=Object.keys,Ufe=Number.POSITIVE_INFINITY,Tht=Math.sqrt(2);function h_(x,c,h,g,j,T){const P=Lfe(x)&&x.collisionPadding?x.collisionPadding:[0,0,0,0],R={top:x.top-P[1],bottom:x.bottom+P[3],left:x.left-P[0],right:x.right+P[2],scaled:!1};return g!==void 0&&function(F,H){F.top*=H,F.bottom*=H,F.left*=H,F.right*=H,F.scaled=!0}(R,g),T&&(R.left+=T[0],R.right+=T[0],R.top+=T[1],R.bottom+=T[1]),h&&function(F,H,Q){if(!H)return;const se=Kt(H),re=new Xt(Q?Q[0]:0,Q?Q[1]:0),oe=new Xt(F.left,F.top),ue=new Xt(F.right,F.top),_e=new Xt(F.left,F.bottom),ke=new Xt(F.right,F.bottom);oe._rotateAround(se,re),ue._rotateAround(se,re),_e._rotateAround(se,re),ke._rotateAround(se,re),F.left=Math.min(oe.x,ue.x,_e.x,ke.x),F.right=Math.max(oe.x,ue.x,_e.x,ke.x),F.top=Math.min(oe.y,ue.y,_e.y,ke.y),F.bottom=Math.max(oe.y,ue.y,_e.y,ke.y)}(R,h,j),c?{top:Math.min(c.top,R.top),bottom:Math.max(c.bottom,R.bottom),left:Math.min(c.left,R.left),right:Math.max(c.right,R.right),scaled:c.scaled||R.scaled}:R}function qMe(x,[c,h]){let g=0,j=0;if(h===Ufe){c<0&&(c=0);const T=c/Tht;switch(x){case"top-right":case"top-left":j=T-7;break;case"bottom-right":case"bottom-left":j=7-T;break;case"bottom":j=7-c;break;case"top":j=c-7}switch(x){case"top-right":case"bottom-right":g=-T;break;case"top-left":case"bottom-left":g=T;break;case"left":g=c;break;case"right":g=-c}}else{switch(c=Math.abs(c),h=Math.abs(h),x){case"top-right":case"top-left":case"top":j=h-7;break;case"bottom-right":case"bottom-left":case"bottom":j=7-h}switch(x){case"top-right":case"bottom-right":case"right":g=-c;break;case"top-left":case"bottom-left":case"left":g=c}}return[g,j]}function Aht(x,c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue){const _e=x.layers[0],ke=_e.appearances;if(ke.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Pe={iconBBox:null,iconVerticalBBox:null},We={textBBox:null,textVerticalBBox:null},{baseIconRotate:qe,baseTextRotate:rt,iconScaleFactor:it}=function(It,wt,At){const kt=It.get("icon-rotate").evaluate(wt,{},At),St=It.get("text-rotate").evaluate(wt,{},At),[rs,is]=It.get("icon-size-scale-range");return{baseIconRotate:kt,baseTextRotate:St,iconScaleFactor:De(1,rs,is)}}(g,j,T);c&&(Pe.iconBBox=h_(c,Pe.iconBBox,qe),h)&&(Pe.iconVerticalBBox=h_(h,Pe.iconVerticalBBox,qe+90));const ot=S7(se.horizontal);ot&&(We.textBBox=h_(ot,We.textBBox,rt,1,oe)),se.vertical&&(We.textVerticalBBox=h_(se.vertical,We.textVerticalBBox,rt+90,1,oe));for(const It of ke)It.hasIconLayoutProperties()&&Eht(Pe,x,_e,It,j,T,R,qe,P,F,c,H,it,Q,ue),It.hasTextLayoutProperties()&&Pht(We,_e,It,j,T,oe,rt,re,ot,se.vertical);return{iconBBox:Pe.iconBBox,iconVerticalBBox:Pe.iconVerticalBBox,textBBox:We.textBBox,textVerticalBBox:We.textVerticalBBox}}function Eht(x,c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue){const{appearanceIconOffset:_e,appearanceIconRotate:ke,appearanceIconSize:Pe}=UMe(g,h,j,T,P,R,F,H.iconScaleFactor);let We=null,qe=null,rt=null;g.hasLayoutProperty("icon-image")?rt=function(ot,It,wt,At,kt,St,rs,is){let us=null;const ws=It.getAppearanceValueAndResolveTokens(wt,"icon-image",At,kt,is);if(ws){const hs=ot.getResolvedImageFromTokens(ws),Ds=wt.hasLayoutProperty("icon-size")?wt.getUnevaluatedLayoutProperty("icon-size"):It._unevaluatedLayout._values["icon-size"],ts=jI(hs,A2(ot.zoom,Ds,ot.worldview,is),Ds,kt,ot.zoom,At,ot.pixelRatio,rs,ot.worldview,is);us=St.get(ts.iconPrimary.toString())}return us}(c,h,g,j,T,se,re,ue):Q&&(rt=Q.imagePrimary),rt&&(We=v7(rt,null,_e,oe),c.allowVerticalPlacement&&(qe=v7(rt,null,_e,oe)));const it=F>0?Pe/F:1;We&&(x.iconBBox=h_(We,x.iconBBox,ke,it!==1?it:void 0)),qe&&(x.iconVerticalBBox=h_(qe,x.iconVerticalBBox,ke+90,it!==1?it:void 0))}function UMe(x,c,h,g,j,T,P,R){const F=x.hasLayoutProperty("icon-offset")?c.getAppearanceValueAndResolveTokens(x,"icon-offset",h,g,[]):null,H=F&&Array.isArray(F)?F:j,Q=x.hasLayoutProperty("icon-rotate")?c.getAppearanceValueAndResolveTokens(x,"icon-rotate",h,g,[]):null,se=typeof Q=="number"?Q:T,re=x.hasLayoutProperty("icon-size")?c.getAppearanceValueAndResolveTokens(x,"icon-size",h,g,[]):null;return{appearanceIconOffset:H,appearanceIconRotate:se,appearanceIconSize:typeof re=="number"?re*R:P}}function Pht(x,c,h,g,j,T,P,R,F,H){const{appearanceTextOffset:Q,appearanceTextRotate:se,appearanceTextSize:re}=VMe(h,c,g,j,T,P,R),oe=re/R,ue=[(Q[0]-T[0])*oe,(Q[1]-T[1])*oe],_e=ue[0]!==0||ue[1]!==0;F&&(x.textBBox=h_(F,x.textBBox,se,oe,Q,_e?ue:void 0)),H&&(x.textVerticalBBox=h_(H,x.textVerticalBBox,se+90,oe,Q,_e?ue:void 0))}function VMe(x,c,h,g,j,T,P){const R=x.hasLayoutProperty("text-offset")?c.getAppearanceValueAndResolveTokens(x,"text-offset",h,g,[]):null,F=R&&Array.isArray(R)?[R[0]*ic,R[1]*ic]:j,H=x.hasLayoutProperty("text-rotate")?c.getAppearanceValueAndResolveTokens(x,"text-rotate",h,g,[]):null,Q=typeof H=="number"?H:T,se=x.hasLayoutProperty("text-size")?c.getAppearanceValueAndResolveTokens(x,"text-size",h,g,[]):null;return{appearanceTextOffset:F,appearanceTextRotate:Q,appearanceTextSize:typeof se=="number"?se:P}}function k7(x,c,h,g,j,T,P,R,F){if(!c||!c.usvg)return;const H=SMe(g),Q=SMe(j),se=T!=="both"&&T!=="width"||!NMe(g)?1:Q.width/H.width,re=T!=="both"&&T!=="height"||!kMe(g)?1:Q.height/H.height;h.scaleSelf(se,re);const oe=h.toString();P.set(oe,h),R.set(oe,c);const{imagePosition:ue}=zfe(oe,c,1);F.set(oe,ue)}function HMe(x,c,h,g,j,T,P,R,F,H){if(!x)return;const Q=function(se,re,oe,ue,_e,ke,Pe){if(se.kind==="camera")return se.maxSize;if(se.kind==="composite"){const We=re.possiblyEvaluate(new Ga(se.maxZoom,{worldview:ke}),oe,Pe).evaluate(_e,{},oe,Pe),qe=re.possiblyEvaluate(new Ga(se.minZoom,{worldview:ke}),oe,Pe).evaluate(_e,{},oe,Pe);return Math.max(We,qe)}return re.possiblyEvaluate(new Ga(ue,{worldview:ke}),oe,Pe).evaluate(_e,{},oe,Pe)}(c,h,g,j,T,F,H);return x.scaleSelf(Q*R*P)}function jI(x,c,h,g,j,T,P,R,F,H){return{iconPrimary:HMe(x.getPrimary(),c,h,g,j,T,P,R,F,H),iconSecondary:HMe(x.getSecondary(),c,h,g,j,T,P,R,F,H)}}function Iht(x,c,h){if(!c)return;const g=h.get(x.toString()),j=h.get(c.toString());g&&j&&(g.paddedRect.w===j.paddedRect.w&&g.paddedRect.h===j.paddedRect.h||zr(`Mismatch in icon variant sizes: ${x.toString()} and ${c.toString()}`),g.usvg!==j.usvg&&zr(`Mismatch in icon variant image types: ${x.id} and ${c.id}`))}function GMe(x,c,h,g){if(!x)return;const j=c.get(h.toString());if(j&&(x.imagePrimary=j),g){const T=c.get(g.toString());x.imageSecondary=T}}function Lht(x,c){for(const h in x.horizontal)WMe(x.horizontal[h],c);WMe(x.vertical,c)}function WMe(x,c){if(x){for(const h of x.positionedLines)for(const g of h.positionedGlyphs)if(g.image!==null){const j=g.image.toString();g.rect=c.get(j).paddedRect}}}function Vfe(x){switch(x){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Dht(x,c,h,g,j,T,P,R,F){const H=S7(T.horizontal)||T.vertical,Q=h.get("icon-text-fit-padding").evaluate(g,{},j);let se,re=c;return c&&F!=="none"&&(x.allowVerticalPlacement&&T.vertical&&(se=Dfe(c,T.vertical,F,Q,R,P)),H&&(re=Dfe(c,H,F,Q,R,P))),{defaultShapedIcon:re,verticallyShapedIcon:se}}function KMe(x,c){return x*c/24}function Rht(x,c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e,ke,Pe,We,qe,rt,it,ot,It){let wt=P.textMaxSize.evaluate(c,{},re);wt===void 0?wt=R*P.textScaleFactor:wt*=P.textScaleFactor;const At=x.layers[0].layout,kt=KMe(R,P.textScaleFactor),St=S7(h.horizontal)||h.vertical,rs=x.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),is=x.getAppearanceFeatureData(c.index);(ke!=="none"||rs)&&is&&(is.textShaping=St,is.iconTextFitPadding=At.get("icon-text-fit-padding").evaluate(c,{},re),is.fontScale=kt,is.textScaleFactor=P.textScaleFactor);const us=oe.name==="globe",ws=x.tilePixelRatio*wt/24,hs=(Ks=x.overscaling,x.zoom>18&&Ks>2&&(Ks>>=1),Math.max(sr/(512*Ks),1)*At.get("symbol-spacing")),Ds=At.get("text-padding")*x.tilePixelRatio,ts=At.get("icon-padding")*x.tilePixelRatio,vs=Kt(At.get("text-max-angle")),Ms=At.get("icon-rotation-alignment")==="map"&&qe!=="point",Rs=hs/2;var Ks;x.hasAnyIconTextFit===!1&&ke!=="none"&&(x.hasAnyIconTextFit=!0);const fr=c.properties?+c.properties[Ln]:null,er=fr&&x.elevationFeatureIdToIndex?x.elevationFeatureIdToIndex.get(fr):65535,Js=(Zs,dr,jr)=>{if(dr.x<0||dr.x>=sr||dr.y<0||dr.y>=sr)return;let $r=null;if(us){const{x:Pr,y:kn,z:ba}=oe.projectTilePoint(dr.x,dr.y,jr);$r={anchor:new lv(Pr,kn,ba,0,void 0),up:oe.upVector(jr,dr.x,dr.y)}}(function(Pr,kn,ba,Sn,ka,Un,po,Wa,Ia,ki,io,oc,oo,Eo,el,Po,ld,lc,Wn,ju,zo,Ac,Nu,cd,fo,Xd,Ec,V7,t5,Wu,pxe,s5){const cv=Pr.addToLineVertexArray(kn,Sn);let dv,Dp,Rp,R2,r5,Jn,Pc,Io=0,Ul=0,Op=0,am=0,im=-1,om=-1;const Vf={};let H7=jt("");const lg=ba?ba.anchor:kn,n5=V7!=="none";let a5=0,Cl=0;if(Ia._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Bo=Ia.layout.get("text-offset").evaluate(zo,{},fo);a5=Bo[0]*ic,Cl=Bo[1]*ic}else a5=Ia.layout.get("text-radial-offset").evaluate(zo,{},fo)*ic,Cl=Ufe;if(Pr.allowVerticalPlacement&&ka.vertical){const Bo=ka.vertical;if(el)Jn=Wfe(Bo),Wa&&(Pc=Wfe(Wa));else{const ku=Ia.layout.get("text-rotate").evaluate(zo,{},fo)+90;Rp=C7(ki,lg,kn,io,oc,oo,Bo,Eo,ku,Po,s5),Wa&&(R2=C7(ki,lg,kn,io,oc,oo,Wa,lc,ku,null,pxe))}}if(Un){const Bo=Ia.layout.get("icon-rotate").evaluate(zo,{},fo),ku=qfe(Un,Bo,Nu,n5,Ac.iconScaleFactor),Ku=Wa?qfe(Wa,Bo,Nu,n5,Ac.iconScaleFactor):void 0;Dp=C7(ki,lg,kn,io,oc,oo,Un,lc,Bo,null,Wu);const Gf=function(cg,FI,i5,Xmt,Qmt,fAe,xAe,Jmt,YAs,xxe){const gAe=cg.layers[0],yAe=gAe.appearances;let o5=FI.length;if(i5&&(o5=Math.max(o5,i5.length)),yAe.length===0)return o5;const[ept,tpt]=Xmt.get("icon-size-scale-range"),spt=De(1,ept,tpt);for(const Z7 of yAe)if(Z7.hasLayoutProperty("icon-image")){const vAe=gAe.getAppearanceValueAndResolveTokens(Z7,"icon-image",fAe,xAe,xxe);if(vAe){const _Ae=cg.getResolvedImageFromTokens(vAe);if(_Ae){const bAe=Z7.hasLayoutProperty("icon-size")?Z7.getUnevaluatedLayoutProperty("icon-size"):Qmt._values["icon-size"],rpt=jI(_Ae,A2(cg.zoom,bAe,cg.worldview,xxe),bAe,xAe,cg.zoom,fAe,cg.pixelRatio,spt,cg.worldview,xxe),wAe=Jmt.get(rpt.iconPrimary.toString());wAe&&(o5=Math.max(o5,Nht(wAe)))}}}return o5}(Pr,ku,Ku,Ia.layout,Ia._unevaluatedLayout,zo,fo,Pr.iconAtlasPositions,0,cd);Io=4*Gf;const G7=Ia.layout.get("icon-size").evaluate(zo,{},fo,cd),W7=Ac.compositeIconSizes?Ac.compositeIconSizes[0].evaluate(zo,{},fo,cd):0,fxe=Ac.compositeIconSizes?Ac.compositeIconSizes[1].evaluate(zo,{},fo,cd):0,K7=Gfe(Pr.layerIds[0],Pr.iconSizeData,G7,Ac.iconScaleFactor,W7,fxe);Pr.addSymbols(Pr.icon,ku,K7,ju,Wn,zo,void 0,ba,kn,cv.lineStartIndex,cv.lineLength,-1,cd,fo,Xd,Ec,Pr.symbolInstances.length,Gf),im=Pr.icon.placedSymbolArray.length-1,Ku&&(Ul=4*Gf,Pr.addSymbols(Pr.icon,Ku,K7,ju,Wn,zo,nm.vertical,ba,kn,cv.lineStartIndex,cv.lineLength,-1,cd,fo,Xd,Ec,Pr.symbolInstances.length,Gf),om=Pr.icon.placedSymbolArray.length-1)}for(const Bo in ka.horizontal){const ku=Bo,Ku=ka.horizontal[ku];dv||(H7=jt(Ku.text),el?r5=Wfe(Ku):dv=C7(ki,lg,kn,io,oc,oo,Ku,Eo,Ia.layout.get("text-rotate").evaluate(zo,{},fo),Po,s5));const Gf=Ku.positionedLines.length===1;if(Op+=ZMe(Pr,ba,kn,Ku,po,Ia,el,zo,Po,cv,ka.vertical?nm.horizontal:nm.horizontalOnly,Gf?Mht(ka.horizontal):[ku],Vf,im,Ac,cd,fo,Pr.symbolInstances.length,Xd),Gf)break}ka.vertical&&(am+=ZMe(Pr,ba,kn,ka.vertical,po,Ia,el,zo,Po,cv,nm.vertical,["vertical"],Vf,om,Ac,cd,fo,Pr.symbolInstances.length,Xd));let cl=-1;const Vl=(Bo,ku)=>Bo?Math.max(Bo,ku):ku;cl=Vl(r5,cl),cl=Vl(Jn,cl),cl=Vl(Pc,cl);const Hf=cl>-1?1:0;Pr.glyphOffsetArray.length>=65535&&zr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),zo.sortKey!==void 0&&Pr.addToSortKeyRanges(Pr.symbolInstances.length,zo.sortKey),Pr.symbolInstances.emplaceBack(kn.x,kn.y,lg.x,lg.y,lg.z,Vf.right>=0?Vf.right:-1,Vf.center>=0?Vf.center:-1,Vf.left>=0?Vf.left:-1,Vf.vertical>=0?Vf.vertical:-1,im,om,H7,dv!==void 0?dv:Pr.collisionBoxArray.length,dv!==void 0?dv+1:Pr.collisionBoxArray.length,Rp!==void 0?Rp:Pr.collisionBoxArray.length,Rp!==void 0?Rp+1:Pr.collisionBoxArray.length,Dp!==void 0?Dp:Pr.collisionBoxArray.length,Dp!==void 0?Dp+1:Pr.collisionBoxArray.length,R2||Pr.collisionBoxArray.length,R2?R2+1:Pr.collisionBoxArray.length,io,Op,am,Io,Ul,Hf,0,a5,Cl,cl,0,n5?1:0,t5)})(x,dr,$r,Zs,h,g,T,j,x.layers[0],x.collisionBoxArray,c.index,c.sourceLayerIndex,x.index,Ds,We,H,0,ts,Ms,Pe,c,P,Q,se,re,ue,_e,ke,er,rt,it,ot)};if(qe==="line")for(const Zs of i7(c.geometry,0,0,sr,sr)){const dr=jht(Zs,hs,vs,h.vertical||St,g,24,ws,x.overscaling,sr);for(const jr of dr)St&&Oht(x,St.text,Rs,jr)||Js(Zs,jr,re)}else if(qe==="line-center"){for(const Zs of c.geometry)if(Zs.length>1){const dr=wht(Zs,vs,h.vertical||St,g,24,ws);dr&&Js(Zs,dr,re)}}else if(c.type==="Polygon")for(const Zs of aI(c.geometry,0)){const dr=Sht(Zs,16);Js(Zs[0],new lv(dr.x,dr.y,0,0,void 0),re)}else if(c.type==="LineString")for(const Zs of c.geometry)Js(Zs,new lv(Zs[0].x,Zs[0].y,0,0,void 0),re);else if(c.type==="Point")for(const Zs of c.geometry)for(const dr of Zs)Js([dr],new lv(dr.x,dr.y,0,0,void 0),re)}const Hfe=255,E2=Hfe*ov;function ZMe(x,c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e,ke,Pe,We){const qe=$Me(0,g,F,T,P,R,j,x.allowVerticalPlacement,void 0,ue.textScaleFactor),rt=T.layout.get("text-size").evaluate(R,{},ke),it=ue.compositeTextSizes?ue.compositeTextSizes[0].evaluate(R,{},ke):0,ot=ue.compositeTextSizes?ue.compositeTextSizes[1].evaluate(R,{},ke):0,It=Gfe(x.layerIds[0],x.textSizeData,rt,ue.textScaleFactor,it,ot);x.addSymbols(x.text,qe,It,F,P,R,Q,c,h,H.lineStartIndex,H.lineLength,oe,_e,ke,We,!1,Pe,qe.length);for(const wt of se)re[wt]=x.text.placedSymbolArray.length-1;return 4*qe.length}function Gfe(x,c,h,g,j,T){const P=c;let R=null;return P.kind==="source"?(R=[ov*h*g],R[0]>E2&&zr(`${x}: Value for "text-size" is >= ${Hfe}. Reduce your "text-size".`)):P.kind==="composite"&&(R=[ov*j*g,ov*T*g],(R[0]>E2||R[1]>E2)&&zr(`${x}: Value for "text-size" is >= ${Hfe}. Reduce your "text-size".`)),R}function S7(x){for(const c in x)return x[c];return null}function C7(x,c,h,g,j,T,P,R,F,H,Q){let se,re,oe,ue;if(se=Q?Q.top:P.top,re=Q?Q.bottom:P.bottom,oe=Q?Q.left:P.left,ue=Q?Q.right:P.right,Lfe(P)&&P.collisionPadding){const _e=P.collisionPadding;oe-=_e[0],se-=_e[1],ue+=_e[2],re+=_e[3]}if(F){const _e=new Xt(oe,se),ke=new Xt(ue,se),Pe=new Xt(oe,re),We=new Xt(ue,re),qe=Kt(F);let rt=new Xt(0,0);H&&(rt=new Xt(H[0],H[1])),_e._rotateAround(qe,rt),ke._rotateAround(qe,rt),Pe._rotateAround(qe,rt),We._rotateAround(qe,rt),oe=Math.min(_e.x,ke.x,Pe.x,We.x),ue=Math.max(_e.x,ke.x,Pe.x,We.x),se=Math.min(_e.y,ke.y,Pe.y,We.y),re=Math.max(_e.y,ke.y,Pe.y,We.y)}return x.emplaceBack(c.x,c.y,c.z,h.x,h.y,oe,se,ue,re,R,g,j,T),x.length-1}function Wfe(x){Lfe(x)&&x.collisionPadding&&(x.top-=x.collisionPadding[1],x.bottom+=x.collisionPadding[3]);const c=x.bottom-x.top;return c>0?Math.max(10,c):null}function Oht(x,c,h,g){const j=x.compareText;if(c in j){const T=j[c];for(let P=T.length-1;P>=0;P--)if(g.dist(T[P])qe&&(rt(ot,us,wt,At,rs,is),rt(us,It,rs,is,kt,St))}rt(se,re,g,T,j,T),rt(re,oe,j,T,j,P),rt(oe,ue,j,P,g,P),rt(ue,se,g,P,g,T),_e-=qe,ke-=qe,Pe+=qe,We+=qe;const it=1/Math.max(Pe-_e,We-ke);return{scale:it,x:_e*it,y:ke*it,x2:Pe*it,y2:We*it,projection:c}}function XMe(x,{x:c,y:h},g=0){return new Xt(((c-g)*x.scale-x.x)*sr,(h*x.scale-x.y)*sr)}const Fht=w(new Float32Array(16));class m_{constructor(c){this.spec=c,this.name=c.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(c,h){return{x:0,y:0,z:0}}unproject(c,h){return new qt(0,0)}projectTilePoint(c,h,g){return{x:c,y:h,z:0}}locationPoint(c,h,g,j=!0){return c._coordinatePoint(c.locationCoordinate(h,g),j)}pixelsPerMeter(c,h){return Zt(1,c)*h}pixelSpaceConversion(c,h,g){return 1}farthestPixelDistance(c){return YMe(c,c.pixelsPerMeter)}pointCoordinate(c,h,g,j){const T=c.horizonLineFromTop(!1),P=new Xt(h,Math.max(T,g));return c.rayIntersectionCoordinate(c.pointRayIntersection(P,j))}pointCoordinate3D(c,h,g){const j=new Xt(h,g);if(c.elevation)return c.elevation.pointCoordinate(j);{const T=this.pointCoordinate(c,j.x,j.y,0);return[T.x,T.y,T.z]}}isPointAboveHorizon(c,h){if(c.elevation&&c.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(c,h.x,h.y);const g=c.horizonLineFromTop();return h.y0?h<-K3+g&&(h=-K3+g):h>K3-g&&(h=K3-g);const P=T/Math.pow(T7(h),j);let R=P*Math.sin(j*c),F=T-P*Math.cos(j*c);return R=.5*(R/Math.PI+.5),F=.5*(F/Math.PI+.5),{x:R,y:this.southernCenter?F:1-F,z:0}}unproject(c,h){c=(2*c-.5)*Math.PI,this.southernCenter&&(h=1-h),h=(2*(1-h)-.5)*Math.PI;const{n:g,f:j}=this,T=j-h,P=Math.sign(T),R=Math.sign(g)*Math.sqrt(c*c+T*T);let F=Math.atan2(c,Math.abs(T))*P;T*g<0&&(F-=Math.PI*Math.sign(c)*P);const H=De(Mr(F/g)+this.center[0],-180,180),Q=De(Mr(2*Math.atan(Math.pow(j/R,1/g))-K3),-85.051129,ds);return new qt(H,this.southernCenter?-Q:Q)}}class QMe extends m_{constructor(c){super(c),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(c,h){return{x:Ns(c),y:Is(h),z:0}}unproject(c,h){const g=Ut(c),j=ss(h);return new qt(g,j)}}const JMe=Kt(ds);class Uht extends m_{project(c,h){const g=(h=Kt(h))*h,j=g*g;return{x:.5*((c=Kt(c))*(.8707-.131979*g+j*(j*(.003971*g-.001529*j)-.013791))/Math.PI+.5),y:1-.5*(h*(1.007226+g*(.015085+j*(.028874*g-.044475-.005916*j)))/Math.PI+1),z:0}}unproject(c,h){c=(2*c-.5)*Math.PI;let g=h=(2*(1-h)-1)*Math.PI,j=25,T=0,P=g*g;do{P=g*g;const H=P*P;T=(g*(1.007226+P*(.015085+H*(.028874*P-.044475-.005916*H)))-h)/(1.007226+P*(.045255+H*(.259866*P-.311325-.005916*11*H))),g=De(g-T,-JMe,JMe)}while(Math.abs(T)>1e-6&&--j>0);P=g*g;const R=De(Mr(c/(.8707+P*(P*(P*P*P*(.003971-.001529*P)-.013791)-.131979))),-180,180),F=Mr(g);return new qt(R,F)}}const eTe=Kt(ds);class Vht extends m_{project(c,h){h=Kt(h),c=Kt(c);const g=Math.cos(h),j=2/Math.PI,T=Math.acos(g*Math.cos(c/2)),P=Math.sin(T)/T,R=.5*(c*j+2*g*Math.sin(c/2)/P)||0,F=.5*(h+Math.sin(h)/P)||0;return{x:.5*(R/Math.PI+.5),y:1-.5*(F/Math.PI+1),z:0}}unproject(c,h){let g=c=(2*c-.5)*Math.PI,j=h=(2*(1-h)-1)*Math.PI,T=25;const P=1e-6;let R=0,F=0;do{const H=Math.cos(j),Q=Math.sin(j),se=2*Q*H,re=Q*Q,oe=H*H,ue=Math.cos(g/2),_e=Math.sin(g/2),ke=2*ue*_e,Pe=_e*_e,We=1-oe*ue*ue,qe=We?1/We:0,rt=We?Math.acos(H*ue)*Math.sqrt(1/We):0,it=.5*(2*rt*H*_e+2*g/Math.PI)-c,ot=.5*(rt*Q+j)-h,It=.5*qe*(oe*Pe+rt*H*ue*re)+1/Math.PI,wt=qe*(ke*se/4-rt*Q*_e),At=.125*qe*(se*_e-rt*Q*oe*ke),kt=.5*qe*(re*ue+rt*Pe*H)+.5,St=wt*At-kt*It;R=(ot*wt-it*kt)/St,F=(it*At-ot*It)/St,g=De(g-R,-Math.PI,Math.PI),j=De(j-F,-eTe,eTe)}while((Math.abs(R)>P||Math.abs(F)>P)&&--T>0);return new qt(Mr(g),Mr(j))}}class tTe extends m_{constructor(c){super(c),this.center=c.center||[0,0],this.parallels=c.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Kt(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(c,h){const{scale:g,cosPhi:j}=this;return{x:Kt(c)*j*g+.5,y:-Math.sin(Kt(h))/j*g+.5,z:0}}unproject(c,h){const{scale:g,cosPhi:j}=this,T=-(h-.5)/g,P=De(Mr((c-.5)/g)/j,-180,180),R=Math.asin(De(T*j,-1,1)),F=De(Mr(R),-85.051129,ds);return new qt(P,F)}}class Hht extends QMe{constructor(c){super(c),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(c,h,g){const j=QP(c,h,g);return ct(j,j,JP(fy(g))),{x:j[0],y:j[1],z:j[2]}}locationPoint(c,h,g){const j=vt(h.lat,h.lng),T=ve([],j),P=g?c._centerAltitude+g:c.elevation?c.elevation.getAtPointOrZero(c.locationCoordinate(h),c._centerAltitude):c._centerAltitude;Ve(j,j,T,Zt(1,0)*sr*P);const R=w(new Float64Array(16));return C(R,c.pixelMatrix,c.globeMatrix),ct(j,j,R),new Xt(j[0],j[1])}pixelsPerMeter(c,h){return Zt(1,0)*h}pixelSpaceConversion(c,h,g){const j=Zt(1,c)*h,T=en(Zt(1,45)*h,j,g);return this.pixelsPerMeter(c,h)/T}createTileMatrix(c,h,g){const j=$pe(fy(g.canonical));return C(new Float64Array(16),c.globeMatrix,j)}createInversionMatrix(c,h){const{center:g}=c,j=JP(fy(h));return O(j,j,Kt(g.lng)),L(j,j,Kt(g.lat)),I(j,j,[c._pixelsPerMercatorPixel,c._pixelsPerMercatorPixel,1]),Float32Array.from(j)}pointCoordinate(c,h,g,j){return g3e(c,h,g,!0)||new wr(0,0)}pointCoordinate3D(c,h,g){const j=this.pointCoordinate(c,h,g,0);return[j.x,j.y,j.z]}isPointAboveHorizon(c,h){return!g3e(c,h.x,h.y,!1)}farthestPixelDistance(c){const h=function(j,T){const P=j.cameraToCenterDistance,R=j._centerAltitude*T,F=j._camera,H=j._camera.forward(),Q=le([],Ne([],H,-P),[0,0,R]),se=j.worldSize/(2*Math.PI),re=[0,0,-se],oe=j.width/j.height,ue=Math.tan(j.fovAboveCenter),_e=Ne([],F.up(),ue),ke=Ne([],F.right(),ue*oe),Pe=ve([],le([],le([],H,_e),ke)),We=[];let qe;if(new sa(Q,Pe).closestPointOnSphere(re,se,We)){const rt=le([],We,re),it=Ce([],rt,Q);qe=Math.cos(j.fovAboveCenter)*ce(it)}else{const rt=Ce([],Q,re),it=Ce([],re,Q);ve(it,it);const ot=ce(rt)-se;qe=Math.sqrt(ot*(ot+2*se));const It=Math.acos(qe/(se+ot))-Math.acos(Re(H,it));qe*=Math.cos(It)}return 1.01*qe}(c,this.pixelsPerMeter(c.center.lat,c.worldSize)),g=nv(c.zoom);if(g>0){const j=YMe(c,Zt(1,c.center.lat)*c.worldSize),T=c.worldSize/(2*Math.PI),P=Math.max(c.width,c.height)/c.worldSize*Math.PI;return en(h,j+T*(1-Math.cos(P)),Math.pow(g,10))}return h}upVector(c,h,g){return QP(h,g,c,1)}upVectorScale(c){return{metersToTile:qF(VF(fy(c)))}}}function sTe(x){const c=x.parallels,h=!!c&&Math.abs(c[0]+c[1])<.01;switch(x.name){case"mercator":return new QMe(x);case"equirectangular":return new $ht(x);case"naturalEarth":return new Uht(x);case"equalEarth":return new Bht(x);case"winkelTripel":return new Vht(x);case"albers":return h?new tTe(x):new zht(x);case"lambertConformalConic":return h?new tTe(x):new qht(x);case"globe":return new Hht(x)}throw new Error(`Invalid projection name: ${x.name}`)}class Ght{constructor(c,h){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=h,this.appearances=c;const g=c.map(j=>function(T){if(!T.condition)return{featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};const P=T.condition.expression;return{featureDependent:!V0(P),stateDependent:!G1(P),zoomDependent:!Df(P,["zoom"]),pitchDependent:!Df(P,["pitch"]),brightnessDependent:!Df(P,["brightness","measure-light"]),worldviewDependent:!Df(P,["worldview"])}}(j));this.anyFeatureDependent=g.some(j=>j.featureDependent),this.anyStateDependent=g.some(j=>j.stateDependent)}update(c,h){const g=this.lastParams,j=!g||g.zoom!==c.zoom||g.pitch!==(c.pitch||0)||g.brightness!==(c.brightness||0)||g.worldview!==c.worldview;this.lastParams={zoom:c.zoom,pitch:c.pitch||0,brightness:c.brightness||0,worldview:c.worldview};const T=h&&this.anyStateDependent;if(!j&&!T&&this.lastAllFeaturesIndex!==-2)return{kind:"no-changes"};if(!this.anyFeatureDependent&&!T){const P=this.evaluateAllFeatures(c);return P===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=P,{kind:"all-features",appearanceIndex:P})}return{kind:"per-feature"}}evaluateAllFeatures(c){for(let h=0;h{for(let j=0;jP-R),T=new Map;for(const P of j){const R=g.get(P);T.set(P,new wi(R))}return h&&(this.cachedBatchIndices=j,this.cachedBatchSegments=T),{batchIndices:j,batchSegments:T}}snapshotSymbolVertexData(c,h){const g=c*Y3;return this.layoutVertexArray.uint16.slice(g,g+h*Y3)}restoreSymbolVertexData(c,h){this.layoutVertexArray.uint16.set(h,c*Y3)}updateSymbolVertexData(c,h,g,j,T,P,R,F,H,Q,se,re,oe){const ue=this.layoutVertexArray.uint16,_e=c*Y3;ue[_e]=h,ue[_e+1]=g,ue[_e+2]=j,ue[_e+3]=T,ue[_e+4]=P,ue[_e+5]=R,ue[_e+6]=F,ue[_e+7]=H,ue[_e+8]=Q,ue[_e+9]=se,ue[_e+10]=re,ue[_e+11]=oe}upload(c,h,g,j,T,P){this.isEmpty()||(g&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,Zut.members,!!P),this.indexBuffer=c.createIndexBuffer(this.indexArray,h),this.dynamicLayoutVertexBuffer=c.createVertexBuffer(this.dynamicLayoutVertexArray,Xut.members,!0),this.opacityVertexBuffer=c.createVertexBuffer(this.opacityVertexArray,Kht,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=c.createVertexBuffer(this.iconTransitioningVertexArray,tht.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,Yut.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||T)&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,Qut.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=c.createVertexBuffer(this.orientationVertexArray,eht.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray&&this.featureIdArray.length>0&&(this.featureIdBuffer=c.createVertexBuffer(this.featureIdArray,Jut.members,!1))),(g||j)&&(this.programConfigurations.upload(c),this.uboBinder&&this.uboBinder.upload(c)))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy(),this.featureIdBuffer&&this.featureIdBuffer.destroy(),this.uboBinder&&this.uboBinder.destroy())}}gr(Kfe,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class Zfe{constructor(c,h,g){this.layoutVertexArray=new c,this.layoutAttributes=h,this.indexArray=new g,this.segments=new wi,this.collisionVertexArray=new g2,this.collisionVertexArrayExt=new tg}upload(c){this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=c.createVertexBuffer(this.collisionVertexArray,sht.members,!0),this.collisionVertexBufferExt=c.createVertexBuffer(this.collisionVertexArrayExt,rht.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}gr(Zfe,"CollisionBuffers");class ag{constructor(c){this.collisionBoxArray=c.collisionBoxArray,this.zoom=c.zoom,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(P=>P.fqid),this.index=c.index,this.pixelRatio=c.pixelRatio,this.sourceLayerIndex=c.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=w([]),this.placementViewportMatrix=w([]);const h=this.layers[0]._unevaluatedLayout._values;this.worldview=c.worldview,this.localizable=c.localizable,this.maxUniformBufferBindings=c.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=c.maxUniformBlockSizeDwords,this.disableSymbolUBO=c.disableSymbolUBO,this.textSizeData=A2(this.zoom,h["text-size"],this.worldview,c.availableImages),this.iconSizeData=A2(this.zoom,h["icon-size"],this.worldview,c.availableImages);const g=this.layers[0].layout,j=g.get("symbol-sort-key"),T=g.get("symbol-z-order");this.lut=c.lut,this.canOverlap=g.get("text-allow-overlap")||g.get("icon-allow-overlap")||g.get("text-ignore-placement")||g.get("icon-ignore-placement"),this.sortFeaturesByKey=T!=="viewport-y"&&j.constantOr(1)!==void 0,this.sortFeaturesByY=(T==="viewport-y"||T==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=g.get("text-writing-mode").map(P=>nm[P]),this.stateDependentLayerIds=this.layers.filter(P=>P.isStateDependent()).map(P=>P.id),this.sourceID=c.sourceID,this.projection=c.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map}hasAnyAppearanceLayoutProperty(c){const h=this.layers[0].getAppearances();if(!h||h.length===0)return!1;const g=Array.isArray(c)?c:[c];return h.some(j=>g.some(T=>j.hasLayoutProperty(T)))}getAppearanceFeatureData(c){return this.featureAppearanceData.get(c)}createArrays(){this.text=new Kfe(new Me(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("text")||c.startsWith("symbol"))),this.icon=new Kfe(new Me(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("icon")||c.startsWith("symbol"))),this.disableSymbolUBO||(this.text.uboBinder=new Afe(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new Afe(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords)),this.glyphOffsetArray=new RF,this.lineVertexArray=new _2,this.symbolInstances=new DF}calculateGlyphDependencies(c,h,g,j,T){for(const P of c){const R=P.codePointAt(0);if(R===void 0)break;if(h[R]=!0,j&&T&&R<=65535){const F=yI[P];F&&(h[F.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(c,h,g,j,T,P,R){if(!c.hasLayoutProperty("icon-size"))return R*P;let F=1;const H=c.getUnevaluatedLayoutProperty("icon-size"),Q=A2(this.zoom,H,this.worldview,T),se=G3(Q,h);if(Q.kind!=="constant"&&Q.kind!=="camera"||(F=se.uSize),Q.kind==="composite"){const{minZoom:re,maxZoom:oe}=Q,ue=H.possiblyEvaluate(new Ga(re,{worldview:this.worldview}),j),_e=H.possiblyEvaluate(new Ga(oe,{worldview:this.worldview}),j),ke=ue.evaluate(g,{},j,T);F=ke+(_e.evaluate(g,{},j,T)-ke)*se.uSizeT}return Q.kind==="source"&&(F=H.possiblyEvaluate(new Ga(this.zoom,{worldview:this.worldview}),j).evaluate(g,{},j,T)),F*P}updateFootprints(c,h){}updateReplacement(c,h){if(h.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=h.updateTime;const g=h.getReplacementRegionsForTile(c.toUnwrapped(),!0);return!e7(this.activeReplacements,g)&&(this.activeReplacements=g,!0)}getResolvedImageFromTokens(c){return typeof c=="string"?Hu.build(c):c}populate(c,h,g,j){const T=this.layers[0],P=T.layout,R=this.projection.name==="globe",F=P.get("text-font"),H=P.get("text-field"),Q=P.get("icon-image"),[se,re]=P.get("icon-size-scale-range"),oe=De(h.scaleFactor||1,se,re),[ue,_e]=P.get("text-size-scale-range"),ke=De(h.scaleFactor||1,ue,_e),Pe=(H.value.kind!=="constant"||H.value.value instanceof kd&&!H.value.value.isEmpty()||H.value.value.toString().length>0)&&(F.value.kind!=="constant"||F.value.value.length>0),We=Q.value.kind!=="constant"||!!Q.value.value||Object.keys(Q.parameters).length>0,qe=this.hasAnyAppearanceLayoutProperty("icon-image"),rt=P.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!Pe&&!We&&!qe)return;const it=h.iconDependencies,ot=h.glyphDependencies,It=h.availableImages,wt=new Ga(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),At=kt=>{const St=kt.id.toString();it.has(St)?it.get(St).push(kt):it.set(St,[kt])};for(const kt of c){const{feature:St,id:rs,index:is,sourceLayerIndex:us}=kt,ws=T._featureFilter.needGeometry,hs=qn(St,ws);if(!T._featureFilter.filter(wt,hs,g))continue;if(ws||(hs.geometry=Ur(St,g,j)),R&&St.type!==1&&g.z<=5){const er=hs.geometry,Js=.98078528056,Zs=(dr,jr)=>Re(QP(dr.x,dr.y,g,1),QP(jr.x,jr.y,g,1)){if(!er.getLayoutProperty("icon-image"))return;const Js=this.getCombinedIconPrimary(er,vs,hs,g,It,Ks,oe);Js&&At(Js)}),Ds){const er=F.evaluate(hs,{},g).join(","),Js=P.get("text-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(nm.vertical)>=0;for(const Zs of Ds.sections)if(Zs.image){const dr=Zs.image.getPrimary().scaleSelf(this.pixelRatio*ke),jr=dr.id.toString(),$r=it.get(jr)||[];$r.push(dr),it.set(jr,$r)}else{const dr=_P(Ds.toString()),jr=Zs.fontStack||er,$r=ot[jr]=ot[jr]||{};this.calculateGlyphDependencies(Zs.text,$r,Js,this.allowVerticalPlacement,dr)}}}if(P.get("symbol-placement")==="line"&&(this.features=function(kt){const St={},rs={},is=[];let us=0;function ws(vs){is.push(kt[vs]),us++}function hs(vs,Ms,Rs){const Ks=rs[vs];return delete rs[vs],rs[Ms]=Ks,is[Ks].geometry[0].pop(),is[Ks].geometry[0]=is[Ks].geometry[0].concat(Rs[0]),Ks}function Ds(vs,Ms,Rs){const Ks=St[Ms];return delete St[Ms],St[vs]=Ks,is[Ks].geometry[0].shift(),is[Ks].geometry[0]=Rs[0].concat(is[Ks].geometry[0]),Ks}function ts(vs,Ms,Rs){const Ks=Rs?Ms[0][Ms[0].length-1]:Ms[0][0];return`${vs}:${Ks.x}:${Ks.y}`}for(let vs=0;vsvs.geometry)}(this.features)),P.get("symbol-elevation-reference")==="hd-road-markup"){if(this.elevationType="road",h.elevationFeatures){!this.elevationFeatures&&h.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const kt of h.elevationFeatures)this.elevationFeatureIdToIndex.set(kt.id,this.elevationFeatures.length),this.elevationFeatures.push(kt)}}else P.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((kt,St)=>kt.sortKey-St.sortKey)}getCombinedIconPrimary(c,h,g,j,T,P,R){let F,H;if(c.hasLayoutProperty("icon-image")){const Q=h.getAppearanceValueAndResolveTokens(c,"icon-image",g,j,T);F=this.getResolvedImageFromTokens(Q)}else{const Q=h.getValueAndResolveTokens("icon-image",g,j,T);F=this.getResolvedImageFromTokens(Q)}if(F){const Q=c.hasLayoutProperty("icon-size")?c.getUnevaluatedLayoutProperty("icon-size"):h._unevaluatedLayout._values["icon-size"];H=jI(F,A2(this.zoom,Q,this.worldview,T),Q,j,this.zoom,P,this.pixelRatio,R,this.worldview,T).iconPrimary}return H}updateSymbolInstanceIconVertices(c,h,g,j,T,P){const{canonical:R,availableImages:F,globalProperties:H,layer:Q,iconScaleFactor:se,featureState:re,layoutIconOffset:oe,layoutIconSize:ue,layoutIconRotate:_e}=P;if(c.placedIconSymbolIndex<0)return{vertexOffsetDelta:0,hasChanges:!1};if(h.activeAppearanceIndex===g)return{vertexOffsetDelta:c.numIconVertices,hasChanges:!1};const ke=g>=0?Q.appearances[g]:null;if(ke){const Pe=this.getCombinedIconPrimary(ke,Q,j,R,F,{sortKey:void 0,text:void 0,icon:null,index:c.featureIndex,sourceLayerIndex:c.featureIndex,geometry:[],properties:h.properties,type:"Point",id:h.id},se);if(!Pe)return{vertexOffsetDelta:0,hasChanges:!1};const We=Pe.toString(),qe=this.iconAtlasPositions&&this.iconAtlasPositions.get(We);if(qe){const{appearanceIconOffset:rt,appearanceIconRotate:it}=UMe(ke,Q,j,R,oe,_e,ue,se);let ot=v7(qe,void 0,rt,Q.layout.get("icon-anchor").evaluate(j,re,R));const It=qe.sdf,wt=Q.layout.get("icon-text-fit").constantOr("none");wt!=="none"&&h.textShaping&&h.iconTextFitPadding&&h.fontScale&&(ot=Dfe(ot,h.textShaping,wt,h.iconTextFitPadding,rt,h.fontScale));const At=this.calculateEffectiveAppearanceIconSize(ke,H.zoom,j,R,F,se,ue),kt=0,St=1+(Math.min(E2,Math.round(At*ov))<<1),rs=qfe(ot,it,It,wt!=="none",se);h.isUsingAppearanceIconVertexData||(h.isUsingAppearanceIconVertexData=!0,h.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(T,c.numIconVertices));const is=Math.floor(c.numIconVertices/4),us=Math.min(rs.length,is);let ws=T;for(let Ds=0;Ds0||c.numVerticalGlyphVertices>0;if(!rt)return{vertexOffsetDelta:rt?c.numHorizontalGlyphVertices+c.numVerticalGlyphVertices:0,hasChanges:!1};if(h.activeAppearanceIndex===g)return{vertexOffsetDelta:c.numHorizontalGlyphVertices+c.numVerticalGlyphVertices,hasChanges:!1};const it=g>=0?F.appearances[g]:null;if(it&&h.textShaping){const{appearanceTextOffset:ot,appearanceTextRotate:It,appearanceTextSize:wt}=VMe(it,F,j,R,re,ue,oe);h.fontScale=KMe(wt,h.textScaleFactor);const At=it.getUnevaluatedLayoutProperty("text-size");let kt=this.textSizeData,St=Pe,rs=We;it.hasLayoutProperty("text-size")&&(kt=A2(this.zoom,At,this.worldview,qe),St=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,rs=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0);const is=h.textShaping.bottom-re[1],us=h.textShaping.left-re[0],ws=h.textShaping.right-re[0];h.textShaping.top=ot[1]+(h.textShaping.top-re[1]),h.textShaping.bottom=ot[1]+is,h.textShaping.left=ot[0]+us,h.textShaping.right=ot[0]+ws;const hs=$Me(0,h.textShaping,ot,F,!1,j,Q,this.allowVerticalPlacement,It),Ds=wt&&kt.kind==="composite"?At.possiblyEvaluate(new Ga(St,{}),R).evaluate(j,se,R):_e,ts=wt&&kt.kind==="composite"?At.possiblyEvaluate(new Ga(rs,{}),R).evaluate(j,se,R):ke,vs=Gfe(it.name,kt,wt,H,Ds,ts),Ms=Array.isArray(vs)?vs[1]:wt,Rs=0,Ks=1+(Math.min(E2,Math.round(Ms*ov))<<1);h.isUsingAppearanceTextVertexData||(h.isUsingAppearanceTextVertexData=!0,h.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(T,c.numHorizontalGlyphVertices+c.numVerticalGlyphVertices));for(let fr=0;fr0){const H=new Set(Object.keys(c).map(Q=>{const se=Number(Q);return!isNaN(se)&&Number.isSafeInteger(se)&&String(se)===Q?se:Q}));this.text.uboBinder&&this.text.uboBinder.updateFeatures(H,T[0],h,F,g,c,R),this.icon.uboBinder&&this.icon.uboBinder.updateFeatures(H,T[0],h,F,g,c,R)}}}updateRoadElevation(c){if(this.elevationType!=="road"||!this.elevationFeatures||this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let h=!1;const g=Ts(c),j=1/g;let T=!1,P=!1;for(let R=0;R0||re>0,ke=oe>0,Pe=this.elevationFeatures[F.elevationFeatureIndex];if(Pe){const We=new Xt(F.tileAnchorX,F.tileAnchorY),qe=.075+Pe.pointElevation(We);F.zOffset!==qe&&(h=!0,F.zOffset=qe),qe!==0&&(this.hasAnyZOffset=!0);const rt=Pe.computeSlopeNormal(We,j),it=Ar(Ke(),ae(0,0,1),rt);Ge(H,H,it),Ge(Q,Q,it),H[2]*=g,Q[2]*=g,H[0]===1&&H[1]===0&&H[2]===0&&Q[0]===0&&Q[1]===1&&Q[2]===0||(T=T||_e,P=P||ke)}if(_e&&(A7(this.text.orientationVertexArray,se,H,Q),A7(this.text.orientationVertexArray,re,H,Q)),ke){const{placedIconSymbolIndex:We,verticalPlacedIconSymbolIndex:qe}=F;We>=0&&A7(this.icon.orientationVertexArray,oe,H,Q),qe>=0&&A7(this.icon.orientationVertexArray,ue,H,Q)}}T||(this.text.orientationVertexArray=void 0),P||(this.icon.orientationVertexArray=void 0),h&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const c=(T,P,R)=>{g+=P,g>T.length&&T.resize(g);for(let F=-P;F<0;F++)T.emplace(F+g,R)},h=(T,P,R)=>{j+=P,j>T.length&&T.resize(j);for(let F=-P;F<0;F++)T.emplace(F+j,R)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let g=0,j=0;for(let T=0;T0;if((R>0||F>0)&&(c(this.text.zOffsetVertexArray,R,Q),c(this.text.zOffsetVertexArray,F,Q)),se){const{placedIconSymbolIndex:re,verticalPlacedIconSymbolIndex:oe}=P;re>=0&&h(this.icon.zOffsetVertexArray,H,Q),oe>=0&&h(this.icon.zOffsetVertexArray,P.numVerticalIconVertices,Q)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(c,h,g,j,T){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(c),this.iconCollisionBox.upload(c)),this.text.upload(c,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.hasAppearances===null&&(this.hasAppearances=this.layers.some(P=>P.appearances&&P.appearances.length>0)),this.icon.upload(c,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(c,h,g,j,T,P=!1){const R={hasLayoutChanges:!1,hasUboChanges:!1};if(!c||!g||!this.featureAppearanceData)return R;const F=h||{},H=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,Q=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!H&&!Q)return R;const se=this.layers[0],re=se.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===se.appearancesVersion||(this.featureAppearances=new Ght(se.appearances,se.appearancesVersion));const oe=this.featureAppearances.update(j,P);if(oe.kind==="no-changes")return R;let ue=1,_e=0,ke=!1,Pe=!1;if(H){const[ot,It]=re.get("icon-size-scale-range");ue=De(1,ot,It)}let We=1,qe=0,rt=!1;if(Q){const[ot,It]=re.get("text-size-scale-range");We=De(1,ot,It)}const it=new Map;if(T&&g)for(const ot of g){const It=T.getImage(ot,se.scope);if(It){const wt=new $m(ot.toString());it.set(wt.toString(),It)}}for(let ot=0;otws.isActive({globals:j,feature:St,canonical:c,featureState:kt})):-1;rs=us>=0?us:-1}const is=wt.activeAppearanceIndex!==rs;if(Q){const us=re.get("text-size"),ws=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,hs=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0,Ds={canonical:c,layer:se,featureState:kt,availableImages:g,textScaleFactor:We,imageMap:it,layoutTextOffset:re.get("text-offset").evaluate(St,kt,c).map(vs=>vs*ic),layoutTextSize:us.evaluate(St,kt,c),layoutTextRotate:re.get("text-rotate").evaluate(St,kt,c),layoutMinZoomSize:us.evaluate(St,{zoom:ws},c),layoutMaxZoomSize:us.evaluate(St,{zoom:hs},c),layoutTextSizeMinZoom:ws,layoutTextSizeMaxZoom:hs},ts=this.updateSymbolInstanceTextVertices(It,wt,rs,St,qe,Ds);qe+=ts.vertexOffsetDelta,rt=rt||ts.hasChanges}if(H){const us={canonical:c,layer:se,featureState:kt,availableImages:g,globalProperties:j,iconScaleFactor:ue,layoutIconOffset:re.get("icon-offset").evaluate(St,kt,c),layoutIconSize:re.get("icon-size").evaluate(St,kt,c,g),layoutIconRotate:re.get("icon-rotate").evaluate(St,kt,c)},ws=this.updateSymbolInstanceIconVertices(It,wt,rs,St,_e,us);_e+=ws.vertexOffsetDelta,ke=ke||ws.hasChanges}if(is){const us=It.featureIndex,ws=j?j.brightness:null,hs=kt||{},Ds=rs>=0?se.appearances[rs]:null;this.text.uboBinder&&(this.text.uboBinder.layer=se,Pe=this.text.uboBinder.updateFeaturePaintForAppearance(us,St,hs,c,g,ws,Ds)||Pe),this.icon.uboBinder&&(this.icon.uboBinder.layer=se,Pe=this.icon.uboBinder.updateFeaturePaintForAppearance(us,St,hs,c,g,ws,Ds)||Pe)}wt.activeAppearanceIndex=rs}return ke&&this.icon.layoutVertexBuffer&&this.icon.layoutVertexArray.arrayBuffer!==null&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),rt&&this.text.layoutVertexBuffer&&this.text.layoutVertexArray.arrayBuffer!==null&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:ke||rt,hasUboChanges:Pe}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=sTe(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(c,h){const g=this.lineVertexArray.length;if(c.segment!==void 0)for(const{x:j,y:T}of h)this.lineVertexArray.emplaceBack(j,T);return{lineStartIndex:g,lineLength:this.lineVertexArray.length-g}}addSymbols(c,h,g,j,T,P,R,F,H,Q,se,re,oe,ue,_e,ke,Pe,We){const qe=c.indexArray,rt=c.layoutVertexArray,it=c.globeExtVertexArray,ot=We,It=c.uboBinder?c.uboBinder.getCurrentBatchIndex():void 0,wt=c.segments.prepareSegment(4*ot,rt,qe,this.canOverlap?P.sortKey:void 0,It),At=this.glyphOffsetArray.length,kt=wt.vertexLength,St=this.allowVerticalPlacement&&R===nm.vertical?Math.PI/2:0,rs=P.text&&P.text.sections;let is=rt.length,us=-1;for(let Ds=0;Ds=0)){const Ds=4*ws;for(let ts=0;ts=0?h.rightJustifiedTextSymbolIndex:h.centerJustifiedTextSymbolIndex>=0?h.centerJustifiedTextSymbolIndex:h.leftJustifiedTextSymbolIndex>=0?h.leftJustifiedTextSymbolIndex:h.verticalPlacedTextSymbolIndex>=0?h.verticalPlacedTextSymbolIndex:j),P=Rfe(this.textSizeData,c,T)/ic;return this.tilePixelRatio*P}getSymbolInstanceIconSize(c,h,g){const j=this.icon.placedSymbolArray.get(g),T=Rfe(this.iconSizeData,c,j);return this.tilePixelRatio*T}_commitDebugCollisionVertexUpdate(c,h,g,j){c.emplaceBack(h,-g,-g,j),c.emplaceBack(h,g,-g,j),c.emplaceBack(h,g,g,j),c.emplaceBack(h,-g,g,j)}_updateTextDebugCollisionBoxes(c,h,g,j,T,P,R){for(let F=j;F0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(c,h){const g=c.placedSymbolArray.get(h),j=g.vertexStartIndex+4*g.numGlyphs;for(let T=g.vertexStartIndex;Tj[R]-j[F]||T[F]-T[R]),P}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let c=0;cthis.symbolInstances.get(h).zOffset-this.symbolInstances.get(c).zOffset)}addToSortKeyRanges(c,h){const g=this.sortKeyRanges[this.sortKeyRanges.length-1];g&&g.sortKey===h?g.symbolInstanceEnd=c+1:this.sortKeyRanges.push({sortKey:h,symbolInstanceStart:c,symbolInstanceEnd:c+1})}sortFeatures(c){if(this.sortFeaturesByY&&this.sortedAngle!==c)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesWithinSegments();else{this.symbolInstanceIndexes=this.getSortedSymbolIndexes(c),this.sortedAngle=c,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const h of this.symbolInstanceIndexes){const g=this.symbolInstances.get(h);this.featureSortOrder.push(g.featureIndex);const{rightJustifiedTextSymbolIndex:j,centerJustifiedTextSymbolIndex:T,leftJustifiedTextSymbolIndex:P,verticalPlacedTextSymbolIndex:R,placedIconSymbolIndex:F,verticalPlacedIconSymbolIndex:H}=g;j>=0&&this.addIndicesForPlacedSymbol(this.text,j),T>=0&&T!==j&&this.addIndicesForPlacedSymbol(this.text,T),P>=0&&P!==T&&P!==j&&this.addIndicesForPlacedSymbol(this.text,P),R>=0&&this.addIndicesForPlacedSymbol(this.text,R),F>=0&&this.addIndicesForPlacedSymbol(this.icon,F),H>=0&&this.addIndicesForPlacedSymbol(this.icon,H)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getOrCreateSortedSymbolsByBatch(c,h){const g=(this.text.uboBinder&&this.text.uboBinder.maxFeaturesPerBatch>0?this.text.uboBinder:this.icon.uboBinder&&this.icon.uboBinder.maxFeaturesPerBatch>0?this.icon.uboBinder:null).maxFeaturesPerBatch;if(this.symbolsByBatch)for(const j of this.symbolsByBatch.values())for(const T of j){const P=this.symbolInstances.get(T.index);T.rotatedY=0|Math.round(c*P.tileAnchorX+h*P.tileAnchorY)}else{this.symbolsByBatch=new Map;for(let j=0;jT.rotatedY-P.rotatedY||P.featureIndex-T.featureIndex);return this.symbolsByBatch}rebuildTextSegmentIndices(c,h){for(const g of c){const j=g.batchIndex;if(j===void 0)continue;const T=h.get(j);if(!T){g.primitiveOffset=this.text.indexArray.length,g.primitiveLength=0;continue}g.primitiveOffset=this.text.indexArray.length;const P=this.text.indexArray.length;for(const{index:R}of T){const F=this.symbolInstances.get(R),{rightJustifiedTextSymbolIndex:H,centerJustifiedTextSymbolIndex:Q,leftJustifiedTextSymbolIndex:se,verticalPlacedTextSymbolIndex:re}=F;H>=0&&this.addIndicesForPlacedSymbol(this.text,H),Q>=0&&Q!==H&&this.addIndicesForPlacedSymbol(this.text,Q),se>=0&&se!==Q&&se!==H&&this.addIndicesForPlacedSymbol(this.text,se),re>=0&&this.addIndicesForPlacedSymbol(this.text,re)}g.primitiveLength=this.text.indexArray.length-P}}rebuildIconSegmentIndices(c,h){for(const g of c){const j=g.batchIndex;if(j===void 0)continue;const T=h.get(j);if(!T){g.primitiveOffset=this.icon.indexArray.length,g.primitiveLength=0;continue}g.primitiveOffset=this.icon.indexArray.length;const P=this.icon.indexArray.length;for(const{index:R}of T){const F=this.symbolInstances.get(R),{placedIconSymbolIndex:H,verticalPlacedIconSymbolIndex:Q}=F;H>=0&&this.addIndicesForPlacedSymbol(this.icon,H),Q>=0&&this.addIndicesForPlacedSymbol(this.icon,Q)}g.primitiveLength=this.icon.indexArray.length-P}}sortFeaturesWithinSegments(){this.featureSortOrder=[];const c=Math.sin(this.sortedAngle),h=Math.cos(this.sortedAngle),g=this.getOrCreateSortedSymbolsByBatch(c,h),j=Array.from(g.keys()).sort((T,P)=>T-P);for(const T of j){const P=g.get(T);for(const{index:R}of P){const F=this.symbolInstances.get(R);this.featureSortOrder.push(F.featureIndex)}}this.text.indexArray.clear(),this.icon.indexArray.clear(),this.rebuildTextSegmentIndices(this.text.segments.get(),g),this.rebuildIconSegmentIndices(this.icon.segments.get(),g),this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}getElevationFeatureForText(c){const h=this.symbolInstances.get(this.text.symbolInstanceIndices[c]).elevationFeatureIndex;let g;return this.elevationFeatures&&hg in x?String(x[g]):"")}let nTe,aTe,Yfe;gr(ag,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),ag.addDynamicAttributes=Z3;class iTe{constructor(c){this.type=c.property.overrides?c.property.overrides.runtimeType:Wx,this.defaultValue=c}evaluate(c){if(c.formattedSection){const h=this.defaultValue.property.overrides;if(h&&h.hasOverride(c.formattedSection))return h.getOverride(c.formattedSection)}return c.feature&&c.featureState?this.defaultValue.evaluate(c.feature,c.featureState):this.defaultValue.property.specification.default}eachChild(c){this.defaultValue.isConstant()||c(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}gr(iTe,"FormatSectionOverride",{omit:["defaultValue"]});const Xfe=()=>Yfe||(Yfe={layout:nTe||(nTe=new Xi({"symbol-placement":new Ys(Ht.layout_symbol["symbol-placement"]),"symbol-spacing":new Ys(Ht.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ys(Ht.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Hs(Ht.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ys(Ht.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ys(Ht.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Ys(Ht.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Ys(Ht.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ys(Ht.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ys(Ht.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ys(Ht.layout_symbol["icon-rotation-alignment"]),"icon-size":new Hs(Ht.layout_symbol["icon-size"]),"icon-size-scale-range":new Ys(Ht.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Hs(Ht.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Hs(Ht.layout_symbol["icon-text-fit-padding"]),"icon-image":new Hs(Ht.layout_symbol["icon-image"]),"icon-image-use-theme":new Ys({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new Hs(Ht.layout_symbol["icon-rotate"]),"icon-padding":new Ys(Ht.layout_symbol["icon-padding"]),"icon-keep-upright":new Ys(Ht.layout_symbol["icon-keep-upright"]),"icon-offset":new Hs(Ht.layout_symbol["icon-offset"]),"icon-anchor":new Hs(Ht.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ys(Ht.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ys(Ht.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ys(Ht.layout_symbol["text-rotation-alignment"]),"text-field":new Hs(Ht.layout_symbol["text-field"]),"text-font":new Hs(Ht.layout_symbol["text-font"]),"text-size":new Hs(Ht.layout_symbol["text-size"]),"text-size-scale-range":new Ys(Ht.layout_symbol["text-size-scale-range"]),"text-max-width":new Hs(Ht.layout_symbol["text-max-width"]),"text-line-height":new Hs(Ht.layout_symbol["text-line-height"]),"text-letter-spacing":new Hs(Ht.layout_symbol["text-letter-spacing"]),"text-justify":new Hs(Ht.layout_symbol["text-justify"]),"text-radial-offset":new Hs(Ht.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ys(Ht.layout_symbol["text-variable-anchor"]),"text-anchor":new Hs(Ht.layout_symbol["text-anchor"]),"text-max-angle":new Ys(Ht.layout_symbol["text-max-angle"]),"text-writing-mode":new Ys(Ht.layout_symbol["text-writing-mode"]),"text-rotate":new Hs(Ht.layout_symbol["text-rotate"]),"text-padding":new Ys(Ht.layout_symbol["text-padding"]),"text-keep-upright":new Ys(Ht.layout_symbol["text-keep-upright"]),"text-transform":new Hs(Ht.layout_symbol["text-transform"]),"text-offset":new Hs(Ht.layout_symbol["text-offset"]),"text-allow-overlap":new Ys(Ht.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ys(Ht.layout_symbol["text-ignore-placement"]),"text-optional":new Ys(Ht.layout_symbol["text-optional"]),visibility:new Ys(Ht.layout_symbol.visibility)})),paint:aTe||(aTe=new Xi({"icon-opacity":new Hs(Ht.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Hs(Ht.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Hs(Ht.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Hs(Ht.paint_symbol["text-emissive-strength"]),"icon-color":new Hs(Ht.paint_symbol["icon-color"]),"icon-halo-color":new Hs(Ht.paint_symbol["icon-halo-color"]),"icon-halo-width":new Hs(Ht.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Hs(Ht.paint_symbol["icon-halo-blur"]),"icon-translate":new Ys(Ht.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ys(Ht.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Ys(Ht.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Hs(Ht.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Hs(Ht.paint_symbol["text-occlusion-opacity"]),"text-color":new Hs(Ht.paint_symbol["text-color"],{runtimeType:bu,getOverride:x=>x.textColor,hasOverride:x=>!!x.textColor}),"text-halo-color":new Hs(Ht.paint_symbol["text-halo-color"]),"text-halo-width":new Hs(Ht.paint_symbol["text-halo-width"]),"text-halo-blur":new Hs(Ht.paint_symbol["text-halo-blur"]),"text-translate":new Ys(Ht.paint_symbol["text-translate"]),"text-translate-anchor":new Ys(Ht.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ys(Ht.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ys(Ht.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ys(Ht.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ys(Ht.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Hs(Ht.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"})}))},Yfe);class E7 extends Yd{constructor(c,h,g,j){super(c,Xfe(),h,g,j,c.layout?c.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=w([]),this.hasOcclusionOpacityProperties=c.paint!==void 0&&("icon-occlusion-opacity"in c.paint||"text-occlusion-opacity"in c.paint)}_handleSpecialPaintPropertyUpdate(c){c!=="icon-occlusion-opacity"&&c!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(c,h){super.recalculate(c,h),this.appearances&&this.appearances.forEach(j=>{j.recalculate(c,h,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 g=this.layout.get("text-writing-mode");if(g){const j=[];for(const T of g)j.indexOf(T)<0&&j.push(T);this.layout._values["text-writing-mode"]=j}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(c,h,g,j){return this._saturation===c&&this._contrast===h&&this._brightnessMin===g&&this._brightnessMax===j||(this._colorAdjustmentMatrix=function(T,P,R,F){T=Ki(T),P=fi(P);const H=b(),Q=T/3,se=1-2*Q,re=[se,Q,Q,0,Q,se,Q,0,Q,Q,se,0,0,0,0,1],oe=.5-.5*P,ue=F-R;return C(H,[ue,0,0,0,0,ue,0,0,0,0,ue,0,R,R,R,1],[P,0,0,0,0,P,0,0,0,0,P,0,oe,oe,oe,1]),C(H,H,re),H}(c,h,g,j),this._saturation=c,this._contrast=h,this._brightnessMin=g,this._brightnessMax=j),this._colorAdjustmentMatrix}getValueAndResolveTokens(c,h,g,j){const T=this.layout.get(c).evaluate(h,{},g,j),P=this._unevaluatedLayout._values[c];return P.isDataDriven()||a2(P.value)||!T?T:rTe(h.properties,T)}getAppearanceValueAndResolveTokens(c,h,g,j,T){const P=c.getLayoutProperty(h);if(!P)return;const R=P.evaluate(g,{},j,T),F=c.getUnevaluatedLayoutProperties()._values[h];return F.isDataDriven()||a2(F.value)||!R||typeof R!="string"?R:rTe(g.properties,R)}createBucket(c){return new ag(c)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const c of Xfe().paint.overridableProperties){if(!E7.hasPaintOverride(this.layout,c))continue;const h=this.paint.get(c),g=new iTe(h),j=new u3(g,h.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let T=null;T=h.value.kind==="constant"||h.value.kind==="source"?new Q1("source",j):new G0("composite",j,h.value.zoomStops,h.value.interpolationType),this.paint._values[c]=new Y0(h.property,T,h.parameters)}}_handleOverridablePaintPropertyUpdate(c,h,g){return!(!this.layout||h.isDataDriven()||g.isDataDriven())&&E7.hasPaintOverride(this.layout,c)}static hasPaintOverride(c,h){const g=c.get("text-field"),j=Xfe().paint.properties[h];let T=!1;const P=R=>{for(const F of R)if(j.overrides&&j.overrides.hasOverride(F))return void(T=!0)};if(g.value.kind==="constant"&&g.value.value instanceof kd)P(g.value.value.sections);else if(g.value.kind==="source"){const R=H=>{T||(H instanceof kr&&Oo(H.value)===Dw?P(H.value.sections):H instanceof z0?P(H.sections):H.eachChild(R))},F=g.value;F._styleExpression&&R(F._styleExpression.expression)}return T}getProgramIds(){return["symbol"]}getDefaultProgramParams(c,h,g){return{config:new be(this,{zoom:h,lut:g}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let oTe,lTe,cTe,dTe;var P7=ia([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);function I7(x,c,h,g,j,T,P,R){const F=[x,c,1,h,g,1,j,T,1],H=[P,R,1],Q=y([],F),[se,re,oe]=pe(H,H,Q);return _(F,F,[se,0,0,0,re,0,0,0,oe])}function uTe(x,c,h,g,j,T,P,R){const F=function(H,Q,se,re,oe,ue,_e,ke){const Pe=I7(0,0,1,0,1,1,0,1),We=I7(H,Q,se,re,oe,ue,_e,ke);return _(We,We,y([],Pe))}(x,c,h,g,j,T,P,R);return[F[2]/F[8]/sr,F[5]/F[8]/sr]}function L7(x){return[x[0],Math.min(Math.max(x[1],-85.051129),ds)]}class hTe extends Na{constructor(c,h,g,j){super(),this.id=c,this.dispatcher=g,this.coordinates=h.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(j),this.options=h,this._dirty=!1}load(c,h){if(this._loaded=h||!1,this.fire(new Ps("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return c&&(this.coordinates=c),this._loaded=!0,void this._finishLoading();this._imageRequest=Cp(this.map._requestManager.transformRequest(this.url,Pf.Image),(g,j)=>{this._imageRequest=null,this._loaded=!0,g?this.fire(new nr(g)):j&&(this.image=j,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,c&&(this.coordinates=c),this._finishLoading())})}loaded(){return this._loaded}updateImage(c){return c.url?(this._imageRequest&&c.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=c.url,this.load(c.coordinates,this._loaded),this):this}setTexture(c){if(!(c.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new fI(this.map.painter.context,c.handle),this.width=c.dimensions[0],this.height=c.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Ps("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(c){this.map=c,this.load()}onRemove(c){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof fI||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(c){if(this.coordinates=c,this._boundsArray=void 0,this._unsupportedCoords=!1,!c.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let h=c[0][1],g=c[0][1];for(const T of c)T[1]>g&&(g=T[1]),T[1]ds?this.onNorthPole=!0:j<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const T=c.map(wr.fromLngLat);this.tileID=function(P){let R=1/0,F=1/0,H=-1/0,Q=-1/0;for(const _e of P)R=Math.min(R,_e.x),F=Math.min(F,_e.y),H=Math.max(H,_e.x),Q=Math.max(Q,_e.y);const se=Math.max(H-R,Q-F),re=Math.max(0,Math.floor(-Math.log2(se))),oe=Math.pow(2,re);let ue=Math.floor((R+H)/2*oe);return ue>1&&(ue-=1),new k2(re,ue,Math.floor((F+Q)/2*oe))}(T),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Ps("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof fI||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(c){for(const ke in this.tiles){const Pe=this.tiles[ke];Pe.state!=="loaded"&&(Pe.state="loaded",Pe.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const h=P2(new k2(0,0,0),this.map.transform.projection),g=[h.projection.project(this.coordinates[0][0],this.coordinates[0][1]),h.projection.project(this.coordinates[1][0],this.coordinates[1][1]),h.projection.project(this.coordinates[2][0],this.coordinates[2][1]),h.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(ke){const Pe=ke[1].x-ke[0].x,We=ke[1].y-ke[0].y,qe=ke[2].x-ke[1].x,rt=ke[2].y-ke[1].y,it=ke[3].x-ke[2].x,ot=ke[3].y-ke[2].y,It=ke[0].x-ke[3].x,wt=ke[0].y-ke[3].y,At=Pe*rt-qe*We,kt=qe*ot-it*rt,St=it*wt-It*ot,rs=It*We-Pe*wt;return At>0&&kt>0&&St>0&&rs>0||At<0&&kt<0&&St<0&&rs<0}(g))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const j=P2(this.tileID,this.map.transform.projection),[T,P,R,F]=this.coordinates.map(ke=>{const Pe=j.projection.project(ke[0],ke[1]);return XMe(j,Pe)._round()});this.perspectiveTransform=uTe(T.x,T.y,P.x,P.y,R.x,R.y,F.x,F.y);const H=this._boundsArray=new id;H.emplaceBack(T.x,T.y,0,0),H.emplaceBack(P.x,P.y,sr,0),H.emplaceBack(F.x,F.y,0,sr),H.emplaceBack(R.x,R.y,sr,sr),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=c.createVertexBuffer(H,P7.members),this.boundsSegments=wi.simpleSegment(0,0,4,2);const Q=[],se=function(ke){return[L7(ke[0]),L7(ke[1]),L7(ke[2]),L7(ke[3])]}(this.coordinates),[re,oe,ue,_e]=function(ke){let Pe=ke[0][0],We=Pe,qe=ke[0][1],rt=qe;for(let it=1;itWe&&(We=ke[it][0]),ke[it][1]rt&&(rt=ke[it][1]);return[Pe,qe,We-Pe,rt-qe]}(se);{const ke=new id,[Pe,We,qe,rt]=function(hs){let Ds=hs[0].x,ts=Ds,vs=hs[0].y,Ms=vs;for(let Rs=1;Rsts&&(ts=hs[Rs].x),hs[Rs].yMs&&(Ms=hs[Rs].y);return[Ds,vs,ts-Ds,Ms-vs]}(g),it=hs=>[(hs.x-Pe)/qe,(hs.y-We)/rt],[ot,It,wt,At]=g.map(it),kt=function(hs,Ds,ts,vs,Ms,Rs,Ks,fr){const er=I7(0,0,1,0,1,1,0,1);return _(er,er,y([],I7(hs,Ds,ts,vs,Ms,Rs,Ks,fr)))}(ot[0],ot[1],It[0],It[1],wt[0],wt[1],At[0],At[1]);this.elevatedGlobePerspectiveTransform=uTe(ot[0],ot[1],It[0],It[1],wt[0],wt[1],At[0],At[1]);const St=(hs,Ds)=>{Q.push(hs.lng);const ts=Math.round((hs.lng-re)/ue*sr),vs=Math.round((hs.lat-oe)/_e*sr),Ms=it(Ds),Rs=pe([],[Ms[0],Ms[1],1],kt),Ks=Math.round(Rs[0]/Rs[2]*sr),fr=Math.round(Rs[1]/Rs[2]*sr);ke.emplaceBack(ts,vs,Ks,fr)},rs=g[3].x-g[0].x,is=g[3].y-g[0].y,us=g[2].x-g[1].x,ws=g[2].y-g[1].y;for(let hs=0;hs<65;hs++){const Ds=hs/64,ts=[g[0].x+Ds*rs,g[0].y+Ds*is],vs=[g[1].x+Ds*us,g[1].y+Ds*ws],Ms=vs[0]-ts[0],Rs=vs[1]-ts[1];for(let Ks=0;Ks<65;Ks++){const fr=Ks/64,er={x:ts[0]+Ms*fr,y:ts[1]+Rs*fr};St(h.projection.unproject(er.x,er.y),er)}}this.elevatedGlobeVertexBuffer=c.createVertexBuffer(ke,P7.members)}{this.maxLongitudeTriangleSize=0;let ke=[],Pe=new Ao;const We=(qe,rt,it)=>{Pe.emplaceBack(qe,rt,it);const ot=Q[qe],It=Q[rt],wt=Q[it],At=Math.min(Math.min(ot,It),wt),kt=Math.max(Math.max(ot,It),wt)-At;kt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=kt),ke.push(At+kt/2)};for(let qe=0;qe<64;qe++)for(let rt=0;rt<64;rt++){const it=65*qe+rt,ot=it+1,It=it+65,wt=It+1;We(it,It,ot),We(ot,It,wt)}[ke,Pe]=function(qe,rt){const it=Array.from({length:qe.length},(wt,At)=>At);it.sort((wt,At)=>qe[wt]-qe[At]);const ot=[],It=new Ao;for(let wt=0;wt{P.segments.push({vertexOffset:0,primitiveOffset:se,vertexLength:h.segments[0].vertexLength,primitiveLength:re,sortKey:void 0,vaos:{}})},F=.51*this.maxLongitudeTriangleSize;if(Math.abs(g[0]-j)<=F){const se=Qo(g,0,g.length,j+F);return se===g.length||R(se,zi(g,se+1,g.length,j+360-F)-se),P}j0}}let pTe,fTe,xTe,gTe,yTe,vTe,_Te;class bTe extends Yd{constructor(c,h,g,j){super(c,{layout:pTe||(pTe=new Xi({visibility:new Ys(Ht["layout_raster-particle"].visibility)})),paint:fTe||(fTe=new Xi({"raster-particle-array-band":new Ys(Ht["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new Ys(Ht["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new s_(Ht["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new Ys(Ht["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new Ys(Ht["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new Ys(Ht["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new Ys(Ht["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new Ys(Ht["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"})}))},h,g,j),this._updateColorRamp(),this.lastInvalidatedAt=Gd.now()}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null)}onRemove(c){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy()}hasColorMap(){return!!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return["rasterParticle"]}hasOffscreenPass(){return this.visibility!=="none"}isDraped(c){return!1}_handleSpecialPaintPropertyUpdate(c){c!=="raster-particle-color"&&c!=="raster-particle-max-speed"||(this._updateColorRamp(),this._invalidateAnimationState()),c==="raster-particle-count"&&this._invalidateAnimationState()}_updateColorRamp(){if(!this.hasColorMap())return;const c=this._transitionablePaint._values["raster-particle-color"].value.expression,h=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=eI({expression:c,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:h}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=Gd.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class Xht extends Yd{constructor(c,h){super(c,{},h,null),this.implementation=c,c.slot&&(this.slot=c.slot)}is3D(c){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isDraped(c){return this.implementation.renderToTile!==void 0}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(c){this.implementation.onAdd&&this.implementation.onAdd(c,c.painter.context.gl)}onRemove(c){this.implementation.onRemove&&this.implementation.onRemove(c,c.painter.context.gl)}}function Jfe(x,c,h){const g=[0,0,1],j=He([]);return Mt(j,j,h?-Kt(x)+Math.PI:Kt(x)),gt(j,j,-Kt(c)),Ge(g,g,j),ve(g,g)}class D7{constructor(c,h,g,j){this.message=(c?`${c}: `:"")+g,j&&(this.identifier=j),h!=null&&h.__line__&&(this.line=h.__line__)}}function exe(x,c){const h=x.indexOf("://")===-1;try{return new URL(x,h&&c?"http://example.com":void 0),!0}catch{return!1}}class wTe{constructor(c,h){this.feature=c,this.instancedDataOffset=h,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class jTe{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new HP,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(c){const h=16*c,g=this.instancedDataArray.float32;let j=Math.floor(g[h+2]);const T=1.05*(g[h+2]-j);return j/=100,[g[h]%1*1.05,g[h+1]%1*1.05,T,j]}tileCoordinatesForInstance(c){const h=16*c,g=this.instancedDataArray.float32;let j=g[h+0];return j=j>sr?j-sr:j,new Xt(Math.trunc(j),Math.trunc(g[h+1]))}translationForInstance(c){const h=16*c,g=this.instancedDataArray.float32;return[g[h+4],g[h+5],g[h+6]]}rotationScaleForInstance(c){const h=16*c,g=this.instancedDataArray.float32;return[g[h+7],g[h+8],g[h+9],g[h+10],g[h+11],g[h+12],g[h+13],g[h+14],g[h+15]]}transformForInstance(c){const h=16*c,g=this.instancedDataArray.float32;return[g[h+7],g[h+8],g[h+9],g[h+4],g[h+10],g[h+11],g[h+12],g[h+5],g[h+13],g[h+14],g[h+15],g[h+6],0,0,0,1]}}class txe{constructor(c){this.zoom=c.zoom,this.canonical=c.canonical,this.overscaledZ=this.canonical.z+Math.log2(c.overscaling),this.layers=c.layers,this.layerIds=this.layers.map(h=>h.fqid),this.projection=c.projection,this.index=c.index,this.worldview=c.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=c.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(c,h,g,j){this.tileToMeter=Ts(g);const T=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);const P=this.layers[0].paint.get("model-elevation-reference")==="hd-road-markup"?h.elevationFeatures:void 0;for(const{feature:R,id:F,index:H,sourceLayerIndex:Q}of c){const se=F??(R.properties&&R.properties.hasOwnProperty("id")?R.properties.id:void 0),re=qn(R,T);if(!this.layers[0]._featureFilter.filter(new Ga(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),re,g))continue;const oe={id:se,sourceLayerIndex:Q,index:H,geometry:T?re.geometry:Ur(R,g,j),properties:R.properties,type:R.type,patterns:{}},ue=this.addFeature(oe,oe.geometry,re,P,g);ue&&h.featureIndex.insert(R,oe.geometry,H,Q,this.index,this.instancesPerModel[ue].instancedDataArray.length,256)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const c=this.layers[0].modelManager,h=this.layers[0].scope;let g=0;for(const j of this.modelUris){const T=c.getModel(j,h);if(!T)continue;const P=this.instancesPerModel[j];if(P){const R=.5*Te(T.aabb.max,T.aabb.min)*P.maxScale+P.maxXYTranslationDistance,F=Math.min(sr,Math.max(R/this.tileToMeter,256));g=Math.max(F,g)}}return g}update(c,h,g,j){for(const T in this.instancesPerModel){const P=this.instancesPerModel[T];for(const R in c)P.idToFeaturesIndex.hasOwnProperty(R)&&(this.evaluate(P.features[P.idToFeaturesIndex[R]],c[R],P,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let c=!1;for(const h in this.instancesPerModel){const g=this.instancesPerModel[h];for(const j of g.features){const T=this.layers[0],P=j.feature,R=this.canonical,F=T.paint.get("model-rotation").evaluate(P,{},R),H=T.paint.get("model-scale").evaluate(P,{},R),Q=T.paint.get("model-translation").evaluate(P,{},R);st(j.rotation,F)&&st(j.scale,H)&&st(j.translation,Q)||(this.evaluate(j,j.featureStates,g,!0),c=!0)}}return c}updateReplacement(c,h,g,j){if(h.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=h.updateTime;const T=h.getReplacementRegionsForTile(c.toUnwrapped(),!0);if(e7(this.activeReplacements,T))return!1;this.activeReplacements=T;let P=!1;for(const R in this.instancesPerModel){const F=this.instancesPerModel[R],H=F.instancedDataArray;for(const Q of F.features){const se=Q.instancedDataOffset,re=Q.instancedDataCount;for(let oe=0;oesr;_e=ke?_e-sr:_e;const Pe=Math.floor(_e),We=Math.floor(H.float32[ue+1]);let qe=!1;for(const rt of this.activeReplacements)if(!n5e(rt,g,t7.Model,j)&&!(rt.min.x>Pe||Pe>rt.max.x||rt.min.y>We||We>rt.max.y)&&(qe=c5e(l5e(Pe,We,c.canonical,rt.footprintTileId.canonical),rt.footprint),qe))break;H.float32[ue]=qe?_e+sr:_e,P=P||qe!==ke}}}return P}isEmpty(){for(const c in this.instancesPerModel)if(this.instancesPerModel[c].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(c){if(!this.uploaded)for(const h in this.instancesPerModel){const g=this.instancesPerModel[h];g.instancedDataArray.length<0||g.instancedDataArray.length===0||(g.instancedDataBuffer?g.instancedDataBuffer.updateData(g.instancedDataArray):g.instancedDataBuffer=c.createVertexBuffer(g.instancedDataArray,xut.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(c){for(const g in this.instancesPerModel){const j=this.instancesPerModel[g];j.instancedDataArray.length!==0&&j.instancedDataBuffer&&j.instancedDataBuffer.destroy()}const h=this.layers[0].modelManager;if(c&&h&&this.modelUris&&this.modelsRequested)for(const g of this.modelUris)h.removeModel(g,"",!0)}addFeature(c,h,g,j,T){const P=this.layers[0],R=P.layout.get("model-id"),F=P.layout.get("model-allow-density-reduction"),H=R.evaluate(g,{},this.canonical);if(!H)return zr(`modelId is not evaluated for layer ${P.id} and it is not going to get rendered.`),H;(exe(H,!1)||this.styleDefinedModelURLs[H]!==void 0)&&(this.modelUris.includes(H)||this.modelUris.push(H)),this.instancesPerModel[H]||(this.instancesPerModel[H]=new jTe);const Q=this.instancesPerModel[H],se=Q.instancedDataArray,re=new wTe(g,se.length);let oe;j&&(oe=Ci.getElevationFeature(c,j));for(const ue of h)for(const _e of ue){if(_e.x<0||_e.x>=sr||_e.y<0||_e.y>=sr)continue;if(this.lookupDim!==0&&F){const Pe=(this.lookupDim-1)/sr,We=this.lookupDim*(_e.y*Pe|0)+_e.x*Pe|0;if(this.lookup){if(this.lookup[We]!==0)continue;this.lookup[We]=1}}this.instanceCount++;const ke=se.length;if(se.resize(ke+1),j){Q.instancesRoadElevation||(Q.instancesRoadElevation=[]);const Pe=oe?oe.pointElevation(new Xt(_e.x,_e.y)):0;Q.instancesRoadElevation.push(Pe)}Q.instancesEvaluatedElevation.push(0),se.float32[16*ke]=_e.x,se.float32[16*ke+1]=_e.y}return re.instancedDataCount=Q.instancedDataArray.length-re.instancedDataOffset,re.instancedDataCount>0&&(c.id&&(Q.idToFeaturesIndex[c.id]=Q.features.length),Q.features.push(re),this.evaluate(re,{},Q,!1)),H}getModelUris(){return this.modelUris}evaluate(c,h,g,j){const T=this.layers[0],P=c.feature,R=this.canonical,F=c.rotation=T.paint.get("model-rotation").evaluate(P,h,R),H=c.scale=T.paint.get("model-scale").evaluate(P,h,R),Q=c.translation=T.paint.get("model-translation").evaluate(P,h,R),se=Object.assign({},T.paint.get("model-color").evaluate(P,h,R));se.a=T.paint.get("model-color-mix-intensity").evaluate(P,h,R);const re=[];this.maxVerticalOffset0?Math.sqrt(oe):0;g.maxScale=Math.max(Math.max(g.maxScale,H[0]),Math.max(H[1],H[2])),g.maxXYTranslationDistance=Math.max(g.maxXYTranslationDistance,ue),this.maxScale=Math.max(Math.max(this.maxScale,H[0]),Math.max(H[1],H[2])),W5e(re,F,H);const _e=Math.round(100*se.a)+se.b/1.05;for(let ke=0;ke10?this.tileToMeter:Ts(R,it)),qe[We+4]=Q[0],qe[We+5]=Q[1],qe[We+6]=Q[2]+(g.instancesRoadElevation?g.instancesRoadElevation[Pe]:0)+rt,qe[We+7]=re[0],qe[We+8]=re[1],qe[We+9]=re[2],qe[We+10]=re[4],qe[We+11]=re[5],qe[We+12]=re[6],qe[We+13]=re[8],qe[We+14]=re[9],qe[We+15]=re[10],g.instancesEvaluatedElevation[Pe]=Q[2]}}}gr(txe,"ModelBucket",{omit:["layers"]}),gr(jTe,"PerModelAttributes"),gr(wTe,"ModelFeature");class X3{constructor(c,h,g){this._demTile=c,this._dem=this._demTile.dem,this._scale=h,this._offset=g}static create(c,h,g){const j=g||c.findDEMTileFor(h);if(!j||!j.dem)return;const T=j.dem,P=j.tileID,R=1<H.fqid),this.stateDependentLayerIds=this.layers.filter(H=>H.isStateDependent()).map(H=>H.id),this.modelTraits|=U3.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,j&&(this.modelTraits|=U3.HasMapboxMeshFeatures),T&&(this.modelTraits|=U3.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=P,this.worldview=F,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const H of h)this.nodesInfo.push(new CTe(H)),kTe(H,R.featureIndexArray.length,R.grid),R.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,R.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(c,h){for(const g of this.getNodesInfo()){const j=g.node;j.footprint&&h.push({footprint:j.footprint,id:c})}}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}update(c){const h=Object.keys(c).length!==0;if(h&&!this.stateDependentLayers.length)return;const g=h?this.stateDependentLayers:this.layers;if(!Qa(c,this.states))for(const j of g)this.evaluate(j,c);this.states=structuredClone(c)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(c){if(!this.needsUpload)return;const h=this.getNodesInfo();for(const g of h){const j=g.node;this.uploaded?this.updatePbrBuffer(j):vfe(j,c,!0)}for(const g of h)p7(g.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(c){let h=!1;if(!c.meshes)return h;for(const g of c.meshes)g.pbrBuffer&&(g.pbrBuffer.updateData(g.featureArray),h=!0);return h}needsReEvaluation(c,h,g){const j=c.transform.projectionOptions,T=c.style.getBrightness(),P=this.brightness!==T;if(!this.uploaded||this.dirty||j.name!==this.projection.name||EI(g.paint.get("model-color").value,P)||EI(g.paint.get("model-color-mix-intensity").value,P)||EI(g.paint.get("model-roughness").value,P)||EI(g.paint.get("model-emissive-strength").value,P)||EI(g.paint.get("model-height-based-emissive-strength-multiplier").value,P)){this.projection=j,this.brightness=T;const R=this.getNodesInfo();for(const F of R)F.state=null;return!0}return!1}evaluateTransform(c,h){if(c.transform.zoom===this.zoom)return;this.zoom=c.transform.zoom;const g=this.getNodesInfo(),j=this.id.canonical;for(const T of g){const P=T.feature;T.evaluatedTranslation=h.paint.get("model-translation").evaluate(P,{},j),T.evaluatedScale=h.paint.get("model-scale").evaluate(P,{},j)}}evaluate(c,h){const g=this.getNodesInfo();for(const j of g){if(!j.node.meshes)continue;const T=j.feature,P=h&&h[T.id];if(Qa(P,j.state))continue;j.state=structuredClone(P);const R=j.node.meshes&&j.node.meshes[0].featureData,F=j.evaluatedColor[2],H=j.evaluatedRMEA[2],Q=this.id.canonical;if(j.hasTranslucentParts=!1,R){for(let se=0;se=ot)continue;const Ds=sxe[hs],ts=Math.abs(Ds);ts>St&&(kt=Ds,St=ts,rs=ws,is=us)}if(St>.1){const us=1-(ot+.5*Math.abs(rs*is))/ue;let ws=h._dem.get(wt,It)+kt*us;const hs=h._dem.get(wt+rs,It+is),Ds=h._dem.get(wt-rs,It-is,!0);(ws-hs)*(ws-Ds)>0&&(ws=(hs+Ds)/2),sxe[At]=h._dem.set(wt,It,ws),I2[At]=ot}}}}}R&&(h._demTile.needsDEMTextureUpload=!0,h._dem._timestamp=Gd.now())}setFilter(c){this.filter=c?j3(c):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(c=>this.filter.filter(new Ga(this.id.overscaledZ,{worldview:this.worldview}),c.feature,this.id.canonical)):this.nodesInfo}destroy(){const c=this.getNodesInfo();for(const h of c)p7(h.node),_fe(h.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(c,h){if(h.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=h.updateTime;const g=h.getReplacementRegionsForTile(c.toUnwrapped());for(const j of this.getNodesInfo()){const T=j.node.footprint;j.hiddenByReplacement=!!T&&!g.find(P=>P.footprint===T)}}getHeightAtTileCoord(c,h){const g=[],j=[0,0,0],T=w([]);for(const P of this.getNodesInfo()){const R=P.node.meshes[0],F=R.transformedAabb;if(cF.max[0]||h>F.max[1])continue;if(P.node.hidden===!0)return{height:1/0,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};S(T,P.node.globalMatrix),j[0]=c,j[1]=h,ct(j,j,T);const H=(j[0]-R.aabb.min[0])/(R.aabb.max[0]-R.aabb.min[0])*M2|0,Q=Math.min(63,(j[1]-R.aabb.min[1])/(R.aabb.max[1]-R.aabb.min[1])*M2|0)*M2+Math.min(63,H),se=R.heightmap[Q];if(!(se<0&&P.node.footprint))return P.hiddenByReplacement?void 0:{height:se,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};if(P.node.footprint.grid.query(new Xt(c,h),new Xt(c,h),g),g.length>0)return{height:void 0,maxHeight:P.feature.properties.height,hidden:P.hiddenByReplacement,verticalScale:P.evaluatedScale[2]}}}}function EI(x,c){return x instanceof Q1&&!x.isLightConstant&&c}function Qht(x,c,h,g,j,T,P,R){let F=(61440&c|(61440&c)>>4)>>8,H=(3840&c|(3840&c)>>4)>>4,Q=240&c|(240&c)>>4;h[3]>0&&(F=en(F,255*h[0],h[3]),H=en(H,255*h[1],h[3]),Q=en(Q,255*h[2],h[3]));const se=F<<8|H,re=Q<<8|Math.floor(255*g[3]),oe=function(ot){const It=De(ot,0,2);return Math.min(Math.round(.5*It*255),255)}(g[2])<<8|15*g[0]<<4|15*g[1],ue=De(j[0],0,1),_e=De(j[1],0,1),ke=De(j[2],0,1),Pe=De(j[3],0,1);let We,qe,rt,it;if(ue!==_e&&P!==T&&_e!==ue){const ot=P-T;qe=1/(ot*(_e-ue)),rt=-(T+ot*ue)/(ot*(_e-ue));const It=De(j[4],-1,1);it=Math.pow(10,It),We=255*ke<<8|255*Pe}else We=65535,qe=0,rt=1,it=1;if(x.emplaceBack(se,re,oe,We,qe,rt,it),R){const ot=R.length;R.clear();for(let It=0;It>16&65535,Q=T?F>>16&65535:65535&F,se=(15&Q)<8?15&Q:0,re=x.evaluatedRMEA[se],oe=x.evaluatedColor[se],ue=x.emissionHeightBasedParams[se];let _e;if(R&&se===2&&g.lights&&(_e=new E3,_e.resize(10*g.lights.length)),Qht(P.featureArray,H,oe,re,ue,P.aabb.min[2],P.aabb.max[2],_e),_e&&R){R=!1;const ke=g.meshes[g.lightMeshIndex];ke.featureArray=_e,ke.featureArray._trim()}}P.featureArray._trim(),j++}}gr(R7,"Tiled3dModelBucket",{omit:["layers"]}),gr(CTe,"Tiled3dModelFeature");const emt=["id","tile","layer","source","sourceLayer","state"];class L2{constructor(c,h,g,j,T){this.type="Feature",this._vectorTileFeature=c,this._z=h,this._x=g,this._y=j,this.properties=c?c.properties:{},this.id=T}clone(){const c=new L2(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(c.state=Object.assign({},this.state)),this.layer&&(c.layer=Object.assign({},this.layer)),this.source&&(c.source=this.source),this.sourceLayer&&(c.sourceLayer=this.sourceLayer),c}get geometry(){return this._geometry===void 0&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(c){this._geometry=c}toJSON(){const c={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const h of emt)this[h]!==void 0&&(c[h]=this[h]);return c}}class D2 extends Na{constructor(c,h,g,j){super(),this.id=c,this.type="model",this.models=[],this._options=h,this._modelsInfo=new Map,this._abortController=null}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null)}loadGLTFFromURI(c,h){return U5e(this.map._requestManager.transformRequest(c,Pf.Model).url,h)}async loadModel(c,h,g){try{const j=await this.loadGLTFFromURI(h.uri,g);if(g.aborted)return;const T=this._modelsInfo.get(c);if(!T)return;const P=wfe(j),R=T.modelSpec,F=new K5e(c,R.uri,R.position,R.orientation,P);D2.applyModelSpecification(F,R),F.computeBoundsAndApplyParent(),this.models.push(F),T.model=F}catch(j){if(j instanceof Error&&j.name==="AbortError")return;const T=j instanceof Error?j.message:"Unknown error";this.fire(new nr(new Error(`Could not load model ${c} from ${h.uri}: ${T}`)))}}async load(){this._abortController||(this._abortController=new AbortController);const c=this._abortController.signal,h=[];for(const g in this._options.models){const j=this._options.models[g],T=this._modelsInfo.get(g);if(T&&T.model){T.modelSpec=j;const P=T.model;P.position=j.position!=null?new qt(j.position[0],j.position[1]):new qt(0,0),P.orientation=j.orientation!=null?j.orientation:[0,0,0],D2.applyModelSpecification(P,j),P.computeBoundsAndApplyParent(),this.models.push(P)}else T?T.modelSpec=j:(this._modelsInfo.set(g,{modelSpec:j,model:null}),h.push(this.loadModel(g,j,c)))}h.length!==0?(await Promise.allSettled(h),c.aborted||this.fire(new Ps("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new Ps("data",{dataType:"source",sourceDataType:"metadata"}))}static applyModelSpecification(c,h){h.nodeOverrides&&D2.convertNodeOverrides(c,h.nodeOverrides),h.materialOverrides&&D2.convertMaterialOverrides(c,h.materialOverrides),h.nodeOverrideNames&&(c.nodeOverrideNames=[...h.nodeOverrideNames]),h.materialOverrideNames&&(c.materialOverrideNames=[...h.materialOverrideNames]),h.featureProperties&&(c.featureProperties=h.featureProperties)}static convertNodeOverrides(c,h){if(Array.isArray(h)&&h.every(g=>typeof g=="string")){c.nodeOverrideNames=[];for(const g of h)c.nodeOverrideNames.push(g)}else Object.entries(h).forEach(([g,j])=>{const T={orientation:[0,0,0]};if(j.hasOwnProperty("orientation")){const P=j.orientation;P&&(T.orientation=P)}c.nodeOverrides.set(g,T)})}static convertMaterialOverrides(c,h){if(Array.isArray(h)&&h.every(g=>typeof g=="string")){c.materialOverrideNames=[];for(const g of h)c.materialOverrideNames.push(g)}else Object.entries(h).forEach(([g,j])=>{const T={color:new la(1,1,1),colorMix:0,emissionStrength:0,opacity:1},P=j["model-color"];P!==void 0&&(T.color.r=P[0],T.color.g=P[1],T.color.b=P[2]);const R=j["model-color-mix-intensity"];R!==void 0&&(T.colorMix=R);const F=j["model-emissive-strength"];F!==void 0&&(T.emissionStrength=F);const H=j["model-opacity"];H!==void 0&&(T.opacity=H),c.materialOverrides.set(g,T)})}onAdd(c){this.map=c,this.load()}hasTransition(){return!1}loaded(){if(this._modelsInfo.size===0)return!0;for(const c of this._modelsInfo.values())if(c.model==null)return!1;return!0}getModels(){return this.models}loadTile(c,h){}serialize(){return this._options}setProperty(c,h){return!1}reload(){this.cancelModelRequests();const c=X0(this.id,this.scope);this.map.style.clearSource(c),this.models=[],this._modelsInfo.clear(),this.load()}onRemove(c){this.cancelModelRequests()}setModels(c){this.models=[];const h=new Map;for(const g in c){const j=c[g],T=this._modelsInfo.get(g);T&&T.modelSpec.uri===j.uri&&h.set(g,T)}if(this._modelsInfo.size!==h.size){this.cancelModelRequests();for(const[g,j]of h)j.model||h.delete(g)}this._modelsInfo=h,this._options.models=c,this.load()}}function rxe(x,c,h,g){const j=1<F>=it.vertexArrayOffset&&Frt.polygon).flat());const ke=oe?R:null,[Pe,We]=M5e(T,g,se,Q,H,P,ke,re,ue,T.center.lat,x.tileID.canonical),qe=x.queryGeometry;return C5e(Pe,We,qe.isPointQuery()?qe.screenBounds:qe.screenGeometry)}},building:class extends Yd{constructor(x,c,h,g){super(x,{layout:tMe||(tMe=new Xi({visibility:new Ys(Ht.layout_building.visibility),"building-facade":new Hs(Ht.layout_building["building-facade"]),"building-facade-floors":new Hs(Ht.layout_building["building-facade-floors"]),"building-facade-unit-width":new Hs(Ht.layout_building["building-facade-unit-width"]),"building-facade-window":new Hs(Ht.layout_building["building-facade-window"]),"building-roof-shape":new Hs(Ht.layout_building["building-roof-shape"]),"building-height":new Hs(Ht.layout_building["building-height"]),"building-base":new Hs(Ht.layout_building["building-base"]),"building-flood-light-wall-radius":new Hs(Ht.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new Hs(Ht.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new Hs(Ht.layout_building["building-flip-roof-orientation"])})),paint:sMe||(sMe=new Xi({"building-opacity":new Ys(Ht.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Ys(Ht.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Ys(Ht.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Ys(Ht.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Ys(Ht.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Ys(Ht.paint_building["building-vertical-scale"]),"building-cast-shadows":new Ys(Ht.paint_building["building-cast-shadows"]),"building-color":new Hs(Ht.paint_building["building-color"]),"building-emissive-strength":new Hs(Ht.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Ys(Ht.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Ys(Ht.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new Ys(Ht.paint_building["building-front-cutoff"]),"building-flood-light-color":new Ys(Ht.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Ys(Ht.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Ys(Ht.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new Hs({type:"string",default:"default","property-type":"data-driven"})}))},c,h,g),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(x){return new eMe(x)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(x){return!0}queryRadius(x){return 0}queryIntersectsFeature(x,c,h,g,j,T,P,R,F,H){let Q=this.layout.get("building-height").evaluate(c,h);const se=this.layout.get("building-base").evaluate(c,h),re=x.tile.getBucket(this).getFootprint(c);if(re){if(re.hiddenFlags!==0)return!1;Q=re.height}const[oe,ue]=M5e(T,g,se,Q,new Xt(0,0),P,null,[0,0],1,T.center.lat,x.tileID.canonical),_e=x.queryGeometry;return C5e(oe,ue,_e.isPointQuery()?_e.screenBounds:_e.screenGeometry)}},line:class extends Yd{constructor(x,c,h,g){const j=hMe();super(x,j,c,h,g),j.layout&&(this.layout=new Jx(j.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(x){if(x==="line-gradient"){const c=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=c._styleExpression&&c._styleExpression.expression instanceof Zw,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(x,c){super.recalculate(x,c),this.paint._values["line-floorwidth"]=(()=>{if(gI)return gI;const h=hMe();return gI=new Kut(h.paint.properties["line-width"].specification),gI.useIntegerZoom=!0,gI})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,x)}createBucket(x){return new x7(x)}getProgramIds(){const x=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return this.paint.get("line-blend-mode")!=="default"&&x.push("lineBlendComposite"),x}getDefaultProgramParams(x,c,h){if(x==="lineBlendComposite")return{};const g=dMe(this);return{config:new be(this,{zoom:c,lut:h}),defines:g,overrideFog:!1}}queryRadius(x){const c=x,h=mMe(o_("line-width",this,c),o_("line-gap-width",this,c)),g=o_("line-offset",this,c);return h/2+Math.abs(g)+BF(this.paint.get("line-translate"))}queryIntersectsFeature(x,c,h,g,j,T){if(x.queryGeometry.isAboveHorizon)return!1;const P=u3e(x.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),T.angle,x.pixelToTileUnitsFactor),R=x.pixelToTileUnitsFactor/2*mMe(this.paint.get("line-width").evaluate(c,h),this.paint.get("line-gap-width").evaluate(c,h)),F=this.paint.get("line-offset").evaluate(c,h);return F&&(g=function(H,Q){const se=[],re=new Xt(0,0);for(let oe=0;oe=3){for(let ue=0;ue{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 MTe{constructor(c){this._stringToNumber={},this._numberToString=[];for(let h=0;h=0&&re[3]>=0&&H.insert(F,re[0],re[1],re[2],re[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Fa(new g7(this.rawTileData)).layers,this.sourceLayerCoder=new MTe(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const c in this.vtLayers)this.vtFeatures[c]=[]}return this.vtLayers}query(c,h){const{tilespaceGeometry:g,transform:j,tileTransform:T,pixelPosMatrix:P,availableImages:R,worldview:F}=h;this.loadVTLayers(),this.serializedLayersCache.clear();const H=h.queryRadius?h.queryRadius:0,Q=g.bufferedTilespaceBounds,se=this.grid.query(Q.min.x,Q.min.y,Q.max.x,Q.max.y,(_e,ke,Pe,We)=>hy(g.bufferedTilespaceGeometry,_e-H,ke-H,Pe+H,We+H));se.sort(nmt);let re=null;j.elevation&&se.length>0&&(re=X3.create(j.elevation,this.tileID));const oe={};let ue;for(let _e=0;_e(We||(We=Ur(qe,this.tileID.canonical,T)),rt.queryIntersectsFeature(g,qe,it,We,this.z,j,P,re,ot,h.scope)))}return oe}loadMatchingFeature(c,h,g,j,T,P){const{featureIndex:R,bucketIndex:F,sourceLayerIndex:H,layoutVertexArrayOffset:Q}=h,se=this.bucketLayerIDs[F],re=g.layers,oe=Object.keys(re);if(oe.length&&!Fr(oe,se))return;const ue=g.sourceCache,_e=this.sourceLayerCoder.decode(H),ke=this.vtLayers[_e].feature(R),Pe=this.getId(ke,_e);for(let We=0;We`${R.key}: ${R.message}`).join(", ");return void zr(`Failed to create expression for promoteId: ${P}`)}this.promoteIdExpression=T.value}g=this.promoteIdExpression.evaluate({zoom:0},c)}else g=c.properties[j];typeof g=="boolean"&&(g=Number(g))}return g}}function ATe(x,c,h,g,j){return Es(x,(T,P)=>{const R=c instanceof Jx?c.get(P):null;return R&&R.evaluate?R.evaluate(h,g,void 0,j):R})}function nmt(x,c){return c-x}function ETe(x,c){const h={};if(!c)return h;for(const g of x){const j=g.layerIds.map(T=>c.getLayer(T)).filter(Boolean);if(j.length!==0){g.layers=j,g.stateDependentLayerIds&&(g.stateDependentLayers=g.stateDependentLayerIds.map(T=>j.filter(P=>P.id===T)[0]));for(const T of j)h[T.fqid]=g}}return h}gr(TTe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const qf=32,vy=33,p_=new Uint16Array(8184);for(let x=0;x<2046;x++){let c=x+2,h=0,g=0,j=0,T=0,P=0,R=0;for(1&c?j=T=P=qf:h=g=R=qf;(c>>=1)>1;){const H=h+j>>1,Q=g+T>>1;1&c?(j=h,T=g,h=P,g=R):(h=j,g=T,j=P,T=R),P=H,R=Q}const F=4*x;p_[F+0]=h,p_[F+1]=g,p_[F+2]=j,p_[F+3]=T}const _y=new Uint16Array(2178),f_=new Uint8Array(1089),O7=new Uint16Array(1089);function PTe(x){return x===0?-.03125:x===32?.03125:0}const ITe={Other:0,Symbol:1,FillExtrusion:2},LTe={type:2,extent:sr,loadGeometry:()=>[[new Xt(0,0),new Xt(8193,0),new Xt(8193,8193),new Xt(0,8193),new Xt(0,0)]]};class amt{constructor(){this.tasks={},this.taskQueue=[],Qt(["process"],this),this.invoker=new rmt(this.process),this.nextId=0}add(c,h){const g=this.nextId++,j=function({type:T,renderSourceType:P,zoom:R}){R=R||0;const F=P===ITe.Symbol;return T==="message"?0:T!=="maybePrepare"||F?T!=="parseTile"||F?T==="parseTile"&&F?300-R:T==="maybePrepare"&&F?400-R:500:200-R:100-R}(h);if(j===0){try{c()}finally{}return null}return this.tasks[g]={fn:c,metadata:h,priority:j,id:g},this.taskQueue.push(g),this.invoker.trigger(),{cancel:()=>{delete this.tasks[g]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(g=>!!this.tasks[g]),!this.taskQueue.length)return;const c=this.pick();if(c===null)return;const h=this.tasks[c];if(delete this.tasks[c],this.taskQueue.length&&this.invoker.trigger(),!h)return;h.fn()}finally{}}pick(){let c=null,h=1/0;for(let j=0;j>16&255)/255,(x>>8&255)/255,(255&x)/255,1)}function gmt(x,c,h){x===1?(c.rgb_color=B7(h.readVarint()),c.paint="rgb_color"):x===2?(c.linear_gradient_idx=h.readVarint(),c.paint="linear_gradient_idx"):x===3?(c.radial_gradient_idx=h.readVarint(),c.paint="radial_gradient_idx"):x===5?h.readPackedFloat(c.dasharray):x===6?c.dashoffset=h.readFloat():x===7?c.miterlimit=h.readFloat():x===8?c.opacity=h.readVarint():x===9?c.width=h.readFloat():x===10?c.linecap=h.readVarint():x===11&&(c.linejoin=h.readVarint())}function ymt(x,c,h){x===1?c.transform=z7(h,h.readVarint()+h.pos):x===2?c.spread_method=h.readVarint():x===3?c.stops.push(OTe(h,h.readVarint()+h.pos)):x===4?c.x1=h.readFloat():x===5?c.y1=h.readFloat():x===6?c.x2=h.readFloat():x===7&&(c.y2=h.readFloat())}function OTe(x,c){return x.readFields(vmt,{offset:0,opacity:255,rgb_color:nxe},c)}function vmt(x,c,h){x===1?c.offset=h.readFloat():x===2?c.opacity=h.readVarint():x===3&&(c.rgb_color=B7(h.readVarint()))}function _mt(x,c,h){x===1?c.transform=z7(h,h.readVarint()+h.pos):x===2?c.spread_method=h.readVarint():x===3?c.stops.push(OTe(h,h.readVarint()+h.pos)):x===4?c.cx=h.readFloat():x===5?c.cy=h.readFloat():x===6?c.r=h.readFloat():x===7?c.fx=h.readFloat():x===8?c.fy=h.readFloat():x===9&&(c.fr=h.readFloat())}function bmt(x,c,h){x===1?c.transform=z7(h,h.readVarint()+h.pos):x===2?c.clip_path_idx=h.readVarint():x===3&&c.children.push(F7(h,h.readVarint()+h.pos))}function wmt(x,c,h){x===1?c.left=c.top=h.readFloat():x===2?c.width=c.height=h.readFloat():x===3?c.top=h.readFloat():x===4?c.height=h.readFloat():x===5?c.mask_type=h.readVarint():x===6?c.mask_idx=h.readVarint():x===7&&c.children.push(F7(h,h.readVarint()+h.pos))}class jmt{static calculate(c={},h=[]){const g=new Map,j=new Map;if(Object.keys(c).length===0)return g;h.forEach(T=>{j.set(T.name,T.rgb_color||new la(0,0,0))});for(const[T,P]of Object.entries(c))j.has(T)?g.set(j.get(T).toString(),P):console.warn(`Ignoring unknown image variable "${T}"`);return g}}function Q3(x,c=255,h){const g=c/255,j=x.toString(),T=h.has(j)?h.get(j).clone():x.clone();return T.a*=g,T.toString()}function PI(x,c){if(!xh()){const h=document.createElement("canvas");return h.width=x,h.height=c,h}return new OffscreenCanvas(x,c)}let axe,II=null;function ixe(x,c,h,g,j){for(const T of g.children)FTe(x,c,h,T,j)}function FTe(x,c,h,g,j){g.group?(x.save(),function(T,P,R,F,H){const Q=F.mask_idx!=null?R.masks[F.mask_idx]:null,se=F.clip_path_idx!=null?R.clip_paths[F.clip_path_idx]:null;if(F.transform&&(P=J3(F.transform).preMultiplySelf(P)),!function(ue,_e,ke){return ue.opacity!==255||_e||ke}(F,se!=null,Q!=null))return void ixe(T,P,R,F,H);const re=PI(T.canvas.width,T.canvas.height),oe=re.getContext("2d");ixe(oe,P,R,F,H),se&&HTe(oe,P,R,se),Q&>e(oe,P,R,Q,H),T.globalAlpha=F.opacity/255,T.drawImage(re,0,0)}(x,c,h,g.group,j),x.restore()):g.path&&(x.save(),function(T,P,R,F,H){T.setTransform(P),F.paint_order===1?(zTe(T,R,F,H),$Te(T,R,F,H)):($Te(T,R,F,H),zTe(T,R,F,H))}(x,c,h,g.path,j),x.restore())}function zTe(x,c,h,g){const j=h.fill;if(!j)return;const T=j.opacity/255;switch(x.save(),x.beginPath(),WTe(h,x),j.paint){case"rgb_color":x.fillStyle=Q3(j.rgb_color,j.opacity,g);break;case"linear_gradient_idx":{const P=c.linear_gradients[j.linear_gradient_idx];P.transform&&x.setTransform(J3(P.transform).preMultiplySelf(x.getTransform())),x.fillStyle=qTe(x,P,T,g);break}case"radial_gradient_idx":{const P=c.radial_gradients[j.radial_gradient_idx];P.transform&&x.setTransform(J3(P.transform).preMultiplySelf(x.getTransform())),x.fillStyle=UTe(x,P,T,g)}}x.fill(BTe(h)),x.restore()}function BTe(x){return x.rule===1?"nonzero":x.rule===2?"evenodd":void 0}function $Te(x,c,h,g){const j=h.stroke;if(!j)return;const T=KTe(h);x.lineWidth=j.width,x.miterLimit=j.miterlimit,x.setLineDash(j.dasharray),x.lineDashOffset=j.dashoffset;const P=j.opacity/255;switch(j.paint){case"rgb_color":x.strokeStyle=Q3(j.rgb_color,j.opacity,g);break;case"linear_gradient_idx":x.strokeStyle=qTe(x,c.linear_gradients[j.linear_gradient_idx],P,g,!0);break;case"radial_gradient_idx":x.strokeStyle=UTe(x,c.radial_gradients[j.radial_gradient_idx],P,g,!0)}switch(j.linejoin){case 2:case 1:x.lineJoin="miter";break;case 3:x.lineJoin="round";break;case 4:x.lineJoin="bevel"}switch(j.linecap){case 1:x.lineCap="butt";break;case 2:x.lineCap="round";break;case 3:x.lineCap="square"}x.stroke(T)}function qTe(x,c,h,g,j=!1){if(c.stops.length===1){const re=c.stops[0];return Q3(re.rgb_color,re.opacity*h,g)}const{x1:T,y1:P,x2:R,y2:F}=c;let H=new DOMPoint(T,P),Q=new DOMPoint(R,F);if(j){const re=J3(c.transform);H=re.transformPoint(H),Q=re.transformPoint(Q)}const se=x.createLinearGradient(H.x,H.y,Q.x,Q.y);for(const re of c.stops)se.addColorStop(re.offset,Q3(re.rgb_color,re.opacity*h,g));return se}function UTe(x,c,h,g,j=!1){if(c.stops.length===1){const Pe=c.stops[0];return Q3(Pe.rgb_color,Pe.opacity*h,g)}const T=J3(c.transform),{fx:P,fy:R,fr:F,cx:H,cy:Q,r:se}=c;let re=new DOMPoint(P,R),oe=new DOMPoint(H,Q),ue=F,_e=se;if(j){re=T.transformPoint(re),oe=T.transformPoint(oe);const Pe=(T.a+T.d)/2;ue=F*Pe,_e=c.r*Pe}const ke=x.createRadialGradient(re.x,re.y,ue,oe.x,oe.y,_e);for(const Pe of c.stops)ke.addColorStop(Pe.offset,Q3(Pe.rgb_color,Pe.opacity*h,g));return ke}function VTe(x,c,h,g){const j=g.transform?J3(g.transform).preMultiplySelf(c):c,T=PI(x.canvas.width,x.canvas.height),P=T.getContext("2d");for(const F of g.children)if(F.group)VTe(P,j,h,F.group);else if(F.path){const H=F.path,Q=new Path2D;Q.addPath(KTe(H),j),P.fill(Q,BTe(H))}const R=g.clip_path_idx!=null?h.clip_paths[g.clip_path_idx]:null;R&&HTe(P,j,h,R),x.globalCompositeOperation="source-over",x.drawImage(T,0,0)}function HTe(x,c,h,g){const j=PI(x.canvas.width,x.canvas.height);VTe(j.getContext("2d"),c,h,g),x.globalCompositeOperation="destination-in",x.drawImage(j,0,0)}function GTe(x,c,h,g,j){if(g.children.length===0)return;const T=g.mask_idx!=null?h.masks[g.mask_idx]:null;T&>e(x,c,h,T,j);const P=x.canvas.width,R=x.canvas.height,F=PI(P,R),H=F.getContext("2d"),Q=g.width,se=g.height,re=g.left,oe=g.top,ue=new Path2D,_e=new Path2D;_e.rect(re,oe,Q,se),ue.addPath(_e,c),H.clip(ue);for(const We of g.children)FTe(H,c,h,We,j);const ke=H.getImageData(0,0,P,R),Pe=ke.data;if(g.mask_type===1)for(let We=0;Wec[P])return null}else{const R=1/g[P];let F=(x[P]-h[P])*R,H=(c[P]-h[P])*R;if(F>H){const Q=F;F=H,H=Q}if(F>j&&(j=F),HT)return null}return j}function XTe(x,c,h,g,j,T,P,R,F,H,Q){const se=g-x,re=j-c,oe=T-h,ue=P-x,_e=R-c,ke=F-h,Pe=Q[1]*ke-Q[2]*_e,We=Q[2]*ue-Q[0]*ke,qe=Q[0]*_e-Q[1]*ue,rt=se*Pe+re*We+oe*qe;if(Math.abs(rt)<1e-15)return null;const it=1/rt,ot=H[0]-x,It=H[1]-c,wt=H[2]-h,At=(ot*Pe+It*We+wt*qe)*it;if(At<0||At>1)return null;const kt=It*oe-wt*re,St=wt*se-ot*oe,rs=ot*re-It*se,is=(Q[0]*kt+Q[1]*St+Q[2]*rs)*it;return is<0||At+is>1?null:(ue*kt+_e*St+ke*rs)*it}function QTe(x,c,h){return(x-c)/(h-c)}function JTe(x,c,h,g,j,T,P,R,F){const H=1<{const We=ke?1:0,qe=(oe+1)*_e-We,rt=ue*_e,it=(ue+1)*_e-We;Pe[0]=oe*_e,Pe[1]=rt,Pe[2]=qe,Pe[3]=it};let se=new ZTe(F);const re=[];for(let oe=0;oe=1;F/=2){const oe=R[R.length-1];se=new ZTe(F);for(let ue=0;ue0;){const{idx:ue,t:_e,nodex:ke,nodey:Pe,depth:We}=oe.pop();if(this.leaves[ue]){JTe(ke,Pe,We,c,h,g,j,se,re);const rt=1<=hs[2])return _e}continue}let qe=0;for(let rt=0;rt=H[Q[wt]]&&(Q.splice(wt,0,rt),It=!0);It||(Q[qe]=rt),qe++}}for(let rt=0;rt=this.dim+1||h<-1||h>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(h+1)*this.stride+(c+1)}static pack(c,h){const g=[0,0,0,0],j=q7.getUnpackVector(h);let T=Math.floor((c+j[3])/j[2]);return g[2]=T%256,T=Math.floor(T/256),g[1]=T%256,T=Math.floor(T/256),g[0]=T,g}getPixels(){return new R3e({width:this.stride,height:this.stride},this.pixels)}backfillBorder(c,h,g){if(this.dim!==c.dim)throw new Error("dem dimension mismatch");let j=h*this.dim,T=h*this.dim+this.dim,P=g*this.dim,R=g*this.dim+this.dim;switch(h){case-1:j=T-1;break;case 1:T=j+1}switch(g){case-1:P=R-1;break;case 1:R=P+1}const F=-h*this.dim,H=-g*this.dim;for(let Q=P;Q=1;g--){const j=g===1?1:0,T=g===2?1:0;for(let P=0;P>>1^-(1&x[c]);return x}function Omt(x,c){switch(c){case"uint32":return x;case"uint16":for(let h=0;h>4|(61440&g)>>8|(240&j)<<4|61440&j,x[h+1]=15&g|(3840&g)>>4|(15&j)<<8|(3840&j)<<4}return x;case"uint8":for(let h=0;h>6|(192&j)>>4|(192&T)>>2|192&P,x[h+1]=(48&g)>>4|(48&j)>>2|48&T|(48&P)<<2,x[h+2]=(12&g)>>2|12&j|(12&T)<<2|(12&P)<<4,x[h+3]=3&g|(3&j)<<2|(3&T)<<4|(3&P)<<6}return x;default:throw new Error(`Invalid pixel format, "${c}"`)}}gr(q7,"DEMData"),gr(eAe,"DemMinMaxQuadTree",{omit:["dem"]});var Lp=Uint8Array,LI=Uint16Array,Fmt=Int32Array,sAe=new Lp([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]),rAe=new Lp([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]),zmt=new Lp([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),nAe=function(x,c){for(var h=new LI(31),g=0;g<31;++g)h[g]=c+=1<>1|(21845&ql)<<1;oAe[ql]=((65280&(e5=(61680&(e5=(52428&e5)>>2|(13107&e5)<<2))>>4|(3855&e5)<<4))>>8|(255&e5)<<8)>>1}var DI=function(x,c,h){for(var g=x.length,j=0,T=new LI(c);j>F]=H;return P},RI=new Lp(288);for(ql=0;ql<144;++ql)RI[ql]=8;for(ql=144;ql<256;++ql)RI[ql]=9;for(ql=256;ql<280;++ql)RI[ql]=7;for(ql=280;ql<288;++ql)RI[ql]=8;var lAe=new Lp(32);for(ql=0;ql<32;++ql)lAe[ql]=5;var qmt=DI(RI,9),Umt=DI(lAe,5),lxe=function(x){for(var c=x[0],h=1;hc&&(c=x[h]);return c},ig=function(x,c,h){var g=c/8|0;return(x[g]|x[g+1]<<8)>>(7&c)&h},cxe=function(x,c){var h=c/8|0;return(x[h]|x[h+1]<<8|x[h+2]<<16)>>(7&c)},Vmt=function(x){return(x+7)/8|0},Hmt=["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"],og=function(x,c,h){var g=new Error(c||Hmt[x]);if(g.code=x,Error.captureStackTrace&&Error.captureStackTrace(g,og),!h)throw g;return g},Gmt=new Lp(0),Wmt=typeof TextDecoder<"u"&&new TextDecoder;try{Wmt.decode(Gmt,{stream:!0})}catch{}const Kmt={gzip_data:"gzip"};class Uf extends Error{constructor(c){super(c),this.name="MRTError"}}const Zmt={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},cAe={uint32:1,uint16:2,uint8:4},Ymt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let dxe;class U7{constructor(c=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=c}getLayer(c){const h=this.layers[c];if(!h)throw new Uf(`Layer '${c}' not found`);return h}getHeaderLength(c){const h=new Uint8Array(c),g=new DataView(c);if(h[0]!==13)throw new Uf("File is not a valid MRT.");return g.getUint32(1,!0)}parseHeader(c){const h=new Uint8Array(c),g=this.getHeaderLength(c);if(h.length= ${g} but got buffer of length ${h.length}`);const j=new dxe(h.subarray(0,g)).readFields(Cmt,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==j.x||this.y!==j.y||this.z!==j.z))throw new Uf(`Invalid attempt to parse header ${j.z}/${j.x}/${j.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=j.x,this.y=j.y,this.z=j.z;for(const T of j.layers)this.layers[T.name]=new dAe(T,{cacheSize:this._cacheSize});return this}createDecodingTask(c){const h=[],g=this.getLayer(c.layerName);for(let j of c.blockIndices){const T=g.dataIndex[j],P=T.firstByte-c.firstByte,R=T.lastByte-c.firstByte;if(g._blocksInProgress.has(j))continue;const F={layerName:g.name,firstByte:P,lastByte:R,pixelFormat:g.pixelFormat,blockIndex:j,blockShape:[T.bands.length].concat(g.bandShape),buffer:g.buffer,codec:T.codec.codec,filters:T.filters.map(H=>H.filter)};g._blocksInProgress.add(j),h.push(F)}return new uAe(h,()=>{h.forEach(j=>g._blocksInProgress.delete(j.blockIndex))},(j,T)=>{if(h.forEach(P=>g._blocksInProgress.delete(P.blockIndex)),j)throw j;T.forEach(P=>{this.getLayer(P.layerName).processDecodedData(P)})})}}class dAe{constructor({version:c,name:h,units:g,tileSize:j,pixelFormat:T,buffer:P,dataIndex:R},F){if(this.version=c,this.version!==1)throw new Uf(`Cannot parse raster layer encoded with MRT version ${c}`);this.name=h,this.units=g,this.tileSize=j,this.buffer=P,this.pixelFormat=Zmt[T],this.dataIndex=R,this.bandShape=[j+2*P,j+2*P,cAe[this.pixelFormat]],this._decodedBlocks=new $7(F?F.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return cAe[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:c})=>c).flat()}processDecodedData(c){const h=c.blockIndex.toString();this._decodedBlocks.get(h)||this._decodedBlocks.put(h,c.data)}getBlockForBand(c){let h=0;switch(typeof c){case"string":for(const[g,j]of this.dataIndex.entries()){for(const[T,P]of j.bands.entries())if(P===c)return{bandIndex:h+T,blockIndex:g,blockBandIndex:T};h+=j.bands.length}break;case"number":for(const[g,j]of this.dataIndex.entries()){if(c>=h&&cthis.cacheSize)throw new Uf(`Number of blocks to decode (${T.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:h,lastByte:g,blockIndices:j}}hasBand(c){const{blockIndex:h}=this.getBlockForBand(c);return h>=0}hasDataForBand(c){const{blockIndex:h}=this.getBlockForBand(c);return h>=0&&!!this._decodedBlocks.get(h.toString())}getBandView(c){const{blockIndex:h,blockBandIndex:g}=this.getBlockForBand(c);if(h<0)throw new Uf(`Band not found: ${JSON.stringify(c)}`);const j=this._decodedBlocks.get(h.toString());if(!j)throw new Uf(`Data for band ${JSON.stringify(c)} of layer "${this.name}" not decoded.`);const T=this.dataIndex[h],P=this.bandShape.reduce((H,Q)=>H*Q,1),R=g*P,F=j.subarray(R,R+P);return{data:F,bytes:new Uint8Array(F.buffer).subarray(F.byteOffset,F.byteOffset+F.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:T.offset,scale:T.scale}}}U7.setPbf=function(x){dxe=x};class uAe{constructor(c,h,g){this.tasks=c,this._onCancel=h,this._onComplete=g,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(c,h){this._finalized||(this._onComplete(c,h),this._finalized=!0)}}U7.performDecoding=function(x,c){const h=new Uint8Array(x);return Promise.all(c.tasks.map(g=>{const{layerName:j,firstByte:T,lastByte:P,pixelFormat:R,blockShape:F,blockIndex:H,filters:Q,codec:se}=g,re=h.subarray(T,P+1),oe=new Uint32Array(F[0]*F[1]*F[2]);let ue;if(se!=="gzip_data")throw new Uf(`Unhandled codec: ${se}`);return ue=function(_e,ke){if(!globalThis.DecompressionStream&&ke==="gzip_data")return Promise.resolve((it=function(wt){wt[0]==31&&wt[1]==139&&wt[2]==8||og(6,"invalid gzip data");var At=wt[3],kt=10;4&At&&(kt+=2+(wt[10]|wt[11]<<8));for(var St=(At>>3&1)+(At>>4&1);St>0;St-=!wt[kt++]);return kt+(2&At)}(Pe=_e),it+8>Pe.length&&og(6,"invalid gzip data"),function(wt,At,kt,St){var rs=wt.length;if(!rs||At.f&&!At.l)return kt||new Lp(0);var is=!kt,us=is||At.i!=2,ws=At.i;is&&(kt=new Lp(3*rs));var hs=function(fo){var Xd=kt.length;if(fo>Xd){var Ec=new Lp(Math.max(2*Xd,fo));Ec.set(kt),kt=Ec}},Ds=At.f||0,ts=At.p||0,vs=At.b||0,Ms=At.l,Rs=At.d,Ks=At.m,fr=At.n,er=8*rs;do{if(!Ms){Ds=ig(wt,ts,1);var Js=ig(wt,ts+1,3);if(ts+=3,!Js){var Zs=wt[(Wa=Vmt(ts)+4)-4]|wt[Wa-3]<<8,dr=Wa+Zs;if(dr>rs){ws&&og(0);break}us&&hs(vs+Zs),kt.set(wt.subarray(Wa,dr),vs),At.b=vs+=Zs,At.p=ts=8*dr,At.f=Ds;continue}if(Js==1)Ms=qmt,Rs=Umt,Ks=9,fr=5;else if(Js==2){var jr=ig(wt,ts,31)+257,$r=ig(wt,ts+10,15)+4,Pr=jr+ig(wt,ts+5,31)+1;ts+=14;for(var kn=new Lp(Pr),ba=new Lp(19),Sn=0;Sn<$r;++Sn)ba[zmt[Sn]]=ig(wt,ts+3*Sn,7);ts+=3*$r;var ka=lxe(ba),Un=(1<>4)<16)kn[Sn++]=Wa;else{var ki=0,io=0;for(Wa==16?(io=3+ig(wt,ts,3),ts+=2,ki=kn[Sn-1]):Wa==17?(io=3+ig(wt,ts,7),ts+=3):Wa==18&&(io=11+ig(wt,ts,127),ts+=7);io--;)kn[Sn++]=ki}}var oc=kn.subarray(0,jr),oo=kn.subarray(jr);Ks=lxe(oc),fr=lxe(oo),Ms=DI(oc,Ks),Rs=DI(oo,fr)}else og(1);if(ts>er){ws&&og(0);break}}us&&hs(vs+131072);for(var Eo=(1<>4;if((ts+=15&ki)>er){ws&&og(0);break}if(ki||og(2),ld<256)kt[vs++]=ld;else{if(ld==256){Po=ts,Ms=null;break}var lc=ld-254;ld>264&&(lc=ig(wt,ts,(1<<(zo=sAe[Sn=ld-257]))-1)+iAe[Sn],ts+=zo);var Wn=Rs[cxe(wt,ts)&el],ju=Wn>>4;if(Wn||og(3),ts+=15&Wn,oo=$mt[ju],ju>3){var zo=rAe[ju];oo+=cxe(wt,ts)&(1<er){ws&&og(0);break}us&&hs(vs+131072);var Ac=vs+lc;if(vsfo.length)&&(Ec=fo.length),new Lp(fo.subarray(0,Ec))}(kt,0,vs):kt.subarray(0,vs)}(Pe.subarray(it,-8),{i:2},new Lp(((qe=Pe)[(rt=qe.length)-4]|qe[rt-3]<<8|qe[rt-2]<<16|qe[rt-1]<<24)>>>0),We)));var Pe,We,qe,rt,it;const ot=Kmt[ke];if(!ot)throw new Error(`Unhandled codec: ${ke}`);const It=new globalThis.DecompressionStream(ot);return new Response(new Blob([_e]).stream().pipeThrough(It)).arrayBuffer().then(wt=>new Uint8Array(wt))}(re,se).then(_e=>(function(ke,Pe){ke.readFields(Imt,Pe)}(new dxe(_e),oe),new Ymt[R](oe.buffer))),ue.then(_e=>{for(let ke=Q.length-1;ke>=0;ke--)switch(Q[ke]){case"delta_filter":Dmt(_e,F);break;case"zigzag_filter":Rmt(_e);break;case"bitshuffle_filter":Omt(_e,R);break;default:throw new Uf(`Unhandled filter "${Q[ke]}"`)}return{layerName:j,blockIndex:H,data:_e}}).catch(_e=>{throw _e})}))},gr(uAe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),gr(U7,"MapboxRasterTile"),gr(dAe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const hAe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class uxe{static from(c){if(!(c instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[h,g]=new Uint8Array(c,0,2);if(h!==219)throw new Error("Data does not appear to be in a KDBush format.");const j=g>>4;if(j!==1)throw new Error(`Got v${j} data when expected v1.`);const T=hAe[15&g];if(!T)throw new Error("Unrecognized array type.");const[P]=new Uint16Array(c,2,1),[R]=new Uint32Array(c,4,1);return new uxe(R,P,T,c)}constructor(c,h=64,g=Float64Array,j){if(isNaN(c)||c<0)throw new Error(`Unpexpected numItems value: ${c}.`);this.numItems=+c,this.nodeSize=Math.min(Math.max(+h,2),65535),this.ArrayType=g,this.IndexArrayType=c<65536?Uint16Array:Uint32Array;const T=hAe.indexOf(this.ArrayType),P=2*c*this.ArrayType.BYTES_PER_ELEMENT,R=c*this.IndexArrayType.BYTES_PER_ELEMENT,F=(8-R%8)%8;if(T<0)throw new Error(`Unexpected typed array class: ${g}.`);j&&j instanceof ArrayBuffer?(this.data=j,this.ids=new this.IndexArrayType(this.data,8,c),this.coords=new this.ArrayType(this.data,8+R+F,2*c),this._pos=2*c,this._finished=!0):(this.data=new ArrayBuffer(8+P+R+F),this.ids=new this.IndexArrayType(this.data,8,c),this.coords=new this.ArrayType(this.data,8+R+F,2*c),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+T]),new Uint16Array(this.data,2,1)[0]=h,new Uint32Array(this.data,4,1)[0]=c)}add(c,h){const g=this._pos>>1;return this.ids[g]=g,this.coords[this._pos++]=c,this.coords[this._pos++]=h,g}finish(){const c=this._pos>>1;if(c!==this.numItems)throw new Error(`Added ${c} items when expected ${this.numItems}.`);return hxe(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(c,h,g,j){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:T,coords:P,nodeSize:R}=this,F=[0,T.length-1,0],H=[];for(;F.length;){const Q=F.pop()||0,se=F.pop()||0,re=F.pop()||0;if(se-re<=R){for(let ke=re;ke<=se;ke++){const Pe=P[2*ke],We=P[2*ke+1];Pe>=c&&Pe<=g&&We>=h&&We<=j&&H.push(T[ke])}continue}const oe=re+se>>1,ue=P[2*oe],_e=P[2*oe+1];ue>=c&&ue<=g&&_e>=h&&_e<=j&&H.push(T[oe]),(Q===0?c<=ue:h<=_e)&&(F.push(re),F.push(oe-1),F.push(1-Q)),(Q===0?g>=ue:j>=_e)&&(F.push(oe+1),F.push(se),F.push(1-Q))}return H}within(c,h,g){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:j,coords:T,nodeSize:P}=this,R=[0,j.length-1,0],F=[],H=g*g;for(;R.length;){const Q=R.pop()||0,se=R.pop()||0,re=R.pop()||0;if(se-re<=P){for(let ke=re;ke<=se;ke++)pAe(T[2*ke],T[2*ke+1],c,h)<=H&&F.push(j[ke]);continue}const oe=re+se>>1,ue=T[2*oe],_e=T[2*oe+1];pAe(ue,_e,c,h)<=H&&F.push(j[oe]),(Q===0?c-g<=ue:h-g<=_e)&&(R.push(re),R.push(oe-1),R.push(1-Q)),(Q===0?c+g>=ue:h+g>=_e)&&(R.push(oe+1),R.push(se),R.push(1-Q))}return F}}function hxe(x,c,h,g,j,T){if(j-g<=h)return;const P=g+j>>1;mAe(x,c,P,g,j,T),hxe(x,c,h,g,P-1,1-T),hxe(x,c,h,P+1,j,1-T)}function mAe(x,c,h,g,j,T){for(;j>g;){if(j-g>600){const H=j-g+1,Q=h-g+1,se=Math.log(H),re=.5*Math.exp(2*se/3),oe=.5*Math.sqrt(se*re*(H-re)/H)*(Q-H/2<0?-1:1);mAe(x,c,h,Math.max(g,Math.floor(h-Q*re/H+oe)),Math.min(j,Math.floor(h+(H-Q)*re/H+oe)),T)}const P=c[2*h+T];let R=g,F=j;for(OI(x,c,g,h),c[2*j+T]>P&&OI(x,c,g,j);RP;)F--}c[2*g+T]===P?OI(x,c,g,F):(F++,OI(x,c,F,j)),F<=h&&(g=F+1),h<=F&&(j=F-1)}}function OI(x,c,h,g){mxe(x,h,g),mxe(c,2*h,2*g),mxe(c,2*h+1,2*g+1)}function mxe(x,c,h){const g=x[c];x[c]=x[h],x[h]=g}function pAe(x,c,h,g){const j=x-h,T=c-g;return j*j+T*T}i.$=G1,i.A=class{constructor(x,c,h){this.target=x,this.parent=c,this.mapId=h,this.callbacks={},this.cancelCallbacks={},Qt(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new amt}send(x,c,h,g,j=!1,T){const P=Math.round(1e18*Math.random()).toString(36).substring(0,10);h&&(h.metadata=T,this.callbacks[P]=h);const R=new Set;return this.target.postMessage({id:P,type:x,hasCallback:!!h,targetMapId:g,mustQueue:j,sourceMapId:this.mapId,data:Yx(c,R)},R),{cancel:()=>{h&&delete this.callbacks[P],this.target.postMessage({id:P,type:"",targetMapId:g,sourceMapId:this.mapId})}}}receive(x){const c=x.data;if(!c)return;const h=c.id;if(h&&(!c.targetMapId||this.mapId===c.targetMapId))if(c.type===""){const g=this.cancelCallbacks[h];delete this.cancelCallbacks[h],g&&g.cancel()}else if(c.mustQueue||vi(self)){const g=this.callbacks[h],j=this.scheduler.add(()=>this.processTask(h,c),g&&g.metadata||{type:"message"});j&&(this.cancelCallbacks[h]=j)}else this.processTask(h,c)}processTask(x,c){if(delete this.cancelCallbacks[x],c.type===""){const h=this.callbacks[x];delete this.callbacks[x],h&&(c.error?h(dy(c.error)):h(null,dy(c.data)))}else{const h=new Set,g=c.hasCallback?(T,P)=>{this.target.postMessage({id:x,type:"",sourceMapId:this.mapId,error:T?Yx(T):null,data:Yx(P,h)},h)}:()=>{},j=dy(c.data);if(this.parent[c.type])this.parent[c.type](c.sourceMapId,j,g);else if(this.parent.getWorkerSource){const T=c.type.split("."),{source:P,scope:R}=j;this.parent.getWorkerSource(c.sourceMapId,{type:T[0],source:P,scope:R,uid:0})[T[1]](j,g)}else g(new Error(`Could not find function ${c.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.B=nr,i.C=Ps,i.D=$m,i.E=Na,i.F=X0,i.G=2,i.H=_I,i.I=Bn,i.J=PMe,i.K=qC,i.L=NF,i.M=zw,i.N=Bw,i.O=d3,i.P=Xt,i.Q=c3,i.R=Pf,i.S=oP,i.T=yy,i.U=a2,i.V=D7,i.W=w3,i.X=cy,i.Y=cP,i.Z=Df,i._=V0,i.a=function(x){return oa.API_CDN_URL_REGEX.test(x)},i.a$=g7,i.a0=ac,i.a1=$w,i.a2=UC,i.a3=zm,i.a4=MP,i.a5=class extends D7{},i.a6=lP,i.a7=oF,i.a8=Ht,i.a9=function(x){const c=x.value;return c?UC(c)?exe(c,!0)?[]:[new D7(x.key,c,`invalid url "${c}"`)]:[new D7(x.key,c,`string expected, "${zw(c)}" found`)]:[]},i.aA=iMe,i.aB=function(x){let c=1/0,h=1/0,g=-1/0,j=-1/0;for(const T of x)c=Math.min(c,T.x),h=Math.min(h,T.y),g=Math.max(g,T.x),j=Math.max(j,T.y);return{min:new Xt(c,h),max:new Xt(g,j)}},i.aC=De,i.aD=C,i.aE=at,i.aF=mt,i.aG=Gu,i.aH=Ns,i.aI=pr,i.aJ=function(x,c){const h={};for(let g=0;g=0?c.slice(h+1):""}catch{return""}},i.aN=class{constructor(x){this.entries={},this.scheduler=x}request(x,c,h,g){const j=this.entries[x]=this.entries[x]||{callbacks:[]};if(j.result){const[T,P]=j.result;return this.scheduler?this.scheduler.add(()=>{g(T,P)},c):g(T,P),()=>{}}return j.callbacks.push(g),j.cancel||(j.cancel=h((T,P)=>{j.result=[T,P];for(const R of j.callbacks)this.scheduler?this.scheduler.add(()=>{R(T,P)},c):R(T,P);setTimeout(()=>delete this.entries[x],3e3)})),()=>{j.result||(j.callbacks=j.callbacks.filter(T=>T!==g),j.callbacks.length||(j.cancel(),delete this.entries[x]))}}},i.aO=function(x,c,h){const g=JSON.stringify(x.request);return x.data&&(this.deduped.entries[g]={result:[null,x.data]}),this.deduped.request(g,{type:"parseTile",renderSourceType:x.renderSourceType,zoom:x.tileZoom},j=>{const T=If(x.request,(P,R,F)=>{P?Lw(P)?j(null,null):j(P):R&&j(null,{rawData:R,vectorTile:h?void 0:new Fa(new g7(R)),responseHeaders:new Map(F.entries())})});return()=>{T.cancel(),j(null,null)}},c)},i.aP=function(x){return x?{cacheControl:x.get("cache-control"),expires:x.get("expires")}:{cacheControl:void 0,expires:void 0}},i.aQ=function(x){kp++,kp>Np&&(x.getActor().send("enforceCacheSizeLimit",I1),kp=0)},i.aR=wu,i.aS=mTe,i.aT=bTe,i.aU=qt,i.aV=hTe,i.aW=function(x,c){const h=document.createElement("video");h.muted=!0,h.onloadstart=function(){c(null,h)};for(let g=0;g{}}},i.aX=fI,i.aY=D2,i.aZ=Qt,i.a_=U7,i.aa=b3,i.ab=Xi,i.ac=Ys,i.ad=class{constructor(x){this.specification=x}possiblyEvaluate(x,c){return Zn(x.expression.evaluate(c))}interpolate(x,c,h){return{x:en(x.x,c.x,h),y:en(x.y,c.y,h),z:en(x.z,c.z,h),azimuthal:en(x.azimuthal,c.azimuthal,h),polar:en(x.polar,c.polar,h)}}},i.ae=Ga,i.af=G0,i.ag=wr,i.ah=ct,i.ai=ce,i.aj=Ze,i.ak=Jx,i.al=nv,i.am=en,i.an=sr,i.ao=Tp,i.ap=Kt,i.aq=la,i.ar=class{constructor(x){this.specification=x}possiblyEvaluate(x,c){return function([h,g]){const j=Zn([1,h,g]);return{x:j.x,y:j.y,z:j.z}}(x.expression.evaluate(c))}interpolate(x,c,h){return{x:en(x.x,c.x,h),y:en(x.y,c.y,h),z:en(x.z,c.z,h)}}},i.as=function(x,c,h=0,g=!0){const j=new Xt(h,h),T=x.sub(j),P=c.add(j),R=[T,new Xt(P.x,T.y),P,new Xt(T.x,P.y)];return g&&R.push(T.clone()),R},i.at=function(x,c){const h=[];for(let g=0;gthis.buckets[se].layers.some(re=>P.has(re.fqid))),F=Object.keys(this.buckets).some(se=>this.buckets[se].layers.some(re=>re.hasTransition&&re.hasTransition())),H=this._firstPrepareComplete&&T!==this._lastAvailableImagesCount;this._hasAppearances===null&&(this._hasAppearances=this.hasAppearances(c));const Q=this._lastUpdatedBrightness!==g;this._lastAvailableImagesCount=T,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||g||this._hasAppearances||R||F||H)&&(!(this._hasAppearances||R||F||H)&&this._lastUpdatedBrightness&&g&&Math.abs(this._lastUpdatedBrightness-g)<.001||(this.updateBuckets(c,Q,void 0,H||R||F,P,j),this._lastUpdatedBrightness=g))}evaluateQueryRenderedFeaturePadding(){let x=0;for(const c in this.buckets){const h=this.buckets[c];h.evaluateQueryRenderedFeaturePadding&&(x=Math.max(x,h.evaluateQueryRenderedFeaturePadding()))}return x}queryRenderedFeatures(x,c,h,g,j,T,P){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};const R=this.evaluateQueryRenderedFeaturePadding(),F=function(H,Q){const se=q([],[.5*H.width,.5*-H.height,1]);return A(se,se,[1,-1,0]),C(se,se,H.calculateProjMatrix(Q.toUnwrapped())),Float32Array.from(se)}(j,this.tileID);return this.latestFeatureIndex.query(x,{tilespaceGeometry:c,pixelPosMatrix:F,transform:g,availableImages:h,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:R,scope:P})}querySourceFeatures(x,c){const h=this.latestFeatureIndex;if(!h||!h.rawTileData)return;const g=h.loadVTLayers(),j=c?c.sourceLayer:"",T=g._geojsonTileLayer||g[j];if(!T)return;const P=j3(c&&c.filter),{z:R,x:F,y:H}=this.tileID.canonical,Q={z:R,x:F,y:H};for(let se=0;seh)g=!1;else if(c)if(this.expirationTimeh.appearances&&h.appearances.length>0))return!0;return!1}updateBuckets(x,c,h,g,j,T){if(!this.latestFeatureIndex||!x.style)return;const P=T||x.style.listImages(),R=x.style.getBrightness(),F=j||new Set;for(const H in this.buckets){if(!x.style.hasLayer(H))continue;const Q=this.buckets[H],se=Q.layers[0],re=se.sourceLayer||"_geojsonTileLayer",oe=x.style.getLayerSourceCache(se),ue=Q.layers.some(it=>F.has(it.fqid)),_e=(g||ue)&&Q instanceof ag?x.style.getOwnLayer(H):void 0;let ke=h&&h[re]||{};oe&&!h&&(ke=oe._state.getState(re,void 0));const Pe=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},We=Object.keys(ke).length>0&&!c;Q.hasAppearances=Q.layers.some(it=>it.appearances&&it.appearances.length>0);const qe=We?Q.stateDependentLayers:Q.layers;if(We&&Q.stateDependentLayers.length!==0||c||ue||g){const it=this.latestFeatureIndex.loadVTLayers()[re];if(Q.update(ke,it,P,Pe,qe,c,R,this.tileID.canonical),(g||ue)&&!c&&Q instanceof ag&&_e&&_e.type==="symbol"){const ot=Q;ot.text&&ot.text.uboBinder&&ot.text.uboBinder.updateDynamicExpressions(_e,it,this.tileID.canonical,P,ke,R),ot.icon&&ot.icon.uboBinder&&ot.icon.uboBinder.updateDynamicExpressions(_e,it,this.tileID.canonical,P,ke,R)}if(Q instanceof ag){const ot=Q,It=x.context;ot.text&&ot.text.uboBinder&&ot.text.uboBinder.upload(It),ot.icon&&ot.icon.uboBinder&&ot.icon.uboBinder.upload(It)}}if(We&&Q.stateDependentLayers.length!==0||c||Q.hasAppearances){const it={zoom:x.transform.zoom,pitch:x.transform.pitch,brightness:x.style.getBrightness()||0,worldview:x.worldview},ot=Q.updateAppearances(this.tileID.canonical,ke,P,it,x.imageManager,We&&Q.stateDependentLayers.length!==0);if(ot&&ot.hasUboChanges){const It=x.context;Q instanceof ag&&Q.text&&Q.text.uboBinder&&Q.text.uboBinder.upload(It),Q instanceof ag&&Q.icon&&Q.icon.uboBinder&&Q.icon.uboBinder.upload(It)}}(Q instanceof x7||Q instanceof XF)&&x._terrain&&x._terrain.enabled&&oe&&Q.uploadPending()&&x._terrain._clearRenderCacheForTile(oe.id,this.tileID);const rt=x&&x.style&&x.style.getOwnLayer(H);rt&&(this.queryPadding=Math.max(this.queryPadding,rt.queryRadius(Q)||0))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;_e--){const ke=4*_e,Pe=p_[ke+0],We=p_[ke+1],qe=p_[ke+2],rt=p_[ke+3],it=Pe+qe>>1,ot=We+rt>>1,It=it+ot-We,wt=ot+Pe-it,At=We*vy+Pe,kt=rt*vy+qe,St=ot*vy+it,rs=Math.hypot((_y[2*At+0]+_y[2*kt+0])/2-_y[2*St+0],(_y[2*At+1]+_y[2*kt+1])/2-_y[2*St+1])>=16;f_[St]=f_[St]||(rs?1:0),_e<1022&&(f_[St]=f_[St]||f_[(We+wt>>1)*vy+(Pe+It>>1)]||f_[(rt+wt>>1)*vy+(qe+It>>1)])}const Q=new id,se=new Ao;let re=0;function oe(_e,ke){const Pe=ke*vy+_e;return O7[Pe]===0&&(Q.emplaceBack(_y[2*Pe+0],_y[2*Pe+1],_e*sr/qf,ke*sr/qf),O7[Pe]=++re),O7[Pe]-1}function ue(_e,ke,Pe,We,qe,rt){const it=_e+Pe>>1,ot=ke+We>>1;if(Math.abs(_e-qe)+Math.abs(ke-rt)>1&&f_[ot*vy+it])ue(qe,rt,_e,ke,it,ot),ue(Pe,We,qe,rt,it,ot);else{const It=oe(_e,ke),wt=oe(Pe,We),At=oe(qe,rt);se.emplaceBack(It,wt,At)}}return ue(0,0,qf,qf,qf,0),ue(qf,qf,0,0,0,qf),{vertices:Q,indices:se}}(this.tileID.canonical,c);g=T.vertices,j=T.indices}else{g=new id,j=new Ao;for(const{x:P,y:R}of h)g.emplaceBack(P,R,0,0);const T=F3(g.int16.subarray(0,4*g.length),void 0,4);for(let P=0;P0&&(P=S(new Float64Array(16),c.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(x,g,c,j,P,T),this._makeGlobeTileDebugTextBuffer(x,g,c,j,P,T)}_globePoint(x,c,h,g,j,T,P){let R=QP(x,c,h);if(T){const F=1<.5?re=-1:se<-.5&&(re=1);let oe=(x/sr+h.x)/F+re,ue=(c/sr+h.y)/F;oe=(oe-H)*g._pixelsPerMercatorPixel+H,ue=(ue-Q)*g._pixelsPerMercatorPixel+Q;const _e=[oe*g.worldSize,ue*g.worldSize,0];ct(_e,_e,T),R=rv(R,_e,P)}return ct(R,R,j)}_makeGlobeTileDebugBorderBuffer(x,c,h,g,j,T){const P=new yh,R=new ev,F=new zf,H=(se,re,oe,ue,_e)=>{const ke=(oe-se)/(_e-1),Pe=(ue-re)/(_e-1),We=P.length;for(let qe=0;qe<_e;qe++){const rt=se+qe*ke,it=re+qe*Pe;P.emplaceBack(rt,it);const ot=this._globePoint(rt,it,c,h,g,j,T);F.emplaceBack(ot[0],ot[1],ot[2]),R.emplaceBack(We+qe)}},Q=sr;H(0,0,Q,0,16),H(Q,0,Q,Q,16),H(Q,Q,0,Q,16),H(0,Q,0,0,16),this._tileDebugIndexBuffer=x.createIndexBuffer(R),this._tileDebugBuffer=x.createVertexBuffer(P,XP.members),this._globeTileDebugBorderBuffer=x.createVertexBuffer(F,x3e.members),this._tileDebugSegments=wi.simpleSegment(0,0,P.length,R.length)}_makeGlobeTileDebugTextBuffer(x,c,h,g,j,T){const P=new yh,R=new Ao,F=new zf,H=25;R.reserve(32),P.reserve(H),F.reserve(H);const Q=(se,re)=>H*se+re;for(let se=0;se1)return!1;const h=c.getSource().maxzoom,g=1<1)return c;const j=g.getSource().maxzoom,T=1<{const R=this.getAtTileOffset(x,j,T,P),F=g.upVector(x.canonical,j.x,j.y);return Ne(F,F,R*g.upVectorScale(x.canonical,c,h).metersToTile),F}}getForTilePoints(x,c,h,g){if(this.isUsingMockSource())return!1;const j=X3.create(this,x,g);return!!j&&(c.forEach(T=>{T[2]=this.exaggeration()*j.getElevationAt(T[0],T[1],h)}),!0)}getMinMaxForTile(x){if(this.isUsingMockSource())return null;const c=this.findDEMTileFor(x);if(!c||!c.dem)return null;const h=c.dem.tree,g=c.tileID,j=1<0&&(g+=(x[j]-0)*(x[j]-0)),c[j]<0&&(g+=(0-c[j])*(0-c[j]));return g},i.cL=function(x){return x*x*x*x*x},i.cM=Jt,i.cN=45,i.cO=D3,i.cP=function(x,c,h){const g=Math.sqrt(x*x+c*c+h*h),j=g>0?Math.acos(h/g)*Fn:0;let T=x!==0||c!==0?Math.atan2(-c,-x)*Fn+90:0;return T<0&&(T+=360),[g,T,j]},i.cQ=ae,i.cR=Zn,i.cS=Ts,i.cT=le,i.cU=Ja,i.cV=fe,i.cW=function(x){return[Math.pow(x[0],1/2.2),Math.pow(x[1],1/2.2),Math.pow(x[2],1/2.2)]},i.cX=U5e,i.cY=wfe,i.cZ=K5e,i.c_=exe,i.ca=2,i.cb=7,i.cc=6,i.cd=ye,i.ce=J,i.cf=Y,i.cg=0,i.ch=1,i.ci=4,i.cj=5,i.ck=O3,i.cl=vh,i.cm=H5e,i.cn=k2,i.co=_3e,i.cp=function(x,c,h,g,j,T,P,R,F){if(F.name==="globe")return _3e(x,c,new k2(h,g,j),!1);const H=P2({z:h,x:g,y:j},F);return new Ja([(T+H.x/H.scale)*c,c*(H.y/H.scale),P],[(T+H.x2/H.scale)*c,c*(H.y2/H.scale),R])},i.cq=function(x,c,h){return x[0]=Math.min(c[0],h[0]),x[1]=Math.min(c[1],h[1]),x[2]=Math.min(c[2],h[2]),x[3]=Math.min(c[3],h[3]),x},i.cr=function(x,c,h){return x[0]=Math.max(c[0],h[0]),x[1]=Math.max(c[1],h[1]),x[2]=Math.max(c[2],h[2]),x[3]=Math.max(c[3],h[3]),x},i.cs=function(x){const c=Math.round((x+45+360)%360/90)%4;return On[c]},i.ct=ds,i.cu=ut,i.cv=6,i.cw=function(x){const c=w(new Float64Array(16));C(c,x.pixelMatrix,x.globeMatrix);const h=[0,bt,0],g=[0,Dt,0];return ct(h,h,c),ct(g,g,c),[h[0]>0&&h[0]<=x.width&&h[1]>0&&h[1]<=x.height&&!Upe(x,new qt(x.center.lat,90)),g[0]>0&&g[0]<=x.width&&g[1]>0&&g[1]<=x.height&&!Upe(x,new qt(x.center.lat,-90))]},i.cx=function(x,c){const{scale:h}=x.tileTransform,g=h*sr/(x.tileSize*Math.pow(2,c.zoom-x.tileID.overscaledZ+x.tileID.canonical.z));return function(j,T,P){var R=T[1],F=T[2],H=T[3],Q=P[0],se=P[1];return j[0]=T[0]*Q,j[1]=R*Q,j[2]=F*se,j[3]=H*se,j}(new Float32Array(4),c.inverseAdjustmentMatrix,[g,g])},i.cy=d7,i.cz=Z,i.d=function(x){return oa.API_TILEJSON_REGEX.test(x)},i.d$=adt,i.d0=mo,i.d1=class{static calculate(x,c,h){const g=new Set,j=new Map,T=new Set,P=new Set;for(const F of Object.values(x))for(const[H,Q]of Object.entries(F.floors)){T.add(H),Q.isDefault&&P.add(H),Q.conflicts&&j.set(H,Q.conflicts);const se=H===c,re=Q.connections&&c&&Q.connections.has(c);(se||re)&&g.add(H)}const R=F=>{const H=j.get(F)||new Set;for(const Q of g)if((j.get(Q)||new Set).has(F)||H.has(Q))return!0;return!1};if(h)for(const F of h)T.has(F)&&(R(F)||g.add(F));for(const F of P)g.has(F)||R(F)||g.add(F);return g}},i.d2=b7,i.d3=$fe,i.d4=Pa,i.d5=function(){return{API_URL:oa.API_URL,DRACO_URL:oa.DRACO_URL,MESHOPT_URL:oa.MESHOPT_URL,MESHOPT_SIMD_URL:oa.MESHOPT_SIMD_URL,BUILDING_GEN_URL:oa.BUILDING_GEN_URL}},i.d6=bF,i.d7=P1,i.d8=jt,i.d9=lr,i.dA=qF,i.dB=yh,i.dC=Ao,i.dD=function(x,c){return[Math.pow(x[0],2.2)*c,Math.pow(x[1],2.2)*c,Math.pow(x[2],2.2)*c]},i.dE=f,i.dF=function(x,c){var h=Math.sin(c),g=Math.cos(c);return x[0]=g,x[1]=h,x[2]=0,x[3]=-h,x[4]=g,x[5]=0,x[6]=0,x[7]=0,x[8]=1,x},i.dG=pe,i.dH=w3e,i.dI=fi,i.dJ=Ki,i.dK=Qfe,i.dL=function(x,c){const h=[0,0,0];return ct(h,h,JP(fy(c.canonical))),ct(h,h,x),h},i.dM=x=>({u_matrix:new m(x),u_texsize:new Gm(x),u_pixels_to_tile_units:new D(x),u_device_pixel_ratio:new kl(x),u_width_scale:new kl(x),u_floor_width_scale:new kl(x),u_image:new j2(x),u_units_to_pixels:new Gm(x),u_tile_units_to_pixels:new kl(x),u_alpha_discard_threshold:new kl(x),u_trim_offset:new Gm(x),u_trim_fade_range:new Gm(x),u_trim_gradient_mix_range:new Gm(x),u_trim_color:new D3(x),u_zbias_factor:new kl(x),u_tile_to_meter:new kl(x),u_ground_shadow_factor:new N2(x),u_pattern_transition:new kl(x)}),i.dN=x=>({u_matrix:new m(x),u_pixels_to_tile_units:new D(x),u_device_pixel_ratio:new kl(x),u_width_scale:new kl(x),u_floor_width_scale:new kl(x),u_units_to_pixels:new Gm(x),u_dash_image:new j2(x),u_gradient_image:new j2(x),u_image_height:new kl(x),u_texsize:new Gm(x),u_tile_units_to_pixels:new kl(x),u_alpha_discard_threshold:new kl(x),u_trim_offset:new Gm(x),u_trim_fade_range:new Gm(x),u_trim_gradient_mix_range:new Gm(x),u_trim_color:new D3(x),u_zbias_factor:new kl(x),u_tile_to_meter:new kl(x),u_ground_shadow_factor:new N2(x)}),i.dO=x=>({u_camera_to_center_distance:new kl(x),u_extrude_scale:new D(x),u_device_pixel_ratio:new kl(x),u_matrix:new m(x),u_inv_rot_matrix:new m(x),u_merc_center:new Gm(x),u_tile_id:new N2(x),u_zoom_transition:new kl(x),u_up_dir:new N2(x),u_emissive_strength:new kl(x)}),i.dP=BP,i.dQ=nht,i.dR=class{constructor(x,c,h,g){this.context=x,this.format=g,this.size=h,this.texture=x.gl.createTexture();const[j,T,P]=this.size,{gl:R}=x;R.bindTexture(R.TEXTURE_3D,this.texture),x.pixelStoreUnpackFlipY.set(!1),x.pixelStoreUnpack.set(1),x.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in c&&c.data&&R.texImage3D(R.TEXTURE_3D,0,this.format,j,T,P,0,ffe(this.format),xfe(this.format),c.data)}bind(x,c){const{context:h}=this,{gl:g}=h;g.bindTexture(g.TEXTURE_3D,this.texture),x!==this.minFilter&&(g.texParameteri(g.TEXTURE_3D,g.TEXTURE_MAG_FILTER,x),g.texParameteri(g.TEXTURE_3D,g.TEXTURE_MIN_FILTER,x),this.minFilter=x),c!==this.wrapS&&(g.texParameteri(g.TEXTURE_3D,g.TEXTURE_WRAP_S,c),g.texParameteri(g.TEXTURE_3D,g.TEXTURE_WRAP_T,c),this.wrapS=c)}destroy(){const{gl:x}=this.context;x.deleteTexture(this.texture),this.texture=null}},i.dS=S3e,i.dT=(x,c,h,g,j,T)=>{const P=x.transform,R=P.projection.name==="globe";let F;if(T.paint.get("circle-pitch-alignment")==="map")if(R){const Q=w3e(P.zoom,c.canonical)*P._pixelsPerMercatorPixel;F=Float32Array.from([Q,0,0,Q])}else F=P.calculatePixelsToTileUnitsMatrix(h);else F=new Float32Array([P.pixelsToGLUnits[0],0,0,P.pixelsToGLUnits[1]]);const H={u_camera_to_center_distance:x.transform.getCameraToCenterDistance(P.projection),u_matrix:x.translatePosMatrix(c.projMatrix,h,T.paint.get("circle-translate"),T.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Gd.devicePixelRatio,u_extrude_scale:F,u_inv_rot_matrix:udt,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:T.paint.get("circle-emissive-strength")};if(R){H.u_inv_rot_matrix=g,H.u_merc_center=j,H.u_tile_id=[c.canonical.x,c.canonical.y,1<{const Q=x.transform,se=Q.pitch<15?oMe(.07,.7,De((14-Q.zoom)/5,0,1)):.07,re=h.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:cMe(x,c,h,g),u_texsize:c.imageAtlasTexture?c.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:Q.calculatePixelsToTileUnitsMatrix(c),u_device_pixel_ratio:j,u_width_scale:T,u_floor_width_scale:P,u_image:0,u_tile_units_to_pixels:lMe(c,Q),u_units_to_pixels:[1/Q.pixelsToGLUnits[0],1/Q.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:R,u_trim_fade_range:h.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:h.paint.get("line-trim-color").toPremultipliedRenderColor(re?null:h.lut).toArray01(),u_zbias_factor:se,u_tile_to_meter:Ts(c.tileID.canonical,0),u_ground_shadow_factor:F,u_pattern_transition:H}},i.dX=(x,c,h,g,j,T,P,R,F,H)=>{const Q=x.transform,se=Q.calculatePixelsToTileUnitsMatrix(c),re=h.paint.get("line-trim-color-use-theme").constantOr("default")==="none",oe=Q.pitch<15?oMe(.07,.7,De((14-Q.zoom)/5,0,1)):.07;return{u_matrix:cMe(x,c,h,g),u_pixels_to_tile_units:se,u_device_pixel_ratio:T,u_width_scale:P,u_floor_width_scale:R,u_units_to_pixels:[1/Q.pixelsToGLUnits[0],1/Q.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:j,u_texsize:uMe(h)&&c.lineAtlasTexture?c.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:lMe(c,x.transform),u_alpha_discard_threshold:0,u_trim_offset:F,u_trim_fade_range:h.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:h.paint.get("line-trim-color").toPremultipliedRenderColor(re?null:h.lut).toArray01(),u_zbias_factor:oe,u_tile_to_meter:Ts(c.tileID.canonical,0),u_ground_shadow_factor:H}},i.dY=Vt,i.dZ=eI,i.d_=as,i.da=function(x){const c=x.indexOf(h2);return c>=0?x.slice(0,c):x},i.db=function(x){return x.indexOf(h2)>=0},i.dc=function(x){const c=x.lastIndexOf(h2);return c>=0?x.slice(c+1):""},i.dd=function(x){const c=[],h=x.id;return h===void 0&&c.push({message:`layers.${h}: missing required property "id"`}),x.render===void 0&&c.push({message:`layers.${h}: missing required method "render"`}),x.renderingMode&&x.renderingMode!=="2d"&&x.renderingMode!=="3d"&&c.push({message:`layers.${h}: property "renderingMode" must be either "2d" or "3d"`}),c},i.de=function(x,c,h,g){return x.type==="custom"?new Xht(x,c):new smt[x.type](x,c,h,g)},i.df=ys,i.dg=j3,i.dh=TF,i.di=class extends L2{constructor(x,c){super(x._vectorTileFeature,x._z,x._x,x._y,x.id),x.state&&(this.state=Object.assign({},x.state)),this.target=c.target,this.namespace=c.namespace,c.properties&&(this.properties=c.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=x.source,this.sourceLayer=x.sourceLayer,this.layer=x.layer)}toJSON(){const x=super.toJSON();return x.target=this.target,x.namespace=this.namespace,x}},i.dj=NP,i.dk=function(x){return x({pluginStatus:Zd,pluginURL:Xh}),NP.on("pluginStateChange",x),x},i.dl=Fpe,i.dm=class extends Hm{constructor(x){super(x),this.current=v}set(x,c,h){if(this.fetchUniformLocation(x,c)){for(let g=0;g<9;g++)if(h[g]!==this.current[g]){this.current=h,this.gl.uniformMatrix3fv(this.location,!1,h);break}}}},i.dn=ua,i.dp=function(x,c,h){const g=nv(h.zoom),j=x.style.map._antialias,T=x.terrain&&x.terrain.exaggeration()>0;return g===0&&!j&&!T},i.dq=function(x){const c=x.pixelsPerMeter,h=c/Zt(1,x.center.lat),g=w(new Float64Array(16));return A(g,g,[x.point.x,x.point.y,0]),I(g,g,[h,h,c]),Float32Array.from(g)},i.dr=UF,i.ds=function(x){const c=80.051129;x=De(x,-80.051129,c)/c*90;const h=Math.pow(Math.abs(Math.sin(Kt(x))),3);return Math.round(h*(zt.length-1))},i.dt=function(x,c,h,g){const j=c.getNorth(),T=c.getSouth(),P=c.getWest(),R=c.getEast(),F=1<0){const ue=180/g;_(oe,oe,[ue/H+1,0,0,0,ue/Q+1,0,-.5*ue/se,.5*ue/re,1])}return oe[2]=F,oe[5]=x.x,oe[8]=x.y,oe},i.du=JP,i.dv=fy,i.dw=function(x,c,h){const g=w(new Float64Array(16)),j=(c/(1<0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(x,c=!1){const h=i5e(new Xt(0,0),new Xt(sr,sr),x),g=[];if(c&&!nfe(h,this._globalClipBounds))return g;for(const j of this._activeRegions){if(j.hiddenByOverlap||!nfe(h,j))continue;const T=Wdt(j.min,j.max,x);g.push({min:T.min,max:T.max,sourceId:this._sourceIds[j.priority],footprint:j.footprint,footprintTileId:j.tileId,order:j.order,clipMask:j.clipMask,clipScope:j.clipScope})}return g}setSources(x){this._setSources(x.map(c=>({getSourceId:()=>c.cache.id,getFootprints:()=>{const h=[];for(const g of c.cache.getVisibleCoordinates()){const j=c.cache.getTile(g).buckets[c.layer];j&&j.updateFootprints(g.toUnwrapped(),h)}return h},getOrder:()=>c.order,getClipMask:()=>c.clipMask,getClipScope:()=>c.clipScope})))}_addSource(x){const c=x.getFootprints();if(c.length===0)return;const h=x.getOrder(),g=x.getClipMask(),j=x.getClipScope();for(const T of c){if(!T.footprint)continue;const P=i5e(T.footprint.min,T.footprint.max,T.id);this._activeRegions.push({min:P.min,max:P.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:T.id,footprint:T.footprint,order:h,clipMask:g,clipScope:j})}this._sourceIds.push(x.getSourceId())}_computeReplacement(){this._activeRegions.sort((c,h)=>c.priority-h.priority||JF(c.min,h.min)||JF(c.max,h.max)||c.order-h.order||c.clipMask-h.clipMask||function(g,j){const T=(P,R)=>P+R;return g.length-j.length||g.reduce(T,"").localeCompare(j.reduce(T,""))}(c.clipScope,h.clipScope));let x=this._activeRegions.length!==this._prevRegions.length;if(!x){let c=0;for(;!x&&c!==this._activeRegions.length;){const h=this._activeRegions[c],g=this._prevRegions[c];x=h.priority!==g.priority||!a5e(h,g)||h.order!==g.order||h.clipMask!==g.clipMask||!Qa(h.clipScope,g.clipScope),this._activeRegions[c].hiddenByOverlap=g.hiddenByOverlap,++c}}if(x){++this._updateTime;for(const h of this._activeRegions)h.order!==lI&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,h.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,h.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,h.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,h.max.y));const c=h=>{const g=this._activeRegions;if(h>=g.length)return h;const j=g[h].priority;for(;h1){let h=0,g=c(h);for(;h!==g;){let j=h;const T=h;for(;j!==g;){const P=this._activeRegions[j];P.hiddenByOverlap=!1;for(let R=0;R=0;c--)this._addSource(x[c]);this._computeReplacement()}},i.eH=id,i.eI=P7,i.eJ=ev,i.eK=lI,i.eL=class{constructor(x){this._createGrid(x),this._createPoles(x)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const x of this._poleSegments)x.destroy();for(const x of this._gridSegments)x.withSkirts.destroy(),x.withoutSkirts.destroy()}_fillGridMeshWithLods(x,c){const h=new yh,g=new Ao,j=[],T=x+1+2,P=c[0]+1,R=c[0]+1+(1+c.length),F=(H,Q,se)=>{let re=H===T-1?H-2:H===0?H:H-1;return re+=se?24575:0,[re,Q]};for(let H=0;H>>=0,x=Math.imul(2747636419^x,2654435769)>>>0,x=Math.imul(x^x>>>16,2654435769)>>>0,(x=Math.imul(x^x>>>16,2654435769)>>>0)/4294967296},i.ec=y3e,i.ed=$pe,i.ee=Um,i.ef=O,i.eg=function(x,c){return x[0]=c[0],x[1]=c[1],x[2]=c[2],x[3]=c[4],x[4]=c[5],x[5]=c[6],x[6]=c[8],x[7]=c[9],x[8]=c[10],x},i.eh=Q0,i.ei=y2,i.ej=function(x,c,h,g,j){return De((x-c)/(h-c)*(j-g)+g,g,j)},i.ek=Mt,i.el=function(x,c){var h=c[0],g=c[1],j=c[2],T=c[3],P=c[4],R=c[5],F=c[6],H=c[7],Q=c[8],se=Q*P-R*H,re=-Q*T+R*F,oe=H*T-P*F,ue=h*se+g*re+j*oe;return ue?(x[0]=se*(ue=1/ue),x[1]=(-Q*g+j*H)*ue,x[2]=(R*g-j*P)*ue,x[3]=re*ue,x[4]=(Q*h-j*F)*ue,x[5]=(-R*h+j*T)*ue,x[6]=oe*ue,x[7]=(-H*h+g*F)*ue,x[8]=(P*h-g*T)*ue,x):null},i.em=rF,i.en=2,i.eo=Ee,i.ep=Ke,i.eq=V,i.er=function(x,c){var h=new u(3);V(h,c);var g=1/h[0],j=1/h[1],T=1/h[2],P=c[0]*g,R=c[1]*j,F=c[2]*T,H=c[4]*g,Q=c[5]*j,se=c[6]*T,re=c[8]*g,oe=c[9]*j,ue=c[10]*T,_e=P+Q+ue,ke=0;return _e>0?(ke=2*Math.sqrt(_e+1),x[3]=.25*ke,x[0]=(se-oe)/ke,x[1]=(re-F)/ke,x[2]=(R-H)/ke):P>Q&&P>ue?(ke=2*Math.sqrt(1+P-Q-ue),x[3]=(se-oe)/ke,x[0]=.25*ke,x[1]=(R+H)/ke,x[2]=(re+F)/ke):Q>ue?(ke=2*Math.sqrt(1+Q-P-ue),x[3]=(re-F)/ke,x[0]=(R+H)/ke,x[1]=.25*ke,x[2]=(se+oe)/ke):(ke=2*Math.sqrt(1+ue-P-Q),x[3]=(R-H)/ke,x[0]=(re+F)/ke,x[1]=(se+oe)/ke,x[2]=.25*ke),x},i.es=function(x,c){var h=2*Math.acos(c[3]),g=Math.sin(h/2);return g>d?(x[0]=c[0]/g,x[1]=c[1]/g,x[2]=c[2]/g):(x[0]=1,x[1]=0,x[2]=0),h},i.et=rxe,i.eu=m7,i.ev=h7,i.ew=[1,1,1],i.ex=X3,i.ey=function(x,c,h,g){var j=c[0],T=c[1],P=c[2],R=c[3];return x[0]=j+g*(h[0]-j),x[1]=T+g*(h[1]-T),x[2]=P+g*(h[2]-P),x[3]=R+g*(h[3]-R),x},i.ez=U3,i.f=Hd,i.f0=N3e,i.f1=function(x){const c=[0,0,0],h=w(new Float64Array(16));return C(h,x.pixelMatrix,x.globeMatrix),ct(c,c,h),new Xt(c[0],c[1])},i.f2=kP,i.f3=function(x,c,h=!1){if(Zd===gh.deferred||Zd===gh.loading||Zd===gh.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Xh=Gd.resolveURL(x),Zd=gh.deferred,Ff=c,jP(),h||wF()},i.f4=Bl,i.f5=Cc,i.f6=Jo,i.f7=function(x){const c=FC();if(!c)return;const h=c.delete(Ux);x&&h.then(()=>x()).catch(x)},i.f8=gr,i.f9=l_,i.fA=ln,i.fB=function(x){let c=0;if(new Uint32Array(x,0,1)[0]!==F5e){const h=new Uint32Array(x,0,7),[,,g,j,T,P]=h;c=h.byteLength+j+T+P+T,(g!==x.byteLength||c>=x.byteLength)&&zr("Invalid b3dm header information.")}return q5e(x,c)},i.fC=function(x,c){const h=wfe(x);for(const g of h){for(const j of g.meshes)Nut(j);g.lights&&(g.lightMeshIndex=g.meshes.length,g.meshes.push(kut(g.lights,c)))}return h},i.fD=R7,i.fE=vi,i.fF=Qx,i.fG=gh,i.fH=function(x){P0(),Wd!=null&&Wd.then(c=>{c.keys().then(h=>{for(let g=0;gzr(j.message))}).catch(h=>zr(h.message))}).catch(c=>zr(c.message))},i.fa=2,i.fb=Zx,i.fc=P2,i.fd=GP,i.fe=MTe,i.ff=TTe,i.fg=rMe,i.fh=Ln,i.fi="hd_road_elevation",i.fj=Ci,i.fk=Es,i.fl=XF,i.fm=av,i.fn=zfe,i.fo=1,i.fp=ag,i.fq=function(x,c,h,g,j,T,P,R=1,F,H,Q,se){x.createArrays(),x.tilePixelRatio=sr/(512*x.overscaling),x.compareText={},x.iconsNeedLinear=!1;const re=x.layers[0].layout,oe=x.layers[0]._unevaluatedLayout._values,ue={};ue.scaleFactor=R,ue.textSizeScaleRange=re.get("text-size-scale-range"),ue.iconSizeScaleRange=re.get("icon-size-scale-range");const[_e,ke]=ue.textSizeScaleRange,[Pe,We]=ue.iconSizeScaleRange;ue.textScaleFactor=De(ue.scaleFactor,_e,ke),ue.iconScaleFactor=De(ue.scaleFactor,Pe,We);const qe=oe["text-size"],rt=oe["icon-size"];if(x.textSizeData.kind==="composite"){const{minZoom:kt,maxZoom:St}=x.textSizeData;ue.compositeTextSizes=[qe.possiblyEvaluate(new Ga(kt,{worldview:Q}),T),qe.possiblyEvaluate(new Ga(St,{worldview:Q}),T)]}if(x.iconSizeData.kind==="composite"){const{minZoom:kt,maxZoom:St}=x.iconSizeData;ue.compositeIconSizes=[rt.possiblyEvaluate(new Ga(kt,{worldview:Q}),T,se),rt.possiblyEvaluate(new Ga(St,{worldview:Q}),T,se)]}ue.layoutTextSize=qe.possiblyEvaluate(new Ga(P+1,{worldview:Q}),T),ue.layoutIconSize=rt.possiblyEvaluate(new Ga(P+1,{worldview:Q}),T,se),ue.textMaxSize=qe.possiblyEvaluate(new Ga(18,{worldview:Q}),T);const it=re.get("symbol-placement"),ot=re.get("text-rotation-alignment")==="map"&&it!=="point",It=re.get("text-size");let wt=!1;const At=[];for(const kt of x.features){const St=re.get("text-font").evaluate(kt,{},T).join(","),rs=It.evaluate(kt,{},T)*ue.textScaleFactor,is=ue.layoutTextSize.evaluate(kt,{},T)*ue.textScaleFactor,us=ue.layoutIconSize.evaluate(kt,{},T,se)*ue.iconScaleFactor,ws={horizontal:{},vertical:void 0},hs=kt.text;let Ds,ts=[0,0];if(hs){const Un=hs.toString(),po=re.get("text-letter-spacing").evaluate(kt,{},T)*ic,Wa=re.get("text-line-height").evaluate(kt,{},T)*ic,Ia=Npe(Un)?po:0,ki=re.get("text-anchor").evaluate(kt,{},T),io=re.get("text-variable-anchor");if(!io){const Po=re.get("text-radial-offset").evaluate(kt,{},T);if(Po)ts=qMe(ki,[Po*ic,Ufe]);else{const ld=re.get("text-offset").evaluate(kt,{},T);ts=[ld[0]*ic,ld[1]*ic]}}let oc=ot?"center":re.get("text-justify").evaluate(kt,{},T);const oo=it==="point",Eo=oo?re.get("text-max-width").evaluate(kt,{},T)*ic:1/0,el=Po=>{x.allowVerticalPlacement&&_P(Un)&&(ws.vertical=Pfe(hs,c,h,j,St,Eo,Wa,ki,Po,Ia,ts,nm.vertical,!0,is,rs,F,ue.textScaleFactor))};if(!ot&&io){const Po=oc==="auto"?io.map(lc=>Vfe(lc)):[oc];let ld=!1;for(let lc=0;lc=0||!_P(Un)){const Po=Pfe(hs,c,h,j,St,Eo,Wa,ki,oc,Ia,ts,nm.horizontal,!1,is,rs,F,ue.textScaleFactor);Po&&(ws.horizontal[oc]=Po)}el(oo?"left":oc)}}let vs,Ms,Rs,Ks,fr,er,Js=!1;const Zs=re.get("icon-text-fit").evaluate(kt,{},T);if(kt.icon&&kt.icon.hasPrimary()){const Un=jI(kt.icon,x.iconSizeData,oe["icon-size"],T,x.zoom,kt,F,ue.iconScaleFactor,Q,se);vs=Un.iconPrimary,Rs=Un.iconSecondary;const po=vs.toString();if(Ms=g.get(po),Ms&&(fr=re.get("icon-offset").evaluate(kt,{},T),er=re.get("icon-anchor").evaluate(kt,{},T),Ds=v7(j.get(po),Rs?j.get(Rs.toString()):void 0,fr,er),Js=Ms.sdf,x.sdfIcons===void 0?x.sdfIcons=Ms.sdf:x.sdfIcons!==Ms.sdf&&zr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Ms.pixelRatio!==x.pixelRatio||re.get("icon-rotate").constantOr(1)!==0)&&(x.iconsNeedLinear=!0)),Rs){const Wa=Rs.toString();Ks=g.get(Wa)}}wt=wt||!(!kt.icon||!kt.icon.hasSecondary());const dr=S7(ws.horizontal)||ws.vertical;x.iconsInText||(x.iconsInText=!!dr&&dr.iconsInText);const jr=is*ue.textScaleFactor/ic,{defaultShapedIcon:$r,verticallyShapedIcon:Pr}=Dht(x,Ds,re,kt,T,ws,jr,fr,Zs);Zs!=="none"&&Ds&&(NMe(Ds)||kMe(Ds))&&(k7(0,Ms,vs,Ds,$r,Zs,H,g,j),k7(0,Ks,Rs,Ds,$r,Zs,H,g,j),Pr&&(k7(0,Ms,vs,Ds,Pr,Zs,H,g,j),k7(0,Ks,Rs,Ds,Pr,Zs,H,g,j))),Ds=$r;const{iconBBox:kn,iconVerticalBBox:ba,textBBox:Sn,textVerticalBBox:ka}=Aht(x,Ds,Pr,re,kt,T,us,fr,ue,j,er,ws,is,ts,se);At.push({feature:kt,shapedTextOrientations:ws,shapedText:dr,shapedIcon:Ds,iconPrimary:vs,iconSecondary:Rs,iconOffset:fr,iconAnchor:er,verticallyShapedIcon:Pr,layoutTextSize:is,layoutIconSize:us,textOffset:ts,isSDFIcon:Js,iconTextFit:Zs,iconCollisionBounds:kn,iconVerticalCollisionBounds:ba,textCollisionBounds:Sn,textVerticalCollisionBounds:ka})}return{featureData:At,sizes:ue,hasAnySecondaryIcon:wt,textAlongLine:ot,symbolPlacement:it}},i.fr=Bfe,i.fs=Ffe,i.ft=LMe,i.fu=DMe,i.fv=function(x,c,h,g,j,T,P,R,F,H){x.iconAtlasPositions=H.iconPositions;const{featureData:Q,hasAnySecondaryIcon:se,sizes:re,textAlongLine:oe,symbolPlacement:ue}=c;for(const _e of Q){const{shapedIcon:ke,verticallyShapedIcon:Pe,feature:We,shapedTextOrientations:qe,shapedText:rt,layoutTextSize:it,textOffset:ot,isSDFIcon:It,iconPrimary:wt,iconSecondary:At,iconTextFit:kt,iconOffset:St,iconCollisionBounds:rs,iconVerticalCollisionBounds:is,textCollisionBounds:us}=_e;GMe(ke,H.iconPositions,wt,At),GMe(Pe,H.iconPositions,wt,At),Lht(qe,H.iconPositions),Iht(wt,At,H.iconPositions),(rt||ke)&&Rht(x,We,qe,ke,Pe,F,re,it,0,ot,It,g,j,P,R,se,kt,St,oe,ue,rs,is,us)}h&&x.generateCollisionDebugBuffers(T,x.collisionBoxArray,re.textScaleFactor)},i.fw=x7,i.fx=Fa,i.fy=function(x){return x<=1?1:Math.pow(2,Math.floor(Math.log2(x)))},i.fz=q7,i.g=oa,i.h=function(x,c){return Hx(Object.assign(x,{method:"GET"}),c)},i.i=function(x){return oa.API_STYLE_REGEX.test(x)&&!vu(x)},i.j=function(x){return btoa(encodeURIComponent(x).replace(/%([0-9A-F]{2})/g,(c,h)=>String.fromCharCode(+("0x"+h))))},i.k=Vx,i.l=function(x){return decodeURIComponent(atob(x).split("").map(c=>"%"+("00"+c.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(x,c){return Hx(Object.assign(x,{type:"json"}),c)},i.n=Cp,i.o=Gd,i.p=function(x,c){return Hx(Object.assign(x,{method:"POST"}),c)},i.q=Md,i.r=Yt,i.s=function(x){try{const c=self[x];return c.setItem("_mapbox_test_",1),c.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=_t,i.u=function(){return function x(c){return c?(c^Math.random()*(16>>c/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,x)}()},i.v=function(x){return!!x&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(x)},i.w=zr,i.x=class{constructor(x){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(x&&x.maxTextureMemoryMB?x.maxTextureMemoryMB:256)*1024,this.finalizationRegistry=new FinalizationRegistry(c=>{this.cache.delete(c),this.clearExpiredTextures()})}calculateTextureMemory(x){return x.image?Math.ceil(x.image.width*x.image.height*4*(x.patternPositions.size>0?1.33:1)):0}evictTexture(x){const c=this.textures.get(x);if(c){const h=this.calculateTextureMemory(x);c.destroy(),this.textures.delete(x),this.textureAccessTimes.delete(x),this.textureMemoryUsed-=h}}evictTexturesIfNeeded(x){for(;this.textureMemoryUsed+x>this.maxTextureMemory&&this.textures.size>0;){let c=null,h=1/0;for(const[g]of this.textures.entries()){const j=this.textureAccessTimes.get(g)||0;jthis._layers[lr.id]),Yt=Pt[0];if(Yt.visibility==="none")continue;const Vt=Yt.source||"";let Qt=this.familiesBySource[Vt];Qt||(Qt=this.familiesBySource[Vt]=Object.create(null));const Es=Yt.sourceLayer||"_geojsonTileLayer";let ys=Qt[Es];ys||(ys=Qt[Es]=[]),ys.push(Pt)}}}const b=1*d.fa;class N{constructor(Se){const De={},Ze=[];for(const Yt in Se){const Vt=Se[Yt],Qt=De[Yt]={};for(const Es in Vt.glyphs){const ys=Vt.glyphs[+Es];if(!ys||ys.bitmap.width===0||ys.bitmap.height===0)continue;const lr=ys.metrics.localGlyph?b:1,Fr={x:0,y:0,w:ys.bitmap.width+2*lr,h:ys.bitmap.height+2*lr};Ze.push(Fr),Qt[Es]=Fr}}const{w:xt,h:_t}=d.J(Ze),Pt=new d.f9({width:xt||1,height:_t||1});for(const Yt in Se){const Vt=Se[Yt];for(const Qt in Vt.glyphs){const Es=Vt.glyphs[+Qt];if(!Es||Es.bitmap.width===0||Es.bitmap.height===0)continue;const ys=De[Yt][Qt],lr=Es.metrics.localGlyph?b:1;d.f9.copy(Es.bitmap,Pt,{x:0,y:0},{x:ys.x+lr,y:ys.y+lr},Es.bitmap)}}this.image=Pt,this.positions=De}}function w($t,Se,De){$t[Se]?De&&($t[Se].center=De):$t[Se]={floorIds:new Set,center:De||[0,0],floors:{}}}function S($t,Se,De,Ze){for(const xt of Se)w($t,xt),$t[xt].floors[De]=Ze,$t[xt].floorIds.add(De)}function C($t){return{id:$t.properties.id.toString(),center:[$t.properties.center_lon||0,$t.properties.center_lat||0]}}function A($t,Se){const De=$t.properties.id.toString(),Ze=!!$t.properties.is_default&&$t.properties.is_default,xt=$t.properties.connected_floor_ids?new Set($t.properties.connected_floor_ids.toString().split(";")):new Set,_t=$t.properties.conflicted_floor_ids?new Set($t.properties.conflicted_floor_ids.toString().split(";")):new Set,Pt=$t.properties.structure_ids?new Set($t.properties.structure_ids.toString().split(";")):new Set,Yt=$t.properties.name.toString(),Vt=$t.properties.z_index,Qt=function(Es,ys){const lr=Es.loadGeometry();if(!lr||lr.length===0)return;const Fr=lr.map(Br=>Br.map(zr=>d.fb(zr,ys,Es.extent)));return Fr.length===0?void 0:{type:"Polygon",coordinates:[Fr[0]]}}($t,Se);return{id:De,isDefault:Ze,connections:xt,conflicts:_t,buildings:Pt,name:Yt,zIndex:Vt,geometry:Qt}}function I($t,Se){return Se.every(De=>$t.properties&&$t.properties[De]!=null)}function L($t){return I($t,["type","id","name"])&&$t.properties.type==="structure"}function O($t){return I($t,["type","id","name","z_index"])&&$t.properties.type==="floor"}d.f8(N,"GlyphAtlas");class U{constructor(Se){this.tileID=new d.aR(Se.tileID.overscaledZ,Se.tileID.wrap,Se.tileID.canonical.z,Se.tileID.canonical.x,Se.tileID.canonical.y),this.tileZoom=Se.tileZoom,this.uid=Se.uid,this.zoom=Se.zoom,this.lut=Se.lut,this.canonical=Se.tileID.canonical,this.pixelRatio=Se.pixelRatio,this.tileSize=Se.tileSize,this.source=Se.source,this.scope=Se.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=Se.showCollisionBoxes,this.collectResourceTiming=!!Se.request&&Se.request.collectResourceTiming,this.promoteId=Se.promoteId,this.renderSourceType=Se.renderSourceType,this.tileTransform=d.fc(Se.tileID.canonical,Se.projection),this.projection=Se.projection,this.worldview=Se.worldview,this.localizableLayerIds=Se.localizableLayerIds,this.brightness=Se.brightness,this.extraShadowCaster=!!Se.extraShadowCaster,this.tessellationStep=Se.tessellationStep,this.scaleFactor=Se.scaleFactor,this.worldview=Se.worldview,this.indoor=Se.indoor}parse(Se,De,Ze,xt,_t,Pt){this.status="parsing",this.data=Se,this.collisionBoxArray=new d.fd;const Yt=new d.fe(Object.keys(Se.layers).sort()),Vt=new d.ff(this.tileID,this.promoteId);Vt.bucketLayerIDs=[];const Qt={},Es=new d.fg(256,256),ys={featureIndex:Vt,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Es,availableImages:Ze,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&(ys.activeFloors=function(zr,un,Vn,Zn){const vi=un.indoorState.activeFloorsVisible;if(!un.sourceLayers)return vi?un.indoorState.activeFloors:void 0;const To=function(ai,zi){if(!ai)return d.w("No source layers defined in indoor specification"),zi;if(ai.size===0)return zi;const Qo=ai.difference(zi);for(const fi of Qo)d.w(`Missing source layer required in indoor specification: ${fi}`);return zi.intersection(zi)}(un.sourceLayers,new Set(Object.keys(zr.layers))),Ha=un.indoorState,no=function(ai,zi,Qo,fi,Ki){const Bi={};for(const oa of zi){const Jo=ai.layers[oa];if(Jo)for(let Cc=0;Cc=fi.maxzoom||fi.visibility==="none")continue;q(Qo,this.zoom,ys.brightness,Ze,this.worldview,ys.activeFloors);const Ki=Qt[fi.id]=fi.createBucket({index:Vt.bucketLayerIDs.length,layers:Qo,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ha,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:xt,worldview:this.worldview,localizable:ai,availableImages:Ze,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});Vt.bucketLayerIDs.push(Qo.map(oa=>d.F(oa.id,oa.scope)));let Bi=Ki.prepare?Ki.prepare():null;Bi!=null?(Bi=Bi.then(()=>Ki.populate(no,ys,this.tileID.canonical,this.tileTransform)),lr.push(Bi)):Ki.populate(no,ys,this.tileID.canonical,this.tileTransform)}}const Br=()=>{Es.trim();const zr=!(!ys.elevationFeatures||!ys.elevationFeatures.some(fi=>fi.heightRange.min<0));let un,Vn,Zn,vi,To,Ha,no;const ai={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},zi=()=>{if(un)return this.status="done",Pt(un);if(this.extraShadowCaster)this.status="done",Pt(null,{buckets:Object.values(Qt).filter(fi=>!fi.isEmpty()),featureIndex:Vt,collisionBoxArray:null,hasTunnelGeometry:zr,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:ys.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Vn&&Zn&&vi&&no){const Ki=new N(Vn),Bi=new Map;for(const[Cc,Bl]of Zn.entries()){const{imagePosition:Hd}=d.fn(Cc,Bl,d.fo);Bi.set(Cc,Hd)}const oa={};for(const Cc in Qt){const Bl=Qt[Cc];Bl instanceof d.fp&&(q(Bl.layers,this.zoom,ys.brightness,Ze,this.worldview,ys.activeFloors),oa[Cc]=d.fq(Bl,Vn,Ki.positions,Zn,Bi,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,To,this.worldview,Ze))}const Jo={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(_t,Zn,To,()=>{Jo.iconsPending=!1,Qo(oa,Ki,Jo,void 0,no)}),this.rasterizeIfNeeded(_t,vi,Ha,()=>{Jo.patternsPending=!1,Qo(oa,Ki,Jo,void 0,no)})}},Qo=(fi,Ki,Bi,oa,Jo)=>{if(Bi.iconsPending||Bi.patternsPending)return;const Cc=Zn.size>0||vi.size>0,Bl=Object.keys(fi).length>0;if(!Cc&&!Bl)return this.status="done",void Pt(null,{buckets:Object.values(Qt).filter(vu=>!vu.isEmpty()),featureIndex:Vt,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:zr,glyphAtlasImage:Ki.image,lineAtlas:Es,imageAtlas:null,brightness:ys.brightness});const Hd=(vu,Rm)=>{for(const Nd in Qt){const _u=Qt[Nd];if(Nd in fi)d.fv(_u,fi[Nd],this.showCollisionBoxes,Ze,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,Zn,Rm);else if(_u.hasPattern&&(_u instanceof d.fw||_u instanceof d.fl||_u instanceof d.e0)){q(_u.layers,this.zoom,ys.brightness,Ze,this.worldview,ys.activeFloors);const Om=Object.fromEntries(Rm.patternPositions);_u.addFeatures(ys,this.tileID.canonical,Om,Ze,this.tileTransform,this.brightness)}}this.status="done",Pt(null,{buckets:Object.values(Qt).filter(Nd=>!Nd.isEmpty()),featureIndex:Vt,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:zr,glyphAtlasImage:Ki.image,lineAtlas:Es,imageAtlas:vu,brightness:ys.brightness})};if(Cc){const vu=new Map,Rm=d.fr(Zn,vu),Nd=d.fr(vi,vu),_u=new d.fs(Rm,Nd,Jo,this.lut,vu);_t.send("checkAtlasCache",{descriptor:_u,scope:this.scope},(Om,Vu)=>{let Fm,xh;if(Om&&d.w(`[Worker] Error checking atlas cache: ${Om.message}`),Vu)Fm=new d.ft(Vu.sourceHash),xh=Vu;else{const Gd=new d.fu(Zn,vi,this.lut,Jo);Fm=Gd,xh=Gd}Hd(Fm,xh)})}else Hd(null,{iconPositions:new Map,patternPositions:new Map})};if(!this.extraShadowCaster){const fi=d.fk(ys.glyphDependencies,oa=>Object.keys(oa).map(Number));Object.keys(fi).length?_t.send("getGlyphs",{uid:this.uid,stacks:fi},(oa,Jo)=>{un||(un=oa,Vn=Jo,zi())},void 0,!1,ai):Vn={},no=new Map;const Ki=Array.from(ys.iconDependencies.keys()).map(oa=>d.I.parse(oa));Ki.length?_t.send("getImages",{images:Ki,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(oa,Jo)=>{if(!un){un=oa,Zn=new Map,To=this.updateImageMapAndGetImageTaskQueue(Zn,Jo.images,ys.iconDependencies);for(const[Cc,Bl]of Jo.versions.entries())no.set(Cc,Bl);zi()}},void 0,!1,ai):(Zn=new Map,To=new Map);const Bi=Array.from(ys.patternDependencies.keys()).map(oa=>d.I.parse(oa));Bi.length?_t.send("getImages",{images:Bi,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(oa,Jo)=>{if(!un){un=oa,vi=new Map,Ha=this.updateImageMapAndGetImageTaskQueue(vi,Jo.images,ys.patternDependencies);for(const[Cc,Bl]of Jo.versions.entries())no.set(Cc,Bl);zi()}},void 0,!1,ai):(vi=new Map,Ha=new Map)}if(ys.elevationFeatures&&ys.elevationFeatures.length>0){const fi=[];for(const Bi of Object.values(Qt))if(Bi instanceof d.fl){const oa=Bi.getUnevaluatedPortalGraph();oa&&fi.push(oa)}const Ki=d.fm.evaluate(fi);for(const Bi of Object.values(Qt))if(Bi instanceof d.fl){const oa=Se.layers[Yt.decode(Bi.sourceLayerIndex)];Bi.setEvaluatedPortalGraph(Ki,oa,this.tileID.canonical,ys.availableImages,ys.brightness)}}zi()};lr.length>0?Promise.allSettled(lr).then(Br).catch(Pt):Br()}updateParameters(Se){this.scaleFactor=Se.scaleFactor,this.showCollisionBoxes=Se.showCollisionBoxes,this.projection=Se.projection,this.brightness=Se.brightness,this.tileTransform=d.fc(Se.tileID.canonical,Se.projection),this.extraShadowCaster=Se.extraShadowCaster,this.lut=Se.lut,this.worldview=Se.worldview,this.indoor=Se.indoor}rasterizeIfNeeded(Se,De,Ze,xt){Array.from(De.values()).some(_t=>_t.usvg)?this.rasterize(Se,De,Ze,xt):xt()}updateImageMapAndGetImageTaskQueue(Se,De,Ze){const xt=new Map;for(const _t of De.keys()){const Pt=Ze.get(_t)||[];for(const Yt of Pt){const Vt=Yt.toString(),Qt=De.get(Yt.id.toString());Qt.usvg?xt.has(Vt)||(xt.set(Vt,Yt),Se.set(Vt,Object.assign({},Qt))):Se.set(Vt,Qt)}}return xt}rasterize(Se,De,Ze,xt){this.rasterizeTask=Se.send("rasterizeImages",{scope:this.scope,tasks:Ze},(_t,Pt)=>{if(!_t)for(const[Yt,Vt]of Pt.entries()){const Qt=Object.assign(De.get(Yt),{data:Vt});De.set(Yt,Qt)}xt()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function q($t,Se,De,Ze,xt,_t){const Pt=new d.ae(Se,{brightness:De,worldview:xt,activeFloors:_t});for(const Yt of $t)Yt.recalculate(Pt,Ze)}class $ extends d.E{constructor({actor:Se,layerIndex:De,availableImages:Ze,availableModels:xt,isSpriteLoaded:_t,tileProvider:Pt,brightness:Yt,maxUniformBufferBindings:Vt,maxUniformBlockSizeDwords:Qt,disableSymbolUBO:Es}){super(),this.actor=Se,this.layerIndex=De,this.availableImages=Ze,this.availableModels=xt,this.loadVectorData=d.aO,this.tileProvider=Pt,this.loading={},this.loaded={},this.deduped=new d.aN(Se.scheduler),this.isSpriteLoaded=_t,this.scheduler=Se.scheduler,this.brightness=Yt,this.maxUniformBufferBindings=Vt,this.maxUniformBlockSizeDwords=Qt,this.disableSymbolUBO=Es}loadTileData(Se,De){if(!this.tileProvider)return this.loadVectorData(Se,De);const Ze=new AbortController,{z:xt,x:_t,y:Pt}=Se.tileID.canonical;return this.tileProvider.loadTile({z:xt,x:_t,y:Pt},{request:Se.request,signal:Ze.signal}).then(Yt=>{if(Ze.signal.aborted)return;if(Yt==null){const Qt=new Error("Tile not found");return Qt.status=404,De(Qt)}if(Yt.data===null)return De(null,null);const Vt=new Map;Yt.expires&&Vt.set("expires",Yt.expires),Yt.cacheControl&&Vt.set("cache-control",Yt.cacheControl),De(null,{rawData:Yt.data,responseHeaders:Vt})}).catch(Yt=>{Ze.signal.aborted||De(Yt instanceof Error?Yt:new Error(String(Yt)))}),()=>Ze.abort()}loadTile(Se,De){const Ze=Se.uid,xt=Se&&Se.request,_t=xt&&xt.collectResourceTiming,Pt=this.loading[Ze]=new U(Se);Pt.maxUniformBufferBindings=this.maxUniformBufferBindings,Pt.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords,Pt.disableSymbolUBO=this.disableSymbolUBO,Pt.abort=this.loadTileData(Se,(Yt,Vt)=>{const Qt=!this.loading[Ze];if(delete this.loading[Ze],Pt.cancelRasterize(),Qt||Yt||!Vt)return Pt.status="done",Qt||(this.loaded[Ze]=Pt),De(Yt);const Es=Vt.rawData,ys={},lr=d.aP(Vt.responseHeaders);lr&&lr.expires&&(ys.expires=lr.expires),lr&&lr.cacheControl&&(ys.cacheControl=lr.cacheControl),Pt.vectorTile=Vt.vectorTile||new d.fx(new d.a$(Es));const Fr=()=>{Pt.parse(Pt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(Br,zr)=>{if(Br||!zr)return De(Br);const un={};if(_t){const Vn=u(xt);Vn.length>0&&(un.resourceTiming=JSON.parse(JSON.stringify(Vn)))}De(null,Object.assign({rawTileData:Es.slice(0),responseHeaders:Vt.responseHeaders},zr,ys,un))})};this.isSpriteLoaded?Fr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Fr,{type:"parseTile",renderSourceType:Se.renderSourceType,zoom:Se.tileZoom}):Fr()}),this.loaded=this.loaded||{},this.loaded[Ze]=Pt})}reloadTile(Se,De){const Ze=this.loaded,xt=Se.uid;if(Ze&&Ze[xt]){const _t=Ze[xt];_t.updateParameters(Se);const Pt=(Yt,Vt)=>{const Qt=_t.reloadCallback;Qt&&(delete _t.reloadCallback,_t.parse(_t.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Qt)),De(Yt,Vt)};_t.status==="parsing"?_t.reloadCallback=Pt:_t.status==="done"&&(_t.vectorTile?_t.parse(_t.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Pt):Pt())}else De(null,void 0)}abortTile(Se,De){const Ze=Se.uid,xt=this.loading[Ze];xt&&(xt.abort&&xt.abort(),delete this.loading[Ze]),De()}removeTile(Se,De){const Ze=this.loaded,xt=Se.uid;Ze&&Ze[xt]&&delete Ze[xt],De()}}class V{constructor(Se){this.loading={}}loadTile(Se,De){const Ze=Se.uid,{cancel:xt}=d.b1(Se.request,(_t,Pt,Yt)=>{const Vt=!this.loading[Ze];if(delete this.loading[Ze],Vt||_t||!Pt)return De(_t);this.decodeTile(Ze,Pt,Se.encoding).then(Qt=>{const{expires:Es,cacheControl:ys}=d.aP(Yt);De(null,Object.assign(Qt,{expires:Es,cacheControl:ys}))}).catch(Qt=>De(Qt))});this.loading[Ze]={cancel:xt}}async decodeTile(Se,De,Ze){const xt=await createImageBitmap(new Blob([new Uint8Array(De)],{type:"image/png"})),_t=1-(xt.width-d.fy(xt.width))/2,Pt=_t<1,Yt=this.getImageData(xt,_t);return xt.close(),{dem:new d.fz(Se,Yt,Ze,Pt),borderReady:Pt}}reloadTile(Se,De){De(null,null)}abortTile(Se,De){const Ze=Se.uid,xt=this.loading[Ze];xt&&(xt.cancel(),delete this.loading[Ze]),De()}removeTile(Se,De){De()}getImageData(Se,De){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(Se.width,Se.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=Se.width,this.offscreenCanvas.height=Se.height,this.offscreenCanvasContext.drawImage(Se,0,0,Se.width,Se.height);const Ze=this.offscreenCanvasContext.getImageData(-De,-De,Se.width+2*De,Se.height+2*De);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Ze}}d.a_.setPbf(d.a$);class ee{constructor(Se){this._mrt=new d.a_(Se.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=Se.uid,this.tileID=Se.tileID,this.source=Se.source}parse(Se,De){const Ze=this._mrt;this.status="parsing",this._entireBuffer=Se;try{Ze.parseHeader(Se),this._isHeaderLoaded=!0;const xt=[];for(const _t in Ze.layers){const Pt=Ze.getLayer(_t),Yt=Pt.getDataRange(Pt.getBandList()),Vt=Ze.createDecodingTask(Yt),Qt=Se.slice(Yt.firstByte,Yt.lastByte+1),Es=d.a_.performDecoding(Qt,Vt).then(ys=>Vt.complete(null,ys)).catch(ys=>Vt.complete(ys,null));xt.push(Es)}Promise.allSettled(xt).then(()=>De(null,Ze)).catch(_t=>De(_t))}catch(xt){De(xt)}}}class Z{constructor({actor:Se}){this.actor=Se,this.loading={},this.loaded={}}loadTile(Se,De){const Ze=Se.uid,xt=Se.request,_t=this.loading[Ze]=new ee(Se),{cancel:Pt}=d.b1(xt,(Yt,Vt,Qt)=>{const Es=!this.loading[Ze];if(delete this.loading[Ze],Es||Yt||!Vt)return _t.status="done",Es||(this.loaded[Ze]=_t),De(Yt);_t.parse(Vt,(ys,lr)=>{if(ys||!lr)return De(ys);De(null,lr,Qt)}),this.loaded[Ze]=_t});_t.abort=Pt}reloadTile(Se,De){De(null,void 0)}abortTile(Se,De){const Ze=Se.uid,xt=this.loading[Ze];xt&&(xt.abort&&xt.abort(),delete this.loading[Ze]),De()}removeTile(Se,De){const Ze=Se.uid;this.loaded[Ze]&&delete this.loaded[Ze],De()}decodeRasterArray(Se,De){d.a_.performDecoding(Se.buffer,Se.task).then(Ze=>De(null,Ze)).catch(Ze=>De(Ze))}}const J=d.fA.prototype.toGeoJSON;class Y{constructor(Se){this._feature=Se,this.extent=d.an,this.type=Se.type,this.properties=Se.tags,"id"in Se&&!isNaN(Se.id)&&(this.id=parseInt(Se.id,10))}loadGeometry(){if(this._feature.type===1){const Se=[];for(const De of this._feature.geometry)Se.push([new d.P(De[0],De[1])]);return Se}{const Se=[];for(const De of this._feature.geometry){const Ze=[];for(const xt of De)Ze.push(new d.P(xt[0],xt[1]));Se.push(Ze)}return Se}}toGeoJSON(Se,De,Ze){return J.call(this,Se,De,Ze)}}class ce{constructor(Se,De){this.name=Se,this.extent=d.an,this.length=De.length,this._jsonFeatures=De}feature(Se){return new Y(this._jsonFeatures[Se])}}class ae{constructor(Se){this.layers={},this.extent=d.an;for(const De of Object.keys(Se))this.layers[De]=new ce(De,Se[De])}}const ie=64/4096;class le{constructor(){this.features=new Map}clear(){this.features.clear()}load(Se=[],De){for(const Ze of Se){const xt=Ze.id;if(xt==null)continue;let _t=this.features.get(xt);_t&&this.updateCache(_t,De),Ze.geometry?(_t=xe(Ze),this.updateCache(_t,De),this.features.set(xt,_t)):this.features.delete(xt),this.updateCache(_t,De)}}updateCache(Se,De){for(const{canonical:Ze,uid:xt}of Object.values(De)){const{z:_t,x:Pt,y:Yt}=Ze;fe(Se,Math.pow(2,_t),Pt,Yt)&&delete De[xt]}}getTile(Se,De,Ze){const xt=Math.pow(2,Se),_t=[];for(const Pt of this.features.values())fe(Pt,xt,De,Ze)&&_t.push(Ve(Pt,xt,De,Ze));return{features:_t}}getFeatures(){return[...this.features.values()]}}function fe({minX:$t,minY:Se,maxX:De,maxY:Ze},xt,_t,Pt){return $t<(_t+1+ie)/xt&&Se<(Pt+1+ie)/xt&&De>(_t-ie)/xt&&Ze>(Pt-ie)/xt}function xe($t){const{id:Se,geometry:De,properties:Ze}=$t;if(!De)return;if(De.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:xt,coordinates:_t}=De,Pt={id:Se,type:1,geometry:[],tags:Ze,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Yt=Pt.geometry;if(xt==="Point")he(_t,Yt,Pt);else if(xt==="MultiPoint")for(const Vt of _t)he(Vt,Yt,Pt);else if(xt==="LineString")Pt.type=2,we(_t,Yt,Pt);else if(xt==="MultiLineString")Pt.type=2,Ne(_t,Yt,Pt);else if(xt==="Polygon")Pt.type=3,Ne(_t,Yt,Pt,!0);else{if(xt!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Pt.type=3;for(const Vt of _t)Ne(Vt,Yt,Pt,!0)}return Pt}function he([$t,Se],De,Ze){const xt=d.aH($t);let _t=d.aL(Se);_t=_t<0?0:_t>1?1:_t,De.push(xt,_t),Ze.minX=Math.min(Ze.minX,xt),Ze.minY=Math.min(Ze.minY,_t),Ze.maxX=Math.max(Ze.maxX,xt),Ze.maxY=Math.max(Ze.maxY,_t)}function we($t,Se,De,Ze=!1,xt=!1){const _t=[];for(const Pt of $t)he(Pt,_t,De);Se.push(_t),Ze&&function(Pt,Yt){let Vt=0;for(let Qt=0,Es=Pt.length,ys=Es-2;Qt0===Yt)for(let Qt=0,Es=Pt.length;Qt=Pt&&ys>=Pt||(Qt>=Pt?(Es+=Math.round(Br*((Pt-Qt)/Fr)),Qt=Pt):ys>=Pt&&(lr=Es+Math.round(Br*((Pt-Qt)/Fr)),ys=Pt),Es>=Pt&&lr>=Pt||(Es>=Pt?(Qt+=Math.round(Fr*((Pt-Es)/Br)),Es=Pt):lr>=Pt&&(ys=Qt+Math.round(Fr*((Pt-Es)/Br)),lr=Pt),Yt&&Qt===Yt[Yt.length-1][0]&&Es===Yt[Yt.length-1][1]||(Yt=[[Qt,Es]],xt.push(Yt)),Yt.push([ys,lr])))))}}function Ae($t,Se,De,Ze,xt){const _t=(De-ie)/Se,Pt=(Ze-ie)/Se,Yt=(De+1+ie)/Se,Vt=(Ze+1+ie)/Se;function Qt(lr,Fr){let Br=0;return lr<_t?Br|=1:lr>Yt&&(Br|=2),FrVt&&(Br|=8),Br}let Es=[];for(let lr=1;lr<=8;lr*=2){let Fr=$t[$t.length-2],Br=$t[$t.length-1],zr=!(Qt(Fr,Br)&lr);for(let un=0;un<$t.length;un+=2){const Vn=$t[un],Zn=$t[un+1],vi=!(Qt(Vn,Zn)&lr);vi!==zr&&(8&lr?Es.push(Fr+(Vn-Fr)*(Vt-Br)/(Zn-Br),Vt):4&lr?Es.push(Fr+(Vn-Fr)*(Pt-Br)/(Zn-Br),Pt):2&lr?Es.push(Yt,Br+(Zn-Br)*(Yt-Fr)/(Vn-Fr)):1&lr&&Es.push(_t,Br+(Zn-Br)*(_t-Fr)/(Vn-Fr))),vi&&Es.push(Vn,Zn),Fr=Vn,Br=Zn,zr=vi}if(!($t=Es).length||lr===8)break;Es=[]}const ys=[];for(let lr=0;lr>31}function ye($t,Se){const{geometry:De,type:Ze}=$t;let xt=0,_t=0;if(Ze===1){Se.writeVarint(Re(1,De.length));for(const Pt of De){const Yt=Pt[0]-xt,Vt=Pt[1]-_t;Se.writeVarint(Ue(Yt)),Se.writeVarint(Ue(Vt)),xt+=Yt,_t+=Vt}}else for(const Pt of De){if(Pt.length===0)continue;Se.writeVarint(Re(1,1));const Yt=Pt.length-(Ze===3?1:0);for(let Vt=0;Vt$t},Ge=Math.fround||(tt=new Float32Array(1),$t=>(tt[0]=+$t,tt[0]));var tt;class st{constructor(Se){this.options=Object.assign(Object.create(pe),Se),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(Se){const{log:De,minZoom:Ze,maxZoom:xt}=this.options;De&&console.time("total time");const _t=`prepare ${Se.length} points`;De&&console.time(_t),this.points=Se;const Pt=[];for(let Vt=0;Vt=Ze;Vt--){const Qt=+Date.now();Yt=this.trees[Vt]=this._createTree(this._cluster(Yt,Vt)),De&&console.log("z%d: %d clusters in %dms",Vt,Yt.numItems,+Date.now()-Qt)}return De&&console.timeEnd("total time"),this}getClusters(Se,De){let Ze=((Se[0]+180)%360+360)%360-180;const xt=Math.max(-90,Math.min(90,Se[1]));let _t=Se[2]===180?180:((Se[2]+180)%360+360)%360-180;const Pt=Math.max(-90,Math.min(90,Se[3]));if(Se[2]-Se[0]>=360)Ze=-180,_t=180;else if(Ze>_t){const ys=this.getClusters([Ze,xt,180,Pt],De),lr=this.getClusters([-180,xt,_t,Pt],De);return ys.concat(lr)}const Yt=this.trees[this._limitZoom(De)],Vt=Yt.range(Ct(Ze),Ot(Pt),Ct(_t),Ot(xt)),Qt=Yt.data,Es=[];for(const ys of Vt){const lr=this.stride*ys;Es.push(Qt[lr+5]>1?Ce(Qt,lr,this.clusterProps):this.points[Qt[lr+3]])}return Es}getChildren(Se){const De=this._getOriginId(Se),Ze=this._getOriginZoom(Se),xt="No cluster with the specified id.",_t=this.trees[Ze];if(!_t)throw new Error(xt);const Pt=_t.data;if(De*this.stride>=Pt.length)throw new Error(xt);const Yt=this.options.radius/(this.options.extent*Math.pow(2,Ze-1)),Vt=_t.within(Pt[De*this.stride],Pt[De*this.stride+1],Yt),Qt=[];for(const Es of Vt){const ys=Es*this.stride;Pt[ys+4]===Se&&Qt.push(Pt[ys+5]>1?Ce(Pt,ys,this.clusterProps):this.points[Pt[ys+3]])}if(Qt.length===0)throw new Error(xt);return Qt}getLeaves(Se,De,Ze){const xt=[];return this._appendLeaves(xt,Se,De=De||10,Ze=Ze||0,0),xt}getTile(Se,De,Ze){const xt=this.trees[this._limitZoom(Se)],_t=Math.pow(2,Se),{extent:Pt,radius:Yt}=this.options,Vt=Yt/Pt,Qt=(Ze-Vt)/_t,Es=(Ze+1+Vt)/_t,ys={features:[]};return this._addTileFeatures(xt.range((De-Vt)/_t,Qt,(De+1+Vt)/_t,Es),xt.data,De,Ze,_t,ys),De===0&&this._addTileFeatures(xt.range(1-Vt/_t,Qt,1,Es),xt.data,_t,Ze,_t,ys),De===_t-1&&this._addTileFeatures(xt.range(0,Qt,Vt/_t,Es),xt.data,-1,Ze,_t,ys),ys.features.length?ys:null}getClusterExpansionZoom(Se){let De=this._getOriginZoom(Se)-1;for(;De<=this.options.maxZoom;){const Ze=this.getChildren(Se);if(De++,Ze.length!==1)break;Se=Ze[0].properties.cluster_id}return De}_appendLeaves(Se,De,Ze,xt,_t){const Pt=this.getChildren(De);for(const Yt of Pt){const Vt=Yt.properties;if(Vt&&Vt.cluster?_t+Vt.point_count<=xt?_t+=Vt.point_count:_t=this._appendLeaves(Se,Vt.cluster_id,Ze,xt,_t):_t1;let Es,ys,lr;if(Qt)Es=et(De,Vt,this.clusterProps),ys=De[Vt],lr=De[Vt+1];else{const zr=this.points[De[Vt+3]];Es=zr.properties;const[un,Vn]=zr.geometry.coordinates;ys=Ct(un),lr=Ot(Vn)}const Fr={type:1,geometry:[[Math.round(this.options.extent*(ys*_t-Ze)),Math.round(this.options.extent*(lr*_t-xt))]],tags:Es};let Br;Br=Qt||this.options.generateId?De[Vt+3]:this.points[De[Vt+3]].id,Br!==void 0&&(Fr.id=Br),Pt.features.push(Fr)}}_limitZoom(Se){return Math.max(this.options.minZoom,Math.min(Math.floor(+Se),this.options.maxZoom+1))}_cluster(Se,De){const{radius:Ze,extent:xt,reduce:_t,minPoints:Pt}=this.options,Yt=Ze/(xt*Math.pow(2,De)),Vt=Se.data,Qt=[],Es=this.stride;for(let ys=0;ysDe&&(un+=Vt[Zn+5])}if(un>zr&&un>=Pt){let Vn,Zn=lr*zr,vi=Fr*zr,To=-1;const Ha=(ys/Es<<5)+(De+1)+this.points.length;for(const no of Br){const ai=no*Es;if(Vt[ai+2]<=De)continue;Vt[ai+2]=De;const zi=Vt[ai+5];Zn+=Vt[ai]*zi,vi+=Vt[ai+1]*zi,Vt[ai+4]=Ha,_t&&(Vn||(Vn=this._map(Vt,ys,!0),To=this.clusterProps.length,this.clusterProps.push(Vn)),_t(Vn,this._map(Vt,ai)))}Vt[ys+4]=Ha,Qt.push(Zn/un,vi/un,1/0,Ha,-1,un),_t&&Qt.push(To)}else{for(let Vn=0;Vn1)for(const Vn of Br){const Zn=Vn*Es;if(!(Vt[Zn+2]<=De)){Vt[Zn+2]=De;for(let vi=0;vi>5}_getOriginZoom(Se){return(Se-this.points.length)%32}_map(Se,De,Ze){if(Se[De+5]>1){const Pt=this.clusterProps[Se[De+6]];return Ze?Object.assign({},Pt):Pt}const xt=this.points[Se[De+3]].properties,_t=this.options.map(xt);return Ze&&_t===xt?Object.assign({},_t):_t}}function Ce($t,Se,De){return{type:"Feature",id:$t[Se+3],properties:et($t,Se,De),geometry:{type:"Point",coordinates:[(Ze=$t[Se],360*(Ze-.5)),ut($t[Se+1])]}};var Ze}function et($t,Se,De){const Ze=$t[Se+5],xt=Ze>=1e4?`${Math.round(Ze/1e3)}k`:Ze>=1e3?Math.round(Ze/100)/10+"k":Ze,_t=$t[Se+6],Pt=_t===-1?{}:Object.assign({},De[_t]);return Object.assign(Pt,{cluster:!0,cluster_id:$t[Se+3],point_count:Ze,point_count_abbreviated:xt})}function Ct($t){return $t/360+.5}function Ot($t){const Se=Math.sin($t*Math.PI/180),De=.5-.25*Math.log((1+Se)/(1-Se))/Math.PI;return De<0?0:De>1?1:De}function ut($t){const Se=(180-360*$t)*Math.PI/180;return 360*Math.atan(Math.exp(Se))/Math.PI-90}function Oe($t,Se,De,Ze){let xt=Ze;const _t=Se+(De-Se>>1);let Pt,Yt=De-Se;const Vt=$t[Se],Qt=$t[Se+1],Es=$t[De],ys=$t[De+1];for(let lr=Se+3;lrxt)Pt=lr,xt=Fr;else if(Fr===xt){const Br=Math.abs(lr-_t);BrZe&&(Pt-Se>3&&Oe($t,Se,Pt,Ze),$t[Pt+2]=xt,De-Pt>3&&Oe($t,Pt,De,Ze))}function Xe($t,Se,De,Ze,xt,_t){let Pt=xt-De,Yt=_t-Ze;if(Pt!==0||Yt!==0){const Vt=(($t-De)*Pt+(Se-Ze)*Yt)/(Pt*Pt+Yt*Yt);Vt>1?(De=xt,Ze=_t):Vt>0&&(De+=Pt*Vt,Ze+=Yt*Vt)}return Pt=$t-De,Yt=Se-Ze,Pt*Pt+Yt*Yt}function at($t,Se,De,Ze){const xt={id:$t??null,type:Se,geometry:De,tags:Ze,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(Se==="Point"||Se==="MultiPoint"||Se==="LineString")Ke(xt,De);else if(Se==="Polygon")Ke(xt,De[0]);else if(Se==="MultiLineString")for(const _t of De)Ke(xt,_t);else if(Se==="MultiPolygon")for(const _t of De)Ke(xt,_t[0]);return xt}function Ke($t,Se){for(let De=0;De0&&(Pt+=Ze?(xt*Es-Qt*_t)/2:Math.sqrt(Math.pow(Qt-xt,2)+Math.pow(Es-_t,2))),xt=Qt,_t=Es}const Yt=Se.length-3;Se[2]=1,Oe(Se,0,Yt,De),Se[Yt+2]=1,Se.size=Math.abs(Pt),Se.start=0,Se.end=Se.size}function Wt($t,Se,De,Ze){for(let xt=0;xt<$t.length;xt++){const _t=[];Mt($t[xt],_t,De,Ze),Se.push(_t)}}function xs($t){return $t/360+.5}function Cs($t){const Se=Math.sin($t*Math.PI/180),De=.5-.25*Math.log((1+Se)/(1-Se))/Math.PI;return De<0?0:De>1?1:De}function Us($t,Se,De,Ze,xt,_t,Pt,Yt){if(Ze/=Se,_t>=(De/=Se)&&Pt=Ze)return null;const Vt=[];for(const Qt of $t){const Es=Qt.geometry;let ys=Qt.type;const lr=xt===0?Qt.minX:Qt.minY,Fr=xt===0?Qt.maxX:Qt.maxY;if(lr>=De&&Fr=Ze)continue;let Br=[];if(ys==="Point"||ys==="MultiPoint")Ar(Es,Br,De,Ze,xt);else if(ys==="LineString")Bt(Es,Br,De,Ze,xt,!1,Yt.lineMetrics);else if(ys==="MultiLineString")Nr(Es,Br,De,Ze,xt,!1);else if(ys==="Polygon")Nr(Es,Br,De,Ze,xt,!0);else if(ys==="MultiPolygon")for(const zr of Es){const un=[];Nr(zr,un,De,Ze,xt,!0),un.length&&Br.push(un)}if(Br.length){if(Yt.lineMetrics&&ys==="LineString"){for(const zr of Br)Vt.push(at(Qt.id,ys,zr,Qt.tags));continue}ys!=="LineString"&&ys!=="MultiLineString"||(Br.length===1?(ys="LineString",Br=Br[0]):ys="MultiLineString"),ys!=="Point"&&ys!=="MultiPoint"||(ys=Br.length===3?"Point":"MultiPoint"),Vt.push(at(Qt.id,ys,Br,Qt.tags))}}return Vt.length?Vt:null}function Ar($t,Se,De,Ze,xt){for(let _t=0;_t<$t.length;_t+=3){const Pt=$t[_t+xt];Pt>=De&&Pt<=Ze&&Vs(Se,$t[_t],$t[_t+1],$t[_t+2])}}function Bt($t,Se,De,Ze,xt,_t,Pt){let Yt=Xs($t);const Vt=xt===0?ar:Or;let Qt,Es,ys=$t.start;for(let un=0;un<$t.length-3;un+=3){const Vn=$t[un],Zn=$t[un+1],vi=$t[un+2],To=$t[un+3],Ha=$t[un+4],no=xt===0?Vn:Zn,ai=xt===0?To:Ha;let zi=!1;Pt&&(Qt=Math.sqrt(Math.pow(Vn-To,2)+Math.pow(Zn-Ha,2))),noDe&&(Es=Vt(Yt,Vn,Zn,To,Ha,De),Pt&&(Yt.start=ys+Qt*Es)):no>Ze?ai=De&&(Es=Vt(Yt,Vn,Zn,To,Ha,De),zi=!0),ai>Ze&&no<=Ze&&(Es=Vt(Yt,Vn,Zn,To,Ha,Ze),zi=!0),!_t&&zi&&(Pt&&(Yt.end=ys+Qt*Es),Se.push(Yt),Yt=Xs($t)),Pt&&(ys+=Qt)}let lr=$t.length-3;const Fr=$t[lr],Br=$t[lr+1],zr=xt===0?Fr:Br;zr>=De&&zr<=Ze&&Vs(Yt,Fr,Br,$t[lr+2]),lr=Yt.length-3,_t&&lr>=3&&(Yt[lr]!==Yt[0]||Yt[lr+1]!==Yt[1])&&Vs(Yt,Yt[0],Yt[1],Yt[2]),Yt.length&&Se.push(Yt)}function Xs($t){const Se=[];return Se.size=$t.size,Se.start=$t.start,Se.end=$t.end,Se}function Nr($t,Se,De,Ze,xt,_t){for(const Pt of $t)Bt(Pt,Se,De,Ze,xt,_t,!1)}function Vs($t,Se,De,Ze){$t.push(Se,De,Ze)}function ar($t,Se,De,Ze,xt,_t){const Pt=(_t-Se)/(Ze-Se);return Vs($t,_t,De+(xt-De)*Pt,1),Pt}function Or($t,Se,De,Ze,xt,_t){const Pt=(_t-De)/(xt-De);return Vs($t,Se+(Ze-Se)*Pt,_t,1),Pt}function Rn($t,Se){const De=[];for(let Ze=0;Ze<$t.length;Ze++){const xt=$t[Ze],_t=xt.type;let Pt;if(_t==="Point"||_t==="MultiPoint"||_t==="LineString")Pt=bn(xt.geometry,Se);else if(_t==="MultiLineString"||_t==="Polygon"){Pt=[];for(const Yt of xt.geometry)Pt.push(bn(Yt,Se))}else if(_t==="MultiPolygon"){Pt=[];for(const Yt of xt.geometry){const Vt=[];for(const Qt of Yt)Vt.push(bn(Qt,Se));Pt.push(Vt)}}De.push(at(xt.id,_t,Pt,xt.tags))}return De}function bn($t,Se){const De=[];De.size=$t.size,$t.start!==void 0&&(De.start=$t.start,De.end=$t.end);for(let Ze=0;Ze<$t.length;Ze+=3)De.push($t[Ze]+Se,$t[Ze+1],$t[Ze+2]);return De}function ir($t,Se){if($t.transformed)return $t;const De=1<<$t.z,Ze=$t.x,xt=$t.y;for(const _t of $t.features){const Pt=_t.geometry,Yt=_t.type;if(_t.geometry=[],Yt===1)for(let Vt=0;Vt0&&Se.size<(xt?Pt:Ze))return void(De.numPoints+=Se.length/3);const Yt=[];for(let Vt=0;VtPt)&&(De.numSimplified++,Yt.push(Se[Vt],Se[Vt+1])),De.numPoints++;xt&&function(Vt,Qt){let Es=0;for(let ys=0,lr=Vt.length,Fr=lr-2;ys0===Qt)for(let ys=0,lr=Vt.length;ys24)throw new Error("maxZoom should be in the 0-24 range");if(De.promoteId&&De.generateId)throw new Error("promoteId and generateId cannot be used together.");let xt=function(_t,Pt){const Yt=[];if(_t.type==="FeatureCollection")for(let Vt=0;Vt<_t.features.length;Vt++)He(Yt,_t.features[Vt],Pt,Vt);else He(Yt,_t.type==="Feature"?_t:{geometry:_t},Pt);return Yt}(Se,De);this.tiles={},this.tileCoords=[],Ze&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",De.indexMaxZoom,De.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),xt=function(_t,Pt){const Yt=Pt.buffer/Pt.extent;let Vt=_t;const Qt=Us(_t,1,-1-Yt,Yt,0,-1,2,Pt),Es=Us(_t,1,1-Yt,2+Yt,0,-1,2,Pt);return(Qt||Es)&&(Vt=Us(_t,1,-Yt,1+Yt,0,-1,2,Pt)||[],Qt&&(Vt=Rn(Qt,1).concat(Vt)),Es&&(Vt=Vt.concat(Rn(Es,-1)))),Vt}(xt,De),xt.length&&this.splitTile(xt,0,0,0),Ze&&(xt.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(Se,De,Ze,xt,_t,Pt,Yt){const Vt=[Se,De,Ze,xt],Qt=this.options,Es=Qt.debug;for(;Vt.length;){xt=Vt.pop(),Ze=Vt.pop(),De=Vt.pop(),Se=Vt.pop();const ys=1<1&&console.time("creation"),Fr=this.tiles[lr]=hr(Se,De,Ze,xt,Qt),this.tileCoords.push({z:De,x:Ze,y:xt}),Es)){Es>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",De,Ze,xt,Fr.numFeatures,Fr.numPoints,Fr.numSimplified),console.timeEnd("creation"));const zi=`z${De}`;this.stats[zi]=(this.stats[zi]||0)+1,this.total++}if(Fr.source=Se,_t==null){if(De===Qt.indexMaxZoom||Fr.numPoints<=Qt.indexMaxPoints)continue}else{if(De===Qt.maxZoom||De===_t)continue;if(_t!=null){const zi=_t-De;if(Ze!==Pt>>zi||xt!==Yt>>zi)continue}}if(Fr.source=null,Se.length===0)continue;Es>1&&console.time("clipping");const Br=.5*Qt.buffer/Qt.extent,zr=.5-Br,un=.5+Br,Vn=1+Br;let Zn=null,vi=null,To=null,Ha=null,no=Us(Se,ys,Ze-Br,Ze+un,0,Fr.minX,Fr.maxX,Qt),ai=Us(Se,ys,Ze+zr,Ze+Vn,0,Fr.minX,Fr.maxX,Qt);Se=null,no&&(Zn=Us(no,ys,xt-Br,xt+un,1,Fr.minY,Fr.maxY,Qt),vi=Us(no,ys,xt+zr,xt+Vn,1,Fr.minY,Fr.maxY,Qt),no=null),ai&&(To=Us(ai,ys,xt-Br,xt+un,1,Fr.minY,Fr.maxY,Qt),Ha=Us(ai,ys,xt+zr,xt+Vn,1,Fr.minY,Fr.maxY,Qt),ai=null),Es>1&&console.timeEnd("clipping"),Vt.push(Zn||[],De+1,2*Ze,2*xt),Vt.push(vi||[],De+1,2*Ze,2*xt+1),Vt.push(To||[],De+1,2*Ze+1,2*xt),Vt.push(Ha||[],De+1,2*Ze+1,2*xt+1)}}getTile(Se,De,Ze){Se=+Se,De=+De,Ze=+Ze;const xt=this.options,{extent:_t,debug:Pt}=xt;if(Se<0||Se>24)return null;const Yt=1<1&&console.log("drilling down to z%d-%d-%d",Se,De,Ze);let Qt,Es=Se,ys=De,lr=Ze;for(;!Qt&&Es>0;)Es--,ys>>=1,lr>>=1,Qt=this.tiles[Xt(Es,ys,lr)];return Qt&&Qt.source?(Pt>1&&(console.log("found parent tile z%d-%d-%d",Es,ys,lr),console.time("drilling down")),this.splitTile(Qt.source,Es,ys,lr,Se,De,Ze),Pt>1&&console.timeEnd("drilling down"),this.tiles[Vt]?ir(this.tiles[Vt],_t):null):null}}function Xt($t,Se,De){return 32*((1<<$t)*De+Se)+$t}function Qa($t,Se){const De=$t.tileID.canonical;if(!this._geoJSONIndex)return void Se(null,null);const Ze=this._geoJSONIndex.getTile(De.z,De.x,De.y);if(!Ze)return void Se(null,null);const xt=Qt=>Qt.tags&&"3d_elevation_id"in Qt.tags&&"source"in Qt.tags&&Qt.tags.source==="elevation",_t=Ze.features.filter(Qt=>xt(Qt));let Pt={_geojsonTileLayer:Ze.features};_t.length>0&&(Pt={_geojsonTileLayer:Ze.features.filter(Qt=>!xt(Qt)),hd_road_elevation:_t});const Yt=new ae(Pt),Vt=function(Qt){const Es=new d.a$;for(const ys of Object.keys(Qt))Es.writeMessage(3,ze,{name:ys,features:Qt[ys]});return Es.finish()}(Pt).buffer;Se(null,{vectorTile:Yt,rawData:Vt})}class Cr extends ${constructor(Se){super(Se),this.loadVectorData=Qa,this._dynamicIndex=new le}loadData(Se,De){const Ze=Se&&Se.request,xt=Ze&&Ze.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(Se,(_t,Pt)=>{if(_t||!Pt)return De(_t);if(typeof Pt!="object")return De(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));{try{if(Se.filter){const Vt=d.X(Se.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Vt.result==="error")throw new Error(Vt.value.map(Qt=>`${Qt.key}: ${Qt.message}`).join(", "));Pt.features=Pt.features.filter(Qt=>Vt.value.evaluate({zoom:0},Qt))}Se.dynamic?(Pt.type==="Feature"&&(Pt={type:"FeatureCollection",features:[Pt]}),Se.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Pt.features,this.loaded),Se.cluster&&(Pt.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=Se.cluster?new st(function({superclusterOptions:Vt,clusterProperties:Qt}){if(!Qt||!Vt)return Vt;const Es={},ys={},lr={accumulated:null,zoom:0},Fr={properties:null},Br=Object.keys(Qt);for(const zr of Br){const[un,Vn]=Qt[zr],Zn=d.X(Vn),vi=d.X(typeof un=="string"?[un,["accumulated"],["get",zr]]:un);Es[zr]=Zn.value,ys[zr]=vi.value}return Vt.map=zr=>{Fr.properties=zr;const un={};for(const Vn of Br)un[Vn]=Es[Vn].evaluate(lr,Fr);return un},Vt.reduce=(zr,un)=>{Fr.properties=un;for(const Vn of Br)lr.accumulated=zr[Vn],zr[Vn]=ys[Vn].evaluate(lr,Fr)},Vt}(Se)).load(Pt.features):Se.dynamic?this._dynamicIndex:function(Vt,Qt){return new $a(Vt,Qt)}(Pt,Se.geojsonVtOptions)}catch(Vt){return De(Vt)}const Yt={};if(xt){const Vt=u(Ze);Vt&&(Yt.resourceTiming={},Yt.resourceTiming[Se.source]=JSON.parse(JSON.stringify(Vt)))}De(null,Yt)}})}reloadTile(Se,De){const Ze=this.loaded;return Ze&&Ze[Se.uid]?Se.partial?De(null,void 0):super.reloadTile(Se,De):this.loadTile(Se,De)}loadGeoJSON(Se,De){if(Se.request)d.m(Se.request,De);else{if(typeof Se.data!="string")return De(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return De(null,JSON.parse(Se.data))}catch{return De(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(Se,De){try{De(null,this._geoJSONIndex.getClusterExpansionZoom(Se.clusterId))}catch(Ze){De(Ze)}}getClusterChildren(Se,De){try{De(null,this._geoJSONIndex.getChildren(Se.clusterId))}catch(Ze){De(Ze)}}getClusterLeaves(Se,De){try{De(null,this._geoJSONIndex.getLeaves(Se.clusterId,Se.limit,Se.offset))}catch(Ze){De(Ze)}}}class Fn{constructor(Se,De,Ze){this.tileID=new d.aR(Se.tileID.overscaledZ,Se.tileID.wrap,Se.tileID.canonical.z,Se.tileID.canonical.x,Se.tileID.canonical.y),this.tileZoom=Se.tileZoom,this.uid=Se.uid,this.zoom=Se.zoom,this.canonical=Se.tileID.canonical,this.pixelRatio=Se.pixelRatio,this.tileSize=Se.tileSize,this.source=Se.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=Se.projection,this.brightness=De,this.worldview=Ze}parse(Se,De,Ze,xt){this.status="parsing";const _t=new d.aR(Ze.tileID.overscaledZ,Ze.tileID.wrap,Ze.tileID.canonical.z,Ze.tileID.canonical.x,Ze.tileID.canonical.y),Pt=[],Yt=De.familiesBySource[Ze.source],Vt=new d.ff(_t,Ze.promoteId);Vt.bucketLayerIDs=[],Vt.is3DTile=!0,d.fB(Se).then(Qt=>{const Es=Qt.json.extensionsUsed&&Qt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Qt.json.asset.extras&&Qt.json.asset.extras.MAPBOX_mesh_features,ys=Qt.json.extensionsUsed&&Qt.json.extensionsUsed.includes("EXT_meshopt_compression"),lr=new d.ae(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Fr in Yt)for(const Br of Yt[Fr]){const zr=Br[0];Vt.bucketLayerIDs.push(Br.map(Zn=>d.F(Zn.id,Zn.scope))),zr.recalculate(lr,[]);const un=d.fC(Qt,1/d.cS(Ze.tileID.canonical)),Vn=new d.fD(Br,un,_t,Es,ys,this.brightness,Vt,this.worldview);Es||(Vn.needsUpload=!0),Pt.push(Vn),Vn.evaluate(zr)}this.status="done",xt(null,{buckets:Pt,featureIndex:Vt,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Qt=>xt(new Error(Qt.message)))}}class Kt{constructor({actor:Se,layerIndex:De,availableImages:Ze,availableModels:xt,brightness:_t,worldview:Pt}){this.actor=Se,this.layerIndex=De,this.availableImages=Ze,this.availableModels=xt,this.brightness=_t,this.loading={},this.loaded={},this.worldview=Pt}loadTile(Se,De){const Ze=Se.uid,xt=this.loading[Ze]=new Fn(Se,this.brightness,this.worldview);d.b1(Se.request,(_t,Pt)=>{const Yt=!this.loading[Ze];return delete this.loading[Ze],Yt||_t?(xt.status="done",Yt||(this.loaded[Ze]=xt),De(_t)):Pt&&Pt.byteLength!==0?void xt.parse(Pt,this.layerIndex,Se,(Vt,Qt)=>{xt.status="done",this.loaded=this.loaded||{},this.loaded[Ze]=xt,Vt||!Qt?De(Vt):De(null,Qt)}):(xt.status="done",this.loaded[Ze]=xt,De())})}reloadTile(Se,De){const Ze=this.loaded,xt=Se.uid;if(Ze&&Ze[xt]){const _t=Ze[xt];_t.projection=Se.projection,_t.brightness=Se.brightness;const Pt=(Yt,Vt)=>{_t.reloadCallback&&(delete _t.reloadCallback,this.loadTile(Se,De)),De(Yt,Vt)};_t.status==="parsing"?_t.reloadCallback=Pt:_t.status==="done"&&this.loadTile(Se,De)}}abortTile(Se,De){const Ze=Se.uid;this.loading[Ze]&&delete this.loading[Ze],De()}removeTile(Se,De){const Ze=this.loaded,xt=Se.uid;Ze&&Ze[xt]&&delete Ze[xt],De()}}const Mr=new Map,On=new Map;class ua{constructor(Se){this.self=Se,this.actor=new d.A(Se,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new d.z,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=d.c0({name:"mercator"}),this.workerSourceTypes={vector:$,geojson:Cr,"raster-dem":V,"raster-array":Z,"batched-model":Kt},this.workerSources={},this.self.registerWorkerSource=(De,Ze)=>{if(this.workerSourceTypes[De])throw new Error(`Worker source with name "${De}" already registered.`);this.workerSourceTypes[De]=Ze},this.self.registerRTLTextPlugin=De=>{if(d.fF.isParsed())throw new Error("RTL text plugin already registered.");d.fF.setState({pluginStatus:d.fG.parsed,pluginURL:d.fF.getPluginURL()}),d.fF.applyArabicShaping=De.applyArabicShaping,d.fF.processBidirectionalText=De.processBidirectionalText,d.fF.processStyledBidirectionalText=De.processStyledBidirectionalText;for(const Ze of this.rtlPluginParsingListeners)Ze(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(Se,De,Ze){delete this.layerIndexes[Se],delete this.availableImages[Se],delete this.availableModels[Se],delete this.workerSources[Se],Ze()}checkIfReady(Se,De,Ze){Ze()}setReferrer(Se,De){this.referrer=De}spriteLoaded(Se,De){this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={});const{scope:Ze,isLoaded:xt}=De;if(this.isSpriteLoaded[Se][Ze]=xt,this.workerSources[Se]&&this.workerSources[Se][Ze])for(const _t in this.workerSources[Se][Ze]){const Pt=this.workerSources[Se][Ze][_t];for(const Yt in Pt){const Vt=Pt[Yt];Vt instanceof $&&(Vt.isSpriteLoaded=xt,Vt.fire(new d.C("isSpriteLoaded")))}}}setImages(Se,De,Ze){this.availableImages[Se]||(this.availableImages[Se]={});const{scope:xt,images:_t}=De;if(this.availableImages[Se][xt]=_t,this.workerSources[Se]&&this.workerSources[Se][xt]){for(const Pt in this.workerSources[Se][xt]){const Yt=this.workerSources[Se][xt][Pt];for(const Vt in Yt)Yt[Vt].availableImages=_t}Ze()}else Ze()}setModels(Se,{scope:De,models:Ze},xt){if(this.availableModels[Se]||(this.availableModels[Se]={}),this.availableModels[Se][De]=Ze,this.workerSources[Se]&&this.workerSources[Se][De]){for(const _t in this.workerSources[Se][De]){const Pt=this.workerSources[Se][De][_t];for(const Yt in Pt)Pt[Yt].availableModels=Ze}xt()}else xt()}setProjection(Se,De){this.projections[Se]=d.c0(De)}setBrightness(Se,De,Ze){this.brightness=De,Ze()}setContextParams(Se,De,Ze){this.maxUniformBufferBindings=De.maxBindingPoints,this.maxUniformBlockSizeDwords=De.maxUniformBlockSizeDwords,this.disableSymbolUBO=De.disableSymbolUBO,Ze()}setWorldview(Se,De,Ze){this.worldview=De,Ze()}setLayers(Se,De,Ze){this.getLayerIndex(Se,De.scope).replace(De.layers,De.options),Ze()}updateLayers(Se,De,Ze){this.getLayerIndex(Se,De.scope).update(De.layers,De.removedIds,De.options),Ze()}loadTile(Se,De,Ze){De.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,De).loadTile(De,Ze)}decodeRasterArray(Se,De,Ze){this.getWorkerSource(Se,De).decodeRasterArray(De,Ze)}reloadTile(Se,De,Ze){De.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,De).reloadTile(De,Ze)}abortTile(Se,De,Ze){this.getWorkerSource(Se,De).abortTile(De,Ze)}removeTile(Se,De,Ze){this.getWorkerSource(Se,De).removeTile(De,Ze)}removeSource(Se,De,Ze){if(!(this.workerSources[Se]&&this.workerSources[Se][De.scope]&&this.workerSources[Se][De.scope][De.type]&&this.workerSources[Se][De.scope][De.type][De.source]))return;const xt=this.workerSources[Se][De.scope][De.type][De.source];delete this.workerSources[Se][De.scope][De.type][De.source],xt.removeSource!==void 0?xt.removeSource(De,Ze):Ze()}loadTileProvider(Se,De,Ze){(async function(xt,_t){const Pt=On.get(xt);if(Pt)return Pt;const Yt=Mr.get(xt);if(Yt!==void 0)return Yt;const Vt=import(_t).then(Qt=>{const Es=Qt.default;if(typeof Es!="function")throw new Error(`TileProvider "${xt}" module must default-export a class`);if(typeof Es.prototype.loadTile!="function")throw new Error(`TileProvider "${xt}" class must have a loadTile method`);return On.set(xt,Es),Es}).finally(()=>{Mr.delete(xt)});return Mr.set(xt,Vt),Vt})(De.name,De.url).then(xt=>{const _t=new xt(De.options);return this.getWorkerSource(Se,{type:De.type,source:De.source,scope:De.scope},_t),_t.load&&De.request?_t.load({request:De.request}):null}).then(xt=>Ze(null,xt)).catch(xt=>Ze(xt instanceof Error?xt:new Error(typeof xt=="string"?xt:"Unknown error")))}loadWorkerSource(Se,De,Ze){try{this.self.importScripts(De.url),Ze()}catch(xt){Ze(xt)}}syncRTLPluginState(Se,De,Ze){if(d.fF.isParsed())Ze(null,!0);else if(d.fF.isParsing())this.rtlPluginParsingListeners.push(Ze);else try{d.fF.setState(De);const xt=d.fF.getPluginURL();!d.fF.isLoaded()||d.fF.isParsed()||d.fF.isParsing()||xt==null||(d.fF.setState({pluginStatus:d.fG.parsing,pluginURL:d.fF.getPluginURL()}),this.self.importScripts(xt),d.fF.isParsed()?Ze(null,!0):this.rtlPluginParsingListeners.push(Ze))}catch(xt){Ze(xt)}}setConfig(Se,De){Object.assign(d.g,De)}getAvailableImages(Se,De){this.availableImages[Se]||(this.availableImages[Se]={});let Ze=this.availableImages[Se][De];return Ze||(Ze=[]),Ze}getAvailableModels(Se,De){this.availableModels[Se]||(this.availableModels[Se]={});let Ze=this.availableModels[Se][De];return Ze||(Ze={}),Ze}getLayerIndex(Se,De){this.layerIndexes[Se]||(this.layerIndexes[Se]={});let Ze=this.layerIndexes[Se][De];return Ze||(Ze=this.layerIndexes[Se][De]=new _,Ze.scope=De),Ze}getWorkerSource(Se,De,Ze){const{type:xt,source:_t,scope:Pt}=De,Yt=this.workerSources;if(Yt[Se]||(Yt[Se]={}),Yt[Se][Pt]||(Yt[Se][Pt]={}),Yt[Se][Pt][xt]||(Yt[Se][Pt][xt]={}),this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={}),!Yt[Se][Pt][xt][_t]){const Vt={send:(Es,ys,lr,Fr,Br,zr)=>this.actor.send(Es,ys,lr,Se,Br,zr),scheduler:this.actor.scheduler},Qt=this.workerSourceTypes[xt];if(!Qt)throw new Error(`Unknown worker source type "${xt}".`);Yt[Se][Pt][xt][_t]=new Qt({actor:Vt,layerIndex:this.getLayerIndex(Se,Pt),availableImages:this.getAvailableImages(Se,Pt),availableModels:this.getAvailableModels(Se,Pt),isSpriteLoaded:this.isSpriteLoaded[Se][Pt],tileProvider:Ze,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO})}return Yt[Se][Pt][xt][_t]}rasterizeImagesWorker(Se,De,Ze){const xt=new Map;for(const[_t,{image:Pt,imageVariant:Yt}]of De.tasks.entries()){const Vt=this.imageRasterizer.rasterize(Yt,Pt,De.scope,Se);xt.set(_t,Vt)}Ze(void 0,xt)}removeRasterizedImages(Se,De,Ze){this.imageRasterizer.removeImagesFromCacheByIds(De.imageIds,De.scope,Se),Ze()}enforceCacheSizeLimit(Se,De){d.fH(De)}getWorkerPerformanceMetrics(Se,De,Ze){Ze(void 0,void 0)}}return d.fE(self)&&(self.worker=new ua(self)),ua}),o(["./shared"],function(i){var d="3.22.0";const u={create:"create",load:"load",fullLoad:"fullLoad"},p={mark(M){performance.mark(M)},measure(M,m,v){performance.measure(M,m,v)}};function f(M){const m=M.name.split("?")[0];return i.a(m)&&m.includes("mapbox-gl.js")?"javascript":i.a(m)&&m.includes("mapbox-gl.css")?"css":i.b(m)?"fontRange":i.c(m)?"sprite":i.i(m)?"style":i.d(m)?"tilejson":"other"}var y,_={},b=function(){if(y)return _;function M(E){return!m(E)}function m(E){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var z,B,W=new Blob([""],{type:"text/javascript"}),te=URL.createObjectURL(W);try{B=new Worker(te),z=!0}catch{z=!1}return B&&B.terminate(),URL.revokeObjectURL(te),z}()?function(){var z=document.createElement("canvas");z.width=z.height=1;var B=z.getContext("2d");if(!B)return!1;var W=B.getImageData(0,0,1,1);return W&&W.width===z.width}()?(v[D=E&&E.failIfMajorPerformanceCaveat]===void 0&&(v[D]=function(z){var B,W=function(te){var ne=document.createElement("canvas"),de=Object.create(M.webGLContextAttributes);return de.failIfMajorPerformanceCaveat=te,ne.getContext("webgl2",de)}(z);if(!W)return!1;try{B=W.createShader(W.VERTEX_SHADER)}catch{return!1}return!(!B||W.isContextLost())&&(W.shaderSource(B,"void main() {}"),W.compileShader(B),W.getShaderParameter(B,W.COMPILE_STATUS)===!0)}(D)),v[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=m;var v={};return M.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},_}();function N(M,m,v){const E=document.createElement(M);return m!=null&&(E.className=m),v&&v.appendChild(E),E}function w(M,m,v){const E=document.createElementNS("http://www.w3.org/2000/svg",M);for(const D of Object.keys(m))E.setAttributeNS(null,D,String(m[D]));return v&&v.appendChild(E),E}const S=typeof document<"u"?document.documentElement&&document.documentElement.style:null,C=S&&S.userSelect!==void 0?"userSelect":"WebkitUserSelect";let A;function I(){S&&C&&(A=S[C],S[C]="none")}function L(){S&&C&&(S[C]=A)}function O(M){M.preventDefault(),M.stopPropagation(),window.removeEventListener("click",O,!0)}function U(){window.addEventListener("click",O,!0),window.setTimeout(()=>{window.removeEventListener("click",O,!0)},0)}function q(M,m){const v=M.getBoundingClientRect();return ee(M,v,m)}function $(M,m){const v=M.getBoundingClientRect(),E=[];for(let D=0;Dthis._skuTokenExpiresAt}transformRequest(m,v){return this._transformRequestFn&&this._transformRequestFn(m,v)||{url:m}}normalizeStyleURL(m,v){if(!i.e(m))return m;const E=ae(m);return E.params.push(`sdk=js-${d}`),E.path=`/styles/v1${E.path}`,this._makeAPIURL(E,this._customAccessToken||v)}normalizeGlyphsURL(m,v){if(!i.e(m))return m;const E=ae(m);return E.path=`/fonts/v1${E.path}`,this._makeAPIURL(E,this._customAccessToken||v)}normalizeModelURL(m,v){if(!i.e(m))return m;const E=ae(m);return E.path=`/models/v1${E.path}`,this._makeAPIURL(E,this._customAccessToken||v)}normalizeSourceURL(m,v,E,D){if(!i.e(m))return m;const z=ae(m);return z.path=`/v4/${z.authority}.json`,z.params.push("secure"),E&&z.params.push(`language=${E}`),D&&z.params.push(`worldview=${D}`),this._makeAPIURL(z,this._customAccessToken||v)}normalizeIconsetURL(m,v){const E=ae(m);return i.e(m)?(E.path=`/styles/v1${E.path}/iconset.pbf`,this._makeAPIURL(E,this._customAccessToken||v)):ie(E)}normalizeSpriteURL(m,v,E,D){const z=ae(m);return i.e(m)?(z.path=`/styles/v1${z.path}/sprite${v}${E}`,this._makeAPIURL(z,this._customAccessToken||D)):(z.path+=`${v}${E}`,ie(z))}normalizeTileURL(m,v,E){if(this._isSkuTokenExpired()&&this._createSkuToken(),m&&!i.e(m))return m;const D=ae(m);D.path=D.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${v||E&&D.authority!=="raster"&&E===512?"@2x":""}${i.k.supported?".webp":"$1"}`),D.authority==="raster"?D.path=`/${i.g.RASTER_URL_PREFIX}${D.path}`:D.authority==="rasterarrays"?D.path=`/${i.g.RASTERARRAYS_URL_PREFIX}${D.path}`:D.authority==="3dtiles"?D.path=`/${i.g.TILES3D_URL_PREFIX}${D.path}`:(D.path=D.path.replace(/^.+\/v4\//,"/"),D.path=`/${i.g.TILE_URL_VERSION}${D.path}`);const z=this._customAccessToken||function(B){for(const W of B){const te=W.match(/^access_token=(.*)$/);if(te)return te[1]}return null}(D.params)||i.g.ACCESS_TOKEN;return i.g.REQUIRE_ACCESS_TOKEN&&z&&this._skuToken&&D.params.push(`sku=${this._skuToken}`),this._makeAPIURL(D,z)}canonicalizeTileURL(m,v){const E=ae(m);if(!E.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!E.path.match(/\.[\w]+$/))return m;let D="mapbox://";E.path.match(/^\/raster\/v1\//)?D+=`raster/${E.path.replace(`/${i.g.RASTER_URL_PREFIX}/`,"")}`:E.path.match(/^\/rasterarrays\/v1\//)?D+=`rasterarrays/${E.path.replace(`/${i.g.RASTERARRAYS_URL_PREFIX}/`,"")}`:D+=`tiles/${E.path.replace(`/${i.g.TILE_URL_VERSION}/`,"")}`;let z=E.params;return v&&(z=z.filter(B=>!B.match(/^access_token=/))),z.length&&(D+=`?${z.join("&")}`),D}canonicalizeTileset(m,v){const E=!!v&&i.e(v),D=[];for(const z of m.tiles||[])i.f(z)?D.push(this.canonicalizeTileURL(z,E)):D.push(z);return D}_makeAPIURL(m,v){const E="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",D=ae(i.g.API_URL);if(m.protocol=D.protocol,m.authority=D.authority,m.protocol==="http"){const z=m.params.indexOf("secure");z>=0&&m.params.splice(z,1)}if(D.path!=="/"&&(m.path=`${D.path}${m.path}`),!i.g.REQUIRE_ACCESS_TOKEN)return ie(m);if(v=v||i.g.ACCESS_TOKEN,!this._silenceAuthErrors){if(!v)throw new Error(`An API access token is required to use Mapbox GL. ${E}`);if(v[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${E}`)}return m.params=m.params.filter(z=>z.indexOf("access_token")===-1),m.params.push(`access_token=${v||""}`),ie(m)}}const ce=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ae(M){const m=M.match(ce);if(!m)throw new Error("Unable to parse URL object");return{protocol:m[1],authority:m[2],path:m[3]||"/",params:m[4]?m[4].split("&"):[]}}function ie(M){const m=M.params.length?`?${M.params.join("&")}`:"";return`${M.protocol}://${M.authority}${M.path}${m}`}const le="mapbox.eventData";function fe(M){if(!M)return null;const m=M.split(".");if(!m||m.length!==3)return null;try{return JSON.parse(i.l(m[1]))}catch{return null}}function xe(M){return!(!i.g.EVENTS_URL||!M&&!i.g.ACCESS_TOKEN)}class he{constructor(m){this.type=m,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(m){const v=fe(i.g.ACCESS_TOKEN);let E="";return E=v&&v.u?i.j(v.u):i.g.ACCESS_TOKEN||"",m?`${le}.${m}:${E}`:`${le}:${E}`}fetchEventData(){const m=i.s("localStorage"),v=this.getStorageKey(),E=this.getStorageKey("uuid"),D=this.getStorageKey("uuidTimestamp");if(m)try{const z=localStorage.getItem(v);z&&(this.eventData=JSON.parse(z));const B=localStorage.getItem(E);B&&(this.anonId=B);const W=localStorage.getItem(D);W&&(this.anonIdTimestamp=Number(W));const te=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(v,JSON.stringify(this.eventData)),B&&localStorage.setItem(D,B.toString())}catch{i.w("Unable to write to LocalStorage")}}processRequests(m){}postEvent(m,v,E,D){if(!i.g.EVENTS_URL)return;const z=ae(i.g.EVENTS_URL);z.params.push(`access_token=${D||i.g.ACCESS_TOKEN||""}`);const B={event:this.type,created:new Date(m).toISOString()},W=v?Object.assign(B,v):B,te={url:ie(z),headers:{"Content-Type":"text/plain"},body:JSON.stringify([W])};this.pendingRequest=i.p(te,ne=>{this.pendingRequest=null,E(ne),this.saveEventData(),this.processRequests(D)})}queueRequest(m,v){this.queue.push(m),this.processRequests(v)}}class we extends he{constructor(m){super("metrics"),m&&(this.data=m)}postMetricsEvent(m){if(!xe(m))return;this.anonId||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID();const v=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:v},m)}processRequests(m){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:v,payload:E}=this.queue.shift();this.postEvent(v,E,()=>{},m)}}const Ne=new class extends he{constructor(M){super("appUserTurnstile"),this._customAccessToken=M}postTurnstileEvent(M,m){xe(m)&&Array.isArray(M)&&M.some(v=>i.e(v)||i.f(v))&&this.queueRequest(Date.now(),m)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const m=fe(i.g.ACCESS_TOKEN),v=m?m.u:i.g.ACCESS_TOKEN;let E=v!==this.eventData.tokenU;i.v(this.anonId)||(this.refreshUUID(),E=!0);const D=this.queue.shift();if(this.eventData.lastSuccess){const z=new Date(this.eventData.lastSuccess),B=new Date(D),W=(D-this.eventData.lastSuccess)/864e5;E=E||W>=1||W<-1||z.getDate()!==B.getDate()}else E=!0;E?this.postEvent(D,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:Z,"enabled.telemetry":!1,userId:this.anonId},z=>{z||(this.eventData.lastSuccess=D,this.eventData.tokenU=v)},M):this.processRequests()}},Ve=Ne.postTurnstileEvent.bind(Ne),Te=new class extends he{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(M,m,v,E){this.skuToken=m,this.errorCb=E,i.g.EVENTS_URL&&(v||i.g.ACCESS_TOKEN?this.queueRequest({id:M,timestamp:Date.now()},v):this.errorCb(new Error(J)))}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{id:m,timestamp:v}=this.queue.shift();m&&this.success[m]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID(),this.postEvent(v,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:Z,skuToken:this.skuToken,userId:this.anonId},E=>{E?this.errorCb(E):m&&(this.success[m]=!0)},M))}remove(){this.errorCb=null}},Ae=Te.postMapLoadEvent.bind(Te),ze=new class extends he{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(M){let m=this.mapInstanceIdMap.get(M);return m||(m=i.u(),this.mapInstanceIdMap.set(M,m)),m}getEventId(M){const m=this.eventIdPerMapInstanceMap.get(M)||0;return this.eventIdPerMapInstanceMap.set(M,m+1),m}postStyleLoadEvent(M,m){const{map:v,style:E,importedStyles:D}=m;if(!xe(M))return;const z=this.getMapInstanceId(v),B={mapInstanceId:z,eventId:this.getEventId(z),style:E};D.length&&(B.importedStyles=D),this.queueRequest({timestamp:Date.now(),payload:B},M)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:m,payload:v}=this.queue.shift();this.postEvent(m,v,()=>{},M)}},Ee=ze.postStyleLoadEvent.bind(ze),ve=new we({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Re=ve.postMetricsEvent.bind(ve),Ue=new we({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),ye=Ue.postMetricsEvent.bind(Ue),ct=new class extends he{constructor(){super("gljs.performance")}postPerformanceEvent(M,m){xe(M)&&this.queueRequest({timestamp:Date.now(),performanceData:m},M)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:m,performanceData:v}=this.queue.shift(),E=function(D){const z=performance.getEntriesByType("resource"),B=performance.getEntriesByType("mark"),W=function(Me){const $e={};if(Me){for(const Le in Me)if(Le!=="other")for(const Je of Me[Le]){const Qe=`${Le}ResolveRangeMin`,lt=`${Le}ResolveRangeMax`,mt=`${Le}RequestCount`,nt=`${Le}RequestCachedCount`;$e[Qe]=Math.min($e[Qe]||1/0,Je.startTime),$e[lt]=Math.max($e[lt]||-1/0,Je.responseEnd);const zt=bt=>{$e[bt]===void 0&&($e[bt]=0),++$e[bt]};Je.transferSize!==void 0&&Je.transferSize===0&&zt(nt),zt(mt)}}return $e}(function(Me,$e){const Le={};if(Me)for(const Je of Me){const Qe=$e(Je);Le[Qe]===void 0&&(Le[Qe]=[]),Le[Qe].push(Je)}return Le}(z,f)),te=window.devicePixelRatio,ne=navigator.connection||navigator.mozConnection||navigator.webkitConnection,de=ne?ne.effectiveType:void 0,je={counters:[],metadata:[],attributes:[]},be=(Me,$e,Le)=>{Le!=null&&Me.push({name:$e,value:Le.toString()})};for(const Me in W)be(je.counters,Me,W[Me]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(be(je.counters,"interactionRangeMin",D.interactionRange[0]),be(je.counters,"interactionRangeMax",D.interactionRange[1])),B)for(const Me of Object.values(u)){const $e=B.find(Le=>Le.name===Me);$e&&be(je.counters,Me,$e.startTime)}return be(je.counters,"visibilityHidden",D.visibilityHidden),be(je.attributes,"style",function(Me){if(Me)for(const $e of Me){const Le=$e.name.split("?")[0];if(i.i(Le)){const Je=Le.split("/").slice(-2);if(Je.length===2)return`mapbox://styles/${Je[0]}/${Je[1]}`}}}(z)),be(je.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),be(je.attributes,"fogEnabled",D.fogEnabled?"true":"false"),be(je.attributes,"projection",D.projection),be(je.attributes,"zoom",D.zoom),be(je.metadata,"devicePixelRatio",te),be(je.metadata,"connectionEffectiveType",de),be(je.metadata,"navigatorUserAgent",navigator.userAgent),be(je.metadata,"screenWidth",window.screen.width),be(je.metadata,"screenHeight",window.screen.height),be(je.metadata,"windowWidth",window.innerWidth),be(je.metadata,"windowHeight",window.innerHeight),be(je.metadata,"mapWidth",D.width/te),be(je.metadata,"mapHeight",D.height/te),be(je.metadata,"webglRenderer",D.renderer),be(je.metadata,"webglVendor",D.vendor),be(je.metadata,"sdkVersion",d),be(je.metadata,"sdkIdentifier","mapbox-gl-js"),je}(v);for(const D of E.metadata);for(const D of E.counters);for(const D of E.attributes);this.postEvent(m,E,()=>{},M)}},pe=ct.postPerformanceEvent.bind(ct),Ge=new class extends he{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(M,m,v,E){if(!i.g.API_URL||!i.g.SESSION_PATH)return;const D=ae(i.g.API_URL+i.g.SESSION_PATH);D.params.push(`sku=${m||""}`),D.params.push(`access_token=${E||i.g.ACCESS_TOKEN||""}`);const z={url:ie(D),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.h(z,B=>{this.pendingRequest=null,v(B),this.saveEventData(),this.processRequests(E)})}getSessionAPI(M,m,v,E){this.skuToken=m,this.errorCb=E,i.g.EVENTS_URL&&i.g.SESSION_PATH&&i.g.API_URL&&(v||i.g.ACCESS_TOKEN?this.queueRequest({id:M,timestamp:Date.now()},v):this.errorCb(new Error(J)))}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{id:m,timestamp:v}=this.queue.shift();m&&this.success[m]||this.getSession(v,this.skuToken,E=>{E?this.errorCb(E):m&&(this.success[m]=!0)},M)}remove(){this.errorCb=null}},tt=Ge.getSessionAPI.bind(Ge),st=new Set;function Ce(M,m){m?st.add(M):st.delete(M)}class et{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(m,v){this._updatedSourceCaches[m]=v,this.setDirty()}discardSourceCacheUpdate(m){delete this._updatedSourceCaches[m]}updateLayer(m){const v=m.scope;this._updatedLayers[v]=this._updatedLayers[v]||new Set,this._updatedLayers[v].add(m.id),this.setDirty()}removeLayer(m){const v=m.scope;this._removedLayers[v]=this._removedLayers[v]||{},this._updatedLayers[v]=this._updatedLayers[v]||new Set,this._removedLayers[v][m.id]=m,this._updatedLayers[v].delete(m.id),this._updatedPaintProps.delete(m.fqid),this.setDirty()}getRemovedLayer(m){return this._removedLayers[m.scope]?this._removedLayers[m.scope][m.id]:null}discardLayerRemoval(m){this._removedLayers[m.scope]&&delete this._removedLayers[m.scope][m.id]}getLayerUpdatesByScope(){const m={};for(const v in this._updatedLayers)m[v]=m[v]||{},m[v].updatedIds=Array.from(this._updatedLayers[v].values());for(const v in this._removedLayers)m[v]=m[v]||{},m[v].removedIds=Object.keys(this._removedLayers[v]);return m}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(m){this._updatedPaintProps.add(m.fqid),this.setDirty()}getUpdatedImages(m){return this._updatedImages[m]?Array.from(this._updatedImages[m].values()):[]}updateImage(m,v){this._updatedImages[v]=this._updatedImages[v]||new Set,this._updatedImages[v].add(i.I.toString(m)),this.setDirty()}resetUpdatedImages(m){this._updatedImages[m]&&this._updatedImages[m].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function Ct(M){const{userImage:m}=M;return!!(m&&m.render&&m.render())&&(M.data.replace(new Uint8Array(m.data.buffer)),!0)}const Ot={workerUrl:"",workerClass:null,workerParams:void 0};function ut(M){return Ot.workerClass!=null?new Ot.workerClass:new self.Worker(Ot.workerUrl,Object.assign({name:M},Ot.workerParams))}const Oe="mapboxgl_preloaded_worker_pool";class Xe{constructor(m){this.active={},this.name=m}acquire(m,v=Xe.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{v.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Oe]}numActive(){return Object.keys(this.active).length}}Xe.workerCount=2;class at{constructor(m,v,E="Worker",D=Xe.workerCount){this.workerPool=m,this.actors=[],this.currentActor=0,this.id=i.r();const z=this.workerPool.acquire(this.id,D);for(let B=0;B{this.ready=!0})}broadcast(m,v,E){i.t(this.actors,(D,z)=>{D.send(m,v,z)},E=E||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(m=>{m.remove()}),this.actors=[],this.workerPool.release(this.id)}}let Ke,He;function gt(){return Ke||(Ke=new Xe),Ke}at.Actor=i.A;class Mt extends i.E{constructor(m){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=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.imageAtlasCache=new i.x,this.dirty=!0,this.spriteFormat=m,m!=="raster"&&i.y()&&(this.imageRasterizerDispatcher=new at((He||(He=new Xe("ImageRasterizer")),He),this,"Image Rasterizer Worker",1))}addScope(m){this.loaded.set(m,!1),this.imageProviders.set(m,new Map),this.images.set(m,new Map),this.updatedImages.set(m,new Set),this.callbackDispatchedThisFrame.set(m,new Set),this.imageVersions.set(m,new Map),this.patterns.set(m,new Map),this.atlasImage.set(m,new i.q({width:1,height:1}))}removeScope(m){this.loaded.delete(m),this.imageProviders.delete(m),this.images.delete(m),this.updatedImages.delete(m),this.callbackDispatchedThisFrame.delete(m),this.imageVersions.delete(m),this.patterns.delete(m),this.atlasImage.delete(m);const v=this.atlasTexture.get(m);v&&(v.destroy(),this.atlasTexture.delete(m))}addImageProvider(m,v){this.imageProviders.has(v)||this.imageProviders.set(v,new Map),this.imageProviders.get(v).set(m.id,m)}removeImageProvider(m,v){this.imageProviders.has(v)&&this.imageProviders.get(v).delete(m)}getPendingImageProviders(){const m=[];for(const v of this.imageProviders.values())for(const E of v.values())E.hasPendingRequests()&&m.push(E);return m}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new i.z),this._imageRasterizer}isLoaded(){for(const m of this.loaded.keys())if(!this.loaded.get(m))return!1;return!0}setLoaded(m,v){if(this.loaded.get(v)!==m&&(this.loaded.set(v,m),m)){for(const{ids:E,callback:D}of this.requestors)this._notify(E,v,D);this.requestors=[]}}hasImage(m,v){return!!this.getImage(m,v)}getImage(m,v){return this.images.get(v).get(m.toString())}addImage(m,v,E){if(this._validate(m,E)){this.images.get(v).set(m.toString(),E);const D=this.imageVersions.get(v),z=D.get(m.toString())||0;D.set(m.toString(),z+1)}}_validate(m,v){let E=!0;return this._validateStretch(v.stretchX,v.data&&v.data.width)||(this.fire(new i.B(new Error(`Image "${m.name}" has invalid "stretchX" value`))),E=!1),this._validateStretch(v.stretchY,v.data&&v.data.height)||(this.fire(new i.B(new Error(`Image "${m.name}" has invalid "stretchY" value`))),E=!1),this._validateContent(v.content,v)||(this.fire(new i.B(new Error(`Image "${m.name}" has invalid "content" value`))),E=!1),E}_validateStretch(m,v){if(!m)return!0;let E=0;for(const D of m){if(D[0]i.I.from(v))}getImageVersions(m){const v=this.imageVersions.get(m);if(v)return v}getImages(m,v,E){const D=[],z=[],B=this.imageProviders.get(v);for(const de of m){if(!de.iconsetId){D.push(de);continue}const je=B.get(de.iconsetId);je&&(this.getImage(de,v)?z.push(de):je.addPendingRequest(de))}if(D.length===0)return void this._notify(z,v,E);let W=!0;const te=!!this.loaded.get(v),ne=this.images.get(v);if(!te)for(const de of D)ne.has(de.toString())||(W=!1);te||W?this._notify(D,v,E):this.requestors.push({ids:D,scope:v,callback:E})}rasterizeImages(m,v){const E=new Map,{tasks:D,scope:z}=m;for(const[B,W]of D.entries()){const te=this.getImage(W.id,z);te&&E.set(B,{image:te,imageVariant:W})}this._rasterizeImages(z,E,v)}_rasterizeImages(m,v,E){if(i.y())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:v,scope:m},E);else{const D=new Map;for(const[z,{image:B,imageVariant:W}]of v.entries())D.set(z,this.imageRasterizer.rasterize(W,B,m,0));E(void 0,D)}}getUpdatedImages(m){return this.updatedImages.get(m)||new Set}_notify(m,v,E){const D=this.images.get(v),z=new Map;for(const B of m){if(!D.get(B.toString())){if(B.iconsetId)continue;this.fire(new i.C("styleimagemissing",{id:B.name}))}const W=D.get(B.toString());if(!W){i.w(`Image "${B.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 te={data:W.usvg?null:W.data.clone(),pixelRatio:W.pixelRatio,sdf:W.sdf,usvg:W.usvg,stretchX:W.stretchX,stretchY:W.stretchY,content:W.content,hasRenderCallback:!!(W.userImage&&W.userImage.render)};W.usvg&&Object.assign(te,{width:W.icon.usvg_tree.width,height:W.icon.usvg_tree.height}),z.set(i.I.toString(B),te)}E(null,{images:z,versions:this.getImageVersions(v)})}getPixelSize(m){const{width:v,height:E}=this.atlasImage.get(m);return{width:v,height:E}}getPattern(m,v,E){const D=m.toString(),z=this.patterns.get(v),B=z.get(D),W=this.getImage(m,v);if(!W)return null;if(B){if(B.position.version===W.version)return B.position;B.position.version=W.version}else{if(W.usvg&&!W.data){const te=this.getPatternInFlightId(D,v);if(this.patternsInFlight.has(te))return null;this.patternsInFlight.add(te);const ne=new i.D(m).scaleSelf(i.o.devicePixelRatio),de=new Map([[ne.toString(),{image:W,imageVariant:ne}]]);return this._rasterizeImages(v,de,(je,be)=>this.storePatternImage(ne,v,W,E,be)),null}this.storePattern(m,v,W)}return this._updatePatternAtlas(v,E),z.get(D).position}getPatternInFlightId(m,v){return i.F(m,v)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(m,v,E,D,z){const B=m.toString(),W=z?z.get(B):void 0;W&&(E.data=W,this.storePattern(m.id,v,E),this._updatePatternAtlas(v,D),this.patternsInFlight.delete(this.getPatternInFlightId(m.id.toString(),v)))}storePattern(m,v,E){const D={w:E.data.width+2*i.G,h:E.data.height+2*i.G,x:0,y:0},z=new i.H(D,E,i.G);this.patterns.get(v).set(m.toString(),{bin:D,position:z})}destroyAtlasTextures(){for(const m of this.atlasTexture.values())m&&m.destroy();this.atlasTexture.clear()}bind(m,v){const E=m.gl;let D=this.atlasTexture.get(v);D?this.dirty&&(D.update(this.atlasImage.get(v)),this.dirty=!1):(D=new i.T(m,this.atlasImage.get(v),E.RGBA8),this.atlasTexture.set(v,D)),D.bind(E.LINEAR,E.CLAMP_TO_EDGE)}_updatePatternAtlas(m,v){const E=this.patterns.get(m),D=Array.from(E.values()).map(({bin:ne})=>ne),{w:z,h:B}=i.J(D),W=this.atlasImage.get(m);W.resize({width:z||1,height:B||1});const te=this.images.get(m);for(const[ne,{bin:de,position:je}]of E.entries()){let be=je.padding;const Me=de.x+be,$e=de.y+be,Le=te.get(ne).data,Je=Le.width,Qe=Le.height;be=be>1?be-1:be,i.q.copy(Le,W,{x:0,y:0},{x:Me,y:$e},{width:Je,height:Qe},v),i.q.copy(Le,W,{x:0,y:Qe-be},{x:Me,y:$e-be},{width:Je,height:be},v),i.q.copy(Le,W,{x:0,y:0},{x:Me,y:$e+Qe},{width:Je,height:be},v),i.q.copy(Le,W,{x:Je-be,y:0},{x:Me-be,y:$e},{width:be,height:Qe},v),i.q.copy(Le,W,{x:0,y:0},{x:Me+Je,y:$e},{width:be,height:Qe},v),i.q.copy(Le,W,{x:Je-be,y:Qe-be},{x:Me-be,y:$e-be},{width:be,height:be},v),i.q.copy(Le,W,{x:0,y:Qe-be},{x:Me+Je,y:$e-be},{width:be,height:be},v),i.q.copy(Le,W,{x:0,y:0},{x:Me+Je,y:$e+Qe},{width:be,height:be},v),i.q.copy(Le,W,{x:Je-be,y:0},{x:Me-be,y:$e+Qe},{width:be,height:be},v)}this.dirty=!0}beginFrame(){for(const m of this.images.keys())this.callbackDispatchedThisFrame.set(m,new Set)}dispatchRenderCallbacks(m,v){const E=this.images.get(v);for(const D of m){if(this.callbackDispatchedThisFrame.get(v).has(D.toString()))continue;this.callbackDispatchedThisFrame.get(v).add(D.toString());const z=E.get(D.toString());Ct(z)&&this.updateImage(D,v,z)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function Wt(M){const m=M.value,v=M.valueSpec,E=M.style,D=M.styleSpec,z=M.key,B=M.arrayElementValidator||Cr;if(!Array.isArray(m))return[new i.V(z,m,`array expected, ${i.M(m)} found`)];if(v.length&&m.length!==v.length)return[new i.V(z,m,`array length ${v.length} expected, length ${m.length} found`)];if(v["min-length"]&&m.lengthD)return[new i.V(m,v,`${v} is greater than the maximum value ${D}`)]}return[]}function Cs(M){const m=M.key,v=M.value;if(!i.K(v))return[new i.V(m,v,`object expected, ${i.M(v)} found`)];const E=M.valueSpec,D=i.L(v.type);let z,B,W,te={};const ne=D!=="categorical"&&v.property===void 0,de=!ne,je=function(Le){const Je=Le.stops;return Array.isArray(Je)&&Array.isArray(Je[0])&&i.K(Je[0][0])}(v),be=Fn({key:M.key,value:M.value,valueSpec:M.styleSpec.function,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{stops:function(Le){if(D==="identity")return[new i.V(Le.key,Le.value,'identity function may not have a "stops" property')];let Je=[];const Qe=Le.value;return Je=Je.concat(Wt({key:Le.key,value:Qe,valueSpec:Le.valueSpec,style:Le.style,styleSpec:Le.styleSpec,arrayElementValidator:Me})),Array.isArray(Qe)&&Qe.length===0&&Je.push(new i.V(Le.key,Qe,"array must have at least one stop")),Je},default:function(Le){return Cr({key:Le.key,value:Le.value,valueSpec:E,style:Le.style,styleSpec:Le.styleSpec})}}});return D==="identity"&&ne&&be.push(new i.V(M.key,M.value,'missing required property "property"')),D==="identity"||v.stops||be.push(new i.V(M.key,M.value,'missing required property "stops"')),D==="exponential"&&E.expression&&!i.O(E)&&be.push(new i.V(M.key,M.value,"exponential functions not supported")),M.styleSpec.$version>=8&&(de&&!i.Q(E)?be.push(new i.V(M.key,M.value,"property functions not supported")):ne&&!i.S(E)&&be.push(new i.V(M.key,M.value,"zoom functions not supported"))),D!=="categorical"&&!je||v.property!==void 0||be.push(new i.V(M.key,M.value,'"property" property is required')),be;function Me(Le){let Je=[];const Qe=Le.value,lt=Le.key;if(!Array.isArray(Qe))return[new i.V(lt,Qe,`array expected, ${i.M(Qe)} found`)];if(Qe.length!==2)return[new i.V(lt,Qe,`array length 2 expected, length ${Qe.length} found`)];if(je){if(!i.K(Qe[0]))return[new i.V(lt,Qe,`object expected, ${i.M(Qe[0])} found`)];const mt=Qe[0];if(mt.zoom===void 0)return[new i.V(lt,Qe,"object stop key must have zoom")];if(mt.value===void 0)return[new i.V(lt,Qe,"object stop key must have value")];const nt=i.L(mt.zoom);if(typeof nt!="number")return[new i.V(lt,mt.zoom,"stop zoom values must be numbers")];if(W&&W>nt)return[new i.V(lt,mt.zoom,"stop zoom values must appear in ascending order")];nt!==W&&(W=nt,B=void 0,te={}),Je=Je.concat(Fn({key:`${lt}[0]`,value:Qe[0],valueSpec:{zoom:{}},style:Le.style,styleSpec:Le.styleSpec,objectElementValidators:{zoom:xs,value:$e}}))}else Je=Je.concat($e({key:`${lt}[0]`,value:Qe[0],style:Le.style,styleSpec:Le.styleSpec},Qe));return i.U(i.W(Qe[1]))?Je.concat([new i.V(`${lt}[1]`,Qe[1],"expressions are not allowed in function stops.")]):Je.concat(Cr({key:`${lt}[1]`,value:Qe[1],valueSpec:E,style:Le.style,styleSpec:Le.styleSpec}))}function $e(Le,Je){const Qe=i.M(Le.value),lt=i.L(Le.value),mt=Le.value!==null?Le.value:Je;if(z){if(Qe!==z)return[new i.V(Le.key,mt,`${Qe} stop domain type must match previous stop domain type ${z}`)]}else z=Qe;if(Qe!=="number"&&Qe!=="string"&&Qe!=="boolean"&&typeof lt!="number"&&typeof lt!="string"&&typeof lt!="boolean")return[new i.V(Le.key,mt,"stop domain value must be a number, string, or boolean")];if(Qe!=="number"&&D!=="categorical"){let nt=`number expected, ${Qe} found`;return i.Q(E)&&D===void 0&&(nt+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(Le.key,mt,nt)]}return D!=="categorical"||Qe!=="number"||typeof lt=="number"&&isFinite(lt)&&Math.floor(lt)===lt?D!=="categorical"&&Qe==="number"&&typeof lt=="number"&&typeof B=="number"&&B!==void 0&<new i.V(`${M.key}${E.key}`,M.value,E.message));const v=m.value.expression||m.value._styleExpression.expression;if(M.expressionContext==="property"&&M.propertyKey==="text-font"&&!v.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.$(v))return[new i.V(M.key,M.value,'"feature-state" data expressions are not supported with layout properties.')];if(M.expressionContext==="filter")return Ar(v,M);if(M.expressionContext==="appearance")return Bt(v,M);if(M.expressionContext&&M.expressionContext.indexOf("cluster")===0){if(!i.Z(v,["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._(v))return[new i.V(M.key,M.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ar(M,m){const v=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(m.valueSpec&&m.valueSpec.expression)for(const D of m.valueSpec.expression.parameters)v.delete(D);if(v.size===0)return[];const E=[];return M instanceof i.a0&&v.has(M.name)?[new i.V(m.key,m.value,`["${M.name}"] expression is not supported in a filter for a ${m.object.type} layer with id: ${m.object.id}`)]:(M.eachChild(D=>{E.push(...Ar(D,m))}),E)}function Bt(M,m){const v=new Set;if(m.valueSpec&&m.valueSpec.expression)for(const D of m.valueSpec.expression.parameters)v.add(D);if(v.size===0)return[];const E=[];return M instanceof i.a0&&!v.has(M.name)?[new i.V(m.key,m.value,`["${M.name}"] is not an allowed parameter`)]:(M.eachChild(D=>{E.push(...Bt(D,m))}),E)}function Xs(M){const m=M.key,v=M.value,E=M.valueSpec,D=[];return Array.isArray(E.values)?E.values.indexOf(i.L(v))===-1&&D.push(new i.V(m,v,`expected one of [${E.values.join(", ")}], ${JSON.stringify(v)} found`)):Object.keys(E.values).indexOf(i.L(v))===-1&&D.push(new i.V(m,v,`expected one of [${Object.keys(E.values).join(", ")}], ${JSON.stringify(v)} found`)),D}function Nr(M){return i.a4(i.W(M.value))?Us(Object.assign({},M,{expressionContext:"filter",valueSpec:M.styleSpec[`filter_${M.layerType||"fill"}`]})):Vs(M)}function Vs(M){const m=M.value,v=M.key;if(!Array.isArray(m))return[new i.V(v,m,`array expected, ${i.M(m)} found`)];if(m.length<1)return[new i.V(v,m,"filter array must have at least 1 element")];const E=M.styleSpec;let D=Xs({key:`${v}[0]`,value:m[0],valueSpec:E.filter_operator});const z=()=>{m.length>=2&&(i.a2(m[1])||D.push(new i.V(`${v}[1]`,m[1],`string expected, ${i.M(m[1])} found`)));for(let B=2;B":case">=":m.length>=2&&i.L(m[1])==="$type"&&D.push(new i.V(v,m,`"$type" cannot be use with operator "${m[0]}"`)),m.length!==3&&D.push(new i.V(v,m,`filter array for operator "${m[0]}" must have 3 elements`)),z();break;case"==":case"!=":m.length!==3&&D.push(new i.V(v,m,`filter array for operator "${m[0]}" must have 3 elements`)),z();break;case"in":case"!in":z();break;case"any":case"all":case"none":for(let B=1;B{ne in v&&m.push(new i.V(E,v[ne],`"${ne}" is prohibited for ref layers`))}),D.layers.forEach(ne=>{i.L(ne.id)===W&&(te=ne)}),te?te.ref?m.push(new i.V(E,v.ref,"ref cannot reference another ref layer")):B=i.L(te.type):typeof W=="string"&&m.push(new i.V(E,v.ref,`ref layer "${W}" not found`))}else if(B!=="background"&&B!=="sky"&&B!=="slot")if(v.source)if(i.a2(v.source)){const te=D.sources&&D.sources[v.source],ne=te&&i.L(te.type);te?ne==="vector"&&B==="raster"?m.push(new i.V(E,v.source,`layer "${v.id}" requires a raster source`)):ne==="raster"&&B!=="raster"?m.push(new i.V(E,v.source,`layer "${v.id}" requires a vector source`)):ne!=="vector"||v["source-layer"]?ne==="raster-dem"&&B!=="hillshade"?m.push(new i.V(E,v.source,"raster-dem source can only be used with layer type 'hillshade'.")):ne!=="raster-array"||["raster","raster-particle"].includes(B)?B==="line"&&v.paint&&(v.paint["line-gradient"]||v.paint["line-trim-offset"])&&ne==="geojson"&&!te.lineMetrics?m.push(new i.V(E,v,`layer "${v.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):B==="raster-particle"&&ne!=="raster-array"&&m.push(new i.V(E,v.source,`layer "${v.id}" requires a 'raster-array' source.`)):m.push(new i.V(E,v.source,"raster-array source can only be used with layer type 'raster'.")):m.push(new i.V(E,v,`layer "${v.id}" must specify a "source-layer"`)):m.push(new i.V(E,v.source,`source "${v.source}" not found`))}else m.push(new i.V(`${E}.source`,v.source,'"source" must be a string'));else m.push(new i.V(E,v,'missing required property "source"'));return m=m.concat(Fn({key:E,value:v,valueSpec:z.layer,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Cr({key:`${E}.type`,value:v.type,valueSpec:z.layer.type,style:M.style,styleSpec:M.styleSpec,object:v,objectKey:"type"}),filter:te=>Nr(Object.assign({layerType:B},te)),layout:te=>Fn({layer:v,key:te.key,value:te.value,valueSpec:{},style:te.style,styleSpec:te.styleSpec,objectElementValidators:{"*":ne=>Rn(Object.assign({layerType:B},ne))}}),paint:te=>Fn({layer:v,key:te.key,value:te.value,valueSpec:{},style:te.style,styleSpec:te.styleSpec,objectElementValidators:{"*":ne=>Or(Object.assign({layerType:B,layer:v},ne))}}),appearances(te){const ne=Wt({key:te.key,value:te.value,valueSpec:te.valueSpec,style:te.style,styleSpec:te.styleSpec,arrayElementValidator:be=>function(Me){const{key:$e,layer:Le,layerType:Je}=Me,Qe=i.L(Me.value),lt=i.L(Qe.name),mt=i.L(Qe.condition),nt=Fn({key:$e,value:Qe,valueSpec:Me.styleSpec.appearance,style:Me.style,styleSpec:Me.styleSpec,objectElementValidators:{condition:zt=>function(bt){const Dt=[];return Dt.push(...Us({key:bt.key,value:bt.object.condition,valueSpec:i.a8.appearance.condition,expressionContext:"appearance"})),Dt}(Object.assign({layer:Le,layerType:Je},zt)),properties:zt=>function(bt){const Dt=[],{styleSpec:pt,layer:vt,layerType:Tt}=bt,Gt=pt[`paint_${Tt}`],qt=pt[`layout_${Tt}`],ns=bt.object[bt.objectKey];for(const Jt in ns){const Ns=Jt in Gt?"paint":Jt in qt?"layout":void 0;if(!Ns){Dt.push(new i.V(bt.key,Jt,`unknown property "${Jt}" for layer type "${Tt}"`));continue}const Is=Object.assign({},bt,{key:`${bt.key}.${Jt}`,object:ns,objectKey:Jt,layer:vt,layerType:Tt,value:ns[Jt],valueSpec:Ns==="paint"?Gt[Jt]:qt[Jt]});Dt.push(...ar(Is,Ns))}return Dt}(Object.assign({layer:Le,layerType:Je},zt))}});return lt!=="hidden"&&mt===void 0&&nt.push(new i.V(Me.key,"name",'Appearance with name different than "hidden" must have a condition')),nt}(Object.assign({layerType:B,layer:v},be))}),de=Array.isArray(te.value)?te.value:[],je=new Set;return de.forEach((be,Me)=>{const $e=i.L(be.name);if($e)if(je.has($e)){const Le=i.L(v.id);ne.push(new i.V(te.key,$e,`Duplicated appearance name "${$e}" for layer "${Le}"`))}else je.add($e)}),ne}}})),m}function ir({key:M,value:m}){return i.a2(m)?[]:[new i.V(M,m,`string expected, ${i.M(m)} found`)]}const or={promoteId:function M({key:m,value:v}){if(i.a2(v))return ir({key:m,value:v});if(Array.isArray(v)){const D=[],z=i.W(v),B=i.X(z);return B.result==="error"?(B.value.forEach(W=>{D.push(new i.V(`${m}${W.key}`,null,`${W.message}`))}),D):(i.Z(B.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(`${m}`,null,"promoteId expression should be only feature dependent")),D)}if(!i.K(v))return[new i.V(m,v,`string, expression or object expected, "${i.M(v)}" found`)];const E=[];for(const D in v)E.push(...M({key:`${m}.${D}`,value:v[D]}));return E}};function hr(M){const m=M.value,v=M.key,E=M.styleSpec,D=M.style;if(!i.K(m))return[new i.V(v,m,`object expected, ${i.M(m)} found`)];if(!("type"in m))return[new i.V(v,m,'"type" is required')];const z=i.L(m.type);let B=[];switch(["vector","raster","raster-dem","raster-array"].includes(z)&&("url"in m||"tiles"in m||B.push(new i.a5(v,m,'Either "url" or "tiles" is required.'))),z){case"vector":case"raster":case"raster-dem":case"raster-array":return B=B.concat(Fn({key:v,value:m,valueSpec:E[`source_${z.replace("-","_")}`],style:M.style,styleSpec:E,objectElementValidators:or})),B;case"geojson":if(B=Fn({key:v,value:m,valueSpec:E.source_geojson,style:D,styleSpec:E,objectElementValidators:or}),"cluster"in m&&"clusterProperties"in m){if(!i.K(m.clusterProperties))return[new i.V(`${v}.clusterProperties`,m,`object expected, ${i.M(m)} found`)];for(const W in m.clusterProperties){const te=m.clusterProperties[W];if(!Array.isArray(te))return[new i.V(`${v}.clusterProperties.${W}`,te,"array expected")];const[ne,de]=te,je=typeof ne=="string"?[ne,["accumulated"],["get",W]]:ne;B.push(...Us({key:`${v}.${W}.map`,value:de,expressionContext:"cluster-map"})),B.push(...Us({key:`${v}.${W}.reduce`,value:je,expressionContext:"cluster-reduce"}))}}return B;case"video":return Fn({key:v,value:m,valueSpec:E.source_video,style:D,styleSpec:E});case"image":return Fn({key:v,value:m,valueSpec:E.source_image,style:D,styleSpec:E});case"canvas":return[new i.V(v,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Xs({key:`${v}.type`,value:m.type,valueSpec:{values:an(E)}})}}function an(M){return M.source.reduce((m,v)=>{const E=M[v];return E.type.type==="enum"&&(m=m.concat(Object.keys(E.type.values||{}))),m},[])}function Gr(M){const m=M.value,v=M.styleSpec,E=v.light,D=M.style;if(m===void 0)return[];if(!i.K(m))return[new i.V("light",m,`object expected, ${i.M(m)} found`)];let z=[];for(const B in m){const W=B.match(/^(.*)-transition$/),te=B.match(/^(.*)-use-theme$/);z=z.concat(te&&E[te[1]]?Cr({key:B,value:m[B],valueSpec:{type:"string"},style:D,styleSpec:v}):W&&E[W[1]]&&E[W[1]].transition?Cr({key:B,value:m[B],valueSpec:v.transition,style:D,styleSpec:v}):E[B]?Cr({key:B,value:m[B],valueSpec:E[B],style:D,styleSpec:v}):[new i.V(B,m[B],`unknown property "${B}"`)])}return z}function Va(M){const m=M.value;if(!m)return[];const v=M.key;if(!i.K(m))return[new i.V(v,m,`object expected, ${i.M(m)} found`)];let E=[];const D=M.styleSpec,z=D["light-3d"],B=M.style,W=M.style.lights;for(const de of["type","id"])if(!(de in m))return E=E.concat([new i.V(v,m,`missing property "${de}"`)]),E;if(!i.a2(m.type))return E=E.concat([new i.V(`${v}.type`,m.type,"string expected")]),E;if(W)for(let de=0;de[],array:Wt,boolean:function(M){const m=M.value,v=M.key;return i.a1(m)?[]:[new i.V(v,m,`boolean expected, ${i.M(m)} found`)]},number:xs,color:function({key:M,value:m}){return i.a2(m)?i.a3.parseCSSColor(m)===null?[new i.V(M,m,`color expected, "${m}" found`)]:[]:[new i.V(M,m,`color expected, ${i.M(m)} found`)]},enum:Xs,filter:Nr,function:Cs,layer:bn,object:Fn,source:hr,model:i.a9,light:Gr,"light-3d":Va,terrain:$a,fog:Xt,string:ir,formatted:function(M){return ir(M).length===0?[]:Us(M)},resolvedImage:function(M){return ir(M).length===0?[]:Us(M)},projection:function(M){const m=M.value,v=M.styleSpec,E=v.projection,D=M.style;if(i.K(m)){let z=[];for(const B in m)z=z.concat(Cr({key:B,value:m[B],valueSpec:E[B],style:D,styleSpec:v}));return z}return i.a2(m)?[]:[new i.V("projection",m,`object or string expected, ${i.M(m)} found`)]},import:function(M){const m=M.key,{value:v,styleSpec:E}=M;if(!i.K(v))return[new i.V(m,v,"import must be an object")];const{data:D,...z}=v;Object.defineProperty(z,"__line__",{value:v.__line__,enumerable:!1});let B=Fn(Object.assign({},M,{value:z,valueSpec:E.import}));return i.L(z.id)===""&&B.push(new i.V(`${M.key}.id`,z,"import id can't be an empty string")),D&&(B=B.concat(Mr(D,E,{key:`${M.key}.data`}))),B},iconset:function(M){const m=M.value,v=M.key,E=M.styleSpec,D=M.style;if(!i.K(m))return[new i.V(v,m,"object expected")];if(!m.type)return[new i.V(v,m,'"type" is required')];const z=i.L(m.type);let B=[];if(B=B.concat(Fn({key:v,value:m,valueSpec:E[`iconset_${z}`],style:D,styleSpec:E})),function(W,te){return!(W!=="source"||!te.source)}(z,m)){const W=D.sources&&D.sources[m.source],te=W&&i.L(W.type);W?te!=="raster-array"&&B.push(new i.V(v,m.source,`iconset cannot be used with a source of type ${String(te)}, it only be used with a "raster-array" source type`)):B.push(new i.V(v,m.source,`source "${m.source}" not found`))}return B}};function Cr(M,m=!1){const v=M.value,E=M.valueSpec,D=M.styleSpec;if(E.expression){if(i.a6(i.L(v)))return Cs(M);if(i.U(i.W(v)))return Us(M)}if(E.type&&Qa[E.type]){const z=Qa[E.type](M);return m===!0&&z.length>0&&Array.isArray(M.value)?Us(M):z}return Fn(Object.assign({},M,{valueSpec:E.type?D[E.type]:E}))}function Fn(M){const m=M.key,v=M.value,E=M.valueSpec||{},D=M.objectElementValidators||{},z=M.style,B=M.styleSpec;if(!i.K(v))return[new i.V(m,v,`object expected, ${i.M(v)} found`)];let W=[];for(const te in v){const ne=te.split(".")[0];let de;D[ne]?de=D[ne]:E[ne]?de=Cr:D["*"]?de=D["*"]:E["*"]&&(de=Cr),de?W=W.concat(de({key:(m&&`${m}.`)+te,value:v[te],valueSpec:E[ne]||E["*"],style:z,styleSpec:B,object:v,objectKey:te},v)):W.push(new i.a5(m,v[te],`unknown property "${te}"`))}for(const te in E){if(D[te])continue;const ne=E[te];ne.required&&ne.default===void 0&&v[te]===void 0&&W.push(new i.V(m,v,`missing required property "${te}"`))}return W}function Kt({key:M,value:m}){const v=ir({key:M,value:m});if(v.length)return v;const E=m;return E.indexOf("{fontstack}")===-1&&v.push(new i.V(M,m,'"glyphs" url must include a "{fontstack}" token')),E.indexOf("{range}")===-1&&v.push(new i.V(M,m,'"glyphs" url must include a "{range}" token')),v}function Mr(M,m=i.a8,v={}){return Fn({key:v.key||"",value:M,valueSpec:Object.assign(m.$root,{"*":{type:"*"}}),styleSpec:m,style:M,objectElementValidators:{glyphs:Kt}})}function On(M,m=i.a8){return ys(Mr(M,m))}const ua=M=>ys(hr(M)),$t=M=>ys(Gr(M)),Se=M=>ys(Va(M)),De=M=>ys($a(M)),Ze=M=>ys(Xt(M)),xt=M=>ys(function(m){const v=m.value,E=m.style,D=m.styleSpec,z=D.snow;if(v===void 0)return[];if(!i.K(v))return[new i.V("snow",v,`object expected, ${i.M(v)} found`)];let B=[];for(const W in v){const te=W.match(/^(.*)-transition$/);B=B.concat(te&&z[te[1]]&&z[te[1]].transition?Cr({key:W,value:v[W],valueSpec:D.transition,style:E,styleSpec:D}):z[W]?Cr({key:W,value:v[W],valueSpec:z[W],style:E,styleSpec:D}):[new i.a5(W,v[W],`unknown property "${W}"`)])}return B}(M)),_t=M=>ys(function(m){const v=m.value,E=m.style,D=m.styleSpec,z=D.rain;if(v===void 0)return[];if(!i.K(v))return[new i.V("rain",v,`object expected, ${i.M(v)} found`)];let B=[];for(const W in v){const te=W.match(/^(.*)-transition$/);B=B.concat(te&&z[te[1]]&&z[te[1]].transition?Cr({key:W,value:v[W],valueSpec:D.transition,style:E,styleSpec:D}):z[W]?Cr({key:W,value:v[W],valueSpec:z[W],style:E,styleSpec:D}):[new i.a5(W,v[W],`unknown property "${W}"`)])}return B}(M)),Pt=M=>ys(bn(M)),Yt=M=>ys(Nr(M)),Vt=M=>ys(Or(M)),Qt=M=>ys(Rn(M)),Es=M=>ys(i.a9(M));function ys(M){return M.slice().sort((m,v)=>m.line&&v.line?m.line-v.line:0)}function lr(M,m){let v=!1;if(m&&m.length)for(const E of m)E instanceof i.a5?i.w(E.message):(M.fire(new i.B(new Error(E.message))),v=!0);return v}const Fr=i.a8.light;let Br;class zr extends i.E{constructor(m,v="flat"){super(),this._transitionable=new i.aa(Br||(Br=new i.ab({anchor:new i.ac(Fr.anchor),position:new i.ad(Fr.position),color:new i.ac(Fr.color),intensity:new i.ac(Fr.intensity)}))),this.setLight(m,v),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(m,v,E={}){this._validate($t,m,E)||(this._transitionable.setTransitionOrValue(m),this.id=v)}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,v,E){return(!E||E.validate!==!1)&&lr(this,m.call(On,Object.assign({value:v,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}}const un=i.a8.terrain;let Vn=class extends i.E{constructor(M,m,v,E,D){super(),this.scope=v,this._transitionable=new i.aa(new i.ab({source:new i.ac(un.source),exaggeration:new i.ac(un.exaggeration)}),v,E),this._transitionable.setTransitionOrValue(M,E),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=m,this.worldview=D}get(){return this._transitionable.serialize()}set(M,m){this._transitionable.setTransitionOrValue(M,m)}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.ae(M,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const M=this._transitionable._values.exaggeration;if(!M)return null;const m=M.value.expression;if(!m)return null;let v=-1,E=-1,D=1;for(const z of m.zoomStops)D=m.evaluate(new i.ae(z,{worldview:this.worldview})),D>.01?(v=z,E=-1):E=z;return D<.01&&v>0&&E>v?[v,E]:null}isZoomDependent(){const M=this._transitionable._values.exaggeration;return M!=null&&M.value!=null&&M.value.expression!=null&&M.value.expression instanceof i.af}};const Zn=.05;function vi(M,m,v,E){const D=i.aj(45,65,v),[z,B]=To(M,E);let W=1-Math.min(1,Math.exp((m-z)/(B-z)*-6));return W*=W*W,W=Math.min(1,1.00747*W),W*D*M.alpha}function To(M,m){const v=.5/Math.tan(.5*m);return[M.range[0]+v,M.range[1]+v]}function Ha(M,m,v,E,D){const z=i.ah([],[m,v,E],D.mercatorFogMatrix);return vi(M,i.ai(z),D.pitch,D._fov)}function no(M,m,v,E,D,z,B){const W=[[v,E,0],[D,E,0],[D,z,0],[v,z,0]];let te=Number.MAX_VALUE,ne=-Number.MAX_VALUE;for(const de of W){const je=i.ah([],de,m),be=i.ai(je);te=Math.min(te,be),ne=Math.max(ne,be)}return[vi(M,te,B.pitch,B._fov),vi(M,ne,B.pitch,B._fov)]}const ai=i.a8.fog;class zi extends i.E{constructor(m,v,E,D){super();const z=new i.ab({range:new i.ac(ai.range),color:new i.ac(ai.color),"color-use-theme":new i.ac({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.ac(ai["high-color"]),"high-color-use-theme":new i.ac({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.ac(ai["space-color"]),"space-color-use-theme":new i.ac({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.ac(ai["horizon-blend"]),"star-intensity":new i.ac(ai["star-intensity"]),"vertical-range":new i.ac(ai["vertical-range"])});this._transitionable=new i.aa(z,E,new Map(D)),this.set(m,D),this._transitioning=this._transitionable.untransitioned(),this._transform=v,this.properties=new i.ak(z),this.scope=E}get state(){const m=this._transform,v=m.projection.name==="globe",E=i.al(m.zoom),D=this.properties.get("range"),z=[.5,3];return{range:v?[i.am(z[0],D[0],E),i.am(z[1],D[1],E)]:D,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(m,v,E={}){if(this._validate(Ze,m,E))return;const D=Object.assign({},m);for(const z of Object.keys(ai))D[z]===void 0&&(D[z]=ai[z].default);this._options=D,this._transitionable.setTransitionOrValue(this._options,v)}getOpacity(m){if(!this._transform.projection.supportsFog)return 0;const v=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:i.aj(45,65,m))*v.a}getOpacityAtLatLng(m,v){return this._transform.projection.supportsFog?function(E,D,z){const B=i.ag.fromLngLat(D),W=z.elevation?z.elevation.getAtPointOrZero(B):0;return Ha(E,B.x,B.y,W,z)}(this.state,m,v):0}getOpacityForTile(m){if(!this._transform.projection.supportsFog)return[1,1];const v=this._transform.calculateFogTileMatrix(m.toUnwrapped());return no(this.state,v,0,0,i.an,i.an,this._transform)}getOpacityForBounds(m,v,E,D,z){return this._transform.projection.supportsFog?no(this.state,m,v,E,D,z,this._transform):[1,1]}getFovAdjustedRange(m){return this._transform.projection.supportsFog?To(this.state,m):[0,1]}isVisibleOnFrustum(m){if(!this._transform.projection.supportsFog)return!1;const v=[4,5,6,7];for(const E of v){const D=m.points[E];let z;if(D[2]>=0)z=D;else{const B=m.points[E-4];z=i.ao(B,D,B[2]/(B[2]-D[2]))}if(Ha(this.state,z[0],z[1],0,this._transform)>=Zn)return!0}return!1}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,v,E){return(!E||E.validate!==!1)&&lr(this,m.call(On,Object.assign({value:v,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}}let Qo,fi,Ki,Bi=class extends i.E{constructor(M,m,v,E){super();const D=Qo||(Qo=new i.ab({density:new i.ac(i.a8.snow.density),intensity:new i.ac(i.a8.snow.intensity),color:new i.ac(i.a8.snow.color),opacity:new i.ac(i.a8.snow.opacity),vignette:new i.ac(i.a8.snow.vignette),"vignette-color":new i.ac(i.a8.snow["vignette-color"]),"center-thinning":new i.ac(i.a8.snow["center-thinning"]),direction:new i.ac(i.a8.snow.direction),"flake-size":new i.ac(i.a8.snow["flake-size"])}));this._transitionable=new i.aa(D,v,new Map(E)),this.set(M,E),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ak(D),this.scope=v}get state(){const M=this.properties.get("opacity"),m=this.properties.get("color"),v=this.properties.get("direction"),E=i.ap(v[0]),D=-Math.max(i.ap(v[1]),.01),z=[Math.cos(E)*Math.cos(D),Math.sin(E)*Math.cos(D),Math.sin(D)],B=this.properties.get("vignette"),W=this.properties.get("vignette-color");return W.a=B,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.aq(m.r,m.g,m.b,m.a*M),direction:z,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:W}}get(){return this._transitionable.serialize()}set(M,m,v={}){if(this._validate(xt,M,v))return;const E=Object.assign({},M),D=i.a8.snow;for(const z of Object.keys(D))E[z]===void 0&&(E[z]=D[z].default);this._options=E,this._transitionable.setTransitionOrValue(this._options,m)}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,m,v){return(!v||v.validate!==!1)&&lr(this,M.call(On,Object.assign({value:m,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}},oa=class extends i.E{constructor(M,m,v,E){super();const D=fi||(fi=new i.ab({density:new i.ac(i.a8.rain.density),intensity:new i.ac(i.a8.rain.intensity),color:new i.ac(i.a8.rain.color),opacity:new i.ac(i.a8.rain.opacity),vignette:new i.ac(i.a8.rain.vignette),"vignette-color":new i.ac(i.a8.rain["vignette-color"]),"center-thinning":new i.ac(i.a8.rain["center-thinning"]),direction:new i.ac(i.a8.rain.direction),"droplet-size":new i.ac(i.a8.rain["droplet-size"]),"distortion-strength":new i.ac(i.a8.rain["distortion-strength"])}));this._transitionable=new i.aa(D,v,new Map(E)),this.set(M,E),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ak(D),this.scope=v}get state(){const M=this.properties.get("opacity"),m=this.properties.get("color"),v=this.properties.get("direction"),E=i.ap(v[0]),D=-Math.max(i.ap(v[1]),.01),z=[Math.cos(E)*Math.cos(D),Math.sin(E)*Math.cos(D),Math.sin(D)],B=this.properties.get("vignette-color");return B.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.aq(m.r,m.g,m.b,m.a*M),direction:z,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:B}}get(){return this._transitionable.serialize()}set(M,m,v={}){if(this._validate(_t,M,v))return;const E=Object.assign({},M),D=i.a8.rain;for(const z of Object.keys(D))E[z]===void 0&&(E[z]=D[z].default);this._options=E,this._transitionable.setTransitionOrValue(this._options,m)}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,m,v){return(!v||v.validate!==!1)&&lr(this,M.call(On,Object.assign({value:m,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}};class Jo extends i.E{constructor(m,v,E,D){super(),this.scope=E,this._options=m,this.properties=new i.ak(v),this._transitionable=new i.aa(v,E,new Map(D)),this._transitionable.setTransitionOrValue(m.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(m){this._transitionable.setTransitionOrValue(this._options.properties,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)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(m,v){this._options=m,this._transitionable.setTransitionOrValue(m.properties,v)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}const Cc=()=>Ki||(Ki=new i.ab({color:new i.ac(i.a8.properties_light_ambient.color),"color-use-theme":new i.ac({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.ac(i.a8.properties_light_ambient.intensity)}));let Bl;const Hd=()=>Bl||(Bl=new i.ab({direction:new i.ar(i.a8.properties_light_directional.direction),color:new i.ac(i.a8.properties_light_directional.color),"color-use-theme":new i.ac({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.ac(i.a8.properties_light_directional.intensity),"cast-shadows":new i.ac(i.a8.properties_light_directional["cast-shadows"]),"shadow-quality":new i.ac(i.a8.properties_light_directional["shadow-quality"]),"shadow-intensity":new i.ac(i.a8.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new i.ac(i.a8.properties_light_directional["shadow-draw-before-layer"])}));class vu{constructor(m,v,E){this.screenBounds=m,this.cameraPoint=E.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=v,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,E)}static createFromScreenPoints(m,v){let E,D;if(m instanceof i.P||typeof m[0]=="number"){const z=i.P.convert(m);E=[z],D=v.isPointAboveHorizon(z)}else{const z=i.P.convert(m[0]),B=i.P.convert(m[1]),W=z.add(B)._div(2);E=[z,B],D=i.as(z,B).every(te=>v.isPointAboveHorizon(te))&&v.isPointAboveHorizon(W)}return new vu(E,D,v)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(m){return i.as(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],m)}bufferedCameraGeometry(m){const v=this.screenBounds[0],E=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.as(v,E,0,!1);return this.cameraPoint.y>E.y&&(this.cameraPoint.x>v.x&&this.cameraPoint.x=E.x?D[2]=this.cameraPoint:this.cameraPoint.x<=v.x&&(D[3]=this.cameraPoint)),i.at(D,m)}bufferedCameraGeometryGlobe(m){const v=this.screenBounds[0],E=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.as(v,E,m),z=this.cameraPoint.clone(),B=+(z.x>v.x)+ +(z.x>E.x);switch(3*(+(z.y>v.y)+ +(z.y>E.y))+B){case 0:D[0]=z,D[4]=z.clone();break;case 1:D.splice(1,0,z);break;case 2:D[1]=z;break;case 3:D.splice(4,0,z);break;case 5:D.splice(2,0,z);break;case 6:D[3]=z;break;case 7:D.splice(3,0,z);break;case 8:D[2]=z}return D}containsTile(m,v,E,D=0){const z=Math.max(m.queryPadding,m.evaluateQueryRenderedFeaturePadding())/v._pixelsPerMercatorPixel+1,B=E?this._bufferedCameraMercator(z,v):this._bufferedScreenMercator(z,v);let W=m.tileID.wrap+(B.unwrapped?D:0);const te=B.polygon.map(Je=>i.au(m.tileTransform,Je,W));if(!i.av(te,0,0,i.an,i.an))return;W=m.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const ne=this.screenGeometryMercator.polygon.map(Je=>i.aw(m.tileTransform,Je,W)),de=ne.map(Je=>new i.P(Je[0],Je[1])),je=v.getFreeCameraOptions().position||new i.ag(0,0,0),be=i.aw(m.tileTransform,je,W),Me=ne.map(Je=>{const Qe=i.ax(Je,Je,be);return i.ay(Qe,Qe),new i.az(be,Qe)}),$e=i.aA(m,1,v.zoom)*v._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:de,tilespaceRays:Me,bufferedTilespaceGeometry:te,bufferedTilespaceBounds:(Le=i.aB(te),Le.min.x=i.aC(Le.min.x,0,i.an),Le.min.y=i.aC(Le.min.y,0,i.an),Le.max.x=i.aC(Le.max.x,0,i.an),Le.max.y=i.aC(Le.max.y,0,i.an),Le),tile:m,tileID:m.tileID,pixelToTileUnitsFactor:$e};var Le}_bufferedScreenMercator(m,v){const E=_u(m);if(this._screenRaycastCache[E])return this._screenRaycastCache[E];{let D;return D=v.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(m),v):{polygon:this.bufferedScreenGeometry(m).map(z=>v.pointCoordinate3D(z)),unwrapped:!0},this._screenRaycastCache[E]=D,D}}_bufferedCameraMercator(m,v){const E=_u(m);if(this._cameraRaycastCache[E])return this._cameraRaycastCache[E];{let D;return D=v.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(m),v):{polygon:this.bufferedCameraGeometry(m).map(z=>v.pointCoordinate3D(z)),unwrapped:!0},this._cameraRaycastCache[E]=D,D}}_projectAndResample(m,v){const E=function(z,B){const W=i.aD([],B.pixelMatrix,B.globeMatrix),te=[0,-i.aF,0,1],ne=[0,i.aF,0,1],de=[0,0,0,1];i.aE(te,te,W),i.aE(ne,ne,W),i.aE(de,de,W);const je=new i.P(te[0]/te[3],te[1]/te[3]),be=new i.P(ne[0]/ne[3],ne[1]/ne[3]),Me=i.aG(z,je)&&te[3]1?Rm(z.slice(0,Je),B):[],mt=Jenew i.P(Nd(Dt.x),Dt.y)),mt=mt.map(Dt=>new i.P(Nd(Dt.x),Dt.y));const nt=[...lt];nt.length===0&&nt.push(mt[mt.length-1]);const zt=i.am(nt[nt.length-1].y,(mt.length===0?lt[0]:mt[0]).y,Qe);let bt;return bt=Me?[new i.P(0,zt),new i.P(0,0),new i.P(1,0),new i.P(1,zt)]:[new i.P(1,zt),new i.P(1,1),new i.P(0,1),new i.P(0,zt)],nt.push(...bt),mt.length===0?nt.push(lt[0]):nt.push(...mt),{polygon:nt.map(Dt=>new i.ag(Dt.x,Dt.y)),unwrapped:!1}}(m,v);if(E)return E;const D=function(z,B){let W=!1,te=-1/0,ne=0;for(let je=0;jete&&(te=z[je].x,ne=je);for(let je=0;je.5&&(Me.x<$e.x?(Me.x+=1,be===0&&(z[z.length-1].x+=1)):($e.x+=1,be+1===z.length-1&&(z[0].x+=1)),W=!0)}const de=i.aH(B.center.lng);return W&&de{je.x-=1}),{polygon:z,unwrapped:W}}(Rm(m,v).map(z=>new i.P(Nd(z.x),z.y)),v);return{polygon:D.polygon.map(z=>new i.ag(z.x,z.y)),unwrapped:D.unwrapped}}}function Rm(M,m){return i.aI(M,v=>{const E=m.pointCoordinate3D(v);v.x=E.x,v.y=E.y},1/256)}function Nd(M){return M<0?1+M%1:M%1}function _u(M){return 100*M|0}function Om(M,m,v){try{m=function(D){if(!D.variants)return D;if(!Array.isArray(D.variants))throw new Error("variants must be an array");for(const z of D.variants){if(z==null||typeof z!="object"||z.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(z.capabilities))throw new Error("capabilities must be an array");if(z.capabilities.length===1&&z.capabilities[0]==="meshopt")return Object.assign(D,z)}return D}(m)}catch(D){return new Error("Failed to process TileJSON variants",{cause:D})}const E=i.aJ(Object.assign({},m,M),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return M.url&&m.tiles&&M.tiles&&(E.tiles=m.tiles),E.tiles=v.canonicalizeTileset(E,M.url),E}function Vu(M,m,v,E,D){const z=function(W,te){if(W)return D(W);if(te){M.url&&te.tiles&&M.tiles&&delete M.tiles;const ne=Om(M,te,m);if(ne instanceof Error)return D(ne);D(null,ne)}},B=function(W,te,ne){if(!W)return null;if(!te&&!ne)return W;ne=ne||W.worldview_default;const de=Object.values(W.language||{});if(de.length===0)return null;const je=Object.values(W.worldview||{});if(je.length===0)return null;const be=de.every($e=>$e===te),Me=je.every($e=>$e===ne);return be&&Me?W:te in(W.language_options||{})||ne in(W.worldview_options||{})?null:W.language_options&&W.worldview_options?W:null}(M.data,v,E);return B?i.o.frame(()=>z(null,B)):M.url?i.m(m.transformRequest(m.normalizeSourceURL(M.url,null,v,E),i.R.Source),z):i.o.frame(()=>{const{data:W,...te}=M;z(null,te)})}function Fm(M,m){const v=Math.pow(2,m.z),E=Math.floor(i.aH(M.getWest())*v),D=Math.floor(i.aL(M.getNorth())*v),z=Math.ceil(i.aH(M.getEast())*v),B=Math.ceil(i.aL(M.getSouth())*v);return m.x>=E&&m.x=D&&m.ythis.maxzoom||m.z{this._tileJSONRequest=null,this._loaded=!0,B?(v&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${v}`),E&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${E}`),this.fire(new i.B(B))):W&&(this._setTileJSON(W),Ve(W.tiles,this.map._requestManager._customAccessToken),this.fire(new i.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.C("data",{dataType:"source",sourceDataType:"content"}))),m&&m(B)};this.provider=this._options.provider;const z=function(B){if("provider"in B&&!B.provider)return null;let W=B.provider;if(!W&&"url"in B&&B.url&&(W=i.aM(B.url)),!W)return null;const te=i.g.TILE_PROVIDER_URLS[W];if(!te)return null;let ne;try{ne=new URL(te,i.g.API_URL).href}catch{return i.w(`TileProvider "${W}" has an invalid URL: "${te}"`),null}return{name:W,url:ne}}(this._options);if(this.provider&&!z)return this._loaded=!0,this.fire(new i.B(new Error(`TileProvider "${this.provider}" is not registered`))),void(m&&m());this._tileJSONRequest=z?this._loadWithProvider(z,D):Vu(this._options,this.map._requestManager,v,E,D)}_loadWithProvider(m,v){this.provider=m.name;const E=new AbortController,D=this._options.url&&!this._options.tiles?this.map._requestManager.transformRequest(this._options.url,i.R.Source):void 0,z=D?Object.assign({},this._options,{url:D.url}):this._options;return this.dispatcher.broadcast("loadTileProvider",{name:m.name,url:m.url,source:this.id,scope:this.scope,type:this.type,options:z,request:D},(B,W)=>{if(E.signal.aborted)return;if(B)return void v(B);const te=W?W.find(ne=>ne!=null):null;if(te){const ne=Om(this._options,te,this.map._requestManager);ne instanceof Error?v(ne):v(null,ne)}else v(null,{tiles:this._options.tiles})}),{cancel:()=>{E.abort()}}}_setTileJSON(m){if(Object.assign(this,m),this.hasWorldviews=!!m.worldview_options,m.worldview_default&&(this.worldviewDefault=m.worldview_default),m.vector_layers){this.vectorLayers=m.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const v of m.vector_layers)this.vectorLayerIds.push(v.id),m.worldview&&m.worldview[v.source]&&this.localizableLayerIds.add(v.id)}this.tileBounds=xh.fromTileJSON(m)}loaded(){return this._loaded}hasTile(m){return!this.tileBounds||this.tileBounds.contains(m.canonical)}onAdd(m){this.map=m,this.load()}reload(){this.cancelTileJSONRequest();const m=i.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(m))}setTiles(m){return this._options.tiles=m,this.reload(),this}setUrl(m){return this.url=m,this._options.url=m,this.reload(),this}onRemove(m){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(m,v){const E=m.tileID.canonical.url(this.tiles,this.scheme),D=this.map._requestManager.normalizeTileURL(E),z=this.map._requestManager.transformRequest(D,i.R.Tile),B=this.map.style?this.map.style.getLut(this.scope):null,W=B?{image:B.image.clone()}:null,te={request:z,data:void 0,uid:m.uid,tileID:m.tileID,tileZoom:m.tileZoom,zoom:m.tileID.overscaledZ,maxZoom:this.maxzoom,lut:W,tileSize:this.tileSize*m.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,renderSourceType:m.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:m.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&i.e(E)&&(te.localizableLayerIds=this.localizableLayerIds),te.request.collectResourceTiming=this._collectResourceTiming,m.actor&&m.state!=="expired")m.state==="loading"?m.reloadCallback=v:m.request=m.actor.send("reloadTile",te,ne.bind(this));else if(m.actor=this._tileWorkers[D]=this._tileWorkers[D]||this.dispatcher.getActor(),this.dispatcher.ready||this.provider)m.request=m.actor.send("loadTile",te,ne.bind(this),void 0,!0);else{const de=i.aO.call({deduped:this._deduped},te,(je,be)=>{if(je||!be)ne.call(this,je);else{const Me=i.aP(be.responseHeaders);te.data={rawData:be.rawData.slice(0),expires:Me.expires,cacheControl:Me.cacheControl},m.actor&&m.actor.send("loadTile",te,ne.bind(this),void 0,!0)}},!0);m.request={cancel:de}}function ne(de,je){return delete m.request,m.aborted?v(null):de?v(de):(je&&je.resourceTiming&&(m.resourceTiming=je.resourceTiming),this.map._refreshExpiredTiles&&je&&m.setExpiryData(je),m.loadVectorData(je,this.map.painter),i.aQ(this.dispatcher),v(null,je),void(m.reloadCallback&&(this.loadTile(m,m.reloadCallback),m.reloadCallback=null)))}}abortTile(m){m.request&&(m.request.cancel(),delete m.request),m.actor&&m.actor.send("abortTile",{uid:m.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(m,v){m.actor&&m.actor.send("removeTile",{uid:m.uid,type:this.type,source:this.id,scope:this.scope}),m.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class jp extends i.E{constructor(m,v,E,D){super(),this.id=m,this.dispatcher=E,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"},v),Object.assign(this,i.aJ(v,["url","scheme","tileSize"]))}load(m){this._loaded=!1,this.fire(new i.C("dataloading",{dataType:"source"}));const v=this.map.getWorldview();this._tileJSONRequest=Vu(this._options,this.map._requestManager,null,v,(E,D)=>{this._tileJSONRequest=null,this._loaded=!0,E?this.fire(new i.B(E)):D&&(Object.assign(this,D),D.raster_layers&&(this.rasterLayers=D.raster_layers,this.rasterLayerIds=this.rasterLayers.map(z=>z.id)),this.tileBounds=xh.fromTileJSON(D),Ve(D.tiles),this.fire(new i.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.C("data",{dataType:"source",sourceDataType:"content"}))),m&&m(E)})}loaded(){return this._loaded}onAdd(m){this.map=m,this.load()}reload(){this.cancelTileJSONRequest();const m=i.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(m))}setTiles(m){return this._options.tiles=m,this.reload(),this}setUrl(m){return this.url=m,this._options.url=m,this.reload(),this}onRemove(m){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(m){return!this.tileBounds||this.tileBounds.contains(m.canonical)}loadTile(m,v){const E=i.o.devicePixelRatio>=2,D=this.map._requestManager.normalizeTileURL(m.tileID.canonical.url(this.tiles,this.scheme),E,this.tileSize);m.request=i.n(this.map._requestManager.transformRequest(D,i.R.Tile),(z,B,W)=>{if(delete m.request,m.aborted)return m.state="unloaded",v(null);if(z)return m.state="errored",v(z);if(!B)return v(null);const te=i.aP(W);this.map._refreshExpiredTiles&&m.setExpiryData(te),m.setTexture(B,this.map.painter),m.state="loaded",i.aQ(this.dispatcher),v(null)})}abortTile(m,v){m.request&&(m.request.cancel(),delete m.request),v&&v()}unloadTile(m,v){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(),v&&v()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function P1([M,m],v,E,{scaled:D=!0}={}){const{tileSize:z,buffer:B}=E,{x:W,y:te,z:ne}=v;if(!isFinite(W)||!isFinite(te)||!isFinite(ne))throw new Error("Invalid MRT header");const de=2**ne,je=de*i.aH(M),be=de*i.aL(m);return function([Me,$e],Le,{scaled:Je=!0}={}){if(!Le)throw new Error("bandView is undefined");const{data:Qe,tileSize:lt,buffer:mt,offset:nt,scale:zt,dimension:bt}=Le;if(Me<-mt||Me>lt+mt||$e<-mt||$e>lt+mt)throw new Error(`Point (${Me}, ${$e}) out of bounds for tileSize=${lt}, buffer=${mt}`);const Dt=($e+mt)*(lt+2*mt)+(Me+mt);if(new Uint32Array(Qe.buffer)[Dt]===4294967295)return null;let pt=[];pt=Je?[]:new Le.data.constructor(bt);for(let vt=0;vt{if(delete m.request,m.aborted)return m.state="unloaded",v(null);if(W)return W.name==="AbortError"?void 0:(m.state="errored",v(W));if(this.map._refreshExpiredTiles&&te){const de=i.aP(ne);m.setExpiryData(de)}if(this.partial&&m.state!=="expired")m.state="empty";else if(!this.partial){if(!te)return v(null);m.state="loaded",m._isHeaderLoaded=!0,m._mrt=te}v(null)};m.request=this.partial?m.fetchHeader(void 0,B.bind(this)):m.actor.send("loadTile",z,B.bind(this),void 0,!0)}abortTile(m){m.request&&(m.request.cancel(),delete m.request),m.actor&&m.actor.send("abortTile",{uid:m.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(m,v){const E=m.texturePerLayer;if(m.flushAllQueues(),E.size){m.destroy(!1);for(const D of E.values())this.map.painter.saveTileTexture(D)}else m.destroy()}prepareTile(m,v,E,D){m._isHeaderLoaded&&(m.state!=="empty"&&(m.state="reloading"),m.fetchBandForRender(v,E,D,(z,B)=>{z?(m.state="errored",this.fire(new i.B(z))):B&&(m._isHeaderLoaded=!0,m.setTexturePerLayer(E,B,this.map.painter),m.state="loaded"),this.triggerRepaint(m)}))}getInitialBand(m){if(!this.rasterLayers)return 0;const v=this.rasterLayers.find(({id:z})=>z===m),E=v&&v.fields,D=E&&E.bands&&E.bands;return D?D[0]:0}getTextureDescriptor(m,v,E){if(!m)return;const D=v.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!D)return;let z=null;v instanceof i.aS?z=v.paint.get("raster-array-band"):v instanceof i.aT&&(z=v.paint.get("raster-particle-array-band"));const B=z||this.getInitialBand(D);if(B==null)return;if(!m.textureDescriptorPerLayer.get(v.id))return void this.prepareTile(m,D,v.id,B);if(m.updateNeeded(v.id,B)&&!E)return;const W=m.textureDescriptorPerLayer.get(v.id);return Object.assign({},W,{texture:m.texturePerLayer.get(v.id)})}getImages(m,v){const E=new Map;for(const D of m)for(const z of v){const[B,W]=z.split("/"),te=D.getLayer(B);if(!te||!te.hasBand(W)||!te.hasDataForBand(W))continue;const{bytes:ne,tileSize:de,buffer:je}=te.getBandView(W),be=de+2*je,Me={data:new i.q({width:be,height:be},ne),pixelRatio:2,sdf:!1,usvg:!1,version:0};E.set(z,Me)}return E}queryRasterArrayValueByBandId(m,v,E){const D=v._mrt;return new Promise(z=>{const B={},W=new Set;for(const[te,ne]of Object.entries(D.layers)){if(E.layerName&&te!==E.layerName)continue;const de={};B[te]=de;for(const{bands:je}of ne.dataIndex)for(const be of je)E.bands&&!E.bands.includes(be)||(W.add(i.F(te,be)),v.fetchBand(te,null,be,Me=>{i.o.frame(()=>{de[be]=Me?null:P1([m.lng,m.lat],D,ne.getBandView(be)),W.delete(i.F(te,be)),W.size===0&&z(B)})},!1))}W.size===0&&z(B)})}_loadTileForQuery(m,v){if(this._loadTileLoaded[m.uid])return void v(null,m._mrt);if(this._loadTilePending[m.uid])return void this._loadTilePending[m.uid].push(v);this._loadTilePending[m.uid]=[v];const E=this.map._requestManager.normalizeTileURL(m.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),D=this.map._requestManager.transformRequest(E,i.R.Tile);m.actor.send("loadTile",{request:D,uid:m.uid,tileID:m.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(z,B,W)=>{if(z)return this._loadTilePending[m.uid].forEach(te=>te(z,null)),void delete this._loadTilePending[m.uid];if(!B)return this._loadTilePending[m.uid].forEach(te=>te(null,null)),void delete this._loadTilePending[m.uid];if(this.map._refreshExpiredTiles&&B){const te=i.aP(W);m.setExpiryData(te)}m._mrt=B,m._isHeaderLoaded=!0,m.state="loaded",this._loadTilePending[m.uid].forEach(te=>te(null,B)),this._loadTileLoaded[m.uid]=!0,delete this._loadTilePending[m.uid]},void 0,!0)}queryRasterArrayValueByAllBands(m,v,E){return new Promise((D,z)=>{this._loadTileForQuery(v,(B,W)=>{B?z(B):D(W?this.queryRasterArrayValueByBandId(m,v,E):null)})})}queryRasterArrayValue(m,v){const E=i.aU.convert(m),D=this.findLoadedParent(E);return D&&D._mrt?v.bands||!this.partial?this.queryRasterArrayValueByBandId(E,D,v):this.queryRasterArrayValueByAllBands(E,D,v):Promise.resolve(null)}findLoadedParent(m){const v=i.ag.fromLngLat(m,this.map.transform.tileSize),E=this.maxzoom+1,D=1<0&&(W[new i.aR(M.overscaledZ,D,m.z,E,m.y-1).key]={backfilled:!1},W[new i.aR(M.overscaledZ,M.wrap,m.z,m.x,m.y-1).key]={backfilled:!1},W[new i.aR(M.overscaledZ,B,m.z,z,m.y-1).key]={backfilled:!1}),m.y+1{if(this._loaded=!0,this._pendingLoad=null,E)this.fire(new i.B(E));else{const z={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&D&&D.resourceTiming&&D.resourceTiming[this.id]&&(z.resourceTiming=D.resourceTiming[this.id]),M&&(this._partialReload=!0),this.fire(new i.C("data",z)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(M),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const M=i.F(this.id,this.scope);this.map.style.clearSource(M),this._updateWorkerData()}loadTile(M,m){const v=M.actor?"reloadTile":"loadTile";M.actor=this.actor;const E=this.map.style?this.map.style.getLut(this.scope):null,D=E?{image:E.image.clone()}:null,z=this._partialReload,B={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:z,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};M.request=this.actor.send(v,B,(W,te)=>z&&!te?(M.state="loaded",m(null)):(delete M.request,M.destroy(!1),M.aborted?m(null):W?m(W):(M.loadVectorData(te,this.map.painter,v==="reloadTile"),m(null))),void 0,v==="loadTile")}abortTile(M){M.request&&(M.request.cancel(),delete M.request),M.aborted=!0}unloadTile(M,m){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.aV{constructor(M,m,v,E){super(M,m,v,E),this.roundZoom=!0,this.type="video",this.options=m}load(){this._loaded=!1;const M=this.options;this.urls=[];for(const m of M.urls)this.urls.push(this.map._requestManager.transformRequest(m,i.R.Source).url);i.aW(this.urls,(m,v)=>{this._loaded=!0,m?this.fire(new i.B(m)):v&&(this.video=v,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 m=this.video.seekable;Mm.end(0)?this.fire(new i.B(new i.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${m.start(0)} and ${m.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,m=M.gl;this.texture?this.video.paused||(this.texture.bind(m.LINEAR,m.CLAMP_TO_EDGE),m.texSubImage2D(m.TEXTURE_2D,0,0,0,m.RGBA,m.UNSIGNED_BYTE,this.video)):(this.texture=new i.T(M,this.video,m.RGBA8),this.texture.bind(m.LINEAR,m.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.aV,model:i.aY,"batched-model":class extends i.E{constructor(M,m,v,E){super(),this.type="batched-model",this.id=M,this.tileSize=512,this._options=m,this.tiles=this._options.tiles,this.maxzoom=m.maxzoom||19,this.minzoom=m.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=v,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(E)}onAdd(M){this.map=M,this.load()}reload(){this.cancelTileJSONRequest();const M=i.F(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.C("dataloading",{dataType:"source"}));const m=Array.isArray(this.map._language)?this.map._language.join():this.map._language,v=this.map.getWorldview();this._tileJSONRequest=Vu(this._options,this.map._requestManager,m,v,(E,D)=>{this._tileJSONRequest=null,this._loaded=!0,E?(m&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${m}`),v&&v.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${v}`),this.fire(new i.B(E))):D&&(Object.assign(this,D),D.bounds&&(this.tileBounds=new xh(D.bounds,this.minzoom,this.maxzoom)),Ve(D.tiles,this.map._requestManager._customAccessToken),this.fire(new i.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.C("data",{dataType:"source",sourceDataType:"content"}))),M&&M(E)})}hasTransition(){return!1}hasTile(M){return!this.tileBounds||this.tileBounds.contains(M.canonical)}loaded(){return this._loaded}loadTile(M,m){const v=this.map._requestManager.normalizeTileURL(M.tileID.canonical.url(this.tiles,this.scheme)),E={request:this.map._requestManager.transformRequest(v,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,renderSourceType:M.renderSourceType,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=m;else{if(M.buckets){const z=Object.values(M.buckets);for(const B of z)B.dirty=!0;return void(M.state="loaded")}M.request=M.actor.send("reloadTile",E,D.bind(this))}else M.actor=this.dispatcher.getActor(),M.request=M.actor.send("loadTile",E,D.bind(this),void 0,!0);function D(z,B){return M.aborted?m(null):z&&z.status!==404?m(z):(this.map._refreshExpiredTiles&&B&&M.setExpiryData(B),M.loadModelData(B,this.map.painter),M.state="loaded",void m(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends i.aV{constructor(M,m,v,E){super(M,m,v,E),m.coordinates?Array.isArray(m.coordinates)&&m.coordinates.length===4&&!m.coordinates.some(D=>!Array.isArray(D)||D.length!==2||D.some(z=>typeof z!="number"))||this.fire(new i.B(new i.V(`sources.${M}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.B(new i.V(`sources.${M}`,null,'missing required property "coordinates"'))),m.animate&&typeof m.animate!="boolean"&&this.fire(new i.B(new i.V(`sources.${M}`,null,'optional "animate" property must be a boolean value'))),m.canvas?typeof m.canvas=="string"||m.canvas instanceof HTMLCanvasElement||this.fire(new i.B(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.B(new i.V(`sources.${M}`,null,'missing required property "canvas"'))),this.options=m,this.animate=m.animate===void 0||m.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.B(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 m=this.map.painter.context;this.texture?!M&&!this._playing||this.texture instanceof i.aX||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.T(m,this.canvas,m.gl.RGBA8,{premultiply:!0}),this._prepareData(m)}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,m,v,E){super(),this.id=M,this.type="custom",this._dataType="raster",this._dispatcher=v,this._implementation=m,this.setEventedParent(E),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new i.B(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new i.B(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new xh(this._implementation.bounds,this.minzoom,this.maxzoom));const D=m;D.update=this._update.bind(this),D.clearTiles=this._clearTiles.bind(this),D.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,i.aJ(m,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return i.aJ(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new i.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.C("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(M){this.map=M,this._loaded=!1,this.fire(new i.C("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:m,y:v,z:E}=M.canonical;return this._implementation.hasTile({x:m,y:v,z:E})}return!this.tileBounds||this.tileBounds.contains(M.canonical)}loadTile(M,m){const{x:v,y:E,z:D}=M.tileID.canonical,z=new AbortController,B=Promise.resolve(this._implementation.loadTile({x:v,y:E,z:D},{signal:z.signal})).then((function(W){return delete M.request,M.aborted?(M.state="unloaded",m(null)):W===void 0?(M.state="errored",m(null)):W===null?(this.loadTileData(M,{width:this.tileSize,height:this.tileSize,data:null}),M.state="loaded",m(null)):function(te){return te instanceof ImageData||te instanceof HTMLCanvasElement||te instanceof ImageBitmap||te instanceof HTMLImageElement}(W)?(this.loadTileData(M,W),M.state="loaded",void m(null)):(M.state="errored",m(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(W=>{W.name!=="AbortError"&&(M.state="errored",m(W))});B.cancel=()=>z.abort(),M.request=B}loadTileData(M,m){M.setTexture(m,this.map.painter)}unloadTile(M,m){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:v,y:E,z:D}=M.tileID.canonical;this._implementation.unloadTile({x:v,y:E,z:D})}m&&m()}abortTile(M,m){M.request&&M.request.cancel&&(M.request.cancel(),delete M.request),m&&m()}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.F(this.id,this.scope);this.map.style.clearSource(M)}_update(){this.fire(new i.C("data",{dataType:"source",sourceDataType:"content"}))}}},Np=function(M,m,v,E){const D=new I1[m.type](M,m,v,E);if(D.id!==M)throw new Error(`Expected Source id to be ${M} instead of ${D.id}`);return i.aZ(["load","abort","unload","serialize","prepare"],D),D};function Ef(M,m,v=""){return`${v}:${m.id||""}:${m.layer.id}:${function(E){if("layerId"in E)return`layer:${E.layerId}`;{const{featuresetId:D,importId:z}=E;return`featureset:${D}${z?`:import:${z}`:""}`}}(M.target)}`}function Wd(M,m,v,E=""){if(M.uniqueFeatureID){const D=Ef(M,m,E);if(v.has(D))return!0;v.add(D)}return!1}function FC(M,m,v,E,D=!1,z=void 0){const B=m.sourceCache.transform,W=m.sourceCache.tilesIn(M,m.has3DLayers,D);W.sort(Vx);const te=[];for(const ne of W){const de=ne.tile.queryRenderedFeatures(m,ne,v,E,B,D,z);Object.keys(de).length&&te.push({wrappedTileID:ne.tile.tileID.wrapped().key,queryResults:de})}for(const ne in m.layers){const de=m.layers[ne];if(de.styleLayer){const je=de.styleLayer.queryRenderedFeatures(M,m.sourceCache,E);Object.keys(je).length&&te.push({wrappedTileID:0,queryResults:je})}}return te.length===0?{}:function(ne){const de={},je={};for(const be of ne){const Me=be.queryResults,$e=be.wrappedTileID,Le=je[$e]=je[$e]||{};for(const Je in Me){const Qe=Me[Je],lt=Le[Je]=Le[Je]||{},mt=de[Je]=de[Je]||[];for(const nt of Qe)lt[nt.featureIndex]||(lt[nt.featureIndex]=!0,mt.push(nt))}}return de}(te)}function P0(M,m,v,E,D,z){const B={},W=E.queryRenderedSymbols(M),te=[];for(const ne of Object.keys(W).map(Number))te.push(D[ne]);te.sort(Vx);for(const ne of te){const de=ne.featureIndex.lookupSymbolFeatures(W[ne.bucketInstanceId],ne.bucketIndex,ne.sourceLayerIndex,m,v,z);for(const je in de){const be=B[je]=B[je]||[],Me=de[je];Me.sort(($e,Le)=>{const Je=ne.featureSortOrder;if(Je){const Qe=Je.indexOf($e.featureIndex);return Je.indexOf(Le.featureIndex)-Qe}return Le.featureIndex-$e.featureIndex});for(const $e of Me)be.push($e)}}return B}function kp(M,m){const v=M.getRenderableIds().map(z=>M.getTileByID(z)),E=[],D={};for(let z=0;z{if(z)v(z);else try{const te=E.getHeaderLength(B);if(te>m)return void(this.request=this.fetchHeader(te,v));E.parseHeader(B),this._isHeaderLoaded=!0;let ne=0;for(const de of Object.values(E.layers))ne=Math.max(ne,de.dataIndex[de.dataIndex.length-1].lastByte);B.byteLength>=ne&&(this.entireBuffer=B),v(null,this.entireBuffer||B,W)}catch(te){v(te)}}),this.request}fetchBandForRender(m,v,E,D){this.fetchBand(m,v,E,z=>{if(z)return void D(z);this.updateTextureDescriptor(m,v,E);const B=this.textureDescriptorPerLayer.get(v);D(null,B?B.img:null)})}fetchBand(m,v,E,D,z=!0){const B=this._mrt;if(!this._isHeaderLoaded||!B)return void D(new Error("Tile header is not ready"));const W=this.actor;if(!W)return void D(new Error("Can't fetch tile band without an actor"));let te;const ne=i.F(String(E),i.F(this.tileID.key,m));let de=this._taskQueue.get(ne);de?de.add(D):(de=new Set,de.add(D),this._taskQueue.set(ne,de));const je=(Le,Je)=>{te.complete(Le,Je),Le?D(Le):(de.forEach(Qe=>Qe(null,Je)),this._taskQueue.delete(ne))},be=(Le,Je)=>{if(Le)return D(Le);const Qe=W.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:Je,task:te},je,void 0,!0);if(v!==null){const lt=this._workQueuePerLayer.get(v)||[];lt.push(()=>{Qe&&Qe.cancel(),te.cancel()}),this._workQueuePerLayer.has(v)||this._workQueuePerLayer.set(v,lt)}};let Me;try{Me=B.getLayer(m)}catch(Le){if(this.state==="reloading")return;throw Le}if(!Me)return void D(new Error(`Unknown sourceLayer "${m}"`));if(Me.hasDataForBand(E))return de.forEach(Le=>Le(null,null)),void this._taskQueue.delete(ne);const $e=Me.getDataRange([E]);if(te=B.createDecodingTask($e),!te||te.tasks.length)if(v!==null&&this.flushQueues(v),this.entireBuffer)be(null,this.entireBuffer.slice($e.firstByte,$e.lastByte+1));else{const Le=Object.assign({},this.requestParams,{headers:{Range:`bytes=${$e.firstByte}-${$e.lastByte}`}}),Je=i.b1(Le,be);if(v!==null){const Qe=this._fetchQueuePerLayer.get(v)||[];Qe.push(()=>{Je.cancel(),te.cancel()}),this._fetchQueuePerLayer.has(v)||this._fetchQueuePerLayer.set(v,Qe)}}}updateNeeded(m,v){return(!this.textureDescriptorPerLayer.get(m)||this.textureDescriptorPerLayer.get(m).band!==v||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(m,v,E){if(!this._mrt)return;const D=this._mrt.getLayer(m);if(!D||!D.hasBand(E)||!D.hasDataForBand(E))return;const{bytes:z,tileSize:B,buffer:W,offset:te,scale:ne}=D.getBandView(E),de=B+2*W,je=new i.q({width:de,height:de},z),be=this.texturePerLayer.get(v);be&&be instanceof i.T&&be.update(je,{premultiply:!1}),this.textureDescriptorPerLayer.set(v,{layer:m,band:E,img:je,buffer:W,offset:te,tileSize:B,format:D.pixelFormat,mix:[ne,256*ne,65536*ne,16777216*ne]})}destroy(m=!1){if(super.destroy(m),delete this._mrt,!m)for(const v of this.texturePerLayer.values())v&&v instanceof i.T&&v.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 Sp{constructor(m,v){this.max=m,this.onRemove=v,this.reset()}reset(){for(const m in this.data)for(const v of this.data[m])v.timeout&&clearTimeout(v.timeout),this.onRemove(v.value);return this.data={},this.order=[],this}add(m,v,E){const D=m.wrapped().key;this.data[D]===void 0&&(this.data[D]=[]);const z={value:v,timeout:void 0};if(E!==void 0&&(z.timeout=setTimeout(()=>{this.remove(m,z)},E)),this.data[D].push(z),this.order.push(D),this.order.length>this.max){const B=this._getAndRemoveByKey(this.order[0]);B&&this.onRemove(B)}return this}has(m){return m.wrapped().key in this.data}getAndRemove(m){return this.has(m)?this._getAndRemoveByKey(m.wrapped().key):null}_getAndRemoveByKey(m){const v=this.data[m].shift();return v.timeout&&clearTimeout(v.timeout),this.data[m].length===0&&delete this.data[m],this.order.splice(this.order.indexOf(m),1),v.value}getByKey(m){const v=this.data[m];return v?v[0].value:null}get(m){return this.has(m)?this.data[m.wrapped().key][0].value:null}remove(m,v){if(!this.has(m))return this;const E=m.wrapped().key,D=v===void 0?0:this.data[E].indexOf(v),z=this.data[E][D];return this.data[E].splice(D,1),z.timeout&&clearTimeout(z.timeout),this.data[E].length===0&&delete this.data[E],this.onRemove(z.value),this.order.splice(this.order.indexOf(E),1),this}setMaxSize(m){for(this.max=m;this.order.length>this.max;){const v=this._getAndRemoveByKey(this.order[0]);v&&this.onRemove(v)}return this}filter(m){const v=[];for(const E in this.data)for(const D of this.data[E])m(D.value)||v.push(D);for(const E of v)this.remove(E.value.tileID,E)}}class I0{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(m,v,E){const D=String(v);if(this.stateChanges[m]=this.stateChanges[m]||{},this.stateChanges[m][D]=this.stateChanges[m][D]||{},Object.assign(this.stateChanges[m][D],E),this.deletedStates[m]===null){this.deletedStates[m]={};for(const z in this.state[m])z!==D&&(this.deletedStates[m][z]=null)}else if(this.deletedStates[m]&&this.deletedStates[m][D]===null){this.deletedStates[m][D]={};for(const z in this.state[m][D])E[z]||(this.deletedStates[m][D][z]=null)}else for(const z in E)this.deletedStates[m]&&this.deletedStates[m][D]&&this.deletedStates[m][D][z]===null&&delete this.deletedStates[m][D][z]}removeFeatureState(m,v,E){if(this.deletedStates[m]===null)return;const D=String(v);if(this.deletedStates[m]=this.deletedStates[m]||{},E&&v!==void 0)this.deletedStates[m][D]!==null&&(this.deletedStates[m][D]=this.deletedStates[m][D]||{},this.deletedStates[m][D][E]=null);else if(v!==void 0)if(this.stateChanges[m]&&this.stateChanges[m][D])for(E in this.deletedStates[m][D]={},this.stateChanges[m][D])this.deletedStates[m][D][E]=null;else this.deletedStates[m][D]=null;else this.deletedStates[m]=null}getState(m,v){const E=this.state[m]||{},D=this.stateChanges[m]||{},z=this.deletedStates[m];if(z===null)return{};if(v!==void 0){const W=String(v),te=Object.assign({},E[W],D[W]);if(z){const ne=z[v];if(ne===null)return{};for(const de in ne)delete te[de]}return te}const B=Object.assign({},E,D);if(z)for(const W in z)delete B[W];return B}initializeTileState(m,v){m.refreshFeatureState(v)}coalesceChanges(m,v){const E={};for(const D in this.stateChanges){this.state[D]=this.state[D]||{};const z={};for(const B in this.stateChanges[D])this.state[D][B]||(this.state[D][B]={}),Object.assign(this.state[D][B],this.stateChanges[D][B]),z[B]=this.state[D][B];E[D]=z}for(const D in this.deletedStates){this.state[D]=this.state[D]||{};const z={};if(this.deletedStates[D]===null)for(const B in this.state[D])z[B]={},this.state[D][B]={};else for(const B in this.deletedStates[D]){if(this.deletedStates[D][B]===null)this.state[D][B]={};else if(this.state[D][B])for(const W of Object.keys(this.deletedStates[D][B]))delete this.state[D][B][W];z[B]=this.state[D][B]}E[D]=E[D]||{},Object.assign(E[D],z)}if(this.stateChanges={},this.deletedStates={},Object.keys(E).length!==0)for(const D in m)m[D].refreshFeatureState(v,E)}}class $l extends i.E{constructor(m,v,E){super(),this.id=m,this._renderSourceType=E,this._maxzoomOverride=null,v.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))}),v.on("error",()=>{this._sourceErrored=!0}),this._source=v,this._tiles={},this._cache=new Sp(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=v.minTileCacheSize,this._maxTileCacheSize=v.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new I0,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="raster-array"||this._source.type==="custom"&&"_dataType"in this._source&&this._source._dataType==="raster",this._supportsFading=this._source.type==="raster"||this._source.type==="raster-array"||this._source.type==="image"||this._source.type==="video"||this._source.type==="custom",this._isRasterElevatedOverTerrain=!1}onAdd(m){this.map=m,this._minTileCacheSize=this._minTileCacheSize===void 0&&m?m._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&m?m._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const m in this._tiles)if(!this._tiles[m].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const m=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,m&&this.reload(),this.transform&&this.update(this.transform)}setMaxzoomOverride(m){this._maxzoomOverride=m}_loadTile(m,v){return m.renderSourceType=this._renderSourceType,m.isExtraShadowCaster=this._shadowCasterTiles[m.tileID.key],this._source.loadTile(m,v)}_unloadTile(m){if(this._source.unloadTile)return this._source.unloadTile(m)}_abortTile(m){if(this._source.abortTile)return this._source.abortTile(m)}serialize(){return this._source.serialize()}prepare(m){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const v in this._tiles){const E=this._tiles[v];E.upload(m,this.map?this.map.painter:void 0),E.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(m=>m.tileID).sort(Iw).map(m=>m.key)}getRenderableIds(m,v){const E=[];for(const D in this._tiles)this._isIdRenderable(+D,m,v)&&E.push(this._tiles[D]);return m?E.sort((D,z)=>{const B=D.tileID,W=z.tileID,te=new i.P(B.canonical.x,B.canonical.y)._rotate(this.transform.angle),ne=new i.P(W.canonical.x,W.canonical.y)._rotate(this.transform.angle);return B.overscaledZ-W.overscaledZ||ne.y-te.y||ne.x-te.x}).map(D=>D.tileID.key):E.map(D=>D.tileID).sort(Iw).map(D=>D.key)}hasRenderableParent(m){const v=this.findLoadedParent(m,0);return!!v&&this._isIdRenderable(v.tileID.key)}_isIdRenderable(m,v,E){return this._tiles[m]&&this._tiles[m].hasData()&&!this._coveredTiles[m]&&(v||!this._tiles[m].holdingForFade())&&(E||!this._shadowCasterTiles[m])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const m in this._tiles)this._tiles[m].state!=="errored"&&this._reloadTile(+m,"reloading")}}_reloadTile(m,v){const E=this._tiles[m];E&&(E.state!=="loading"&&(E.state=v),this._loadTile(E,this._tileLoaded.bind(this,E,m,v)))}_tileLoaded(m,v,E,D,z){if(D){if(m.state="errored",i.b2(D)){if(this._source.fire(new i.C("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:m})),!(m.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const W=this.map.painter.terrain;this.update(this.transform,W.getScaledDemTileSize(),!0),W.resetTileLookupCache(this.id)}else this.update(this.transform)}else this._source.fire(new i.B(D,{tile:m}));return}m.timeAdded=i.o.now(),E==="expired"&&(m.refreshedUponExpiration=!0),this._setTileReloadTimer(v,m),this._source.type==="raster-dem"&&m.dem&&this._backfillDEM(m),this._state.initializeTileState(m,this.map?this.map.painter:null);let B=new Map;z&&z.responseHeaders&&(B=z.responseHeaders),this._source.fire(new i.C("data",{dataType:"source",tile:m,coord:m.tileID,sourceCacheId:this.id,responseHeaders:B}))}_hasTunnelGeometry(){for(const m in this._tiles){const v=this._tiles[m];if(v&&v.hasTunnelGeometry)return!0}return!1}_backfillDEM(m){const v=this.getRenderableIds();for(let D=0;D1||(Math.abs(B)>1&&(Math.abs(B+te)===1?B+=te:Math.abs(B-te)===1&&(B-=te)),z.dem&&D.dem&&(D.dem.backfillBorder(z.dem,B,W),D.neighboringTiles&&D.neighboringTiles[ne]&&(D.neighboringTiles[ne].backfilled=!0)))}}getTile(m){return this.getTileByID(m.key)}getTileByID(m){return this._tiles[m]}_retainLoadedChildren(m,v,E,D){for(const z in this._tiles){let B=this._tiles[z];if(D[z]||!B.hasData()||B.tileID.overscaledZ<=v||B.tileID.overscaledZ>E)continue;let W=B.tileID;for(;B&&B.tileID.overscaledZ>v+1;){const ne=B.tileID.scaledTo(B.tileID.overscaledZ-1);B=this._tiles[ne.key],B&&B.hasData()&&(W=ne)}let te=W;for(;te.overscaledZ>v;)if(te=te.scaledTo(te.overscaledZ-1),m[te.key]){D[W.key]=W;break}}}findLoadedParent(m,v){if(m.key in this._loadedParentTiles){const E=this._loadedParentTiles[m.key];return E&&E.tileID.overscaledZ>=v?E:null}for(let E=m.overscaledZ-1;E>=v;E--){const D=m.scaledTo(E),z=this._getLoadedTile(D);if(z)return z}}_getLoadedTile(m){const v=this._tiles[m.key];return v&&v.hasData()?v:this._cache.getByKey(this._source.reparseOverscaled?m.wrapped().key:m.canonical.key)}updateCacheSize(m,v){v=v||this._source.tileSize;const E=Math.ceil(m.width/v)+1,D=Math.ceil(m.height/v)+1,z=Math.floor(E*D*5),B=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,z):z,W=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,B):B;this._cache.setMaxSize(W)}handleWrapJump(m){const v=Math.round((m-(this._prevLng===void 0?m:this._prevLng))/360);if(this._prevLng=m,v){const E={};for(const D in this._tiles){const z=this._tiles[D];z.tileID=z.tileID.unwrapTo(z.tileID.wrap+v),E[z.tileID.key]=z}this._tiles=E;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(m,v,E,D,z){if(this.transform=m,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!E)return;this.updateCacheSize(m,v),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const B=this._source.type==="batched-model";let W,te=this._source.maxzoom;this._maxzoomOverride!==null&&(te=Math.min(te,this._maxzoomOverride));const ne=this.map&&this.map.painter?this.map.painter._terrain:null;if(ne&&ne.sourceCache===this&&ne.attenuationRange()){const Me=ne.attenuationRange()[0],$e=Math.floor(Me)-Math.log2(ne.getDemUpscale());te>$e&&(te=$e)}const de=this._maxzoomOverride===null&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)W=m.getVisibleUnwrappedCoordinates(this._source.tileID).map(Me=>new i.aR(Me.canonical.z,Me.wrap,Me.canonical.z,Me.canonical.x,Me.canonical.y));else if(this.tileCoverLift!==0){const Me=m.clone();Me.tileCoverLift=this.tileCoverLift,W=Me.coveringTiles({tileSize:v||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:te,roundZoom:this._source.roundZoom&&!E,reparseOverscaled:de,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:B}),this._source.minzoom<=1&&m.projection.name==="globe"&&(W.push(new i.aR(1,0,1,0,0)),W.push(new i.aR(1,0,1,1,0)),W.push(new i.aR(1,0,1,0,1)),W.push(new i.aR(1,0,1,1,1)))}else if(W=m.coveringTiles({tileSize:v||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:te,roundZoom:this._source.roundZoom&&!E,reparseOverscaled:de,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:B}),this._source.hasTile){const Me=this._source.hasTile.bind(this._source);W=W.filter($e=>Me($e))}}else W=[];if(W.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!this._supportsFading){const Me=m.coveringZoomLevel({tileSize:v||this._source.tileSize,roundZoom:this._source.roundZoom&&!E}),$e=Math.min(Me,te);if(B){const Le=m.extendTileCover(W,$e);for(const Je of Le)W.push(Je)}else if(z){const Le=this.transform.getFrustum($e),Je=m.extendTileCoverToNearPlane(W,Le,$e);for(const Qe of Je)W.push(Qe);if($e>=18&&this._hasTunnelGeometry()){const Qe=m.extendTileCoverForTunnels(W,Le,$e,20);for(const lt of Qe)W.push(lt)}}else if(this.castsShadows&&D){const Le=m.extendTileCover(W,$e,D,16);for(const Je of Le)this._shadowCasterTiles[Je.key]=!0,W.push(Je)}}const je=this._updateRetainedTiles(W);if(this._supportsFading&&W.length!==0){const Me={},$e={},Le=i.o.now(),Je=Object.keys(je);for(const lt of Je){const mt=je[lt],nt=this._tiles[lt];if(!nt||nt.fadeEndTime!==void 0&&nt.fadeEndTime<=Le)continue;const zt=this.findLoadedParent(mt,Math.max(mt.overscaledZ-$l.maxOverzooming,this._source.minzoom));zt&&(this._addTile(zt.tileID),Me[zt.tileID.key]=zt.tileID),$e[lt]=mt}const Qe=W[W.length-1].overscaledZ;for(const lt in this._tiles){const mt=this._tiles[lt];if(je[lt]||!mt.hasData())continue;let nt=mt.tileID;for(;nt.overscaledZ>Qe;){nt=nt.scaledTo(nt.overscaledZ-1);const zt=this._tiles[nt.key];if(zt&&zt.hasData()&&$e[nt.key]){je[lt]=mt.tileID;break}}}for(const lt in Me)je[lt]||(this._coveredTiles[lt]=!0,je[lt]=Me[lt])}for(const Me in je)this._tiles[Me].clearFadeHold();const be=i.b3(this._tiles,je);for(const Me of be){const $e=this._tiles[Me];$e.hasSymbolBuckets&&!$e.holdingForFade()?$e.setHoldDuration(this.map._fadeDuration):$e.hasSymbolBuckets&&!$e.symbolFadeFinished()||this._removeTile(+Me)}this._updateLoadedParentTileCache(),this._renderSourceType===i.b4.Symbol&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const m in this._tiles)this._tiles[m].holdingForFade()&&this._removeTile(+m)}_updateRetainedTiles(m){const v={};if(m.length===0)return v;const E={},D=m.reduce((ne,de)=>Math.min(ne,de.overscaledZ),1/0),z=m[0].overscaledZ,B=Math.max(z-$l.maxOverzooming,this._source.minzoom),W=Math.max(z+$l.maxUnderzooming,this._source.minzoom),te={};for(const ne of m){const de=this._addTile(ne);v[ne.key]=ne,de.hasData()||D=this._source.maxzoom){const be=ne.children(this._source.maxzoom)[0],Me=this.getTile(be);if(Me&&Me.hasData()){v[be.key]=be;continue}}else{const be=ne.children(this._source.maxzoom);if(v[be[0].key]&&v[be[1].key]&&v[be[2].key]&&v[be[3].key])continue}let je=de.wasRequested();for(let be=ne.overscaledZ-1;be>=B;--be){const Me=ne.scaledTo(be);if(E[Me.key]||(E[Me.key]=!0,de=this.getTile(Me),!de&&je&&(de=this._addTile(Me)),de&&(v[Me.key]=Me,je=de.wasRequested(),de.hasData())))break}}return v}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const m in this._tiles){const v=[];let E,D=this._tiles[m].tileID;for(;D.overscaledZ>0;){if(D.key in this._loadedParentTiles){E=this._loadedParentTiles[D.key];break}v.push(D.key);const z=D.scaledTo(D.overscaledZ-1);if(E=this._getLoadedTile(z),E)break;D=z}for(const z of v)this._loadedParentTiles[z]=E}}_addTile(m){let v=this._tiles[m.key];if(v)return v.isExtraShadowCaster!==!0||this._shadowCasterTiles[m.key]||this._reloadTile(m.key,"reloading"),v;v=this._cache.getAndRemove(m),v&&(this._setTileReloadTimer(m.key,v),v.tileID=m,this._state.initializeTileState(v,this.map?this.map.painter:null),this._cacheTimers[m.key]&&(clearTimeout(this._cacheTimers[m.key]),delete this._cacheTimers[m.key],this._setTileReloadTimer(m.key,v)));const E=!!v;if(!E){const D=this.map?this.map.painter:null,z=this._source.tileSize*m.overscaleFactor();v=this._source.type==="raster-array"?new nc(m,z,this.transform.tileZoom,D,this._isRaster):new i.b0(m,z,this.transform.tileZoom,D,this._isRaster,this._source.worldview),this._loadTile(v,this._tileLoaded.bind(this,v,m.key,v.state))}return v.uses++,this._tiles[m.key]=v,E||this._source.fire(new i.C("dataloading",{tile:v,coord:v.tileID,dataType:"source"})),v}_setTileReloadTimer(m,v){m in this._timers&&(clearTimeout(this._timers[m]),delete this._timers[m]);const E=v.getExpiryTimeout();E&&(this._timers[m]=setTimeout(()=>{this._reloadTile(m,"expired"),delete this._timers[m]},E))}_removeTile(m){const v=this._tiles[m];v&&(v.uses--,delete this._tiles[m],this._timers[m]&&(clearTimeout(this._timers[m]),delete this._timers[m]),v.uses>0||(v.hasData()&&v.state!=="reloading"||v.state==="empty"?this._cache.add(v.tileID,v,v.getExpiryTimeout()):(v.aborted=!0,this._abortTile(v),this._unloadTile(v))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const m in this._tiles)this._removeTile(+m);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(m,v,E){const D=[],z=this.transform;if(!z)return D;const B=z.projection.name==="globe",W=i.aH(z.center.lng);for(const te in this._tiles){const ne=this._tiles[te];if(E&&ne.clearQueryDebugViz(),ne.holdingForFade())continue;let de;if(B){const je=ne.tileID.canonical;if(je.z===0){const be=[Math.abs(i.aC(W,...ty(je,-1))-W),Math.abs(i.aC(W,...ty(je,1))-W)];de=[0,2*be.indexOf(Math.min(...be))-1]}else{const be=[Math.abs(i.aC(W,...ty(je,-1))-W),Math.abs(i.aC(W,...ty(je,0))-W),Math.abs(i.aC(W,...ty(je,1))-W)];de=[be.indexOf(Math.min(...be))-1]}}else de=[0];for(const je of de){const be=m.containsTile(ne,z,v,je);be&&D.push(be)}}return D}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(m){return this._getRenderableCoordinates(m)}_getRenderableCoordinates(m,v){const E=this.getRenderableIds(m,v).map(z=>this._tiles[z].tileID),D=this.transform.projection.name==="globe";for(const z of E)z.projMatrix=this.transform.calculateProjMatrix(z.toUnwrapped()),z.expandedProjMatrix=D?this.transform.calculateProjMatrix(z.toUnwrapped(),!1,!0):z.projMatrix;return E}sortCoordinatesByDistance(m){const v=m.slice(),E=this.transform._camera.position,D=this.transform._camera.forward(),z={};for(const B of v){const W=1/(1<z[B.key]-z[W.key]),v}hasTransition(){if(this._source.hasTransition())return!0;if(this._supportsFading){const m=i.o.now();for(const v in this._tiles){const E=this._tiles[v];if(E.fadeEndTime!==void 0&&E.fadeEndTime>=m)return!0}}return!1}setFeatureState(m,v,E){this._state.updateState(m=m||"_geojsonTileLayer",v,E)}removeFeatureState(m,v,E){this._state.removeFeatureState(m=m||"_geojsonTileLayer",v,E)}getFeatureState(m,v){return this._state.getState(m=m||"_geojsonTileLayer",v)}setDependencies(m,v,E){const D=this._tiles[m];D&&D.setDependencies(v,E)}reloadTilesForDependencies(m,v){for(const E in this._tiles)this._tiles[E].hasDependency(m,v)&&this._reloadTile(+E,"reloading");this._cache.filter(E=>!E.hasDependency(m,v))}_preloadTiles(m,v){if(!this._sourceLoaded){const te=()=>{this._sourceLoaded&&(this._source.off("data",te),this._preloadTiles(m,v))};return void this._source.on("data",te)}const E=new Map,D=Array.isArray(m)?m:[m],z=this.map.painter.terrain,B=this.usedForTerrain&&z?z.getScaledDemTileSize():this._source.tileSize;for(const te of D){const ne=te.coveringTiles({tileSize:B,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const de of ne)E.set(de.key,de);this.usedForTerrain&&te.updateElevation(!1)}const W=Array.from(E.values());i.t(W,(te,ne)=>{const de=new i.b0(te,this._source.tileSize*te.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(de,je=>{this._source.type==="raster-dem"&&de.dem&&this._backfillDEM(de),ne(je,de)})},v)}}function Iw(M,m){const v=Math.abs(2*M.wrap)-+(M.wrap<0),E=Math.abs(2*m.wrap)-+(m.wrap<0);return M.overscaledZ-m.overscaledZ||E-v||m.canonical.y-M.canonical.y||m.canonical.x-M.canonical.x}function ty(M,m){const v=1<0:E.type==="building"?D=!E.isHidden(m)&&E.paint.get("building-opacity")>0:E.type==="model"&&(D=!E.isHidden(m)&&E.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!D&&v.visible,v.visible=D}}updateZOffset(m,v){this.currentBuildingBuckets=[];for(const D of this.layers){const z=D.layer,B=this.style.getLayerSourceCache(z);let W=1;z.type==="fill-extrusion"?W=D.visible?z.paint.get("fill-extrusion-vertical-scale"):0:z.type==="building"&&(W=D.visible?z.paint.get("building-vertical-scale"):0);let te=B?B.getTile(v):null;if(!te&&B)for(const ne in B._tiles){const de=B._tiles[ne];if(v.canonical.isChildOf(de.tileID.canonical)){te=de;break}}this.currentBuildingBuckets.push({bucket:te?te.getBucket(z):null,tileID:te?te.tileID:v,verticalScale:W})}m.hasAnyZOffset=!1;let E=!1;for(let D=0;D{E in m&&(v[E]=m[E])}),v}function Lw(M){M=M.slice();const m=Object.create(null);for(const v of M)m[v.id]=v;for(let v=0;v0?(D-B)/W:0;return this.points[z].mult(1-te).add(this.points[v].mult(te))}}class R1{constructor(m,v,E){const D=this.boxCells=[],z=this.circleCells=[];this.xCellCount=Math.ceil(m/E),this.yCellCount=Math.ceil(v/E);for(let B=0;Bthis.width||D<0||v>this.height)return!z&&[];const W=[];if(m<=0&&v<=0&&this.width<=E&&this.height<=D){if(z)return!0;for(let te=0;te0:W}_queryCircle(m,v,E,D,z){const B=m-E,W=m+E,te=v-E,ne=v+E;if(W<0||B>this.width||ne<0||te>this.height)return!D&&[];const de=[];return this._forEachCell(B,te,W,ne,this._queryCellCircle,de,{hitTest:D,circle:{x:m,y:v,radius:E},seenUids:{box:{},circle:{}}},z),D?de.length>0:de}query(m,v,E,D,z){return this._query(m,v,E,D,!1,z)}hitTest(m,v,E,D,z){return this._query(m,v,E,D,!0,z)}hitTestCircle(m,v,E,D){return this._queryCircle(m,v,E,!0,D)}_queryCell(m,v,E,D,z,B,W,te){const ne=W.seenUids,de=this.boxCells[z];if(de!==null){const be=this.bboxes;for(const Me of de)if(!ne.box[Me]){ne.box[Me]=!0;const $e=4*Me;if(m<=be[$e+2]&&v<=be[$e+3]&&E>=be[$e+0]&&D>=be[$e+1]&&(!te||te(this.boxKeys[Me]))){if(W.hitTest)return B.push(!0),!0;B.push({key:this.boxKeys[Me],x1:be[$e],y1:be[$e+1],x2:be[$e+2],y2:be[$e+3]})}}}const je=this.circleCells[z];if(je!==null){const be=this.circles;for(const Me of je)if(!ne.circle[Me]){ne.circle[Me]=!0;const $e=3*Me;if(this._circleAndRectCollide(be[$e],be[$e+1],be[$e+2],m,v,E,D)&&(!te||te(this.circleKeys[Me]))){if(W.hitTest)return B.push(!0),!0;{const Le=be[$e],Je=be[$e+1],Qe=be[$e+2];B.push({key:this.circleKeys[Me],x1:Le-Qe,y1:Je-Qe,x2:Le+Qe,y2:Je+Qe})}}}}}_queryCellCircle(m,v,E,D,z,B,W,te){const ne=W.circle,de=W.seenUids,je=this.boxCells[z];if(je!==null){const Me=this.bboxes;for(const $e of je)if(!de.box[$e]){de.box[$e]=!0;const Le=4*$e;if(this._circleAndRectCollide(ne.x,ne.y,ne.radius,Me[Le+0],Me[Le+1],Me[Le+2],Me[Le+3])&&(!te||te(this.boxKeys[$e])))return B.push(!0),!0}}const be=this.circleCells[z];if(be!==null){const Me=this.circles;for(const $e of be)if(!de.circle[$e]){de.circle[$e]=!0;const Le=3*$e;if(this._circlesCollide(Me[Le],Me[Le+1],Me[Le+2],ne.x,ne.y,ne.radius)&&(!te||te(this.circleKeys[$e])))return B.push(!0),!0}}}_forEachCell(m,v,E,D,z,B,W,te){const ne=this._convertToXCellCoord(m),de=this._convertToYCellCoord(v),je=this._convertToXCellCoord(E),be=this._convertToYCellCoord(D);for(let Me=ne;Me<=je;Me++)for(let $e=de;$e<=be;$e++)if(z.call(this,m,v,E,D,this.xCellCount*$e+Me,B,W,te))return}_convertToXCellCoord(m){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(m*this.xScale)))}_convertToYCellCoord(m){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(m*this.yScale)))}_circlesCollide(m,v,E,D,z,B){const W=D-m,te=z-v,ne=E+B;return ne*ne>W*W+te*te}_circleAndRectCollide(m,v,E,D,z,B,W){const te=(B-D)/2,ne=Math.abs(m-(D+te));if(ne>te+E)return!1;const de=(W-z)/2,je=Math.abs(v-(z+de));if(je>de+E)return!1;if(ne<=te||je<=de)return!0;const be=ne-te,Me=je-de;return be*be+Me*Me<=E*E}}const FE=Math.tan(85*Math.PI/180);function jt(M,m,v,E,D,z,B){const W=i.bb();if(v)if(z.name==="globe"){const te=i.bc(D,m);i.aD(W,W,te)}else{const te=i.bd([],B);W[0]=te[0],W[1]=te[1],W[4]=te[2],W[5]=te[3],E||i.ba(W,W,D.angle)}else i.aD(W,D.labelPlaneMatrix,M);return W}function Ps(M,m,v,E,D,z,B){const W=jt(M,m,v,E,D,z,B);return z.name==="globe"&&v||(W[2]=W[6]=W[10]=W[14]=0),W}function nr(M,m,v,E,D,z,B){if(v){if(z.name==="globe"){const W=jt(M,m,v,E,D,z,B);return i.b7(W,W),i.aD(W,M,W),W}{const W=i.b8(M),te=i.b9([]);return te[0]=B[0],te[1]=B[1],te[4]=B[2],te[5]=B[3],i.aD(W,W,te),E||i.ba(W,W,-D.angle),W}}return D.glCoordMatrix}function Yr(M,m,v,E){const D=[M,m,v,1];v?i.aE(D,D,E):en(D,D,E);const z=D[3];return D[0]/=z,D[1]/=z,D[2]/=z,D}function pn(M,m){return Math.min(.5+M/m*.5,1.5)}function Na(M,m){const v=M[0]/M[3],E=M[1]/M[3];return v>=-m[0]&&v<=m[0]&&E>=-m[1]&&E<=m[1]}function Bn(M,m,v,E,D,z,B,W,te,ne,de=1){const je=v.transform,be=E?M.textSizeData:M.iconSizeData,Me=i.bj(be,v.transform.zoom,de),$e=je.projection.name==="globe",Le=[256/v.width*2+1,256/v.height*2+1],Je=E?M.text.dynamicLayoutVertexArray:M.icon.dynamicLayoutVertexArray;Je.clear();let Qe=null;$e&&(Qe=E?M.text.globeExtVertexArray:M.icon.globeExtVertexArray);const lt=M.lineVertexArray,mt=E?M.text.placedSymbolArray:M.icon.placedSymbolArray,nt=v.transform.width/v.transform.height;let zt,bt=!1;for(let Dt=0;DtMath.abs(v)?{useVertical:!0}:M===i.bk.vertical?E>0?{needsFlipping:!0}:null:m!==0&&function(D,z){return D===0||Math.abs(z/D)>FE}(v,E)?m===1?{needsFlipping:!0}:null:v<0?{needsFlipping:!0}:null}function zm(M,m,v,E,D,z,B,W,te,ne,de,je,be,Me,$e,Le,Je,Qe,lt,mt){const nt=m/24,zt=M.lineOffsetX*nt,bt=M.lineOffsetY*nt,{lineStartIndex:Dt,glyphStartIndex:pt,numGlyphs:vt,segment:Tt,writingMode:Gt,flipState:qt}=M,ns=Dt+M.lineLength,Jt=Ns=>{if(de){const[ss,as,ds]=Ns.up,Qs=ne.length;i.bm(de,Qs+0,ss,as,ds),i.bm(de,Qs+1,ss,as,ds),i.bm(de,Qs+2,ss,as,ds),i.bm(de,Qs+3,ss,as,ds)}const[Is,Zt,Ut]=Ns.point;i.bn(ne,Is,Zt,Ut,Ns.angle)};if(vt>1){const Ns=Ri(nt,W,zt,bt,v,je,be,M,te,z,Me,Le,!1,Je,Qe,lt,mt);if(!Ns)return{notEnoughRoom:!0};if(E&&!v){let[Is,Zt,Ut]=Ns.first.point,[ss,as,ds]=Ns.last.point;[Is,Zt]=Yr(Is,Zt,Ut,B),[ss,as]=Yr(ss,as,ds,B);const Qs=Mp(Gt,qt,(ss-Is)*$e,as-Zt);if(M.flipState=Qs&&Qs.needsFlipping?1:2,Qs)return Qs}Jt(Ns.first);for(let Is=pt+1;Is0?ss:R0(be,Ut,Is,1,D,void 0,Je,Qe.canonical),ds=Mp(Gt,qt,(as[0]-Is[0])*$e,as[1]-Is[1]);if(M.flipState=ds&&ds.needsFlipping?1:2,ds)return ds}const Ns=O1(nt*W.getoffsetX(pt),zt,bt,v,je,be,Tt,Dt,ns,te,z,Me,Le,!1,!1,Je,Qe,lt,mt);if(!Ns)return{notEnoughRoom:!0};Jt(Ns)}return{}}function la(M,m,v,E,D){const{x:z,y:B,z:W}=E.projectTilePoint(M.x,M.y,m);if(!D)return Yr(z,B,W,v);const[te,ne,de]=D.getElevation(M,D.elevation,D.elevationFeature);return Yr(z+te,B+ne,W+de,v)}function R0(M,m,v,E,D,z,B,W){const te=la(M.sub(m)._unit()._add(M),W,D,B,z);return i.ax(te,v,te),i.ay(te,te),i.bg(te,v,te,E)}function O1(M,m,v,E,D,z,B,W,te,ne,de,je,be,Me,$e,Le,Je,Qe,lt){const mt=E?M-m:M+m;let nt=mt>0?1:-1,zt=0;E&&(nt*=-1,zt=Math.PI),nt<0&&(zt+=Math.PI);let bt=W+B+(nt>0?0:1)|0,Dt=D,pt=D,vt=0,Tt=0;const Gt=Math.abs(mt),qt=[],ns=[];let Jt=z,Ns=Jt,Is=i.be([]);const Zt=()=>R0(Ns,Jt,pt,Gt-vt+1,de,be,Le,Je.canonical);for(;vt+Tt<=Gt;){if(bt+=nt,bt=te)return null;if(pt=Dt,Ns=Jt,qt.push(pt),Me&&ns.push(Ns),Jt=new i.P(ne.getx(bt),ne.gety(bt)),Dt=je[bt],!Dt){const Ir=la(Jt,Je.canonical,de,Le,be);Dt=Ir[3]>0?je[bt]=Ir:Zt()}vt+=Tt;const Ts=i.ax([],Dt,pt),wr=i.bf(pt,Dt);if(v&&wr>0&&Tt>0&&i.bi(Is,Ts)/(Tt*wr)0,mt),Dt=ne*bt.perspectiveRatio,pt=(E.x1*v+W.x-E.padding)*Dt+bt.point.x,vt=(E.y1*v+W.y-E.padding)*Dt+bt.point.y,Tt=(E.x2*v+W.x+E.padding)*Dt+bt.point.x,Gt=(E.y2*v+W.y+E.padding)*Dt+bt.point.y,qt=bt.perspectiveRatio<=.55||bt.occluded;return!this.isInsideGrid(pt,vt,Tt,Gt)||!te&&this.grid.hitTest(pt,vt,Tt,Gt,je)||qt?{box:[],offscreen:!1,occluded:bt.occluded}:{box:[pt,vt,Tt,Gt],offscreen:this.isOffscreen(pt,vt,Tt,Gt),occluded:!1}}placeCollisionCircles(m,v,E,D,z,B,W,te,ne,de,je,be,Me,$e,Le,Je){const Qe=[],lt=this.transform.elevation,mt=m.getProjection(),nt=m.elevationType==="road",zt=!!lt||nt,bt=i.bu.getAtTileOffsetFunc(Je,this.transform.center.lat,this.transform.worldSize,mt),Dt=new i.P(E.tileAnchorX,E.tileAnchorY),pt=new i.P(E.tileAnchorX,E.tileAnchorY);let{x:vt,y:Tt,z:Gt}=mt.projectTilePoint(pt.x,pt.y,Je.canonical),qt=null;if(zt){const wr=nt?m.getElevationFeatureForText(D):null;qt={getElevation:bt,elevation:lt,elevationFeature:wr};const[Ir,pr,vr]=bt(Dt,lt,wr);vt+=Ir,Tt+=pr,Gt+=vr}const ns=mt.name==="globe",Jt=this.projectAndGetPerspectiveRatio(te,vt,Tt,Gt,Je,ns||!!lt||this.transform.pitch>0,mt),{perspectiveRatio:Ns}=Jt,Is=(be?W/Ns:W*Ns)/i.by,Zt=Yr(vt,Tt,Gt,ne),Ut=E.lineOffsetX*Is,ss=E.lineOffsetY*Is,as=i.ap(m.layers[0].layout.get("text-max-angle")),ds=Math.cos(as),Qs=Jt.signedDistanceFromCamera>0?Ri(Is,B,Ut,ss,nt&&E.flipState===1,Zt,pt,E,z,ne,{},zt&&!be?qt:null,be&&zt,mt,Je,be,ds):null;let Gs=!1,Ws=!1,Ts=!0;if(Qs&&!Jt.occluded){const wr=.5*$e*Ns+Le,Ir=new i.P(-100,-100),pr=new i.P(this.screenRightBoundary,this.screenBottomBoundary),vr=new BC,{first:Zr,last:fn}=Qs,on=Zr.path.length;let $n=[];for(let ln=on-1;ln>=1;ln--)$n.push(Zr.path[ln]);for(let ln=1;ln(zt&&!ns&&(hi=bt(Ziln[3]<=0)&&($n=[]));let qn=[];if($n.length>0){let ln=1/0,Ta=-1/0,hi=1/0,Zi=-1/0;for(const ji of $n)ln=Math.min(ln,ji[0]),hi=Math.min(hi,ji[1]),Ta=Math.max(Ta,ji[0]),Zi=Math.max(Zi,ji[1]);Ta>=Ir.x&&ln<=pr.x&&Zi>=Ir.y&&hi<=pr.y&&(qn=[$n.map(ji=>new i.P(ji[0],ji[1]))],(lnpr.x||hipr.y)&&(qn=i.bv(qn,Ir.x,Ir.y,pr.x,pr.y)))}for(const ln of qn){vr.reset(ln,.25*wr);let Ta=0;Ta=vr.length<=.5*wr?1:Math.ceil(vr.paddedLength/Ur)+1;for(let hi=0;hi0?(i.aE(te,te,m),this.fogState&&z&&W.name!=="globe"&&(ne=function(be,Me,$e,Le,Je,Qe){const lt=Qe.calculateFogTileMatrix(Je),mt=[Me,$e,Le];return i.ah(mt,mt,lt),vi(be,i.ai(mt),Qe.pitch,Qe._fov)}(this.fogState,v,E,D,z.toUnwrapped(),this.transform)>.9)):en(te,te,m);const de=te[3];return{point:new i.P((te[0]/de+1)/2*this.transform.width+Tp,(-te[1]/de+1)/2*this.transform.height+Tp),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(W)/de*.5,1.5),signedDistanceFromCamera:de,occluded:B&&te[2]>de||ne}}isOffscreen(m,v,E,D){return E=this.screenRightBoundary||Dthis.screenBottomBoundary}isInsideGrid(m,v,E,D){return E>=0&&m=0&&vE.collisionGroupID===v}}return this.collisionGroups[m]}}function bu(M,m,v,E,D){const{horizontalAlign:z,verticalAlign:B}=i.bF(M),W=-(z-.5)*m,te=-(B-.5)*v,ne=i.bG(M,E);return new i.P(W+ne[0]*D,te+ne[1]*D)}function sy(M,m,v,E,D){const z=new i.P(M,m);return v&&z._rotate(E?D:-D),z}class oi{constructor(m,v,E,D,z,B){this.transform=m.clone(),this.projection=m.projection.name,this.collisionIndex=new $C(this.transform,z),this.buildingIndex=B,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=v,this.retainedQueryData={},this.collisionGroups=new ii(E),this.collisionCircleArrays={},this.prevPlacement=D,D&&(D.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(m,v,E,D,z=1){const B=E.getBucket(v),W=E.latestFeatureIndex;if(!B||!W||v.fqid!==B.layerIds[0])return;const te=B.layers[0].layout,ne=B.layers[0].paint,de=E.collisionBoxArray,je=Math.pow(2,this.transform.zoom-E.tileID.overscaledZ),be=E.tileSize/i.an,Me=E.tileID.toUnwrapped();this.transform.setProjection(B.projection);const $e=(Le=E.tileID,Je=B.getProjection(),Qe=this.transform,Je.name===this.projection?Qe.calculateProjMatrix(Le.toUnwrapped()):D1(Qe,Je,Le));var Le,Je,Qe;const lt=te.get("text-pitch-alignment")==="map",mt=te.get("text-rotation-alignment")==="map";v.compileFilter(v.options);const nt=v.dynamicFilter(),zt=v.dynamicFilterNeedsFeature(),bt=v.dynamicFilterNeedsGeometry(),Dt=this.transform.calculatePixelsToTileUnitsMatrix(E),pt=Ps($e,E.tileID.canonical,lt,mt,this.transform,B.getProjection(),Dt);let vt=null;const Tt=B.getProjection().createInversionMatrix(this.transform,E.tileID.canonical);if(lt){const ss=nr($e,E.tileID.canonical,lt,mt,this.transform,B.getProjection(),Dt);vt=i.aD([],this.transform.labelPlaneMatrix,ss)}let Gt=null;nt&&E.latestFeatureIndex&&(Gt={unwrappedTileID:Me,dynamicFilter:nt,dynamicFilterNeedsFeature:zt,needGeometry:bt}),this.retainedQueryData[B.bucketInstanceId]=new ri(B.bucketInstanceId,W,B.sourceLayerIndex,B.index,E.tileID);const[qt,ns]=B.layers[0].layout.get("text-size-scale-range"),Jt=i.aC(z,qt,ns),[Ns,Is]=te.get("icon-size-scale-range"),Zt=i.aC(z,Ns,Is),Ut={bucket:B,layout:te,paint:ne,posMatrix:$e,invMatrix:Tt,mercatorCenter:[i.aH(this.transform.center.lng),i.aL(this.transform.center.lat)],textLabelPlaneMatrix:pt,labelToScreenMatrix:vt,clippingData:Gt,scale:je,textPixelRatio:be,holdingForFade:E.holdingForFade(),collisionBoxArray:de,partiallyEvaluatedTextSize:i.bj(B.textSizeData,this.transform.zoom,Jt),partiallyEvaluatedIconSize:i.bj(B.iconSizeData,this.transform.zoom,Zt),collisionGroup:this.collisionGroups.get(B.sourceID),latestFeatureIndex:E.latestFeatureIndex};if(D)for(const ss of B.sortKeyRanges){const{sortKey:as,symbolInstanceStart:ds,symbolInstanceEnd:Qs}=ss;m.push({sortKey:as,symbolInstanceStart:ds,symbolInstanceEnd:Qs,parameters:Ut})}else m.push({symbolInstanceStart:0,symbolInstanceEnd:B.symbolInstances.length,parameters:Ut})}attemptAnchorPlacement(m,v,E,D,z,B,W,te,ne,de,je,be,Me,$e,Le,Je,Qe,lt,mt,nt,zt){const{textOffset0:bt,textOffset1:Dt,crossTileID:pt}=Le,vt=[bt,Dt],Tt=bu(m,B,W,vt,te),Gt=this.collisionIndex.placeCollisionBox(Qe,te,v,E,D,z,sy(Tt.x,Tt.y,ne,de,this.transform.angle),$e,je,be,Me.predicate);if(mt){const qt=Qe.getSymbolInstanceIconSize(zt,this.transform.zoom,Le.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Qe,qt,mt,E,D,z,sy(Tt.x,Tt.y,ne,de,this.transform.angle),$e,je,be,Me.predicate).box.length===0)return}if(Gt.box.length>0){let qt;return this.prevPlacement&&this.prevPlacement.variableOffsets[pt]&&this.prevPlacement.placements[pt]&&this.prevPlacement.placements[pt].text&&(qt=this.prevPlacement.variableOffsets[pt].anchor),this.variableOffsets[pt]={textOffset:vt,width:B,height:W,anchor:m,textScale:te,prevAnchor:qt},this.markUsedJustification(Qe,m,Le,lt),Qe.allowVerticalPlacement&&(this.markUsedOrientation(Qe,lt,Le),this.placedOrientations[pt]=lt),{shift:Tt,placedGlyphBoxes:Gt}}}placeLayerBucketPart(m,v,E,D,z=1){const{bucket:B,layout:W,paint:te,posMatrix:ne,textLabelPlaneMatrix:de,labelToScreenMatrix:je,clippingData:be,textPixelRatio:Me,mercatorCenter:$e,invMatrix:Le,holdingForFade:Je,collisionBoxArray:Qe,partiallyEvaluatedTextSize:lt,partiallyEvaluatedIconSize:mt,collisionGroup:nt,latestFeatureIndex:zt}=m.parameters,bt=W.get("text-optional"),Dt=W.get("icon-optional"),pt=W.get("text-allow-overlap"),vt=W.get("icon-allow-overlap"),Tt=W.get("text-rotation-alignment")==="map",Gt=W.get("icon-rotation-alignment")==="map",qt=W.get("text-pitch-alignment")==="map",ns=te.get("symbol-z-offset"),Jt=W.get("symbol-elevation-reference")==="sea",Ns=W.get("symbol-placement"),[Is,Zt]=W.get("text-size-scale-range"),[Ut,ss]=W.get("icon-size-scale-range"),as=i.aC(z,Is,Zt),ds=i.aC(z,Ut,ss),Qs=W.get("text-variable-anchor"),Gs=Tt&&Ns!=="point",Ws=Gt&&Ns!=="point",Ts=Qs&&B.hasTextData(),wr=B.hasIconTextFit()&&Ts&&B.hasIconData();this.transform.setProjection(B.projection);const Ir=Ts||Gs,pr=Ws||wr;let vr=pt&&(vt||!B.hasIconData()||Dt),Zr=vt&&(pt||!B.hasTextData()||bt);const fn=!ns.isConstant();!B.collisionArrays&&Qe&&B.deserializeCollisionBoxes(Qe),E&&D&&B.updateCollisionDebugBuffers(this.transform.zoom,Qe,as,ds);const on=(Ur,qn,ln)=>{const{crossTileID:Ta,numVerticalGlyphVertices:hi}=Ur;let Zi=null;if(be&&be.dynamicFilterNeedsFeature||fn){const Ci=this.retainedQueryData[B.bucketInstanceId],Pi=zt.loadFeature({featureIndex:Ur.featureIndex,bucketIndex:Ci.bucketIndex,sourceLayerIndex:Ci.sourceLayerIndex,layoutVertexArrayOffset:0}),li=Pi.properties?Pi.properties.worldview:null;if(B.localizable&&B.worldview&&typeof li=="string")if(li==="all")Pi.properties.$localized=!0;else{if(!li.split(",").includes(B.worldview))return;Pi.properties.$localized=!0,Pi.properties.worldview=B.worldview}Zi=be&&be.needGeometry?i.bD(Pi,!0):Pi}if(be&&!(0,be.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:B.worldview},Zi,this.retainedQueryData[B.bucketInstanceId].tileID.canonical,new i.P(Ur.tileAnchorX,Ur.tileAnchorY),this.transform.calculateDistanceTileData(be.unwrappedTileID)))return this.placements[Ta]=new Wx(!1,!1,!1,!0),void v.add(Ta);const ji=ns.evaluate(Zi,{});if((Ur.zOffset||0)+(ji||0)>0&&this.frontCutoffStart>0){const Ci=2*this.frontCutoffStart-1,Pi=[Ur.tileAnchorX,Ur.tileAnchorY,0,1],li=i.aE(i.bE(),Pi,ne);if(li[1]/li[3]{Ci.tileID=this.retainedQueryData[B.bucketInstanceId].tileID;const Pi=this.transform.elevation;Ci.elevation=Jt?ji:ji+i.bu.getAtTileOffset(Ci.tileID,new i.P(Ci.tileAnchorX,Ci.tileAnchorY),Pi,Sl),Ci.elevation+=Ur.zOffset},vh=ln.textBox;if(vh){Mc(vh);const Ci=li=>{let Fo=i.bk.horizontal;if(B.allowVerticalPlacement&&!li&&this.prevPlacement){const Cd=this.prevPlacement.placedOrientations[Ta];Cd&&(this.placedOrientations[Ta]=Cd,Fo=Cd,this.markUsedOrientation(B,Fo,Ur))}return Fo},Pi=(li,Fo)=>{if(B.allowVerticalPlacement&&hi>0&&ln.verticalTextBox){for(const Cd of B.writingModes)if(Cd===i.bk.vertical?(wn=Fo(),$i=wn):wn=li(),wn&&wn.box&&wn.box.length)break}else wn=li()};if(Qs){let li=Qs;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Ta]){const mo=this.prevPlacement.variableOffsets[Ta];li.indexOf(mo.anchor)>0&&(li=li.filter(_h=>_h!==mo.anchor),li.unshift(mo.anchor))}const Fo=(mo,_h,uy)=>{const tv=B.getSymbolInstanceTextSize(lt,Ur,this.transform.zoom,qn),sv=(mo.x2-mo.x1)*tv+2*mo.padding,a_=(mo.y2-mo.y1)*tv+2*mo.padding,sg=Ur.hasIconTextFit&&!vt?_h:null;sg&&Mc(sg);let $f={box:[],offscreen:!1,occluded:!1};const i_=pt?2*li.length:li.length;for(let Gu=0;Gu=li.length,Ur,qn,B,uy,sg,lt,mt);if(hy&&($f=hy.placedGlyphBoxes,$f&&$f.box&&$f.box.length)){Fa=!0,za=hy.shift;break}}return $f};Pi(()=>Fo(vh,ln.iconBox,i.bk.horizontal),()=>{const mo=ln.verticalTextBox;return mo&&Mc(mo),B.allowVerticalPlacement&&!(wn&&wn.box&&wn.box.length)&&hi>0&&mo?Fo(mo,ln.verticalIconBox,i.bk.vertical):{box:null,offscreen:null,occluded:null}}),wn&&(Fa=wn.box,Ln=wn.offscreen,Ni=wn.occluded);const Cd=Ci(!(!wn||!wn.box));if(!Fa&&this.prevPlacement){const mo=this.prevPlacement.variableOffsets[Ta];mo&&(this.variableOffsets[Ta]=mo,this.markUsedJustification(B,mo.anchor,Ur,Cd))}}else{const li=(Fo,Cd)=>{const mo=B.getSymbolInstanceTextSize(lt,Ur,this.transform.zoom,qn),_h=this.collisionIndex.placeCollisionBox(B,mo,Fo,$e,Le,Ir,new i.P(0,0),pt,Me,ne,nt.predicate);return _h&&_h.box&&_h.box.length&&(this.markUsedOrientation(B,Cd,Ur),this.placedOrientations[Ta]=Cd),_h};Pi(()=>li(vh,i.bk.horizontal),()=>{const Fo=ln.verticalTextBox;return B.allowVerticalPlacement&&hi>0&&Fo?(Mc(Fo),li(Fo,i.bk.vertical)):{box:null,offscreen:null,occluded:null}}),Ci(!!(wn&&wn.box&&wn.box.length))}}if(mi=wn,Fa=mi&&mi.box&&mi.box.length>0,Ln=mi&&mi.offscreen,Ni=mi&&mi.occluded,Ur.useRuntimeCollisionCircles){const Ci=Ur.centerJustifiedTextSymbolIndex>=0?Ur.centerJustifiedTextSymbolIndex:Ur.verticalPlacedTextSymbolIndex,Pi=B.text.placedSymbolArray.get(Ci),li=i.bl(B.textSizeData,lt,Pi),Fo=W.get("text-padding");Ho=this.collisionIndex.placeCollisionCircles(B,pt,Pi,Ci,B.lineVertexArray,B.glyphOffsetArray,li,ne,de,je,E,qt,nt.predicate,Ur.collisionCircleDiameter*li/i.by,Fo,this.retainedQueryData[B.bucketInstanceId].tileID),Fa=pt||Ho.circles.length>0&&!Ho.collisionDetected,Ln=Ln&&Ho.offscreen,Ni=Ho.occluded}if(ln.iconFeatureIndex&&(od=ln.iconFeatureIndex),ln.iconBox){const Ci=Pi=>{Mc(Pi);const li=Ur.hasIconTextFit&&za?sy(za.x,za.y,Tt,qt,this.transform.angle):new i.P(0,0),Fo=B.getSymbolInstanceIconSize(mt,this.transform.zoom,Ur.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(B,Fo,Pi,$e,Le,pr,li,vt,Me,ne,nt.predicate)};$i&&$i.box&&$i.box.length&&ln.verticalIconBox?(sa=Ci(ln.verticalIconBox),In=sa.box.length>0):(sa=Ci(ln.iconBox),In=sa.box.length>0),Ln=Ln&&sa.offscreen,Qi=sa.occluded}const Ja=bt||Ur.numHorizontalGlyphVertices===0&&hi===0,em=Dt||Ur.numIconVertices===0;if(Ja||em?em?Ja||(In=In&&Fa):Fa=In&&Fa:In=Fa=In&&Fa,Fa&&mi&&mi.box&&this.collisionIndex.insertCollisionBox(mi.box,W.get("text-ignore-placement"),B.bucketInstanceId,$i&&$i.box&&ll?ll:_i,nt.ID),In&&sa&&this.collisionIndex.insertCollisionBox(sa.box,W.get("icon-ignore-placement"),B.bucketInstanceId,od,nt.ID),Ho&&(Fa&&this.collisionIndex.insertCollisionCircles(Ho.circles,W.get("text-ignore-placement"),B.bucketInstanceId,_i,nt.ID),E)){const Ci=B.bucketInstanceId;let Pi=this.collisionCircleArrays[Ci];Pi===void 0&&(Pi=this.collisionCircleArrays[Ci]=new Dr);for(let li=0;li=0;--qn){const ln=Ur[qn];on(B.symbolInstances.get(ln),ln,B.collisionArrays[ln])}B.hasAnyZOffset&&i.w(`${B.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(B.hasAnyZOffset){const Ur=B.getSortedIndexesByZOffset();for(let qn=0;qn=0&&(m.text.placedSymbolArray.get(z).crossTileID=je>=0&&z!==je?0:ne),B>=0&&(m.text.placedSymbolArray.get(B).crossTileID=je>=0&&B!==je?0:ne),W>=0&&(m.text.placedSymbolArray.get(W).crossTileID=je>=0&&W!==je?0:ne),te>=0&&(m.text.placedSymbolArray.get(te).crossTileID=je>=0&&te!==je?0:ne)}markUsedOrientation(m,v,E){const D=v===i.bk.horizontal||v===i.bk.horizontalOnly?v:0,z=v===i.bk.vertical?v:0,{leftJustifiedTextSymbolIndex:B,centerJustifiedTextSymbolIndex:W,rightJustifiedTextSymbolIndex:te,verticalPlacedTextSymbolIndex:ne}=E,de=m.text.placedSymbolArray;B>=0&&(de.get(B).placedOrientation=D),W>=0&&(de.get(W).placedOrientation=D),te>=0&&(de.get(te).placedOrientation=D),ne>=0&&(de.get(ne).placedOrientation=z)}commit(m){this.commitTime=m,this.zoomAtLastRecencyCheck=this.transform.zoom;const v=this.prevPlacement;let E=!1;this.prevZoomAdjustment=v?v.zoomAdjustment(this.transform.zoom):0;const D=v?v.symbolFadeChange(m):1,z=v?v.opacities:{},B=v?v.variableOffsets:{},W=v?v.placedOrientations:{};for(const te in this.placements){const ne=this.placements[te],de=z[te];de?(this.opacities[te]=new O0(de,D,ne.text,ne.icon,null,ne.clipped),E=E||ne.text!==de.text.placed||ne.icon!==de.icon.placed):(this.opacities[te]=new O0(null,D,ne.text,ne.icon,ne.skipFade,ne.clipped),E=E||ne.text||ne.icon)}for(const te in z){const ne=z[te];if(!this.opacities[te]){const de=new O0(ne,D,!1,!1);de.isHidden()||(this.opacities[te]=de,E=E||ne.text.placed||ne.icon.placed)}}for(const te in B)this.variableOffsets[te]||!this.opacities[te]||this.opacities[te].isHidden()||(this.variableOffsets[te]=B[te]);for(const te in W)this.placedOrientations[te]||!this.opacities[te]||this.opacities[te].isHidden()||(this.placedOrientations[te]=W[te]);E?this.lastPlacementChangeTime=m:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=v?v.lastPlacementChangeTime:m)}updateLayerOpacities(m,v,E,D){D&&(this.lastReplacementSourceUpdateTime=D.updateTime);const z=new Set;for(const B of v){const W=B.getBucket(m);W&&B.latestFeatureIndex&&m.fqid===W.layerIds[0]&&(this.updateBucketOpacities(W,z,B,B.collisionBoxArray,E,D,B.tileID,m.scope),W.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(W,B.tileID),W.elevationType==="road"&&W.updateRoadElevation(B.tileID.canonical),W.updateZOffset())}}updateBucketOpacities(m,v,E,D,z,B,W,te){m.hasTextData()&&m.text.opacityVertexArray.clear(),m.hasIconData()&&m.icon.opacityVertexArray.clear(),m.hasIconCollisionBoxData()&&m.iconCollisionBox.collisionVertexArray.clear(),m.hasTextCollisionBoxData()&&m.textCollisionBox.collisionVertexArray.clear();const ne=m.layers[0].layout,de=m.layers[0].paint,je=!!m.layers[0].dynamicFilter(),be=new O0(null,0,!1,!1,!0),Me=ne.get("text-allow-overlap"),$e=ne.get("icon-allow-overlap"),Le=ne.get("text-variable-anchor"),Je=ne.get("text-rotation-alignment")==="map",Qe=ne.get("text-pitch-alignment")==="map",lt=de.get("symbol-z-offset"),mt=ne.get("symbol-elevation-reference")==="sea",nt=!lt.isConstant(),zt=new O0(null,0,Me&&($e||!m.hasIconData()||ne.get("icon-optional")),$e&&(Me||!m.hasTextData()||ne.get("text-optional")),!0);!m.collisionArrays&&D&&(m.hasIconCollisionBoxData()||m.hasTextCollisionBoxData())&&m.deserializeCollisionBoxes(D);const bt=(pt,vt,Tt)=>{for(let Gt=0;Gt0||Gt>0,Qs=ns>0,Gs=this.placedOrientations[qt],Ws=Gs===i.bk.vertical,Ts=Gs===i.bk.horizontal||Gs===i.bk.horizontalOnly;!ds&&!Qs||as.isHidden()||Dt++;let wr=!1;if((ds||Qs)&&B)for(const Ir of m.activeReplacements){if(i.bz(Ir,z,i.bA.Symbol,te)||Ir.min.x>Jt||Jt>Ir.max.x||Ir.min.y>Ns||Ns>Ir.max.y)continue;const pr=i.bB(Jt,Ns,W.canonical,Ir.footprintTileId.canonical);if(wr=i.bC(pr,Ir.footprint),wr)break}if(wr&&this.collisionIndex.markSymbolAsClipped(m.bucketInstanceId,vt.featureIndex),ds){const Ir=wr?Kx:z1(as.text);bt(m.text,Tt,Ws?Kx:Ir),bt(m.text,Gt,Ts?Kx:Ir);const pr=as.text.isHidden(),{leftJustifiedTextSymbolIndex:vr,centerJustifiedTextSymbolIndex:Zr,rightJustifiedTextSymbolIndex:fn,verticalPlacedTextSymbolIndex:on}=vt,$n=m.text.placedSymbolArray,Ur=pr||Ws?1:0;vr>=0&&($n.get(vr).hidden=Ur),Zr>=0&&($n.get(Zr).hidden=Ur),fn>=0&&($n.get(fn).hidden=Ur),on>=0&&($n.get(on).hidden=pr||Ts?1:0);const qn=this.variableOffsets[qt];qn&&this.markUsedJustification(m,qn.anchor,vt,Gs);const ln=this.placedOrientations[qt];ln&&(this.markUsedJustification(m,"left",vt,ln),this.markUsedOrientation(m,ln,vt))}if(Qs){const Ir=wr?Kx:z1(as.icon),{placedIconSymbolIndex:pr,verticalPlacedIconSymbolIndex:vr}=vt,Zr=m.icon.placedSymbolArray,fn=as.icon.isHidden()?1:0;pr>=0&&(bt(m.icon,ns,Ws?Kx:Ir),Zr.get(pr).hidden=fn),vr>=0&&(bt(m.icon,vt.numVerticalIconVertices,Ts?Kx:Ir),Zr.get(vr).hidden=fn)}if(m.hasIconCollisionBoxData()||m.hasTextCollisionBoxData()){const Ir=m.collisionArrays[pt];if(Ir){let pr=new i.P(0,0),vr=!0;if(Ir.textBox||Ir.verticalTextBox){if(Le){const fn=this.variableOffsets[qt];fn?(pr=bu(fn.anchor,fn.width,fn.height,fn.textOffset,fn.textScale),Je&&pr._rotate(Qe?this.transform.angle:-this.transform.angle)):vr=!1}je&&(vr=!as.clipped),Ir.textBox&&F0(m.textCollisionBox.collisionVertexArray,as.text.placed,!vr||Ws,Ut,mt,pr.x,pr.y),Ir.verticalTextBox&&F0(m.textCollisionBox.collisionVertexArray,as.text.placed,!vr||Ts,Ut,mt,pr.x,pr.y)}const Zr=vr&&!!(!Ts&&Ir.verticalIconBox);Ir.iconBox&&F0(m.iconCollisionBox.collisionVertexArray,as.icon.placed,Zr,Ut,mt,vt.hasIconTextFit?pr.x:0,vt.hasIconTextFit?pr.y:0),Ir.verticalIconBox&&F0(m.iconCollisionBox.collisionVertexArray,as.icon.placed,!Zr,Ut,mt,vt.hasIconTextFit?pr.x:0,vt.hasIconTextFit?pr.y:0)}}}if(m.fullyClipped=Dt===0,m.sortFeatures(this.transform.angle),this.retainedQueryData[m.bucketInstanceId]&&(this.retainedQueryData[m.bucketInstanceId].featureSortOrder=m.featureSortOrder),m.hasTextData()&&m.text.opacityVertexBuffer&&m.text.opacityVertexBuffer.updateData(m.text.opacityVertexArray),m.hasIconData()&&m.icon.opacityVertexBuffer&&m.icon.opacityVertexBuffer.updateData(m.icon.opacityVertexArray),m.hasIconCollisionBoxData()&&m.iconCollisionBox.collisionVertexBuffer&&m.iconCollisionBox.collisionVertexBuffer.updateData(m.iconCollisionBox.collisionVertexArray),m.hasTextCollisionBoxData()&&m.textCollisionBox.collisionVertexBuffer&&m.textCollisionBox.collisionVertexBuffer.updateData(m.textCollisionBox.collisionVertexArray),m.bucketInstanceId in this.collisionCircleArrays){const pt=this.collisionCircleArrays[m.bucketInstanceId];m.placementInvProjMatrix=pt.invProjMatrix,m.placementViewportMatrix=pt.viewportMatrix,m.collisionCircleArray=pt.circles,delete this.collisionCircleArrays[m.bucketInstanceId]}}symbolFadeChange(m){return this.fadeDuration===0?1:(m-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(m){return Math.max(0,(this.transform.zoom-m)/1.5)}hasTransitions(m){return m-this.lastPlacementChangeTimem}isStale(){return this.stale}setStale(){this.stale=!0}}function F0(M,m,v,E,D,z,B){M.emplaceBack(m?1:0,v?1:0,z||0,B||0,E,D?1:0),M.emplaceBack(m?1:0,v?1:0,z||0,B||0,E,D?1:0),M.emplaceBack(m?1:0,v?1:0,z||0,B||0,E,D?1:0),M.emplaceBack(m?1:0,v?1:0,z||0,B||0,E,D?1:0)}const Dw=Math.pow(2,25),Rw=Math.pow(2,24),Kd=Math.pow(2,17),Nl=Math.pow(2,16),ape=Math.pow(2,9),Ow=Math.pow(2,8),zE=Math.pow(2,1);function z1(M){if(M.opacity===0&&!M.placed)return 0;if(M.opacity===1&&M.placed)return 4294967295;const m=M.placed?1:0,v=Math.floor(127*M.opacity);return v*Dw+m*Rw+v*Kd+m*Nl+v*ape+m*Ow+v*zE+m}const Kx=0;class BE{constructor(m){this._sortAcrossTiles=m.layout.get("symbol-z-order")!=="viewport-y"&&m.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(m,v,E,D,z,B){const W=this._bucketParts;for(;this._currentTileIndexte.sortKey-ne.sortKey));this._currentPartIndex{const te=i.o.now()-B;return!this.isFullPlacementRequested()&&this._fadeDuration!==0&&te>2};for(;this._currentPlacementIndex>=0;){const te=v[m[this._currentPlacementIndex]],ne=this.placement.collisionIndex.transform.zoom;if(te.type==="symbol"&&te.visibility!=="none"&&(!te.minzoom||te.minzoom<=ne)&&(!te.maxzoom||te.maxzoom>ne)){const de=te,je=de.layout.get("symbol-z-elevate"),be=de.layout.get("symbol-sort-key").constantOr(1)!==void 0,Me=de.layout.get("symbol-z-order"),$e=Me==="viewport-y"||Me==="auto"&&!(Me!=="viewport-y"&&be),Le=de.layout.get("text-allow-overlap")||de.layout.get("icon-allow-overlap")||de.layout.get("text-ignore-placement")||de.layout.get("icon-ignore-placement"),Je=$e&&Le,Qe=this._inProgressLayer=this._inProgressLayer||new BE(de),lt=i.F(te.source,te.scope);if(Qe.continuePlacement(je||Je?D[lt]:E[lt],this.placement,this._showCollisionBoxes,te,W,z))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._forceFullPlacement=!1,this._done=!0}commit(m){return this.placement.commit(m),this.placement}}const kd=512/i.an/2;class $m{constructor(m,v,E){this.tileID=m,this.bucketInstanceId=E,this.index=new i.bI(v.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const D=m.canonical.x*i.an,z=m.canonical.y*i.an;for(let B=0;BJe-Qe);for(const Je of Le){const Qe=this.crossTileIDs[Je];if(this.keys[Je]===de&&!E.has(Qe)){E.add(Qe),ne.crossTileID=Qe;break}}}}}class Hu{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class IO{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(m){const v=Math.round((m-this.lng)/360);if(v!==0)for(const E in this.indexes){const D=this.indexes[E],z={};for(const B in D){const W=D[B];W.tileID=W.tileID.unwrapTo(W.tileID.wrap+v),z[W.tileID.key]=W}this.indexes[E]=z}this.lng=m}addBucket(m,v,E){if(this.indexes[m.overscaledZ]&&this.indexes[m.overscaledZ][m.key]){if(this.indexes[m.overscaledZ][m.key].bucketInstanceId===v.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(m.overscaledZ,this.indexes[m.overscaledZ][m.key])}for(let z=0;zm.overscaledZ)for(const W in B){const te=B[W];te.tileID.isChildOf(m)&&te.findMatches(v.symbolInstances,m,D)}else{const W=B[m.scaledTo(Number(z)).key];W&&W.findMatches(v.symbolInstances,m,D)}}for(let z=0;z{v[E]=!0});for(const E in this.layerIndexes)v[E]||delete this.layerIndexes[E]}}const Oo=771;class Jr{constructor(m,v,E,D){this.blendFunction=m,this.blendColor=v.toNonPremultipliedRenderColor(null),this.mask=E,this.blendEquation=D}}Jr.Replace=[1,0,1,0],Jr.disabled=new Jr(Jr.Replace,i.aq.transparent,[!1,!1,!1,!1]),Jr.unblended=new Jr(Jr.Replace,i.aq.transparent,[!0,!0,!0,!0]),Jr.alphaBlended=new Jr([1,Oo,1,Oo],i.aq.transparent,[!0,!0,!0,!0]),Jr.alphaBlendedNonPremultiplied=new Jr([770,Oo,770,Oo],i.aq.transparent,[!0,!0,!0,!0]),Jr.multiply=new Jr([774,0,774,0],i.aq.transparent,[!0,!0,!0,!0]),Jr.multiplyAccumulateAlpha=new Jr([774,0,1,Oo],i.aq.transparent,[!0,!0,!0,!0]),Jr.additive=new Jr([1,1,1,1],i.aq.transparent,[!0,!0,!0,!0]);class kr{constructor(m,v,E){this.func=m,this.mask=v,this.range=E}}kr.ReadOnly=!1,kr.ReadWrite=!0,kr.disabled=new kr(519,kr.ReadOnly,[0,1]);const ol=7680;class sn{constructor(m,v,E,D,z,B){this.test=m,this.ref=v,this.mask=E,this.fail=D,this.depthFail=z,this.pass=B}}sn.disabled=new sn({func:519,mask:0},0,0,ol,ol,ol);const Zh=1029,z0=2305;class Wr{constructor(m,v,E){this.enable=m,this.mode=v,this.frontFace=E}}function zw(M,m){const v=i.bO(M,3);i.bR(M,m),i.bW(M,3,v)}function qC(M,m){const v=i.bL([]);return i.bM(v,v,-m),i.bN(v,v,-M),v}function UC(M,m){const v=[M[0],M[1],0],E=[m[0],m[1],0];if(i.ai(v)>=1e-15){const B=i.ay([],v);i.bJ(E,B,i.bi(E,B)),m[0]=E[0],m[1]=E[1]}const D=i.bh([],m,M);if(i.bK(D)<1e-15)return null;const z=Math.atan2(-D[1],D[0]);return qC(Math.atan2(Math.sqrt(M[0]*M[0]+M[1]*M[1]),-M[2]),z)}Wr.disabled=new Wr(!1,Zh,z0),Wr.backCCW=new Wr(!0,Zh,z0),Wr.backCW=new Wr(!0,Zh,2304),Wr.frontCW=new Wr(!0,1028,2304),Wr.frontCCW=new Wr(!0,1028,z0);class Bw{constructor(m,v){this.position=m,this.orientation=v}get position(){return this._position}set position(m){if(m){const v=m instanceof i.ag?m:new i.ag(m[0],m[1],m[2]);this._renderWorldCopies&&(v.x=i.bs(v.x,0,1)),this._position=v}else this._position=null}lookAtPoint(m,v,E){if(this.orientation=null,!this.position)return;const D=this.position,z=E||(this._elevation?this._elevation.getAtPointOrZero(i.ag.fromLngLat(m)):0),B=i.ag.fromLngLat(m,z),W=[B.x-D.x,B.y-D.y,B.z-D.z];v||(v=[0,0,1]),v[2]=Math.abs(v[2]),this.orientation=UC(W,v)}setPitchBearing(m,v){this.orientation=qC(i.ap(m),i.ap(-v))}}class $w{constructor(m,v){this._transform=i.b9([]),this.orientation=v,this.position=m}get mercatorPosition(){const m=this.position;return new i.ag(m[0],m[1],m[2])}get position(){const m=i.bO(this._transform,3);return[m[0],m[1],m[2]]}set position(m){var v;m&&i.bW(this._transform,3,[(v=m)[0],v[1],v[2],1])}get orientation(){return this._orientation}set orientation(m){this._orientation=m||i.bL([]),m&&zw(this._transform,this._orientation)}getPitchBearing(){const m=this.forward(),v=this.right();return{bearing:Math.atan2(-v[1],v[0]),pitch:Math.atan2(Math.sqrt(m[0]*m[0]+m[1]*m[1]),-m[2])}}setPitchBearing(m,v){this._orientation=qC(m,v),zw(this._transform,this._orientation)}forward(){const m=i.bO(this._transform,2);return[-m[0],-m[1],-m[2]]}up(){const m=i.bO(this._transform,1);return[-m[0],-m[1],-m[2]]}right(){const m=i.bO(this._transform,0);return[m[0],m[1],m[2]]}getCameraToWorld(m,v){const E=new Float64Array(16);return i.b7(E,this.getWorldToCamera(m,v)),E}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(m,v,E){const D=this.position;i.bJ(D,D,-m);const z=new Float64Array(16);return i.bP(z,[E,E,E]),i.bx(z,z,D),z[10]*=v,z}getWorldToCamera(m,v){const E=new Float64Array(16),D=new Float64Array(4),z=this.position;return i.bQ(D,this._orientation),i.bJ(z,z,-m),i.bR(E,D),i.bx(E,E,z),E[1]*=-1,E[5]*=-1,E[9]*=-1,E[13]*=-1,E[8]*=v,E[9]*=v,E[10]*=v,E[11]*=v,E}getCameraToClipPerspective(m,v,E,D){const z=new Float64Array(16);return i.bS(z,m,v,E,D),z}getCameraToClipOrthographic(m,v,E,D,z,B){const W=new Float64Array(16);return i.bT(W,m,v,E,D,z,B),W}getDistanceToElevation(m,v=!1){const E=m===0?0:i.bU(m,v?i.bV(this.position[1]):this.position[1]),D=this.forward();return(E-this.position[2])/D[2]}clone(){return new $w([...this.position],[...this.orientation])}}const ipe=(M,m)=>({u_matrix:M,u_ground_shadow_factor:m});class Ap{constructor(m=0,v=0,E=0,D=0){if(isNaN(m)||m<0||isNaN(v)||v<0||isNaN(E)||E<0||isNaN(D)||D<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=m,this.bottom=v,this.left=E,this.right=D}interpolate(m,v,E){return v.top!=null&&m.top!=null&&(this.top=i.am(m.top,v.top,E)),v.bottom!=null&&m.bottom!=null&&(this.bottom=i.am(m.bottom,v.bottom,E)),v.left!=null&&m.left!=null&&(this.left=i.am(m.left,v.left,E)),v.right!=null&&m.right!=null&&(this.right=i.am(m.right,v.right,E)),this}getCenter(m,v){const E=i.aC((this.left+m-this.right)/2,0,m),D=i.aC((this.top+v-this.bottom)/2,0,v);return new i.P(E,D)}equals(m){return this.top===m.top&&this.bottom===m.bottom&&this.left===m.left&&this.right===m.right}clone(){return new Ap(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const B0=15;class qw{constructor(m,v,E,D,z,B,W){this.tileSize=512,this._renderWorldCopies=z===void 0||z,this._minZoom=m||0,this._maxZoom=v||22,this._minPitch=E??0,this._maxPitch=D??60,this.setProjection(B),this.setMaxBounds(W),this.width=0,this.height=0,this._center=new i.aU(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._nearClipOffset=0,this._unmodified=!0,this._edgeInsets=new Ap,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new $w,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 m=new qw(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return m._elevation=this._elevation,m._centerAltitude=this._centerAltitude,m._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,m.tileSize=this.tileSize,m.mercatorFromTransition=this.mercatorFromTransition,m.width=this.width,m.height=this.height,m.cameraElevationReference=this.cameraElevationReference,m._center=this._center,m._setZoom(this.zoom),m._seaLevelZoom=this._seaLevelZoom,m.angle=this.angle,m._fov=this._fov,m._pitch=this._pitch,m._nearZ=this._nearZ,m._farZ=this._farZ,m._nearClipOffset=this._nearClipOffset,m._averageElevation=this._averageElevation,m._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,m._unmodified=this._unmodified,m._edgeInsets=this._edgeInsets.clone(),m._camera=this._camera.clone(),m._calcMatrices(),m.freezeTileCoverage=this.freezeTileCoverage,m.frustumCorners=this.frustumCorners,m._allowWorldUnderZoom=this._allowWorldUnderZoom,m}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||m===Number.NEGATIVE_INFINITY&&(!v||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const E=this._elevation;v||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&E.exaggeration()&&this._centerAltitudeValidForExaggeration!==E.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*E.exaggeration(),this._centerAltitudeValidForExaggeration=E.exaggeration()):(this._centerAltitude=m||0,this._centerAltitudeValidForExaggeration=E.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;const m=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(m)}sampleAverageElevation(){if(!this._elevation)return 0;const m=this._elevation,v=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],E=this.horizonLineFromTop();let D=0,z=0;for(let B=0;B{const Je=i.ck(be,je,Me,$e,Le);te.has(Je)||(z.push(new i.aR(je,be,Me,$e,Le)),te.add(Je))};for(let je=0;jebe.canonical.z)continue;const Me=be.canonical,$e=be.overscaledZ,Le=be.wrap,Je=1<0,mt=Me.y+10,zt=be.wrap-(lt?0:1),bt=be.wrap+(Qe?0:1),Dt=lt?Me.x-1:Je-1,pt=Qe?Me.x+1:0;if(B)E[0]<0?(ne($e,bt,Me.z,pt,Me.y),E[1]<0&&mt&&(ne($e,Le,Me.z,Me.x,Me.y+1),ne($e,bt,Me.z,pt,Me.y+1)),E[1]>0&&nt&&(ne($e,Le,Me.z,Me.x,Me.y-1),ne($e,bt,Me.z,pt,Me.y-1))):E[0]>0?(ne($e,zt,Me.z,Dt,Me.y),E[1]<0&&mt&&(ne($e,Le,Me.z,Me.x,Me.y+1),ne($e,zt,Me.z,Dt,Me.y+1)),E[1]>0&&nt&&(ne($e,Le,Me.z,Me.x,Me.y-1),ne($e,zt,Me.z,Dt,Me.y-1))):E[1]<0&&mt?ne($e,Le,Me.z,Me.x,Me.y+1):nt&&ne($e,Le,Me.z,Me.x,Me.y-1);else{const vt=be.visibleQuadrants;1&vt&&(ne($e,zt,Me.z,Dt,Me.y),nt&&(ne($e,Le,Me.z,Me.x,Me.y-1),ne($e,zt,Me.z,Dt,Me.y-1))),2&vt&&(ne($e,bt,Me.z,pt,Me.y),nt&&(ne($e,Le,Me.z,Me.x,Me.y-1),ne($e,bt,Me.z,pt,Me.y-1))),4&vt&&(ne($e,zt,Me.z,Dt,Me.y),mt&&(ne($e,Le,Me.z,Me.x,Me.y+1),ne($e,zt,Me.z,Dt,Me.y+1))),8&vt&&(ne($e,bt,Me.z,pt,Me.y),mt&&(ne($e,Le,Me.z,Me.x,Me.y+1),ne($e,bt,Me.z,pt,Me.y+1)))}}const de=[];for(const je of z)z.some(be=>je.isChildOf(be))||de.push(je);if(z=de.filter(je=>!m.some(be=>!!(je.overscaledZ{const Qe=Je.canonical.x+.5-Me[0],lt=Je.canonical.y+.5-Me[1];return Qe*Qe+lt*lt{const Dt=i.ck(mt,lt,nt,zt,bt);z.has(Dt)||(D.push(new i.aR(lt,mt,nt,zt,bt)),z.add(Dt))},W=m.reduce((lt,mt)=>Math.max(lt,mt.overscaledZ),E),te=1<{const nt=Math.floor(lt[0]),zt=Math.floor(lt[1]),bt=(lt[0]-nt)*i.an,Dt=(lt[1]-zt)*i.an,pt=Math.floor(mt[0]),vt=Math.floor(mt[1]),Tt=(mt[0]-pt)*i.an,Gt=(mt[1]-vt)*i.an;for(let qt=-1;qt<=1;qt++){const ns=nt+qt;if(!(ns<0||ns>=te)){de.x=bt-qt*i.an,je.x=Tt-(ns-pt)*i.an;for(let Jt=-1;Jt<=1;Jt++){const Ns=zt+Jt;de.y=Dt-Jt*i.an,je.y=Gt-(Ns-vt)*i.an,i.cI(de,je,ne)&&B(W,0,E,ns,Ns)}}}},Me=v.points,$e=Me[i.c9],Le=Me[i.ca],Je=this._projectToGround($e,Me[i.cb]),Qe=this._projectToGround(Le,Me[i.cc]);return be($e,Je),be(Le,Qe),D}_projectToGround(m,v){return i.cd(i.ce(),m,v,m[2]/(m[2]-v[2]))}_projectToZ(m,v,E){const D=m[2]-v[2];return Math.abs(D)<1e-6?i.cf(m):i.cd(i.ce(),m,v,(m[2]-E)/D)}extendTileCoverForTunnels(m,v,E,D){if(E<18)return[];const z=v.points,B=z[i.cg],W=z[i.ch],te=z[i.ci],ne=z[i.cj];if(te[2]>=0&&ne[2]>=0||B[2]<=0||W[2]<=0)return[];const de=te[2]<0?this._projectToZ(B,te,0):te,je=ne[2]<0?this._projectToZ(W,ne,0):ne,be=-D,Me=te[2]3&&(Le.length=3),Le}_findExtensionTilesInQuad(m,v,E,D){const z=[],B=new Set;for(const pt of m)B.add(pt.key);const W=m.reduce((pt,vt)=>Math.max(pt,vt.overscaledZ),v),te=1<{const Tt=pt.canonical.x+.5-bt,Gt=pt.canonical.y+.5-Dt,qt=vt.canonical.x+.5-bt,ns=vt.canonical.y+.5-Dt;return Tt*Tt+Gt*Gt-(qt*qt+ns*ns)||pt.canonical.x-vt.canonical.x||pt.canonical.y-vt.canonical.y}),z}coveringTiles(m){let v=this.coveringZoomLevel(m);const E=v,D=this.elevation&&this.elevation.exaggeration(),z=D&&!m.isTerrainDEM,B=this.projection.name==="mercator";if(m.minzoom!==void 0&&vm.maxzoom&&(v=m.maxzoom);const W=this.locationCoordinate(this.center),te=this.center.lat,ne=1<{const as=new i.ag(Ut.x+25e-6,Ut.y,Ut.z),ds=new i.ag(Ut.x,Ut.y+25e-6,Ut.z),Qs=Ut.toLngLat(),Gs=as.toLngLat(),Ws=ds.toLngLat(),Ts=this.locationCoordinate(Qs),wr=this.locationCoordinate(Gs),Ir=this.locationCoordinate(Ws),pr=Math.hypot(wr.x-Ts.x,wr.y-Ts.y),vr=Math.hypot(Ir.x-Ts.x,Ir.y-Ts.y);return Math.sqrt(pr*vr)*Dt/25e-6},vt=Ut=>{const ss=zt,as=bt;return{aabb:i.cp(this,ne,0,0,0,Ut,as,ss,this.projection),zoom:0,x:0,y:0,minZ:as,maxZ:ss,wrap:Ut,fullyVisible:!1}},Tt=[];let Gt=[];const qt=v,ns=m.reparseOverscaled?E:v,Jt=(Je-this._centerAltitude)*Le,Ns=Ut=>{if(!this._elevation||!Ut.tileID||!B)return;const ss=this._elevation.getMinMaxForTile(Ut.tileID),as=Ut.aabb;ss?(as.min[2]=ss.min,as.max[2]=ss.max,as.center[2]=(as.min[2]+as.max[2])/2):(Ut.shouldSplit=Zt(Ut),Ut.shouldSplit||(as.min[2]=as.max[2]=as.center[2]=this._centerAltitude))},Is=(Ut,ss)=>{if(.707*ss{if(Ut.zoom=.9)return!0}else if(z&&(ds=Ut.aabb.distanceZ(Qe)*Le),this.projection.isReprojectedInTileSpace&&E<=5){const vr=Math.pow(2,Ut.zoom),Zr=pt(new i.ag((Ut.x+.5)/vr,(Ut.y+.5)/vr));Qs=Zr>.85?1:Zr}if(!B&&!je){const vr=Math.sqrt(ss*ss+as*as+ds*ds);let Zr=(1<0;){const Ut=Tt.pop(),ss=Ut.x,as=Ut.y;let ds=Ut.fullyVisible;const Qs=()=>this.projection.name==="globe"&&(Ut.y===0||Ut.y===(1<Gs)continue;let Ws=0;if(!ds){let pr=lt?Ut.aabb.intersectsPrecise(Me):Ut.aabb.intersectsPreciseFlat(Me);if(pr===0&&Qs()){const vr=new i.cn(Ut.zoom,ss,as);pr=i.co(this,ne,vr,!0).intersectsPrecise(Me)}if(pr===0)continue;if(m.calculateQuadrantVisibility)if(Me.containsPoint(Ut.aabb.center))Ws=15;else for(let vr=0;vr<4;vr++)Ut.aabb.quadrant(vr).intersects(Me)!==0&&(Ws|=1<>1),wr={aabb:B?Ut.aabb.quadrant(Gs):i.cp(this,ne,Ut.zoom+1,Ws,Ts,Ut.wrap,Ut.minZ,Ut.maxZ,this.projection),zoom:Ut.zoom+1,x:Ws,y:Ts,wrap:Ut.wrap,fullyVisible:ds,tileID:void 0,shouldSplit:void 0,minZ:Ut.minZ,maxZ:Ut.maxZ};z&&!je&&(wr.tileID=new i.aR(Ut.zoom+1===qt?ns:Ut.zoom+1,Ut.wrap,Ut.zoom+1,Ws,Ts),Ns(wr)),Tt.push(wr)}}if(this.fogCullDistSq){const Ut=this.fogCullDistSq,ss=this.horizonLineFromTop();Gt=Gt.filter(as=>{const ds=[0,0,0,1],Qs=[i.an,i.an,0,1],Gs=this.calculateFogTileMatrix(as.tileID.toUnwrapped());i.aE(ds,ds,Gs),i.aE(Qs,Qs,Gs);const Ws=i.cq([],ds,Qs),Ts=i.cr([],ds,Qs),wr=i.cK(Ws,Ts);if(wr===0)return!0;let Ir=!1;const pr=this._elevation;if(pr&&wr>Ut&&ss!==0){const vr=this.calculateProjMatrix(as.tileID.toUnwrapped());let Zr;m.isTerrainDEM||(Zr=pr.getMinMaxForTile(as.tileID)),Zr||(Zr={min:bt,max:zt});const fn=i.cs(this.rotation),on=[fn[0]*i.an,fn[1]*i.an,Zr.max];i.ah(on,on,vr),Ir=(1-on[1])*this.height*.5Ut.distanceSq-ss.distanceSq).map(Ut=>Ut.tileID)}resize(m,v){this.width=m,this.height=v,this.pixelsToGLUnits=[2/m,-2/v],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(m){return Math.pow(2,m)}scaleZoom(m){return Math.log2(m)}project(m){const v=i.aC(m.lat,-i.ct,i.ct),E=this.projection.project(m.lng,v);return new i.P(E.x*this.worldSize,E.y*this.worldSize)}unproject(m){return this.projection.unproject(m.x/this.worldSize,m.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/i.bU(1,this.center.lat)/this.worldSize}setLocationAtPoint(m,v){let E,D;const z=this.centerPoint;if(this.projection.name==="globe"){const W=this.worldSize;E=(v.x-z.x)/W,D=(v.y-z.y)/W}else{const W=this.pointCoordinate(v),te=this.pointCoordinate(z);E=W.x-te.x,D=W.y-te.y}const B=this.locationCoordinate(m);this.setLocation(new i.ag(B.x-E,B.y-D))}setLocation(m){this.center=this.coordinateLocation(m),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(m,v){return this.projection.locationPoint(this,m,v)}locationPoint3D(m,v){return this.projection.locationPoint(this,m,v,!0)}pointLocation(m){return this.coordinateLocation(this.pointCoordinate(m))}pointLocation3D(m,v){return this.coordinateLocation(this.pointCoordinate3D(m,v))}locationCoordinate(m,v){const E=v?i.bU(v,m.lat):void 0,D=this.projection.project(m.lng,m.lat);return new i.ag(D.x,D.y,E)}coordinateLocation(m){return this.projection.unproject(m.x,m.y)}pointRayIntersection(m,v){const E=v??this._centerAltitude,D=[m.x,m.y,0,1],z=[m.x,m.y,1,1];i.aE(D,D,this.pixelMatrixInverse),i.aE(z,z,this.pixelMatrixInverse);const B=z[3];i.cu(D,D,1/D[3]),i.cu(z,z,1/B);const W=D[2],te=z[2];return{p0:D,p1:z,t:W===te?0:(E-W)/(te-W)}}screenPointToMercatorRay(m){const v=[m.x,m.y,0,1],E=[m.x,m.y,1,1];return i.aE(v,v,this.pixelMatrixInverse),i.aE(E,E,this.pixelMatrixInverse),i.cu(v,v,1/v[3]),i.cu(E,E,1/E[3]),v[2]=i.bU(v[2],this._center.lat)*this.worldSize,E[2]=i.bU(E[2],this._center.lat)*this.worldSize,i.cu(v,v,1/this.worldSize),i.cu(E,E,1/this.worldSize),new i.az([v[0],v[1],v[2]],i.ay([],i.ax([],E,v)))}rayIntersectionCoordinate(m){const{p0:v,p1:E,t:D}=m,z=i.bU(v[2],this._center.lat),B=i.bU(E[2],this._center.lat);return new i.ag(i.am(v[0],E[0],D)/this.worldSize,i.am(v[1],E[1],D)/this.worldSize,i.am(z,B,D))}pointCoordinate(m,v=this._centerAltitude){return this.projection.pointCoordinate(this,m.x,m.y,v)}pointCoordinate3D(m,v){if(!this.elevation)return this.pointCoordinate(m,v);let E=this.projection.pointCoordinate3D(this,m.x,m.y);if(E)return new i.ag(E[0],E[1],E[2]);let D=0,z=this.horizonLineFromTop();if(m.y>z)return this.pointCoordinate(m,v);const B=.02*z,W=m.clone();for(let te=0;te<10&&z-D>B;te++){W.y=i.am(D,z,.66);const ne=this.projection.pointCoordinate3D(this,W.x,W.y);ne?(z=W.y,E=ne):D=W.y}return E?new i.ag(E[0],E[1],E[2]):this.pointCoordinate(m)}isPointAboveHorizon(m){return this.projection.isPointAboveHorizon(this,m)}isPointOnSurface(m){if(m.y<0||m.y>this.height||m.x<0||m.x>this.width)return!1;if(this.elevation||this.zoom>=i.cv)return!this.isPointAboveHorizon(m);const v=this.pointCoordinate(m);return v.y>=0&&v.y<=1}_coordinatePoint(m,v){const E=v&&this.elevation?this.elevation.getAtPointOrZero(m,this._centerAltitude):this._centerAltitude,D=[m.x*this.worldSize,m.y*this.worldSize,E+m.toAltitude(),1];return i.aE(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:m,left:v}=this._edgeInsets,E=this.height-this._edgeInsets.bottom,D=this.width-this._edgeInsets.right,z=this.pointLocation3D(new i.P(v,m)),B=this.pointLocation3D(new i.P(D,m)),W=this.pointLocation3D(new i.P(D,E)),te=this.pointLocation3D(new i.P(v,E));let ne=Math.min(z.lng,B.lng,W.lng,te.lng),de=Math.max(z.lng,B.lng,W.lng,te.lng),je=Math.min(z.lat,B.lat,W.lat,te.lat),be=Math.max(z.lat,B.lat,W.lat,te.lat);const Me=Math.pow(2,-this.zoom)/16*270,$e=this.projection.name==="globe"?1:4,Le=(Je,Qe,lt,mt,nt)=>{const zt=(Je+lt)/2,bt=(Qe+mt)/2,Dt=new i.P(zt,bt),{lng:pt,lat:vt}=this.pointLocation3D(Dt),Tt=Math.max(0,ne-pt,je-vt,pt-de,vt-be);ne=Math.min(ne,pt),de=Math.max(de,pt),je=Math.min(je,vt),be=Math.max(be,vt),(nt<$e||Tt>Me)&&(Le(Je,Qe,zt,bt,nt+1),Le(zt,bt,lt,mt,nt+1))};if(Le(v,m,D,m,1),Le(D,m,D,E,1),Le(D,E,v,E,1),Le(v,E,v,m,1),this.projection.name==="globe"){const[Je,Qe]=i.cw(this);Je?(be=90,de=180,ne=-180):Qe&&(je=-90,de=180,ne=-180)}return new i.aK(new i.aU(ne,je),new i.aU(de,be))}_getBoundsRectangular(m,v){const{top:E,left:D}=this._edgeInsets,z=this.height-this._edgeInsets.bottom,B=this.width-this._edgeInsets.right,W=new i.P(D,E),te=new i.P(B,E),ne=new i.P(B,z),de=new i.P(D,z);let je=this.pointCoordinate(W,m),be=this.pointCoordinate(te,m);const Me=this.pointCoordinate(ne,v),$e=this.pointCoordinate(de,v),Le=(Je,Qe)=>(Qe.y-Je.y)/(Qe.x-Je.x);return je.y>1&&be.y>=0?je=new i.ag((1-$e.y)/Le($e,je)+$e.x,1):je.y<0&&be.y<=1&&(je=new i.ag(-$e.y/Le($e,je)+$e.x,0)),be.y>1&&je.y>=0?be=new i.ag((1-Me.y)/Le(Me,be)+Me.x,1):be.y<0&&je.y<=1&&(be=new i.ag(-Me.y/Le(Me,be)+Me.x,0)),new i.aK().extend(this.coordinateLocation(je)).extend(this.coordinateLocation(be)).extend(this.coordinateLocation($e)).extend(this.coordinateLocation(Me))}_getBoundsRectangularTerrain(){const m=this.elevation;if(!m.visibleDemTiles.length||m.isUsingMockSource())return this._getBoundsRectangular(0,0);const v=m.visibleDemTiles.reduce((E,D)=>{if(D.dem){const z=D.dem.tree;E.min=Math.min(E.min,z.minimums[0]),E.max=Math.max(E.max,z.maximums[0])}return E},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(v.min*m.exaggeration(),v.max*m.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(m=!0){const v=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,E=this.height/2-v*(1-this._horizonShift);return m?Math.max(0,E):E}getMaxBounds(){return this.maxBounds}setMaxBounds(m){this.maxBounds=m,this.minLat=-i.ct,this.maxLat=i.ct,this.minLng=-180,this.maxLng=180,m&&(this.minLat=m.getSouth(),this.maxLat=m.getNorth(),this.minLng=m.getWest(),this.maxLng=m.getEast(),this.maxLngje&&(W=je-ne),je-deMe&&(B=Me-te),Me-be{for(let Zt=0;Zt<16;Zt++)ns[Zt]=i.am(Jt[Zt],Ns[Zt],Is)})(W,W,te,i.cL(this.pitch>=B0?1:this.pitch/B0))}else W=te;const ne=i.cz([],te,B);let de=i.cz([],W,B);if(this.projection.isReprojectedInTileSpace){const vt=this.locationCoordinate(this.center),Tt=i.b9([]);i.bx(Tt,Tt,[vt.x*this.worldSize,vt.y*this.worldSize,0]),i.aD(Tt,Tt,i.cA(this)),i.bx(Tt,Tt,[-vt.x*this.worldSize,-vt.y*this.worldSize,0]),i.aD(de,de,Tt),i.aD(ne,ne,Tt),this.inverseAdjustmentMatrix=i.cB(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=i.cC([],de,[this.worldSize,this.worldSize,this.worldSize/z,1]),this.projMatrix=de,this.invProjMatrix=i.b7(new Float64Array(16),this.projMatrix),v){const vt=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);vt[8]=2*-m.x/this.width,vt[9]=2*m.y/this.height,this.expandedFarZProjMatrix=i.cz([],vt,B)}else this.expandedFarZProjMatrix=this.projMatrix;const je=i.b7([],W);this.frustumCorners=i.cD.fromInvProjectionMatrix(je,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!v);const be=new Float32Array(16);i.b9(be),i.cC(be,be,[1,-1,1]),i.cE(be,be,this._pitch),i.ba(be,be,this.angle);const Me=i.bS(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=i.b8(Me);const $e=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;Me[8]=2*-m.x/this.width,Me[9]=2*(m.y+$e)/this.height,this.skyboxMatrix=i.aD(be,Me,be);const Le=this.point,Je=Le.x,Qe=Le.y,lt=this.width%2/2,mt=this.height%2/2,nt=Math.cos(this.angle),zt=Math.sin(this.angle),bt=Je-Math.round(Je)+nt*lt+zt*mt,Dt=Qe-Math.round(Qe)+nt*mt+zt*lt,pt=new Float64Array(de);if(i.bx(pt,pt,[bt>.5?bt-1:bt,Dt>.5?Dt-1:Dt,0]),this.alignedProjMatrix=pt,de=i.bb(),i.cC(de,de,[this.width/2,-this.height/2,1]),i.bx(de,de,[1,-1,0]),this.labelPlaneMatrix=de,de=i.bb(),i.cC(de,de,[1,-1,1]),i.bx(de,de,[-1,-1,0]),i.cC(de,de,[2/this.width,2/this.height,1]),this.glCoordMatrix=de,this.pixelMatrix=i.aD(new Float64Array(16),this.labelPlaneMatrix,ne),this._calcFogMatrices(),this._distanceTileDataCache={},de=i.b7(new Float64Array(16),this.pixelMatrix),!de)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=de,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.cF(this);const vt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.ah(vt,vt,B),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=de;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const m=this.cameraWorldSizeForFog,v=this.cameraPixelsPerMeter,E=this._camera.position,D=1/this.height/this._pixelsPerMercatorPixel,z=[m,m,v];i.bJ(z,z,D),i.bJ(E,E,-1),i.cG(E,E,z);const B=i.bb();i.bx(B,B,E),i.cC(B,B,z),this.mercatorFogMatrix=B,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(m,v,D)}_computeCameraPosition(m){const v=(m=m||this.pixelsPerMeter)/this.pixelsPerMeter,E=this._camera.forward(),D=this.point,z=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*v-m/this.worldSize*this._centerAltitude;return[D.x/this.worldSize-E[0]*z,D.y/this.worldSize-E[1]*z,m/this.worldSize*this._centerAltitude-E[2]*z]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(m){const v=this._maxCameraBoundsDistance()*Math.cos(this._pitch),E=this._camera.position[2],D=m[2];let z=1;this.projection.wrap&&(this.center=this.center.wrap()),D>0&&(z=Math.min((v-E)/D,1)),this._camera.position=i.bg([],this._camera.position,m,z),this._updateStateFromCamera()}_updateStateFromCamera(){const m=this._camera.position,v=this._camera.forward(),{pitch:E,bearing:D}=this._camera.getPitchBearing(),z=i.bU(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,B=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.ap(this._maxPitch)),W=Math.max((m[2]-z)/Math.cos(E),B),te=this._zoomFromMercatorZ(W);i.bg(m,m,v,W),this._pitch=i.aC(E,i.ap(this.minPitch),i.ap(this.maxPitch)),this.angle=i.bs(D,-Math.PI,Math.PI),this._setZoom(i.aC(te,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new i.ag(m[0],m[1],m[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(m){return Math.pow(2,m)*this.tileSize}_mercatorZfromZoom(m){return this.cameraToCenterDistance/this._worldSizeFromZoom(m)}_minimumHeightOverTerrain(){const m=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(m)}_zoomFromMercatorZ(m){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,m)*this.tileSize))}zoomFromMercatorZAdjusted(m){let v=0,E=i.cv,D=0,z=1/0;for(;E-v>1e-6&&E>v;){const B=v+.5*(E-v),W=this.tileSize*Math.pow(2,B),te=this.getCameraToCenterDistance(this.projection,B,W),ne=this.scaleZoom(te/(Math.max(0,m)*this.tileSize)),de=Math.abs(B-ne);dene||be.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+i.cH(this.fovAboveCenter)>88||this.anyCornerOffEdge(new i.P(0,0),new i.P(this.width,this.height))}zoomDeltaToMovement(m,v){const E=i.ai(i.ax([],this._camera.position,m)),D=this._zoomFromMercatorZ(E)+v;return E-this._mercatorZfromZoom(D)}getCameraPoint(){if(this.projection.name==="globe"){const m=function([v,E,D],z){const B=[v,E,D,1];i.aE(B,B,z);const W=B[3]=Math.max(B[3],1e-6);return B[0]/=W,B[1]/=W,B[2]/=W,B}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new i.P(m[0],m[1])}{const m=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.P(0,m))}}getCameraToCenterDistance(m,v=this.zoom,E=this.worldSize){const D=i.cy(m,v,this.width,this.height,1024),z=m.pixelSpaceConversion(this.center.lat,E,D);let B=.5/Math.tan(.5*this._fov)*this.height*z;return this.isOrthographic&&(B=i.am(1,B,i.cL(this.pitch>=B0?1:this.pitch/B0))),B}getWorldToCameraMatrix(){const m=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&i.aD(m,m,this.globeMatrix),m}getFrustum(m){return i.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,m,this.projection.zAxisUnit==="meters")}}const ac=(M,m)=>{if(m>0&&M.terrain&&i.w("Cutoff is currently disabled on terrain"),m<=0||M.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const v=M.transform,E=v.pitch,D=v.isLODDisabled(!1)?60:30;if(E0,uniformValues:{u_cutoff_params:[v._nearZ,v._farZ,(de-v._nearZ)/z,(de-be-v._nearZ)/z]}}},ry=2048;class VC{constructor(m,v){this.aabb=m,this.lastCascade=v}}class LO{add(m,v){const E=this.receivers[m.key];E!==void 0?(E.aabb.min[0]=Math.min(E.aabb.min[0],v.min[0]),E.aabb.min[1]=Math.min(E.aabb.min[1],v.min[1]),E.aabb.min[2]=Math.min(E.aabb.min[2],v.min[2]),E.aabb.max[0]=Math.max(E.aabb.max[0],v.max[0]),E.aabb.max[1]=Math.max(E.aabb.max[1],v.max[1]),E.aabb.max[2]=Math.max(E.aabb.max[2],v.max[2])):this.receivers[m.key]=new VC(v,null)}clear(){this.receivers={}}get(m){return this.receivers[m.key]}computeRequiredCascades(m,v,E){const D=i.cU.fromPoints(m.points);let z=0;for(const B in this.receivers){const W=this.receivers[B];if(!W||!D.intersectsAabb(W.aabb))continue;W.aabb.min=D.closestPoint(W.aabb.min),W.aabb.max=D.closestPoint(W.aabb.max);const te=W.aabb.getCorners();for(let ne=0;ne1||be[1]<-1||be[1]>1){de=!1;break}}if(W.lastCascade=ne,z=Math.max(z,ne),de)break}}return z+1}}class Uw{constructor(m){this.painter=m,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new LO,this._depthMode=new kr(m.context.gl.LEQUAL,kr.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 m of this._cascades)m.texture.destroy(),m.framebuffer.destroy();this._cascades=[]}updateShadowParameters(m,v){const E=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!v||!v.properties)return;const D=v.properties.get("shadow-intensity"),z=v.properties.get("shadow-draw-before-layer");if(!v.shadowsEnabled()||D<=0)return;let B=-1,W=0;for(const Qe of E.style.order){const lt=E.style._mergedLayers[Qe];lt.hasShadowPass()&&!lt.isHidden(m.zoom)&&(B=W),!z||z!==Qe&&z!==lt.slot||(this._drawShadowAfterLayer=W>0?W-1:0),W+=1}if(this._enabled=B>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=B);const te=E.context,ne=ry,de=ry;if(this._cascades.length===0||ry!==this._cascades[0].texture.size[0]){this._cascades=[];for(let Qe=0;Qe<2;++Qe){const lt=te.gl,mt=te.createFramebuffer(ne,de,0,"texture"),nt=new i.T(te,{width:ne,height:de,data:null},lt.DEPTH_COMPONENT16);mt.depthAttachment.set(nt.texture),this._cascades.push({framebuffer:mt,texture:nt,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cl,scale:0})}}this.shadowDirection=DO(v);let je=0;if(m.elevation){const Qe=m.elevation,lt=[1e4,-1e4];Qe.visibleDemTiles.filter(mt=>mt.dem).forEach(mt=>{const nt=mt.dem.tree;lt[0]=Math.min(lt[0],nt.minimums[0]),lt[1]=Math.max(lt[1],nt.maximums[0])}),lt[0]!==1e4&&(je=(lt[1]-lt[0])*Qe.exaggeration())}const be=1.5*m.cameraToCenterDistance,Me=3*be,$e=new Float64Array(16);for(let Qe=0;Qe=0)return{};const z=function(te,ne,de){const je=de/(1<0&&(i.cT(z[1],z[1],[D[0]*B,0,0]),i.cT(z[2],z[2],[D[0]*B,0,0])),D[1]<0?(i.cT(z[0],z[0],[0,D[1]*B,0]),i.cT(z[1],z[1],[0,D[1]*B,0])):D[1]>0&&(i.cT(z[2],z[2],[0,D[1]*B,0]),i.cT(z[3],z[3],[0,D[1]*B,0]));const W={};return W.vertices=z,W.planes=[HC(z[1],z[0],z[4]),HC(z[2],z[1],z[5]),HC(z[3],z[2],z[6]),HC(z[0],z[3],z[7])],W}addShadowReceiver(m,v,E){this._receivers.add(m,i.cU.fromTileIdAndHeight(m,v,E))}getMaxCascadeForTile(m){const v=this._receivers.get(m);return v&&v.lastCascade?v.lastCascade:0}}function HC(M,m,v){const E=i.ax([],v,m),D=i.ax([],M,m),z=i.bh([],E,D),B=i.ai(z);return B===0?[0,0,1,0]:(i.bJ(z,z,1/B),[z[0],z[1],z[2],-i.bi(z,m)])}function DO(M){const m=M.properties.get("direction"),v=i.cP(m.x,m.y,m.z);v[2]=i.aC(v[2],0,75);const E=i.cR([v[0],v[1],v[2]]);return i.cQ(E.x,E.y,E.z)}function Ep(M,m,v){const E=m.properties.get("color-use-theme")==="none",D=m.properties.get("color"),z=m.properties.get("intensity"),B=m.properties.get("direction"),W=[B.x,B.y,B.z],te=v.properties.get("color-use-theme")==="none",ne=v.properties.get("color"),de=v.properties.get("intensity"),je=Math.max(i.bi([0,0,1],W),0),be=[0,0,0];i.bJ(be,ne.toPremultipliedRenderColor(te?null:M.getLut(m.scope)).toArray01Linear().slice(0,3),de);const Me=[0,0,0];return i.bJ(Me,D.toPremultipliedRenderColor(E?null:M.getLut(v.scope)).toArray01Linear().slice(0,3),je*z),i.cW([be[0]>0?be[0]/(be[0]+Me[0]):0,be[1]>0?be[1]/(be[1]+Me[1]):0,be[2]>0?be[2]/(be[2]+Me[2]):0])}function Vw(M,m,v,E,D,z){const B=M.zoom,W=M.scale,te=M.worldSize,ne=1/te,de=M.aspect,je=Math.sqrt(1+de*de)*Math.tan(.5*M.fovX),be=je*je,Me=E-v,$e=E+v;let Le,Je;be>Me/$e?(Le=E,Je=E*je):(Le=.5*$e*(1+be),Je=.5*Math.sqrt(Me*Me+2*(E*E+v*v)*be+$e*$e*be*be));const Qe=M.projection.pixelsPerMeter(M.center.lat,te),lt=M._camera.getCameraToWorldMercator(),mt=[0,0,-Le*ne];i.ah(mt,mt,lt);let nt=Je*ne;const zt=function(ds){return ds[0]/=W,ds[1]/=W,ds[2]=i.bU(ds[2],M._center.lat),ds},bt=M._edgeInsets;if(!(bt.left===0&&bt.top===0&&bt.right===0&&bt.bottom===0||bt.left===bt.right&&bt.top===bt.bottom)){const ds=M._camera.getWorldToCamera(M.worldSize,M.projection.zAxisUnit==="meters"?Qe:1),Qs=M._camera.getCameraToClipPerspective(M._fov,M.width/M.height,v,E);Qs[8]=2*-M.centerOffset.x/M.width,Qs[9]=2*M.centerOffset.y/M.height;const Gs=new Float64Array(16);i.cz(Gs,Qs,ds);const Ws=new Float64Array(16);i.b7(Ws,Gs);const Ts=i.cl.fromInvProjectionMatrix(Ws,te,B,!0);for(const wr of Ts.points){const Ir=zt(wr);nt=Math.max(nt,i.bK(i.cV([],mt,Ir)))}}nt*=D/(D-1);const Dt=Math.acos(m[2]),pt=Math.atan2(-m[0],-m[1]),vt=new $w;vt.position=mt,vt.setPitchBearing(Dt,pt);const Tt=vt.getWorldToCamera(te,Qe),Gt=nt*te,qt=Math.min(M._mercatorZfromZoom(17)*te*-2,-2*Gt),ns=vt.getCameraToClipOrthographic(-Gt,Gt,-Gt,Gt,qt,(Gt+z*Qe)/m[2]),Jt=new Float64Array(16);i.aD(Jt,ns,Tt);const Ns=i.cQ(Math.floor(1e6*mt[0])/1e6*te,Math.floor(1e6*mt[1])/1e6*te,0),Is=.5*D,Zt=[0,0,0];i.ah(Zt,Ns,Jt),i.bJ(Zt,Zt,Is);const Ut=[Math.floor(Zt[0]),Math.floor(Zt[1]),Math.floor(Zt[2])],ss=[0,0,0];i.ax(ss,Zt,Ut),i.bJ(ss,ss,-1/Is);const as=new Float64Array(16);return i.b9(as),i.bx(as,as,ss),i.aD(Jt,as,Jt),[Jt,Gt]}class ope extends i.E{constructor(m){super(),this.requestManager=m,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(m,v){return i.cX(this.requestManager.transformRequest(v,i.R.Model).url).then(E=>{const D=i.cY(E),z=new i.cZ(m,v,void 0,void 0,D);return z.computeBoundsAndApplyParent(),z}).catch(E=>{if(E&&E.status===404)return null;this.fire(new i.B(new Error(`Could not load model ${m} from ${v}: ${E.message}`)))})}load(m,v,E={forceReload:!1}){this.models[v]||(this.models[v]={});const D=Object.keys(m),z=[],B=[];for(const W of D){const te=m[W];this.hasURLBeenRequested(te)&&!E.forceReload||(this.modelByURL[te]={modelId:W,scope:v},z.push(this.loadModel(W,te)),B.push(W)),this.models[v][W]||(this.models[v][W]={model:null,numReferences:1})}this.numModelsLoading[v]=(this.numModelsLoading[v]||0)+B.length,Promise.allSettled(z).then(W=>{for(let te=0;te{this.fire(new i.B(new Error(`Could not load models: ${W.message}`)))})}isLoaded(){for(const m in this.numModelsLoading)if(this.numModelsLoading[m]>0)return!1;return!0}hasModel(m,v,E={exactIdMatch:!1}){return!!(E.exactIdMatch?this.getModel(m,v):this.getModelByURL(this.modelUris[v][m]))}getModel(m,v){return this.models[v]||(this.models[v]={}),this.models[v][m]?this.models[v][m].model:void 0}getModelByURL(m){if(!m)return null;const v=this.modelByURL[m];return v?this.models[v.scope][v.modelId].model:null}hasModelBeenAdded(m,v){return this.models[v]&&this.models[v][m]!==void 0}getModelURIs(m){return this.modelUris[m]||{}}addModel(m,v,E){this.models[E]||(this.models[E]={}),this.modelUris[E]||(this.modelUris[E]={});const D=this.requestManager.normalizeModelURL(v);if((this.hasModel(m,E,{exactIdMatch:!0})||this.hasModelBeenAdded(m,E))&&this.modelUris[E][m]===D)this.models[E][m].numReferences++;else if(this.hasURLBeenRequested(D)){const{scope:z,modelId:B}=this.modelByURL[D];this.models[z][B].numReferences++}else this.modelUris[E][m]=D,this.load({[m]:this.modelUris[E][m]},E)}addModelURLs(m,v){this.models[v]||(this.models[v]={}),this.modelUris[v]||(this.modelUris[v]={});const E=this.modelUris[v];for(const D in m)E[D]=this.requestManager.normalizeModelURL(m[D])}reloadModels(m){this.load(this.modelUris[m],m,{forceReload:!0})}addModelsFromBucket(m,v){this.models[v]||(this.models[v]={}),this.modelUris[v]||(this.modelUris[v]={});const E={};for(const D of m)this.hasModel(D,v,{exactIdMatch:!0})||this.hasURLBeenRequested(D)?this.models[v][D].numReferences++:this.modelUris[v][D]&&!this.hasURLBeenRequested(D)?E[D]=this.modelUris[v][D]:!this.hasURLBeenRequested(D)&&i.c_(D,!1)&&(this.modelUris[v][D]=this.requestManager.normalizeModelURL(D),E[D]=this.modelUris[v][D]);this.load(E,v)}hasURLBeenRequested(m){return this.modelByURL[m]!==void 0}removeModel(m,v,E=!1,D=!1){if(this.models[v]&&this.models[v][m]&&(this.models[v][m].numReferences--,this.models[v][m].numReferences===0||D)){const z=this.modelUris[v][m];E||delete this.modelUris[v][m],delete this.modelByURL[z];const B=this.models[v][m].model;if(!B)return;delete this.models[v][m],B.destroy()}}destroy(){for(const m of Object.keys(this.models))for(const v of Object.keys(this.models[m])){const E=this.models[m][v].model;delete this.models[m][v],E&&E.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(m){return this.models[m]||(this.models[m]={}),Object.keys(this.models[m])}upload(m,v){this.models[v]||(this.models[v]={});for(const E in this.models[v])this.models[v][E].model&&this.models[v][E].model.upload(m.context)}}const $E=i.a8.colorTheme,$1=new i.ab({data:new i.ac($E.data)});function RO(M){if(!M.metadata||!M.metadata.content_area)return;const m=i.o.devicePixelRatio,{left:v,top:E,width:D,height:z}=M.metadata.content_area,B=v*m,W=E*m;return[B,W,B+D*m,W+z*m]}function Hw(M){if(M)return M.map(([m,v])=>[m*i.o.devicePixelRatio,v*i.o.devicePixelRatio])}class qE{constructor(m,v,E){this.id=m,this.scope=v,this.sourceCache=E,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(m){this.missingRequests.has(m.name)||this.pendingRequests.has(m.name)||this.pendingRequests.add(m.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const m=new Map;if(!this.sourceCache.loaded())return m;const v=this.sourceCache.getVisibleCoordinates();if(v.length===0)return m;const E=this.sourceCache.getSource();if(!(E instanceof Ux))return m;const D=v.map(B=>this.sourceCache.getTile(B)),z=E.getImages(D,Array.from(this.pendingRequests));for(const[B,W]of z)m.set(i.I.from({name:B,iconsetId:this.id}),W),this.pendingRequests.delete(B);for(const B of this.pendingRequests)this.missingRequests.add(B);return this.pendingRequests.clear(),m}}class ny{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16}findClosestBuilding(m,v,E,D,z){if(Ete*this._hysteresisRatio&&(B=this._previousClosestBuildingId):ne&&!B&&(B=this._previousClosestBuildingId),this._previousClosestBuildingId=B,B}_calculateDistance(m,v){if(!v.center)return Number.MAX_VALUE;const E=m.lat-v.center[1],D=m.lng-v.center[0];return E*E+D*D}_isBuildingVisible(m,v,E){if(!E)return!1;for(const D of m.floorIds){const z=m.floors[D];if(!z.geometry)continue;const B=z.geometry;if(B.type==="Polygon"){const W=this._convertRingToPoints(B.coordinates[0]);if(i.bw(W,E))return!0}else if(B.type==="MultiPolygon"){const W=this._convertMultiPolygonToPoints(B.coordinates);if(i.d0(E,W))return!0}}return!1}_convertRingToPoints(m){return m.map(v=>new i.P(v[0],v[1]))}_convertMultiPolygonToPoints(m){return m.map(v=>v.length===0?[]:v[0].map(E=>new i.P(E[0],E[1])))}}class lpe extends i.E{constructor(m){super(),this._style=m,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new ny,this._initialLoadDone=!1,i.aZ(["_updateUI"],this),this._style.on("style.load",()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",()=>{this._initialLoadDone=!0,this._indoorState&&this._indoorState.needsUpdate&&(this._indoorState.needsUpdate=!1,this._style.updateIndoorDependentLayers()),this._updateUI()}),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI))})}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(m){m===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=m,this._recalculateActiveFloors())}setActiveFloorsVisibility(m){this._updateActiveFloors(m),this._updateIndoorSelector()}setIndoorData(m){let v=!1;for(const[E,D]of Object.entries(m.buildings))if(this._buildings[E])for(const z of D.floorIds)this._buildings[E].floorIds.add(z),this._buildings[E].floors[z]?this._mergeFloors(this._buildings[E].floors[z],D.floors[z]):(this._buildings[E].floors[z]=D.floors[z],v=!0);else this._buildings[E]=D,v=!0;v&&this._recalculateActiveFloors()}getIndoorTileOptions(m,v){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(m,v),indoorState:this._indoorState}:null}getControlState(){const m=this._buildings,v=this._closestBuildingId,E=v&&m?m[v]:void 0;if(!E)return{selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let D=null;for(const B of E.floorIds)if(this._activeFloors&&this._activeFloors.has(B)){D=B;break}const z=Array.from(E.floorIds).map(B=>({id:B,name:E.floors[B].name,zIndex:E.floors[B].zIndex})).sort((B,W)=>W.zIndex-B.zIndex).filter((B,W,te)=>W===0||B.zIndex!==te[W-1].zIndex);return{selectedFloorId:D,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:z}}_updateUI(){this._initialLoadDone=!0;const m=this._style.map.transform,v=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,m.center,m.zoom,m.getBounds(),this._makeViewportPolygon());if(v!==this._closestBuildingId){const E=this._closestBuildingId;this._closestBuildingId=v,this._onBuildingTransition(E,v),this._updateIndoorSelector()}}_onBuildingTransition(m,v){if(!this._indoorState)return;!v&&m?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):!!v&&!m&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0))}_updateIndoorSelector(){this.fire(new i.C("selector-update",this.getControlState()))}_updateActiveFloors(m){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:m,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0}_recalculateActiveFloors(){if(!this._buildings)return;const m=i.d1.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(v,E){if(v===E)return!0;if(!v||!E||v.size!==E.size)return!1;for(const D of v)if(!E.has(D))return!1;return!0})(m,this._activeFloors)||(this._activeFloors=m,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector())}_mergeFloors(m,v){v.geometry&&(m.geometry?(m.geometry.type==="Polygon"&&(m.geometry={type:"MultiPolygon",coordinates:[m.geometry.coordinates]}),v.geometry.type==="Polygon"?m.geometry.coordinates.push(v.geometry.coordinates):v.geometry.type==="MultiPolygon"&&m.geometry.coordinates.push(...v.geometry.coordinates)):m.geometry=v.geometry)}_makeViewportPolygon(){const m=this._style.map.transform,v=m.width,E=m.height;return[m.pointLocation(new i.P(0,0)),m.pointLocation(new i.P(v,0)),m.pointLocation(new i.P(v,E)),m.pointLocation(new i.P(0,E))].map(D=>new i.P(D.lng,D.lat))}}const $0=(M,m)=>lr(M,m&&m.filter(v=>v.identifier!=="source.canvas")),cpe=i.aJ(Pa,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),OO=i.aJ(Pa,["setCenter","setZoom","setBearing","setPitch"]),UE=new Set(["background","sky","slot","custom"]),GC={version:8,layers:[],sources:{}},VE={duration:300,delay:0};class qm extends i.E{constructor(m,v={}){if(super(),this.map=m,this.scope=v.scope||"",this.globalId=null,this.fragments=[],this.importDepth=v.importDepth||0,this.importsCache=v.importsCache||new Map,this.resolvedImports=v.resolvedImports||new Set,this.transition=Object.assign({},VE),this._buildingIndex=new Pf(this),this.crossTileSymbolIndex=new B1,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._mergedFillExtrusionSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=v.styleChanges||new et,this._hasDataDrivenEmissive=!1,this.indoorManager=new lpe(this),this.dispatcher=v.dispatcher?v.dispatcher:new at(gt(),this),this.map.painter&&this.map.painter.context){const D=this.map.painter.context.maxUniformBufferBindings,z=Math.floor(this.map.painter.context.maxUniformBlockSize/4);this.dispatcher.broadcast("setContextParams",{maxBindingPoints:D,maxUniformBlockSizeDwords:z,disableSymbolUBO:this.map.painter.context.disableSymbolUBO})}v.imageManager?this.imageManager=v.imageManager:(this.imageManager=new Mt(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=v.glyphManager?v.glyphManager:new i.d2(m._requestManager,v.localFontFamily?i.d3.all:v.localIdeographFontFamily?i.d3.ideographs:i.d3.none,v.localFontFamily||v.localIdeographFontFamily,v.useServerFontComposition),v.modelManager?this.modelManager=v.modelManager:(this.modelManager=new ope(m._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._fillExtrusionSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=v.configOptions?v.configOptions:new Map,this._configDependentLayers=v.configDependentLayers?v.configDependentLayers:new Set,this._indoorDependentLayers=v.indoorDependentLayers?v.indoorDependentLayers:new Set,this._config=v.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:v.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=v.initialConfig,this.dispatcher.broadcast("setReferrer",i.d4()),this.dispatcher.broadcast("setConfig",i.d5());const E=this;this._rtlTextPluginCallback=qm.registerForPluginStateChange(D=>{E.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(z,B)=>{if(i.d6(z),B&&B.every(W=>W))for(const W in E._sourceCaches){const te=E._sourceCaches[W],ne=te.getSource().type;ne!=="vector"&&ne!=="geojson"||te.reload()}})}),this.on("data",D=>{if(D.dataType!=="source"||D.sourceDataType!=="metadata")return;const z=this.getOwnSource(D.sourceId);if(z&&z.vectorLayerIds)for(const B in this._layers){const W=this._layers[B];W.source===z.id&&this._validateLayer(W)}})}load(m){return m?(typeof m=="string"?this.loadURL(m):this.loadJSON(m),this):this}_getGlobalId(m){if(!m)return null;if(typeof m=="string"){if(i.e(m))return m;const v=i.d7(m);if(!v.startsWith("http"))try{return new URL(v,location.href).toString()}catch{return v}return v}return`json://${i.d8(JSON.stringify(m))}`}_diffStyle(m,v,E){this.globalId=this._getGlobalId(m);const D=(z,B)=>{try{B(null,this.setState(z,E))}catch(W){B(W,!1)}};if(typeof m=="string"){const z=this.map._requestManager.normalizeStyleURL(m),B=this.map._requestManager.transformRequest(z,i.R.Style);i.m(B,(W,te)=>{W?this.fire(new i.B(W)):te&&D(te,v)})}else typeof m=="object"&&D(m,v)}loadURL(m,v={}){this.fire(new i.C("dataloading",{dataType:"style"}));const E=typeof v.validate=="boolean"?v.validate:!i.e(m);this.globalId=this._getGlobalId(m),m=this.map._requestManager.normalizeStyleURL(m,v.accessToken),this.resolvedImports.add(m);const D=this.importsCache.get(m);if(D)return this._load(D,E);const z=this.map._requestManager.transformRequest(m,i.R.Style);this._request=i.m(z,(B,W)=>{if(this._request=null,B)this.fire(new i.B(B));else if(W)return this.importsCache.set(m,W),this._load(W,E)})}loadJSON(m,v={}){this.fire(new i.C("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(m),this._request=i.o.frame(()=>{this._request=null,this._load(m,v.validate!==!1)})}loadEmpty(){this.fire(new i.C("dataloading",{dataType:"style"})),this._load(GC,!1)}_loadImports(m,v,E){if(this.importDepth>=4)return i.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const D=[];for(const z of m){const B=this._createFragmentStyle(z),W=new Promise(de=>{B.once("style.import.load",de),B.once("error",de)}).then(()=>{this.mergeAll(),this.fire(new i.C("data",{dataType:"style"}))});if(D.push(W),this.resolvedImports.has(z.url)){B.loadEmpty();continue}const te=z.data||this.importsCache.get(z.url);te?(z.data?(B.fire(new i.C("dataloading",{dataType:"style"})),B.globalId=B._getGlobalId(te),queueMicrotask(()=>B._load(te,v))):B.loadJSON(te,{validate:v}),this._isInternalStyle(te)&&(B.globalId=null)):z.url?B.loadURL(z.url,{validate:v}):B.loadEmpty();const ne={style:B,id:z.id,config:z.config};if(E){const de=this.fragments.findIndex(({id:je})=>je===E);this.fragments=this.fragments.slice(0,de).concat(ne).concat(this.fragments.slice(de))}else this.fragments.push(ne)}return Promise.allSettled(D)}getImportGlobalIds(m=this,v=new Set){for(const E of m.fragments)E.style.globalId&&v.add(E.style.globalId),this.getImportGlobalIds(E.style,v);return[...v.values()]}_createFragmentStyle(m){const v=this.scope?i.F(m.id,this.scope):m.id;let E;const D=this._initialConfig&&this._initialConfig[v];(m.config||D)&&(E=Object.assign({},m.config,D));const z=new qm(this.map,{scope:v,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:E,configOptions:this.options,colorThemeOverride:m["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return z.setEventedParent(this.map,{style:z}),z}_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(m){return this.isRootStyle()&&(m.fragment||!!m.schema&&m.fragment!==!1)}_load(m,v){if(this._isInternalStyle(m)){const z=Object.assign({},GC,{imports:[{id:"basemap",data:m,url:""}]},m.center?{center:m.center}:{},m.bearing?{bearing:m.bearing}:{},m.pitch?{pitch:m.pitch}:{},m.zoom?{zoom:m.zoom}:{},m.light?{light:m.light}:{});return this._importedAsBasemap=!0,void this._load(z,v)}if(this.updateConfig(this._config,m.schema),v&&$0(this,On(m)))return;this._loaded=!0;for(const z in m.sources)this.addSource(z,m.sources[z],{validate:!1,isInitialLoad:!0});this.stylesheet=i.d9(m);const E=()=>{if(m.iconsets)for(const te in m.iconsets)this.addIconset(te,m.iconsets[te]);m.sprite?this._loadIconset(m.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&m.glyphs&&this.glyphManager.setURL(m.glyphs);const z=Lw(this.stylesheet.layers);if(this._order=z.map(te=>te.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 te=this.stylesheet.lights[0];this.light=new zr(te.properties,te.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new zr(this.stylesheet.light)),this._layers={};for(const te of z){const ne=i.de(te,this.scope,this._styleColorTheme.lut,this.options);ne.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(ne.fqid),ne.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(ne.fqid),this._hasAppearances=this._hasAppearances||ne.getAppearances().length!==0,ne.setEventedParent(this,{layer:{id:ne.id}}),this._layers[ne.id]=ne;const de=this.getOwnLayerSourceCache(ne),je=!!this.directionalLight&&this.directionalLight.shadowsEnabled();de&&ne.canCastShadows()&&je&&(de.castsShadows=!0)}if(this.glyphManager.url){const te=new Set;for(const ne in this._layers){const de=this._layers[ne];if(de.type==="symbol"&&de.layout){const je=de.layout.get("text-font");je&&je.value&&je.value.kind==="constant"&&te.add(je.value.value.join(","))}}for(const ne of te)this.glyphManager.prefetchRange(ne,0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const B=this.stylesheet.terrain;B&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(B,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.C("data",{dataType:"style"}));const W=this.isRootStyle();m.imports?this._loadImports(m.imports,v).then(()=>{this._reloadImports(),this.fire(new i.C(W?"style.load":"style.import.load"))}).catch(te=>{this.fire(new i.B(new Error("Failed to load imports",te))),this.fire(new i.C(W?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.C(W?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const D=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(D){const z=this._evaluateColorThemeData(D);this._loadColorTheme(z).then(()=>{E()}).catch(B=>{i.w(`Couldn't load color theme from the stylesheet: ${B}`),E()})}else this._styleColorTheme.lut=null,E()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(m=>m.style.hasAppearances())}mergeAll(){let m,v,E,D,z,B,W,te,ne,de;const je={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(be=>{if(be.stylesheet){if(be.light!=null&&(m=be.light),be.stylesheet.lights)for(const Me of be.stylesheet.lights)Me.type==="ambient"&&be.ambientLight!=null&&(v=be.ambientLight),Me.type==="directional"&&be.directionalLight!=null&&(E=be.directionalLight);D=this._prioritizeTerrain(D,be.terrain,be.stylesheet.terrain),be.stylesheet.fog&&be.fog!=null&&(z=be.fog),be.stylesheet.snow&&be.snow!=null&&(B=be.snow),be.stylesheet.rain&&be.rain!=null&&(W=be.rain),be.stylesheet.camera!=null&&(de=be.stylesheet.camera),be.stylesheet.projection!=null&&(te=be.stylesheet.projection),be.stylesheet.transition!=null&&(ne=be.stylesheet.transition),je[be.scope]=be._styleColorTheme}}),this.light=m,this.ambientLight=v,this.directionalLight=E,this.fog=z,this.snow=B,this.rain=W,this._styleColorThemeForScope=je,D===null?delete this.terrain:this.terrain=D,this.camera=de||{"camera-projection":"perspective"},this.projection=te||{name:"mercator"},this.transition=Object.assign({},VE,ne),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(m){const v=E=>{for(const D of E.fragments)v(D.style);m(E)};v(this)}_prioritizeTerrain(m,v,E){const D=m&&m.drapeRenderMode===0;return E===null?v&&v.drapeRenderMode===0?v:D?m:null:v!=null&&(!m||D||v&&v.drapeRenderMode===1)?v:m}mergeTerrain(){let m;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(v=>{m=this._prioritizeTerrain(m,v.terrain,v.stylesheet.terrain)}),m===null?delete this.terrain:this.terrain=m}mergeProjection(){let m;this.forEachFragmentStyle(v=>{v.stylesheet.projection!=null&&(m=v.stylesheet.projection)}),this.projection=m||{name:"mercator"}}mergeSources(){const m={},v={},E={},D={};this.forEachFragmentStyle(z=>{for(const B in z._sourceCaches){const W=i.F(B,z.scope);m[W]=z._sourceCaches[B]}for(const B in z._otherSourceCaches){const W=i.F(B,z.scope);v[W]=z._otherSourceCaches[B]}for(const B in z._symbolSourceCaches){const W=i.F(B,z.scope);E[W]=z._symbolSourceCaches[B]}for(const B in z._fillExtrusionSourceCaches){const W=i.F(B,z.scope);D[W]=z._fillExtrusionSourceCaches[B]}}),this._mergedSourceCaches=m,this._mergedOtherSourceCaches=v,this._mergedSymbolSourceCaches=E,this._mergedFillExtrusionSourceCaches=D}mergeIndoor(){this.forEachFragmentStyle(m=>{if(m.stylesheet&&m.stylesheet.indoor)for(const v of Object.values(m.stylesheet.indoor)){const E=v,D=i.F(E.sourceId,m.scope);this._mergedIndoor[D]=new Set(E.sourceLayers||[])}})}mergeLayers(){const m={},v=[],E={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(B=>{for(const W of B._order){const te=B._layers[W];if(te.type==="slot"){const ne=i.da(W);if(m[ne])continue;m[ne]=[]}te.slot&&m[te.slot]?m[te.slot].push(te):v.push(te)}}),this._mergedOrder=[];let D=-1;const z=(B=[])=>{for(const W of B)if(W.type==="slot"){const te=i.da(W.id);m[te]&&z(m[te]),this._mergedSlots.push(te)}else{const te=i.F(W.id,W.scope);this._mergedOrder.push(te),E[te]=W,W.is3D(!!this.terrain)&&(this._has3DLayers=!0,D=this._mergedOrder.length-1),W.type==="circle"&&(this._hasCircleLayers=!0),W.type==="symbol"&&(this._hasSymbolLayers=!0),W.type==="clip"&&(this._clipLayerPresent=!0)}};if(z(v),this._has3DLayers){const B={};for(let W=0;WB[W]-B[te])}this._mergedLayers=E,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(m){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,m),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(m){return m.data?function(v,E,D){const z=Object.assign({},E);for(const W of Object.keys($E))z[W]===void 0&&(z[W]=$E[W].default);const B=new i.aa($1,v,new Map(D));return B.setTransitionOrValue(z,D),B.untransitioned().possiblyEvaluate(new i.ae(0,{worldview:void 0}))}(this.scope,m,this.options).get("data"):null}_loadColorTheme(m){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const v=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((E,D)=>{const z="data:image/png;base64,";if(!m||m.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void E();let B=m;B.startsWith(z)||(B=z+B);const W=i.I.from("mapbox-reserved-lut"),te=new Image;te.src=B,te.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},te.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==v)return void E();this._styleColorTheme.lutLoading=!1;const{width:ne,height:de,data:je}=i.o.getImageData(te);if(de>32)return void D(new Error("The height of the image must be less than or equal to 32 pixels."));if(ne!==de*de)return void D(new Error("The width of the image must be equal to the height squared."));this.getImage(W)&&this.removeImage(W),this.addImage(W,{data:new i.q({width:ne,height:de},je),pixelRatio:1,sdf:!1,usvg:!1,version:0});const be=this.imageManager.getImage(W,this.scope);be?(this._styleColorTheme.lut={image:be.data,data:m},E()):D(new Error("Missing LUT image."))}})}getLut(m){const v=this._styleColorThemeForScope[m];return v?v.lut:null}setProjection(m){m?this.stylesheet.projection=m: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(m){this._spriteRequest=function(v,E,D){let z,B,W;const te=i.o.devicePixelRatio>1?"@2x":"";let ne=i.m(E.transformRequest(E.normalizeSpriteURL(v,te,".json"),i.R.SpriteJSON),(be,Me)=>{ne=null,W||(W=be,z=Me,je())}),de=i.n(E.transformRequest(E.normalizeSpriteURL(v,te,".png"),i.R.SpriteImage),(be,Me)=>{de=null,W||(W=be,B=Me,je())});function je(){if(W)D(W);else if(z&&B){const be=i.o.getImageData(B),Me={};for(const $e in z){const{width:Le,height:Je,x:Qe,y:lt,sdf:mt,pixelRatio:nt,stretchX:zt,stretchY:bt,content:Dt}=z[$e],pt=new i.q({width:Le,height:Je});i.q.copy(be,pt,{x:Qe,y:lt},{x:0,y:0},{width:Le,height:Je},null),Me[$e]={data:pt,pixelRatio:nt!==void 0?nt:1,sdf:mt!==void 0&&mt,stretchX:zt,stretchY:bt,content:Dt,usvg:!1,version:0}}D(null,Me)}}return{cancel(){ne&&(ne.cancel(),ne=null),de&&(de.cancel(),de=null)}}}(m,this.map._requestManager,(v,E)=>{if(this._spriteRequest=null,v)this.fire(new i.B(v));else if(E){const D=new Map;for(const z in E)D.set(i.I.from(z),E[z]);this.addImages(D)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.C("data",{dataType:"style"}))})}addIconset(m,v){if(v.type==="sprite")return void this._loadSprite(v.url);const E=this.getOwnSourceCache(v.source);if(!E)return void this.fire(new i.B(new Error(`Source "${v.source}" as specified by iconset "${m}" does not exist and cannot be used as an iconset source`)));const D=E.getSource();if(D.type!=="raster-array")return void this.fire(new i.B(new Error(`Source "${v.source}" as specified by iconset "${m}" is not a "raster-array" source and cannot be used as an iconset source`)));D.partial=!1;const z=new qE(m,this.scope,E);this.imageManager.addImageProvider(z,this.scope)}removeIconset(m){this.imageManager.removeImageProvider(m,this.scope)}_loadIconset(m){if(!i.e(m)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(m);const v=this.map._spriteFormat==="auto";var E,D;this._spriteRequest=(D=(z,B)=>{if(this._spriteRequest=null,z)v?this._loadSprite(m):this.fire(new i.B(z));else if(B){const W=new Map;for(const te in B)W.set(i.I.from(te),B[te]);this.addImages(W)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.C("data",{dataType:"style"}))},i.b1((E=this.map._requestManager).transformRequest(E.normalizeIconsetURL(m),i.R.Iconset),(z,B)=>{if(z)return void D(z);const W={},te=i.c$(new i.a$(B));for(const ne of te.icons){const de={version:1,pixelRatio:i.o.devicePixelRatio,content:RO(ne),stretchX:ne.metadata?Hw(ne.metadata.stretch_x_areas):void 0,stretchY:ne.metadata?Hw(ne.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:ne};W[ne.name]=de}D(null,W)}))}_validateLayer(m){const v=this.getOwnSource(m.source);if(!v)return;const E=m.sourceLayer;E&&(v.type==="geojson"||v.vectorLayerIds&&v.vectorLayerIds.indexOf(E)===-1)&&this.fire(new i.B(new Error(`Source layer "${E}" does not exist on source "${v.id}" as specified by style layer "${m.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const m in this._sourceCaches)if(!this._sourceCaches[m].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(const{style:m}of this.fragments)if(!m.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((m,v)=>{const E=this.fragments[v];return E&&E.style&&(m.data=E.style.serialize()),m})}_serializeSources(){const m={};for(const v in this._sourceCaches){const E=this._sourceCaches[v].getSource();m[E.id]||(m[E.id]=E.serialize())}return m}_serializeLayers(m){const v=[];for(const E of m){const D=this._layers[E];D&&D.type!=="custom"&&v.push(D.serialize())}return v}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 m in this._sourceCaches)if(this._sourceCaches[m].hasTransition())return!0;for(const m in this._layers)if(this._layers[m].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const m in this._mergedLayers){const v=this._mergedLayers[m];if(v._transitionablePaint&&v._transitionablePaint._values){const E=v._transitionablePaint._values["line-emissive-strength"];if(E&&E.value&&E.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(m){return m?this.order:this._mergedOrder}isLayerDraped(m){return!!this.terrain&&m.isDraped(this.getLayerSourceCache(m))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(m){const v=this.getOwnLayer(m);if(v)return v;this.fire(new i.B(new Error(`The layer '${m}' does not exist in the map's style.`)))}_checkSource(m){const v=this.getOwnSource(m);if(v)return v;this.fire(new i.B(new Error(`The source '${m}' does not exist in the map's style.`)))}precompilePrograms(m,v){const E=this.map.painter;if(E)for(let D=m.minzoom||0;D<(m.maxzoom||25.5);D++){const z=m.getProgramIds();if(z)for(const B of z){const W=m.getDefaultProgramParams(B,v.zoom,this._styleColorTheme.lut);W&&(E.style=this,this.fog&&(E._fogVisible=!0,W.overrideFog=!0,E.getOrCreateProgram(B,W)),E._fogVisible=!1,W.overrideFog=!1,E.getOrCreateProgram(B,W),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(W.overrideRtt=!0,E.getOrCreateProgram(B,W)))}}}update(m){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(m),this.directionalLight&&this.directionalLight.recalculate(m);const v=this.calculateLightsBrightness();m.brightness=v||0,v!==this._brightness&&(this._brightness=v,this.dispatcher.broadcast("setBrightness",v)),m.worldview!==this._worldview&&(this._worldview=m.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const E=this._changes.isDirty();let D=!1;if(this._changes.isDirty()){const te=this._changes.getLayerUpdatesByScope();for(const ne in te){const{updatedIds:de,removedIds:je}=te[ne];(de||je)&&(this._updateWorkerLayers(ne,de,je),D=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(m),this.light&&this.light.updateTransitions(m),this.ambientLight&&this.ambientLight.updateTransitions(m),this.directionalLight&&this.directionalLight.updateTransitions(m),this.fog&&this.fog.updateTransitions(m),this.snow&&this.snow.updateTransitions(m),this.rain&&this.rain.updateTransitions(m),this._changes.reset()}const z={};for(const te in this._mergedSourceCaches){const ne=this._mergedSourceCaches[te];z[te]=ne.used,ne.used=!1,ne.tileCoverLift=0}const B={};for(const te of this._mergedOrder){const ne=this._mergedLayers[te];if((ne.visibility!=="none"||ne.hasTransition())&&ne.recalculate(m,this._availableImages),!ne.isHidden(m.zoom)){const de=this.getLayerSourceCache(ne);de&&(de.used=!0,de.tileCoverLift=Math.max(de.tileCoverLift,ne.tileCoverLift()))}if(ne.type==="fill-extrusion"){const de=i.F(ne.source,ne.scope);if(de in this._mergedFillExtrusionSourceCaches){const je=ne.layout&&ne.layout.get("source-max-zoom");if(je!=null){const be=B[de];B[de]=be==null?je:Math.min(be,je)}}}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(ne,m)}):this.precompilePrograms(ne,m))}this._shouldPrecompile&&(this._precompileDone=!0);for(const te in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[te].setMaxzoomOverride(B[te]!=null?B[te]:null);this.terrain&&D&&this.mergeLayers();const W=this.imageManager.getPendingImageProviders();for(const te of W)te.sourceCache.used=!0;for(const te in z){const ne=this._mergedSourceCaches[te];z[te]!==ne.used&&ne.getSource().fire(new i.C("data",{sourceDataType:"visibility",dataType:"source",sourceId:ne.getSource().id}))}this.light&&this.light.recalculate(m),this.terrain&&this.terrain.recalculate(m),this.fog&&this.fog.recalculate(m),this.snow&&this.snow.recalculate(m),this.rain&&this.rain.recalculate(m),this.z=m.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),E&&this.fire(new i.C("data",{dataType:"style"}))}updateImageProviders(){const m=this.imageManager.getPendingImageProviders();for(const v of m){const E=v.resolvePendingRequests(),D=this.getFragmentStyle(v.scope);D&&D.addImages(E)}}_updateTilesForChangedImages(){const m={};for(const v in this._mergedSourceCaches){const E=this._mergedSourceCaches[v].getSource().scope;m[E]=m[E]||this._changes.getUpdatedImages(E),m[E].length!==0&&this._mergedSourceCaches[v].reloadTilesForDependencies(["icons","patterns"],m[E])}for(const v in m)this._changes.resetUpdatedImages(v)}_updateWorkerLayers(m,v,E){const D=this.getFragmentStyle(m);D&&this.dispatcher.broadcast("updateLayers",{layers:v?D._serializeLayers(v):[],scope:m,removedIds:E||[],options:D.options})}setState(m,v){if(this._checkLoaded(),$0(this,On(m)))return!1;(m=i.d9(m)).layers=Lw(m.layers);const E=function(B,W){if(!B)return[{command:Pa.setStyle,args:[W]}];let te=[];try{if(!i.b6(B.version,W.version))return[{command:Pa.setStyle,args:[W]}];if(i.b6(B.center,W.center)||te.push({command:Pa.setCenter,args:[W.center]}),i.b6(B.zoom,W.zoom)||te.push({command:Pa.setZoom,args:[W.zoom]}),i.b6(B.bearing,W.bearing)||te.push({command:Pa.setBearing,args:[W.bearing]}),i.b6(B.pitch,W.pitch)||te.push({command:Pa.setPitch,args:[W.pitch]}),i.b6(B.sprite,W.sprite)||te.push({command:Pa.setSprite,args:[W.sprite]}),i.b6(B.glyphs,W.glyphs)||te.push({command:Pa.setGlyphs,args:[W.glyphs]}),i.b6(B.imports,W.imports)||function(Me=[],$e=[],Le){$e=$e||[];const Je=(Me=Me||[]).map(Cp),Qe=$e.map(Cp),lt=Me.reduce(D0,{}),mt=$e.reduce(D0,{}),nt=Je.slice();let zt,bt,Dt,pt;for(zt=0,bt=0;zt{Me.source&&ne[Me.source]?te.push({command:Pa.removeLayer,args:[Me.id]}):je.push(Me)});let be=B.terrain;be&&ne[be.source]&&(te.push({command:Pa.setTerrain,args:[void 0]}),be=void 0),te=te.concat(de),i.b6(be,W.terrain)||te.push({command:Pa.setTerrain,args:[W.terrain]}),function(Me,$e,Le){$e=$e||[];const Je=(Me=Me||[]).map(Cp),Qe=$e.map(Cp),lt=Me.reduce(D0,{}),mt=$e.reduce(D0,{}),nt=Je.slice(),zt=Object.create(null);let bt,Dt,pt,vt,Tt,Gt,qt;for(bt=0,Dt=0;bt!(B.command in OO));if(E.length===0)return!1;const D=E.filter(B=>!(B.command in cpe));if(D.length>0)throw new Error(`Unimplemented: ${D.map(B=>B.command).join(", ")}.`);const z=[];return E.forEach(B=>{z.push(this[B.command](...B.args))}),v&&Promise.all(z).then(v).catch(v),this.stylesheet=m,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(m){if(m.size===0)return this;for(const[v,E]of m.entries()){if(this.getImage(v))return this.fire(new i.B(new Error(`An image with the name "${v.name}" already exists.`)));this.imageManager.addImage(v,this.scope,E),this._changes.updateImage(v,this.scope)}return this._updateWorkerImages(),this.fire(new i.C("data",{dataType:"style"})),this}addImage(m,v){return this.getImage(m)?this.fire(new i.B(new Error(`An image with the name "${m.name}" already exists.`))):(this.imageManager.addImage(m,this.scope,v),this._changes.updateImage(m,this.scope),this._updateWorkerImages(),this.fire(new i.C("data",{dataType:"style"})),this)}updateImage(m,v,E=!1){this.imageManager.updateImage(m,this.scope,v),E&&(this._changes.updateImage(m,this.scope),this._updateWorkerImages(),this.fire(new i.C("data",{dataType:"style"})))}getImage(m){return this.imageManager.getImage(m,this.scope)}removeImage(m){return this.getImage(m)?(this.imageManager.removeImage(m,this.scope),this._changes.updateImage(m,this.scope),this._updateWorkerImages(),this.fire(new i.C("data",{dataType:"style"})),this):this.fire(new i.B(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(m){return this.modelManager.addModelURLs(m,this.getActualScope()),this._updateWorkerModels(),this.fire(new i.C("data",{dataType:"style"})),this}addModel(m,v,E={}){return this._checkLoaded(),this._validate(Es,`models.${m}`,v,null,E)||(this.modelManager.addModel(m,v,this.getActualScope()),this.fire(new i.C("data",{dataType:"style"}))),this}hasModel(m){return this.modelManager.hasModel(m,this.getActualScope())}removeModel(m){return this.hasModel(m)?(this.modelManager.removeModel(m,this.getActualScope(),!1,!0),this.fire(new i.C("data",{dataType:"style"})),this):this.fire(new i.B(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(m,v,E={}){if(this._checkLoaded(),this.getOwnSource(m)!==void 0)throw new Error(`There is already a source with ID "${m}".`);if(!v.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(v).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(v.type)>=0&&this._validate(ua,`sources.${m}`,v,null,E))return;this.map&&this.map._collectResourceTiming&&(v.collectResourceTiming=!0);const D=Np(m,v,this.dispatcher,this);D.scope=this.scope,D.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(D.id),source:D.serialize(),sourceId:D.id}));const z=B=>{const W=(B===i.b4.Symbol?"symbol:":B===i.b4.FillExtrusion?"fill-extrusion:":"other:")+D.id,te=i.F(W,this.scope),ne=this._sourceCaches[W]=new $l(te,D,B);B===i.b4.Symbol?this._symbolSourceCaches[D.id]=ne:B===i.b4.FillExtrusion?this._fillExtrusionSourceCaches[D.id]=ne:this._otherSourceCaches[D.id]=ne,ne.onAdd(this.map)};z(i.b4.Other),v.type!=="vector"&&v.type!=="geojson"||(z(i.b4.Symbol),v.type==="vector"&&z(i.b4.FillExtrusion)),D.onAdd&&D.onAdd(this.map),E.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(m){this._checkLoaded();const v=this.getOwnSource(m);if(!v)throw new Error("There is no source with this ID");for(const D in this._layers)if(this._layers[D].source===m)return this.fire(new i.B(new Error(`Source "${m}" cannot be removed while layer "${D}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===m)return this.fire(new i.B(new Error(`Source "${m}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const D=Object.entries(this.stylesheet.iconsets).find(([z,B])=>B.type==="source"&&B.source===m);if(D)return this.fire(new i.B(new Error(`Source "${m}" cannot be removed while iconset "${D[0]}" is using it.`)))}const E=this.getOwnSourceCaches(m);for(const D of E){const z=i.da(D.id);delete this._sourceCaches[z],this._changes.discardSourceCacheUpdate(D.id),D.fire(new i.C("data",{sourceDataType:"metadata",dataType:"source",sourceId:D.getSource().id})),D.setEventedParent(null),D.clearTiles()}return delete this._otherSourceCaches[m],delete this._symbolSourceCaches[m],delete this._fillExtrusionSourceCaches[m],this.mergeSources(),v.setEventedParent(null),v.onRemove&&v.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(m,v){this._checkLoaded(),this.getOwnSource(m).setData(v),this._changes.setDirty()}getOwnSource(m){const v=this.getOwnSourceCache(m);return v&&v.getSource()}getOwnSources(){const m=[];for(const v in this._otherSourceCaches){const E=this.getOwnSourceCache(v);E&&m.push(E.getSource())}return m}areTilesLoaded(){const m=this._mergedSourceCaches;for(const v in m){const E=m[v]._tiles;for(const D in E){const z=E[D];if(z.state!=="loaded"&&z.state!=="errored")return!1}}return!0}setLights(m){if(this._checkLoaded(),!m)return delete this.ambientLight,void delete this.directionalLight;const v=this._getTransitionParameters();for(const z of m){if(this._validate(Se,"lights",z))return;switch(z.type){case"ambient":if(this.ambientLight){const B=this.ambientLight;B.set(z),B.updateTransitions(v)}else this.ambientLight=new Jo(z,Cc(),this.scope,this.options);break;case"directional":if(this.directionalLight){const B=this.directionalLight;B.set(z),B.updateTransitions(v)}else this.directionalLight=new Jo(z,Hd(),this.scope,this.options)}}const E=Object.assign(v,{worldview:this.map.getWorldview()}),D=new i.ae(this.z||0,E);this.ambientLight&&this.ambientLight.recalculate(D),this.directionalLight&&this.directionalLight.recalculate(D),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const m=this.directionalLight,v=this.ambientLight;if(!m||!v)return;const E=be=>.2126*(be[0]<=.03928?be[0]/12.92:Math.pow((be[0]+.055)/1.055,2.4))+.7152*(be[1]<=.03928?be[1]/12.92:Math.pow((be[1]+.055)/1.055,2.4))+.0722*(be[2]<=.03928?be[2]/12.92:Math.pow((be[2]+.055)/1.055,2.4)),D=m.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),z=m.properties.get("intensity"),B=m.properties.get("direction"),W=1-i.cP(B.x,B.y,B.z)[2]/90,te=E(D)*z*W,ne=v.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),de=v.properties.get("intensity"),je=E(ne)*de;return Number(((te+je)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const m=[];return this.directionalLight&&m.push(this.directionalLight.get()),this.ambientLight&&m.push(this.ambientLight.get()),m}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(m){if(m==null||m===""&&this.isRootStyle())return this;if(i.db(m)){const v=i.dc(m),E=this.fragments.find(({id:z})=>z===v);if(!E)return;const D=i.da(m);return E.style.getFragmentStyle(D)}{const v=this.fragments.find(({id:E})=>E===m);return v?v.style:void 0}}setFeaturesetSelectors(m){if(!m)return;const v=(E,D="")=>`${E}::${D}`;this._featuresetSelectors={};for(const E in m){const D={},z=this._featuresetSelectors[E]=[];for(const B of m[E].selectors){if(B.featureNamespace){const te=this.getOwnLayer(B.layer);if(!te){i.w(`Layer is undefined for selector: ${B.layer}`);continue}const ne=v(te.source,te.sourceLayer);if(ne in D&&D[ne]!==B.featureNamespace){i.w(`"featureNamespace ${B.featureNamespace} of featureset ${E}'s selector is not associated to the same source, skip this selector`);continue}D[ne]=B.featureNamespace}let W;if(B.properties)for(const te in B.properties){const ne=i.X(B.properties[te]);ne.result==="success"&&(W=W||{},W[te]=ne.value)}z.push({layerId:B.layer,namespace:B.featureNamespace,properties:W,uniqueFeatureID:B._uniqueFeatureID})}}}getFeaturesetDescriptors(m){const v=this.getFragmentStyle(m);if(!v||!v.stylesheet.featuresets)return[];const E=[];for(const D in v.stylesheet.featuresets)E.push({featuresetId:D,importId:v.scope?v.scope:void 0});return E}getFeaturesetLayers(m,v){const E=this.getFragmentStyle(v),D=E.stylesheet.featuresets;if(!D||!D[m])return this.fire(new i.B(new Error(`The featureset '${m}' does not exist in the map's style and cannot be queried.`))),[];const z=[];for(const B of D[m].selectors){const W=E.getOwnLayer(B.layer);W&&z.push(W)}return z}getConfigProperty(m,v){const E=this.getFragmentStyle(m);if(!E)return null;const D=i.F(v,E.scope),z=E.options.get(D),B=z?z.value||z.default:null;return B?B.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(m,v){const E=i.F(m,v);return this._mergedIndoor[E]}setIndoorData(m,v){this.indoorManager.setIndoorData(v)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(m,v,E){const D=this.getFragmentStyle(m);if(!D)return;const z=D.stylesheet.schema;if(!z||!z[v])return;const B=i.X(E);if(B.result!=="success")return void $0(this,B.value);const W=B.value.expression,te=i.F(v,D.scope),ne=D.options.get(te);if(!ne)return;let de;const{minValue:je,maxValue:be,stepValue:Me,type:$e,values:Le}=z[v],Je=i.X(z[v].default);Je.result==="success"&&(de=Je.value.expression),de?(this.options.set(te,Object.assign({},ne,{value:W,default:de,minValue:je,maxValue:be,stepValue:Me,type:$e,values:Le})),this.updateConfigDependencies(v)):this.fire(new i.B(new Error(`No schema defined for the config option "${v}" in the "${m}" fragment.`)))}getConfig(m){const v=this.getFragmentStyle(m);if(!v)return null;const E=v.stylesheet.schema;if(!E)return null;const D={};for(const z in E){const B=i.F(z,v.scope),W=v.options.get(B),te=W?W.value||W.default:null;D[z]=te?te.serialize():null}return D}setConfig(m,v){const E=this.getFragmentStyle(m);E&&(E.updateConfig(v,E.stylesheet.schema),this.updateConfigDependencies())}getSchema(m){const v=this.getFragmentStyle(m);return v?v.stylesheet.schema:null}setSchema(m,v){const E=this.getFragmentStyle(m);E&&(E.stylesheet.schema=v,E.updateConfig(E._config,v),this.updateConfigDependencies())}updateConfig(m,v){if(this._config=m,m||v)if(v)for(const E in v){let D,z;const B=i.X(v[E].default);if(B.result==="success"&&(D=B.value.expression),m&&m[E]!==void 0){const be=i.X(m[E]);be.result==="success"&&(z=be.value.expression)}const{minValue:W,maxValue:te,stepValue:ne,type:de,values:je}=v[E];if(D){const be=i.F(E,this.scope);this.options.set(be,{default:D,value:z,minValue:W,maxValue:te,stepValue:ne,type:de,values:je})}else this.fire(new i.B(new Error(`No schema defined for config option "${E}".`)))}else this.fire(new i.B(new Error("Attempting to set config for a style without schema.")))}_updateLayers(m,v=()=>!0){for(const E of m){const D=this.getLayer(E);D&&v(D)&&(D.possiblyEvaluateVisibility(),this._updateLayer(D),this._changes.setDirty())}}updateConfigDependencies(m){this._updateLayers(this._configDependentLayers,v=>!m||v.expressionDependencies.configDependencies.has(m)),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(v=>{const E=v._styleColorTheme.colorThemeOverride?v._styleColorTheme.colorThemeOverride:v._styleColorTheme.colorTheme;if(E){const D=v._evaluateColorThemeData(E);(!v._styleColorTheme.lut&&D!==""||v._styleColorTheme.lut&&D!==v._styleColorTheme.lut.data)&&v.setColorTheme(E)}}),this._changes.setDirty()}addLayer(m,v,E={}){this._checkLoaded();const D=m.id;if(this._layers[D])return void this.fire(new i.B(new Error(`Layer with id "${D}" already exists on this map`)));let z;if(m.type==="custom"){if($0(this,i.dd(m)))return;z=i.de(m,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof m.source=="object"&&(this.addSource(D,m.source),m=i.d9(m),m=Object.assign(m,{source:D})),this._validate(Pt,`layers.${D}`,m,{arrayIndex:-1},E))return;z=i.de(m,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(z),z.setEventedParent(this,{layer:{id:D}})}const B=i.F(z.source,z.scope);z.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(B),z.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(B);let W=this._order.length;if(v){const je=this._order.indexOf(v);if(je===-1)return void this.fire(new i.B(new Error(`Layer with id "${v}" does not exist on this map.`)));z.slot&&z.slot!==this._layers[v].slot?i.w(`Layer with id "${v}" has a different slot. Layers can only be rearranged within the same slot.`):W=je}this._order.splice(W,0,D),this._handleLayerOrderChange(),this._layers[D]=z;const te=this.getOwnLayerSourceCache(z),ne=!!this.directionalLight&&this.directionalLight.shadowsEnabled();te&&z.canCastShadows()&&ne&&(te.castsShadows=!0);const de=this._changes.getRemovedLayer(z);if(de&&z.source&&te&&z.type!=="custom"){this._changes.discardLayerRemoval(z);const je=i.F(z.source,z.scope);de.type!==z.type?this._changes.updateSourceCache(je,"clear"):(this._changes.updateSourceCache(je,"reload"),te.pause())}this._updateLayer(z),z.onAdd&&z.onAdd(this.map),z.scope=this.scope,this.mergeLayers()}moveLayer(m,v){this._checkLoaded();const E=this._checkLayer(m);if(!E||m===v)return;const D=this._order.indexOf(m);this._order.splice(D,1);let z=this._order.length;if(v){const B=this._order.indexOf(v);if(B===-1)return void this.fire(new i.B(new Error(`Layer with id "${v}" does not exist on this map.`)));E.slot&&E.slot!==this._layers[v].slot?i.w(`Layer with id "${v}" has a different slot. Layers can only be rearranged within the same slot.`):z=B}this._order.splice(z,0,m),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers()}removeLayer(m){this._checkLoaded();const v=this._checkLayer(m);if(!v)return;v.setEventedParent(null);const E=this._order.indexOf(m);this._order.splice(E,1),delete this._layers[m],this._changes.setDirty(),this._handleLayerOrderChange(),this._configDependentLayers.delete(v.fqid),this._indoorDependentLayers.delete(v.fqid),this._changes.removeLayer(v);const D=this.getOwnLayerSourceCache(v);if(D&&D.castsShadows){let z=!1;for(const B in this._layers)if(this._layers[B].source===v.source&&this._layers[B].canCastShadows()){z=!0;break}D.castsShadows=z}v.onRemove&&v.onRemove(this.map),this.mergeLayers()}getOwnLayer(m){return this._layers[m]}hasLayer(m){return m in this._mergedLayers}hasLayerType(m){for(const v in this._layers)if(this._layers[v].type===m)return!0;return!1}setLayerZoomRange(m,v,E){this._checkLoaded();const D=this._checkLayer(m);D&&(D.minzoom===v&&D.maxzoom===E||(v!=null&&(D.minzoom=v),E!=null&&(D.maxzoom=E),this._updateLayer(D)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(m,v){this._checkLoaded();const E=this._checkLayer(m);E&&E.slot!==v&&(E.slot=v,this._updateLayer(E))}setFilter(m,v,E={}){this._checkLoaded();const D=this._checkLayer(m);if(D&&!i.b6(D.filter,v))return v==null?(D.filter=void 0,void this._updateLayer(D)):void(this._validate(Yt,`layers.${D.id}.filter`,v,{layerType:D.type},E)||(D.filter=i.d9(v),this._updateLayer(D)))}getFilter(m){const v=this._checkLayer(m);if(v)return i.d9(v.filter)}setLayoutProperty(m,v,E,D={}){this._checkLoaded();const z=this._checkLayer(m);if(z&&!i.b6(z.getLayoutProperty(v),E)){if(E!=null&&(!D||D.validate!==!1)&&$0(z,Qt.call(On,{key:`layers.${m}.layout.${v}`,layerType:z.type,objectKey:v,value:E,styleSpec:i.a8,style:{glyphs:!0,sprite:!0}})))return;z.setLayoutProperty(v,E),z.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(z.fqid),z.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(z.fqid),this._updateLayer(z)}}setLayerProperty(m,v,E,D={}){this._checkLoaded();const z=this._checkLayer(m);z&&(v==="appearances"?(z.setAppearances(E),this._updateLayer(z)):z.isPaintProperty(v)?this.setPaintProperty(m,v,E,D):this.setLayoutProperty(m,v,E,D))}getLayoutProperty(m,v){const E=this._checkLayer(m);if(E)return E.getLayoutProperty(v)}setPaintProperty(m,v,E,D={}){this._checkLoaded();const z=this._checkLayer(m);if(!z||i.b6(z.getPaintProperty(v),E)||E!=null&&(!D||D.validate!==!1)&&$0(z,Vt.call(On,{key:`layers.${m}.paint.${v}`,layerType:z.type,objectKey:v,value:E,styleSpec:i.a8})))return;const B=z.setPaintProperty(v,E);z.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(z.fqid),z.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(z.fqid),B&&this._updateLayer(z),this._changes.updatePaintProperties(z)}getPaintProperty(m,v){const E=this._checkLayer(m);if(E)return E.getPaintProperty(v)}setFeatureState(m,v){if(this._checkLoaded(),"target"in m){if("featuresetId"in m.target){const{featuresetId:te,importId:ne}=m.target,de=this.getFragmentStyle(ne),je=de.getFeaturesetLayers(te);for(const{source:be,sourceLayer:Me}of je)de.setFeatureState({id:m.id,source:be,sourceLayer:Me},v)}else if("layerId"in m.target){const{layerId:te}=m.target,ne=this.getLayer(te);this.setFeatureState({id:m.id,source:ne.source,sourceLayer:ne.sourceLayer},v)}return}const E=m.source,D=m.sourceLayer,z=this._checkSource(E);if(!z)return;const B=z.type;if(B==="geojson"&&D)return void this.fire(new i.B(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(B==="vector"&&!D)return void this.fire(new i.B(new Error("The sourceLayer parameter must be provided for vector source types.")));m.id===void 0&&this.fire(new i.B(new Error("The feature id parameter must be provided.")));const W=this.getOwnSourceCaches(E);for(const te of W)te.setFeatureState(D,m.id,v)}removeFeatureState(m,v){if(this._checkLoaded(),"target"in m){if("featuresetId"in m.target){const{featuresetId:te,importId:ne}=m.target,de=this.getFragmentStyle(ne),je=de.getFeaturesetLayers(te);for(const{source:be,sourceLayer:Me}of je)de.removeFeatureState({id:m.id,source:be,sourceLayer:Me},v)}else if("layerId"in m.target){const{layerId:te}=m.target,ne=this.getLayer(te);this.removeFeatureState({id:m.id,source:ne.source,sourceLayer:ne.sourceLayer},v)}return}const E=m.source,D=this._checkSource(E);if(!D)return;const z=D.type,B=z==="vector"?m.sourceLayer:void 0;if(z==="vector"&&!B)return void this.fire(new i.B(new Error("The sourceLayer parameter must be provided for vector source types.")));if(v&&typeof m.id!="string"&&typeof m.id!="number")return void this.fire(new i.B(new Error("A feature id is required to remove its specific state property.")));const W=this.getOwnSourceCaches(E);for(const te of W)te.removeFeatureState(B,m.id,v)}getFeatureState(m){if(this._checkLoaded(),"target"in m){let z;if("featuresetId"in m.target){const{featuresetId:B,importId:W}=m.target,te=this.getFragmentStyle(W),ne=te.getFeaturesetLayers(B);for(const{source:de,sourceLayer:je}of ne){const be=te.getFeatureState({id:m.id,source:de,sourceLayer:je});if(be&&!z)z=be;else if(!i.b6(z,be))return void this.fire(new i.B(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 m.target){const{layerId:B}=m.target,W=this.getLayer(B);z=this.getFeatureState({id:m.id,source:W.source,sourceLayer:W.sourceLayer})}return z}const v=m.source,E=m.sourceLayer,D=this._checkSource(v);if(D){if(D.type!=="vector"||E)return m.id===void 0&&this.fire(new i.B(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(v)[0].getFeatureState(E,m.id);this.fire(new i.B(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(m){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,m),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}setWorldview(m){m!==this._worldview&&(this._worldview=m,this.dispatcher.broadcast("setWorldview",this._worldview),this.reloadSources())}serialize(){this._checkLoaded();const m=this.getTerrain(),v=m&&this.terrain&&this.terrain.scope===this.scope?m:this.stylesheet.terrain;return i.df({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:v,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,indoor:this.stylesheet.indoor,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)},E=>E!==void 0)}_updateFilteredLayers(m){for(const v of Object.values(this._mergedLayers))m(v)&&this._updateLayer(v)}_updateLayer(m){this._changes.updateLayer(m);const v=this.getLayerSourceCache(m),E=i.F(m.source,m.scope),D=this._changes.getUpdatedSourceCaches();m.source&&!D[E]&&v&&v.getSource().type!=="raster"&&(this._changes.updateSourceCache(E,"reload"),v.pause()),m.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(m){const v=W=>this._mergedLayers[W].is3D(!!this.terrain),E=this.order,D={},z=[];for(let W=E.length-1;W>=0;W--){const te=E[W];if(v(te)){D[te]=W;for(const ne of m){const de=ne[te];if(de)for(const je of de)z.push(je)}}}z.sort((W,te)=>te.intersectionZ-W.intersectionZ);const B=[];for(let W=E.length-1;W>=0;W--){const te=E[W];if(v(te))for(let ne=z.length-1;ne>=0;ne--){const de=z[ne].feature;if(de.layer&&D[de.layer.id]{if(UE.has(de.type))return;const je=this.getOwnLayerSourceCache(de),be=z[je.id]=z[je.id]||{sourceCache:je,layers:{},has3DLayers:!1};de.is3D(!!this.terrain)&&(be.has3DLayers=!0),be.layers[de.fqid]=be.layers[de.fqid]||{styleLayer:de,targets:[]},be.layers[de.fqid].targets.push({filter:D})};if(v&&v.layers){if(!Array.isArray(v.layers))return this.fire(new i.B(new Error("parameters.layers must be an Array."))),[];for(const de of v.layers){const je=this._layers[de];if(!je)return this.fire(new i.B(new Error(`The layer '${de}' does not exist in the map's style and cannot be queried for features.`))),[];B(je)}}else for(const de in this._layers)B(this._layers[de]);const W=this._queryRenderedFeatures(m,z,E),te=this._flattenAndSortRenderedFeatures(W),ne=[];for(const de of te)i.dh(de.layer.id)===this.scope&&ne.push(de);return ne}queryRenderedFeatureset(m,v,E){let D;v&&!Array.isArray(v)&&v.filter&&(this._validate(Yt,"queryRenderedFeatures.filter",v.filter,null,v),D=i.dg(v.filter));const z="mock",B=[];if(v&&v.target)B.push(Object.assign({},v,{targetId:z,filter:D}));else{const de=this.getFeaturesetDescriptors();for(const je of de)B.push({targetId:z,filter:D,target:je});for(const{style:je}of this.fragments){const be=je.getFeaturesetDescriptors();for(const Me of be)B.push({targetId:z,filter:D,target:Me})}}const W=this.queryRenderedTargets(m,B,E),te=[],ne=new Set;for(const de of W)for(const je of de.variants[z])Wd(je,de,ne)||te.push(new i.di(de,je));return te}queryRenderedTargets(m,v,E){const D={},z=(W,te,ne,de)=>{const je=D[te.id]=D[te.id]||{sourceCache:te,layers:{},has3DLayers:!1};if(je.layers[W.fqid]=je.layers[W.fqid]||{styleLayer:W,targets:[]},W.is3D(!!this.terrain)&&(je.has3DLayers=!0),!de)return ne.uniqueFeatureID=!1,void je.layers[W.fqid].targets.push(ne);je.layers[W.fqid].targets.push(Object.assign({},ne,{namespace:de.namespace,properties:de.properties,uniqueFeatureID:de.uniqueFeatureID}))};for(const W of v)if("featuresetId"in W.target){const{featuresetId:te,importId:ne}=W.target,de=this.getFragmentStyle(ne);if(!de||!de._featuresetSelectors)continue;const je=de._featuresetSelectors[te];if(!je){this.fire(new i.B(new Error(`The featureset '${te}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const be of je){const Me=de.getOwnLayer(be.layerId);Me&&!UE.has(Me.type)&&z(Me,de.getOwnLayerSourceCache(Me),W,be)}}else if("layerId"in W.target){const{layerId:te}=W.target,ne=this.getLayer(te);if(!ne||UE.has(ne.type))continue;z(ne,this.getLayerSourceCache(ne),W)}const B=this._queryRenderedFeatures(m,D,E);return this._flattenAndSortRenderedFeatures(B)}_queryRenderedFeatures(m,v,E){const D=[],z=!!this.map._showQueryGeometry,B=vu.createFromScreenPoints(m,E);for(const W in v){const te=FC(B,v[W],this._availableImages,E,z,this.getActualScope());Object.keys(te).length&&D.push(te)}if(this.placement)for(const W in v){if(v[W].sourceCache._renderSourceType!==i.b4.Symbol)continue;const te=P0(B.screenGeometry,v[W],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(te).length&&D.push(te)}return D}querySourceFeatures(m,v){const E=v&&v.filter;E&&this._validate(Yt,"querySourceFeatures.filter",E,null,v);let D=[];const z=this.getOwnSourceCaches(m);for(const B of z)D=D.concat(kp(B,v));return D}addSourceType(m,v,E){return qm.getSourceType(m)?E(new Error(`A source type called "${m}" already exists.`)):(qm.setSourceType(m,v),v.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:m,url:v.workerSourceURL},E):E(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(m,v,E={}){this._checkLoaded();const D=this.light.getLight();let z=!1;for(const W in m)if(!i.b6(m[W],D[W])){z=!0;break}if(!z)return;const B=this._getTransitionParameters();this.light.setLight(m,v,E),this.light.updateTransitions(B)}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(m,v=1){if(this._checkLoaded(),!m)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),v===0&&delete this.terrain,m===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let E=m;const D=!("source"in m)||m.source==null;if(v===1){if(this.disableElevatedTerrain)return;if("source"in E&&typeof E.source=="object"){const W="terrain-dem-src";this.addSource(W,E.source),E=i.d9(E),E=Object.assign(E,{source:W})}const z=Object.assign({},E),B={};if(this.terrain&&D){z.source=this.terrain.get().source;const W=this.terrain?this.getFragmentStyle(this.terrain.scope):null;W&&(B.style=W.serialize())}if(this._validate(De,"terrain",z,B))return}if(!this.terrain||this.terrain.scope!==this.scope&&!D||this.terrain&&v!==this.terrain.drapeRenderMode){if(!E)return;this._createTerrain(E,v),this.fire(new i.C("data",{dataType:"style"}))}else{const z=this.terrain,B=z.get();for(const W of Object.keys(i.a8.terrain))!E.hasOwnProperty(W)&&i.a8.terrain[W].default&&(E[W]=i.a8.terrain[W].default);for(const W in m)if(!i.b6(m[W],B[W])){z.set(m,this.options),this.stylesheet.terrain=m;const te=this._getTransitionParameters({duration:0});z.updateTransitions(te),this.fire(new i.C("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(m){const v=this.fog=new zi(m,this.map.transform,this.scope,this.options);this.stylesheet.fog=v.get();const E=this._getTransitionParameters({duration:0});v.updateTransitions(E)}_createSnow(m){const v=this.snow=new Bi(m,this.map.transform,this.scope,this.options);this.stylesheet.snow=v.get();const E=this._getTransitionParameters({duration:0});v.updateTransitions(E)}_createRain(m){const v=this.rain=new oa(m,this.map.transform,this.scope,this.options);this.stylesheet.rain=v.get();const E=this._getTransitionParameters({duration:0});v.updateTransitions(E)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const m of this.map._markers)m._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(m){if(this._checkLoaded(),!m)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const v=this.fog;if(!i.b6(v.get(),m)){v.set(m,this.options),this.stylesheet.fog=v.get();const E=this._getTransitionParameters({duration:0});v.updateTransitions(E)}}else this._createFog(m);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(m){if(this._checkLoaded(),!m)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const v=this.snow;if(!i.b6(v.get(),m)){v.set(m,this.options),this.stylesheet.snow=v.get();const E=this._getTransitionParameters({duration:0});v.updateTransitions(E)}}else this._createSnow(m);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(m){if(this._checkLoaded(),!m)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const v=this.rain;if(!i.b6(v.get(),m)){v.set(m,this.options),this.stylesheet.rain=v.get();const E=this._getTransitionParameters({duration:0});v.updateTransitions(E)}}else this._createRain(m);this._markersNeedUpdate=!0}_reloadColorTheme(){const m=()=>{for(const D in this._layers)this._layers[D].lut=this._styleColorTheme.lut;for(const D in this._sourceCaches)this._sourceCaches[D].clearTiles()},v=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!v)return this._styleColorTheme.lut=null,void m();const E=this._evaluateColorThemeData(v);this._loadColorTheme(E).then(()=>{this.fire(new i.C("colorthemeset")),m()}).catch(D=>{i.w(`Couldn't set color theme: ${D}`)})}setColorTheme(m){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=m,this._reloadColorTheme()}setImportColorTheme(m,v){const E=this.getFragmentStyle(m);E&&(E._styleColorTheme.colorThemeOverride=v,E._reloadColorTheme())}_getTransitionParameters(m){return{now:i.o.now(),transition:Object.assign(this.transition,m)}}updateDrapeFirstLayers(){if(!this.terrain)return;const m=[],v=[];for(const E of this._mergedOrder)this.isLayerDraped(this._mergedLayers[E])?m.push(E):v.push(E);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...m),this._drapedFirstOrder.push(...v)}_createTerrain(m,v){const E=this.terrain=new Vn(m,v,this.scope,this.options,this.map.getWorldview());v===1&&(this.stylesheet.terrain=m),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const D=this._getTransitionParameters({duration:0});E.updateTransitions(D)}_force3DLayerUpdate(){for(const m in this._layers){const v=this._layers[m];v.type==="fill-extrusion"&&this._updateLayer(v)}}_forceSymbolLayerUpdate(){for(const m in this._layers){const v=this._layers[m];v.type==="symbol"&&this._updateLayer(v)}}_validate(m,v,E,D,z={}){if(z&&z.validate===!1)return!1;const B=Object.assign({},this.serialize());return $0(this,m.call(On,Object.assign({key:v,style:B,value:E,styleSpec:i.a8},D)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.dj.off("pluginStateChange",this._rtlTextPluginCallback);for(const m in this._mergedLayers)this._mergedLayers[m].setEventedParent(null);for(const m in this._mergedSourceCaches)this._mergedSourceCaches[m].clearTiles(),this._mergedSourceCaches[m].setEventedParent(null);this.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(m){const v=this.getSourceCaches(m);for(const E of v)E.clearTiles()}clearSources(){for(const m in this._mergedSourceCaches)this._mergedSourceCaches[m].clearTiles()}clearLayers(){for(const m in this._mergedLayers){const v=this._mergedLayers[m];v._clear&&v._clear()}}reloadSource(m){const v=this.getSourceCaches(m);for(const E of v)E.resume(),E.reload()}reloadSources(){for(const m of this.getSources())m.reload&&m.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(m=>{m.modelManager.reloadModels(m.scope)})}updateSources(m){let v;this.directionalLight&&(v=DO(this.directionalLight));const E=new Set,D=new Set,z=new Set;for(const B in this._mergedLayers){const W=this._mergedLayers[B];W.type==="building"?E.add(W.source):W.type==="raster"&&W.paint&&W.paint.get("raster-elevation-reference")==="ground"&&z.add(W.source),W.hasElevation()&&!D.has(W.source)&&D.add(W.source)}for(const B in this._mergedSourceCaches){const W=this._mergedSourceCaches[B],te=D.has(W._source.id);W._isRasterElevatedOverTerrain=z.has(W._source.id),E.has(W._source.id)&&(W._source.reparseOverscaled=!1),W.update(m,void 0,void 0,v,te)}}_generateCollisionBoxes(){for(const m in this._sourceCaches){const v=this._sourceCaches[m];v.resume(),v.reload()}}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new i.C("neworder"))}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new Fw),this.pauseablePlacement.requestFullPlacement()}_setLabelPlacementStale(){this.placement&&this.placement.setStale()}_updatePlacement(m,v,E,D,z){this.pauseablePlacement||(this.pauseablePlacement=new Fw);let B=!1,W=!1;const te={},ne={};for(const Le of this._mergedOrder){const Je=this._mergedLayers[Le];if(Je.type!=="symbol")continue;const Qe=i.F(Je.source,Je.scope);let lt=te[Qe];if(!lt){const nt=this.getLayerSourceCache(Je);if(!nt)continue;const zt=nt.getRenderableIds(!0).map(bt=>nt.getTileByID(bt));ne[Qe]=zt.slice(),lt=te[Qe]=zt.sort((bt,Dt)=>Dt.tileID.overscaledZ-bt.tileID.overscaledZ||(bt.tileID.isLessThan(Dt.tileID)?-1:1))}const mt=this.crossTileSymbolIndex.addLayer(Je,lt,m.center.lng,m.projection);B=B||mt}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const de=!!(this.placement&&!m.equals(this.placement.transform)),je=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),be=de||je||B,Me=(be||this.pauseablePlacement.isStale())&&E===0,$e=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),m.zoom)&&E!==0;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||Me||$e)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(m,this._mergedOrder,v,E,D,this.placement,this.fog&&m.projection.supportsFog?this.fog.state:null,this._buildingIndex),this.map.painter)){const Le=this.map.painter.maxFrontCutoffRawStart;if(Le>0){const Je=180*m.pitch/Math.PI;if(Je>=15){const Qe=Math.min(1,Math.max(0,(Je-15)/5)),lt=Qe*Qe*(3-2*Qe);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-lt)+Le*lt}}}if(this.pauseablePlacement.isDone()?be&&E!==0&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,te,ne,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),W=!0),B&&this.pauseablePlacement.setStale()),W||B){this._buildingIndex.onNewFrame(m.zoom);for(let Le=0;Lez===m.id)!==-1)return void this.fire(new i.B(new Error(`Import with id '${m.id}' already exists in the map's style.`)));if(!v)return E.push(m),this._loadImports([m],!0);const D=E.findIndex(({id:z})=>z===v);return D===-1&&this.fire(new i.B(new Error(`Import with id "${v}" does not exist on this map.`))),this.stylesheet.imports=E.slice(0,D).concat(m).concat(E.slice(D)),this._loadImports([m],!0,v)}updateImport(m,v){this._checkLoaded();const E=this.stylesheet.imports||[],D=this.getImportIndex(m);return D===-1?this:typeof v=="string"?(this.setImportUrl(m,v),this):(v.url&&v.url!==E[D].url&&this.setImportUrl(m,v.url),i.b6(v.config,E[D].config)||this.setImportConfig(m,v.config,v.data.schema),i.b6(v.data,E[D].data)||this.setImportData(m,v.data),this)}moveImport(m,v){this._checkLoaded();let E=this.stylesheet.imports||[];const D=this.getImportIndex(m);if(D===-1)return this;const z=this.getImportIndex(v);if(z===-1)return this;const B=E[D],W=this.fragments[D];return E=E.filter(({id:te})=>te!==m),this.fragments=this.fragments.filter(({id:te})=>te!==m),this.stylesheet.imports=E.slice(0,z).concat(B).concat(E.slice(z)),this.fragments=this.fragments.slice(0,z).concat(W).concat(this.fragments.slice(z)),this.mergeLayers(),this}setImportUrl(m,v){this._checkLoaded();const E=this.stylesheet.imports||[],D=this.getImportIndex(m);if(D===-1)return this;E[D].url=v;const z=this.fragments[D];return z.style=this._createFragmentStyle(E[D]),z.style.on("style.import.load",()=>this.mergeAll()),z.style.loadURL(v),this}setImportData(m,v){this._checkLoaded();const E=this.getImportIndex(m),D=this.stylesheet.imports||[];return E===-1?this:v?(this.fragments[E].style.setState(v),this._reloadImports(),this):(delete D[E].data,this.setImportUrl(m,D[E].url))}setImportConfig(m,v,E){this._checkLoaded();const D=this.getImportIndex(m),z=this.stylesheet.imports||[];if(D===-1)return this;v?z[D].config=v:delete z[D].config;const B=this.fragments[D];E&&B.style.stylesheet&&(B.style.stylesheet.schema=E);const W=B.style.stylesheet&&B.style.stylesheet.schema;return B.config=v,B.style.updateConfig(v,W),this.updateConfigDependencies(),this}removeImport(m){this._checkLoaded();const v=this.stylesheet.imports||[],E=this.getImportIndex(m);E!==-1&&(v.splice(E,1),this.fragments[E].style._remove(),this.fragments.splice(E,1),this._reloadImports())}getImportIndex(m){const v=(this.stylesheet.imports||[]).findIndex(E=>E.id===m);return v===-1&&this.fire(new i.B(new Error(`Import '${m}' does not exist in the map's style and cannot be updated.`))),v}getLayer(m){return this._mergedLayers[m]}getSources(){const m=[];for(const v in this._mergedOtherSourceCaches){const E=this._mergedOtherSourceCaches[v];E&&m.push(E.getSource())}return m}getSource(m,v){const E=this.getSourceCache(m,v);return E&&E.getSource()}getLayerSource(m){const v=this.getLayerSourceCache(m);return v&&v.getSource()}getSourceCache(m,v){const E=i.F(m,v);return this._mergedOtherSourceCaches[E]}getLayerSourceCache(m){const v=i.F(m.source,m.scope);return m.type==="symbol"?this._mergedSymbolSourceCaches[v]:m.type==="fill-extrusion"&&this._mergedFillExtrusionSourceCaches[v]||this._mergedOtherSourceCaches[v]}getSourceCaches(m){if(m==null)return Object.values(this._mergedSourceCaches);const v=[];return this._mergedOtherSourceCaches[m]&&v.push(this._mergedOtherSourceCaches[m]),this._mergedSymbolSourceCaches[m]&&v.push(this._mergedSymbolSourceCaches[m]),this._mergedFillExtrusionSourceCaches[m]&&v.push(this._mergedFillExtrusionSourceCaches[m]),v}updateSourceCaches(){const m=this._changes.getUpdatedSourceCaches();for(const v in m){const E=m[v];E==="reload"?this.reloadSource(v):E==="clear"&&this.clearSource(v)}}updateLayers(m){const v=this._changes.getUpdatedPaintProperties();for(const E of v){const D=this.getLayer(E);D&&D.updateTransitions(m)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(m){this.stylesheet.glyphs=m,this.glyphManager.setURL(m)}getImages(m,v,E){this.imageManager.getImages(v.images,v.scope,E),this._updateTilesForChangedImages();const D=B=>{if(B){const W=v.images.map(te=>i.I.toString(te));B.setDependencies(v.tileID.key,v.type,W)}},z=i.F(v.source,v.scope);D(this._mergedOtherSourceCaches[z]),D(this._mergedSymbolSourceCaches[z]),v.images.some(B=>B.iconsetId)&&this.fire(new i.C("data",{dataType:"style"}))}rasterizeImages(m,v,E){this.imageManager.rasterizeImages(v,E)}checkAtlasCache(m,v,E){const D=this.imageManager.imageAtlasCache.findCachedAtlas(v.descriptor);E(null,D&&D.contentDescriptor?{iconPositions:D.iconPositions,patternPositions:D.patternPositions,sourceHash:D.contentDescriptor.hash}:null)}getGlyphs(m,v,E){this.glyphManager.getGlyphs(v.stacks,E)}getOwnSourceCache(m){return this._otherSourceCaches[m]}getOwnLayerSourceCache(m){return m.type==="symbol"?this._symbolSourceCaches[m.source]:m.type==="fill-extrusion"&&this._fillExtrusionSourceCaches[m.source]||this._otherSourceCaches[m.source]}getOwnSourceCaches(m){const v=[];return this._otherSourceCaches[m]&&v.push(this._otherSourceCaches[m]),this._symbolSourceCaches[m]&&v.push(this._symbolSourceCaches[m]),this._fillExtrusionSourceCaches[m]&&v.push(this._fillExtrusionSourceCaches[m]),v}_isSourceCacheLoaded(m){const v=this.getOwnSourceCaches(m);return v.length===0?(this.fire(new i.B(new Error(`There is no source with ID '${m}'`))),!1):v.every(E=>E.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(m,v){if(!this._clipLayerPresent&&m.type!=="fill-extrusion"&&m.type!=="building")return!1;const E=m.type==="fill-extrusion"&&(m.sourceLayer==="building"||m.sourceLayer==="procedural_buildings"),D=m.type==="building";if(m.is3D(!!this.terrain)){if(E||D||v&&v.type==="batched-model"||m.type==="model")return!0}else if(m.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(m=>{m.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}qm.getSourceType=function(M){return I1[M]},qm.setSourceType=function(M,m){I1[M]=m},qm.registerForPluginStateChange=i.dk;var HE=` #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`,GE=` #ifdef DUAL_SOURCE_BLENDING layout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1; #elif defined(FLOAT_RENDER_TARGET) layout(location=0) out highp vec4 glFragColor; #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 const float DITHER_THRESHOLDS[16]=float[16]( 1.0/17.0, 9.0/17.0, 3.0/17.0,11.0/17.0,13.0/17.0, 5.0/17.0,15.0/17.0, 7.0/17.0,4.0/17.0,12.0/17.0, 2.0/17.0,10.0/17.0,16.0/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0 );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 }float cutoutGroundRoofOpacity(vec4 groundRoof) { #ifdef INDICATOR_CUTOUT float fadeStartX=u_indicator_cutout_params.w;float holeRadius=u_indicator_cutout_params.y;float holeMinOpacity=mix(u_indicator_cutout_params.x,1.0,smoothstep(u_indicator_cutout_params.z,u_indicator_cutout_centers.z,groundRoof.y));float distX=abs(u_indicator_cutout_centers.x-groundRoof.x);float roofOpacity=mix(holeMinOpacity,1.0,smoothstep(fadeStartX,holeRadius,u_indicator_cutout_centers.y-groundRoof.w));float groundOpacity=min(smoothstep(fadeStartX,holeRadius,distX)+holeMinOpacity,1.0);return max(roofOpacity,groundOpacity); #else return 1.0; #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;}`,ay=` #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);}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(ivec2 posWithComposedSkirt) {float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(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`,Gw="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;}",WE=` #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`,KE=`#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`,q1=`#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`,U1=`#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`,ZE=`#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;}`,WC=`#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`,Yh=`#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 Ww=/#include\s+"([^"]+)"/g,sr=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,FO=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,zO=new Set(["ifdef","ifndef","elif","if","defined"]),q0=new Set;Zx(HE,q0),Zx(ay,q0),Zx(GE,q0);const Pp={"_prelude_fog.vertex.glsl":KE,"_prelude_terrain.vertex.glsl":WE,"_prelude_shadow.vertex.glsl":WC,"_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":q1,"_prelude_shadow.fragment.glsl":Yh,"_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":U1,"_prelude_raster_particle.glsl":ZE},V1={};fa("",WE),fa(q1,KE),fa(Yh,WC),fa(U1,""),fa(ZE,"");const iy=fa(GE,ay),Kw=HE,H1=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",Kw,iy.fragmentSource].join(` `),dpe=["precision highp float;",Kw,iy.vertexSource].join(` `);var BO={background:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength; #ifdef LIGHTING_3D_MODE in vec4 v_color; #endif void main() {vec4 out_color; #ifdef FEATURE_CUTOUT vec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy; #ifdef FLIP_Y uv.y=1.0-uv.y; #endif float factorTex=min(texture(u_cutout_factor_image,uv).r,1.0);float cutoutFactor=(1.0-u_feature_cutout_params.x)*factorTex;out_color=u_color*(1.0-cutoutFactor); #else #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 #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 ivec2 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); #ifndef FEATURE_CUTOUT #ifdef LIGHTING_3D_MODE v_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength); #endif #ifdef FOG v_fog_pos=fog_position(vec2(a_pos)); #endif #endif }`),backgroundPattern:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif glFragColor=out_color*u_opacity; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in ivec2 a_pos;out highp vec2 v_pos;void main() {vec2 pos=vec2(a_pos);gl_Position=u_matrix*vec4(pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,pos); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),building:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" const float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos; #ifdef RENDER_FRONT_CUTOFF in float v_front_cutoff_opacity; #endif #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT in vec4 v_ground_roof; #endif #endif #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 highp float hash12(in highp vec2 p) {highp 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);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp 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;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp 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;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp 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 highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp 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) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp 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=max(0.0,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 #ifdef FEATURE_CUTOUT {float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}} #else color=applyCutout(color,v_pos.z); #endif #endif #ifdef RENDER_FRONT_CUTOFF if (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}} #endif #ifdef FEATURE_CUTOUT color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x); #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 ivec4 a_normal_3;in ivec4 a_centroid_3; #ifdef FLOOD_LIGHT in int a_flood_light_wall_radius_1i16; #endif #ifdef BUILDING_FAUX_FACADE in uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range; #endif uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter; #ifdef RENDER_FRONT_CUTOFF uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity; #endif #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT out vec4 v_ground_roof; #endif #endif 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 uvec2 part_color_emissive #pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive void main() { #pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive #pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive #ifdef FLOOD_LIGHT v_flood_radius=(float(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(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(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;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3); #ifdef BUILDING_FAUX_FACADE vec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=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=(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=(vec2(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(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;} #endif v_pos=a_pos_3f; #if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) float halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset; #endif #if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) vec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0); #endif #ifdef RENDER_CUTOFF 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 #ifdef RENDER_FRONT_CUTOFF v_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);} #endif gl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w; #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT vec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w); #endif #endif }`),buildingBloom:fa(`in vec4 v_color_emissive; #pragma mapbox: define-attribute highp vec4 bloom_attenuation #pragma mapbox: initialize-attribute highp vec4 bloom_attenuation float saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0; #ifdef HAS_ATTRIBUTE_a_bloom_attenuation float distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance); #endif #ifdef RENDER_CUTOFF opacity*=v_cutoff_opacity; #endif glFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}`,`in vec3 a_pos_3f; #pragma mapbox: define-attribute-vertex-shader-only highp uvec2 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 uvec2 part_color_emissive #pragma mapbox: initialize-attribute highp vec4 bloom_attenuation #ifdef HAS_ATTRIBUTE_a_part_color_emissive vec4 color_emissive=decode_color(vec2(part_color_emissive));float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive); #else v_color_emissive=vec4(1.0); #endif gl_Position=u_matrix*vec4(a_pos_3f,1.0); #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); #endif }`),buildingDepth:fa("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),circle:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" in vec3 v_data;in float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity uniform float u_emissive_strength;void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=v_data.xy;float blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? smoothstep(0.0,-antialiased_blur,1.0-extrude_length) : smoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep( antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width) );vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #endif #ifdef FOG out_color=fog_apply_premultiplied(out_color,v_fog_pos); #endif glFragColor=out_color*(v_visibility*opacity_t); #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif }`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #define NUM_VISIBILITY_RINGS 2 #define INV_SQRT2 0.70710678 #define ELEVATION_BIAS 0.0001 #define NUM_SAMPLES_PER_RING 16 uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in ivec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3;in ivec4 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.0,-1.0),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1.0,-1.0),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1.0,1.0),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1.0,1.0),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 pos2=vec2(a_pos);vec2 extrude=vec2(mod(pos2,2.0)*2.0-1.0);vec2 circle_center=floor(pos2*0.5);float height=circle_elevation(circle_center);vec4 world_center;mat3 surface_vectors; #ifdef PROJECTION_GLOBE_VIEW surface_vectors=globe_mercator_surface_vectors(vec3(a_pos_normal_3)/16384.0,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)*height;vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*height;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);world_center=vec4(circle_center,height,1); #endif #ifdef ELEVATED_ROADS world_center.z+=a_circle_z_offset+ELEVATION_BIAS; #endif vec4 projected_center=u_matrix*world_center;float view_scale=0.0; #ifdef PITCH_WITH_MAP #ifdef SCALE_WITH_MAP view_scale=1.0; #else view_scale=projected_center.w/u_camera_to_center_distance; #endif #else #ifdef SCALE_WITH_MAP view_scale=u_camera_to_center_distance; #else view_scale=projected_center.w; #endif #endif gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0; #ifdef TERRAIN float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center; #ifdef PITCH_WITH_MAP float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center; #else occlusion_world_center=world_center;occlusion_projected_center=projected_center; #endif for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING); #else visibility=1.0; #endif #ifdef PROJECTION_GLOBE_VIEW visibility=1.0; #endif v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur); #ifdef FOG v_fog_pos=fog_position(world_center.xyz); #endif }`),clippingMask:fa("void main() {glFragColor=vec4(1.0);}","in ivec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:fa(`#include "_prelude_fog.fragment.glsl" uniform highp float u_intensity;in vec2 v_extrude; #pragma mapbox: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0); #ifdef FOG if (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);} #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl" #include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in ivec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3;in ivec4 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(vec2(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(vec2(a_pos)*0.5);vec3 pos; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=vec3(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=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #else pos=vec3(tilePos+extrude,elevation(tilePos)); #endif gl_Position=u_matrix*vec4(pos,1); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),heatmapTexture:fa(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(0.0); #endif HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),collisionBox:fa("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`#include "_prelude_terrain.vertex.glsl" in ivec4 a_pos;in ivec2 a_anchor_pos;in ivec2 a_extrude;in uvec2 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() {vec2 anchor_pos=vec2(a_anchor_pos);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(anchor_pos));vec3 proj_pos=vec3(a_pos)+elevationVector(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,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+=(vec2(a_extrude)*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=float(a_placed.x);v_notUsed=float(a_placed.y);}`),collisionCircle:fa("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);glFragColor=color*alpha*opacity_t;}",`in vec2 a_pos_2f;in float a_radius;in ivec2 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;int vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2( mix(-1.0,1.0,float(vertexIdx >=2)),mix(-1.0,1.0,float(vertexIdx >=1 && vertexIdx <=2)));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=float(a_flags.x);gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:fa("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",`#include "_prelude_terrain.vertex.glsl" in ivec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3; #endif out vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {vec2 pos=vec2(a_pos);float h=elevation(pos);v_uv=pos/8192.0; #ifdef PROJECTION_GLOBE_VIEW gl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1); #else gl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1); #endif }`),elevatedStructuresDepth:fa("void main() {}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:fa(`#ifdef DEPTH_RECONSTRUCTION in float v_height; #endif void main() { #ifdef DEPTH_RECONSTRUCTION if (v_height >=0.0) discard; #else #ifdef FEATURE_CUTOUT apply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x); #endif #endif glFragColor=vec4(1.0,0.0,0.0,1.0);}`,`in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth; #ifdef DEPTH_RECONSTRUCTION out float v_height; #endif void main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale); #ifdef DEPTH_RECONSTRUCTION if (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height; #endif gl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}`),elevatedStructures:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" in vec3 v_normal;in float v_height; #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth; #endif vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color) {color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength; #pragma mapbox: define highp vec4 structure_color void main() { #pragma mapbox: initialize highp vec4 structure_color vec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #endif #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 light=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);color.rgb=apply_lighting(color.rgb,transformed_normal,light); #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,cutout_factors.x); #endif glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in ivec2 a_pos;in float a_height;in ivec4 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=vec3(a_pos_normal_3)/16384.0;v_height=a_height;vec3 pos=vec3(vec2(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(vec2(a_pos)); #endif }`),fill:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity uniform float u_emissive_strength; #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #endif void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #endif 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);light=mix(light,1.0,cutout_factors.y);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,cutout_factors.x); #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 ivec2 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(vec2(a_pos)); #endif #ifdef INDICATOR_CUTOUT v_z_offset=z_offset; #endif }`),fillOutline:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" in highp vec2 v_pos;uniform float u_emissive_strength; #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #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);light=mix(light,1.0,cutout_factors.y);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,cutout_factors.x); #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 ivec2 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(vec2(a_pos)); #endif }`),fillOutlinePattern:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FILL_PATTERN_TRANSITION uniform float u_pattern_transition; #endif uniform float u_emissive_strength; #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif in highp vec2 v_pos;in highp vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 pattern_b #endif void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(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 vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #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);light=mix(light,1.0,cutout_factors.y);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,cutout_factors.x); #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 ivec2 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 uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 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 uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize highp float z_offset vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw); #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset; #endif float hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(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,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(pos,z_offset);vec3 shd_pos1=vec3(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(pos); #endif }`),fillPattern:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FILL_PATTERN_TRANSITION uniform float u_pattern_transition; #endif in highp vec2 v_pos;uniform float u_emissive_strength; #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 pattern_b #endif void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(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=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(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 vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #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);light=mix(light,1.0,cutout_factors.y); #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,cutout_factors.x); #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 ivec2 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 uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 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 uvec4 pattern #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize highp float z_offset #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(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);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(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,pos); #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(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(pos); #endif }`),lineBlendComposite:fa(`uniform sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;in vec2 v_pos; #define ADDITIVE 1 void main() {vec4 color=texture(u_image,v_pos);if (u_blend_mode==ADDITIVE) {if (color.a <=0.0) {discard;}float density=color.a;vec3 avgColor=color.rgb/max(density,0.001);float t=density/(1.0+density);glFragColor=vec4(avgColor*t*u_opacity,t*u_opacity);} else {vec3 multiplyFactor=color.rgb*u_opacity+(1.0-u_opacity);glFragColor=vec4(multiplyFactor,1.0);} #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(0.0); #endif HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),fillExtrusion:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" in vec4 v_color;in vec4 v_flat; #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1; #endif uniform lowp float u_opacity; #ifdef RENDER_FRONT_CUTOFF in float v_front_cutoff_opacity; #endif #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT in vec4 v_ground_roof; #endif #endif #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 #ifdef FEATURE_CUTOUT {float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}} #else color=applyCutout(color,h); #endif #endif #ifdef RENDER_FRONT_CUTOFF if (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}} #endif #ifdef FEATURE_CUTOUT color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x); #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 ivec4 a_pos_normal_ed; #if defined(HAS_CENTROID) || defined(TERRAIN) in uvec2 a_centroid_pos; #endif #ifdef RENDER_WALL_MODE in ivec4 a_join_normal_inside; #endif #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3;in ivec4 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; #ifdef RENDER_FRONT_CUTOFF uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity; #endif 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; #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT out vec4 v_ground_roof; #endif #endif 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 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.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_start.y==0.0 && top_up_ny_start.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny_start.x;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=vec2(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);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && (int(centroid_pos.y) & 7)==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? 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; #else h=t > 0.0 ? height : base; #endif pos=vec3(pos_nx.xy,h); #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(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; #if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) vec2 centroid_decoded=pos.xy;bool isBorderCentroid=false;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {int iy=int(centroid_pos.y);int spanYbits=iy & 7;if (spanYbits==7) {isBorderCentroid=true;int borderID=(iy >> 3) & 3;float coordAlongBorder=float(iy >> 5)*4.0;if (borderID==0) centroid_decoded=vec2(0.0,coordAlongBorder);else if (borderID==1) centroid_decoded=vec2(EXTENT,coordAlongBorder);else if (borderID==2) centroid_decoded=vec2(coordAlongBorder,0.0);else centroid_decoded=vec2(coordAlongBorder,EXTENT);} else {centroid_decoded=floor(centroid_pos/8.0);}} #endif #if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) vec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0); #endif #ifdef RENDER_CUTOFF #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 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_random/8.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_FRONT_CUTOFF v_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;if (!isBorderCentroid) {hidden=max(hidden,float(ndc_y < threshold-range_ndc));}float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);} #endif #ifdef RENDER_WALL_MODE vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=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_start.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_start.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 #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT vec4 pos_ground=u_matrix*vec4(pos.xy,ele,1.0);vec4 pos_roof=u_matrix*vec4(pos.xy,ele+height,1.0);v_ground_roof=vec4(pos_ground.xy/pos_ground.w,pos_roof.xy/pos_roof.w); #endif #endif }`),fillExtrusionDepth:fa("void main() {}",`#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 ivec4 a_pos_normal_ed; #if defined(HAS_CENTROID) || defined(TERRAIN) in uvec2 a_centroid_pos; #endif #ifdef RENDER_WALL_MODE in ivec4 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 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 top_up_ny=vec3(a_pos_normal_ed.xyz & 1);vec3 pos_nx=vec3(a_pos_normal_ed.xyz >> 1);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=vec2(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);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);float c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? 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 vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;pos.xy-=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);}`),fillExtrusionPattern:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FILL_EXTRUSION_PATTERN_TRANSITION uniform float u_pattern_transition; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;in vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE in vec3 v_normal; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif in highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity; #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define mediump uvec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 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 uvec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif #pragma mapbox: initialize highp float pixel_ratio vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(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=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(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 ivec4 a_pos_normal_ed; #if defined(HAS_CENTROID) || defined(TERRAIN) in uvec2 a_centroid_pos; #endif #ifdef RENDER_WALL_MODE in ivec4 a_join_normal_inside; #endif #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3;in ivec4 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 uvec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 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 uvec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif #pragma mapbox: initialize highp float pixel_ratio #pragma mapbox: initialize highp float line_width vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=float(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_start.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=vec2(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);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? 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(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(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 vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);p.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;p.xy-=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_start.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE v_normal=normal; #else v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(p); #endif }`),groundShadow:fa(`#include "_prelude_shadow.fragment.glsl" precision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1; #ifdef FOG in float v_fog_opacity; #endif void main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light); #ifdef RENDER_CUTOFF shadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w)); #endif #ifdef FOG shadow=mix(shadow,vec3(1.0),v_fog_opacity); #endif #ifdef INDICATOR_CUTOUT shadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r); #endif #ifdef FEATURE_CUTOUT shadow=mix(shadow,vec3(1.0),get_cutout_factors(gl_FragCoord).y); #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 ivec2 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(vec2(a_pos));v_fog_opacity=fog(v_fog_pos); #endif }`),fillExtrusionGroundEffect:fa(`uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size; #ifdef SDF_SUBPASS in highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);} #ifdef FOG in highp float v_fog; #endif #endif void main() { #ifdef CLEAR_SUBPASS vec4 color=vec4(1.0); #ifdef CLEAR_FROM_TEXTURE color=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)); #endif glFragColor=color; #else #ifdef SDF_SUBPASS highp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0; #ifdef FOG fog=v_fog; #endif #ifdef RENDER_CUTOFF fog*=v_cutoff_opacity; #endif glFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog)); #else #ifdef USE_MRT1 out_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0); #else vec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass); #ifdef OVERDRAW_INSPECTOR color=vec4(1.0); #endif glFragColor=color; #endif #endif HANDLE_WIREFRAME_DEBUG; #endif }`,`#include "_prelude_fog.vertex.glsl" in highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint 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 vec4 pos_end=vec4(a_pos_end);vec2 p=pos_end.xy;vec2 q=floor(pos_end.zw*0.5);vec2 start_bottom=pos_end.zw-q*2.0;float 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=float(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=float(a_hidden_by_landmark); #endif float isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0)); #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); #endif }`),hillshadePrepare:fa(`precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2( (c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c) )/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4( deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;in ivec2 a_pos;in uvec2 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=(vec2(a_texture_pos)/8192.0)*scale+epsilon;}"),hillshade:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color; #ifdef LIGHTING_3D_MODE glFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength); #endif #ifdef FOG glFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos)); #endif #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=vec2(a_texture_pos)/8192.0; #ifdef FOG v_fog_pos=fog_position(vec2(a_pos)); #endif }`),line:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;uniform bool u_emissive_in_shadows;in vec4 v_width2_dilute;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 VARIABLE_LINE_WIDTH in float stub_side; #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 mediump uvec4 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 mediump uvec4 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_dilute.x; #ifdef VARIABLE_LINE_WIDTH blur=mix(blur,0.0,stub_side); #endif float diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0); #ifdef VARIABLE_LINE_WIDTH alpha=mix(alpha,1.0,stub_side); #endif 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)/(float(dash.z)+float(dash.w)/65535.0);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); #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);highp float gradient_trim_color_mix_factor=0.0; #ifdef RENDER_LINE_GRADIENT gradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress); #endif highp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,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 #ifndef VARIABLE_LINE_WIDTH float edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2_dilute.y-edgeBlur),v_width2_dilute.x-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);}out_color*=v_width2_dilute.w;} #endif #endif vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #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);light=mix(light,1.0,cutout_factors.y);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light; #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*diluted_opacity); #ifdef LINE_BLEND_MULTIPLY glFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);HANDLE_WIREFRAME_DEBUG;return; #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,cutout_factors.x); #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 ivec2 a_pos_normal;in uvec4 a_data; #if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH) in vec3 a_z_offset_width; #endif #ifdef ELEVATION_GROUND_SCALE in float a_elevation_ground_scale; #endif #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE) 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 RENDER_LINE_CURVE uniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count; #endif #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 vec4 v_width2_dilute;out float v_gamma_scale;out highp vec3 v_uv; #ifdef ELEVATED_ROADS out highp float v_road_z_offset; #endif #ifdef VARIABLE_LINE_WIDTH out float stub_side; #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 mediump uvec4 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 #ifdef RENDER_LINE_CURVE vec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2=t*t;float t3=t2*t;return 0.5*( 2.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3 );}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*( (-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2 );}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;} #endif void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize mediump uvec4 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 highp float line_progress=0.0; #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE) line_progress=a_packed[2]; #endif float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);mediump vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0; #ifdef RENDER_LINE_CURVE CurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z; #endif gapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0; #ifdef VARIABLE_LINE_WIDTH float left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=(u_width_scale*(left ? left_width : right_width))/2.0;if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=left_f;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale*0.5 : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING; #else halfwidth=(u_width_scale*width)/2.0; #endif 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); #else #ifdef ELEVATED vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset; #ifdef ELEVATION_GROUND_SCALE scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale); #endif #ifdef CROSS_SLOPE_VERTICAL float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_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+scaled_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+scaled_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=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0); #endif #endif #ifndef ELEVATED #ifndef VARIABLE_LINE_WIDTH #ifndef RENDER_TO_TEXTURE float base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (width >=1.0 && base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else { #ifdef RENDER_LINE_BORDER float border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel); #endif }} #endif #endif #ifdef ELEVATED_ROADS gl_Position=gl_Position+projected_extrude; #else gl_Position=mix(gl_Position+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]; #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 vec4 dashf=vec4(dash);float totalLength=dashf.z+dashf.w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dashf.y+dashf.x+0.5)/u_texsize.y); #endif v_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale); #ifdef FOG v_fog_pos=fog_position(pos); #endif #ifdef INDICATOR_CUTOUT v_z_offset=a_z_offset; #endif }`),linePattern:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image; #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef LINE_PATTERN_TRANSITION uniform float u_pattern_transition; #endif in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width; #ifdef RENDER_LINE_TRIM_OFFSET in highp vec3 v_uv; #endif #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef LINE_JOIN_NONE in vec2 v_pattern_data; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #pragma mapbox: define mediump uvec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 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 uvec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 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=vec2(pattern.xy);vec2 pattern_br=vec2(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=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(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 ivec2 a_pos_normal;in uvec4 a_data; #if defined(ELEVATED) || defined(ELEVATED_ROADS) in vec3 a_z_offset_width; #endif #ifdef ELEVATION_GROUND_SCALE in float a_elevation_ground_scale; #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 uvec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 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 uvec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 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=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);vec2 normal=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;float scaled_z_offset=a_z_offset; #ifdef ELEVATION_GROUND_SCALE scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale); #endif #ifdef CROSS_SLOPE_VERTICAL float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_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+scaled_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+scaled_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/(float(pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=float(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y); #endif #ifdef FOG v_fog_pos=fog_position(pos); #endif #ifdef INDICATOR_CUTOUT v_z_offset=a_z_offset; #endif }`),raster:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_raster_array.glsl" uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth; #ifdef PROJECTION_GLOBE_VIEW in float v_split_fade; #endif uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength; #ifndef RASTER_ARRAY uniform highp sampler2D u_image0;uniform sampler2D u_image1; #endif #ifdef RASTER_COLOR uniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res; #endif void main() {vec4 color0,color1,color;vec2 value; #ifdef RASTER_COLOR #ifdef RASTER_ARRAY #ifdef RASTER_ARRAY_LINEAR value=mix( raTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t ); #else value=mix( raTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t ); #endif if (value.y > 0.0) value.x/=value.y; #else color=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a); #endif color=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y; #else color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t); #endif color.a*=u_opacity; #ifdef GLOBE_POLES color.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition); #endif vec3 rgb=color.rgb;rgb=vec3( dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb); #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb; #endif #ifdef FOG highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit)); #endif glFragColor=vec4(out_color*color.a,color.a); #ifdef PROJECTION_GLOBE_VIEW glFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade)); #endif #ifdef RENDER_CUTOFF glFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.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; #ifdef ELEVATED uniform lowp float u_zbias_factor; #endif #define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8 #ifdef GLOBE_POLES in vec3 a_globe_pos;in vec2 a_uv; #else in ivec2 a_pos;in uvec2 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;uv=a_uv;float ele=u_raster_elevation; #ifdef ELEVATION_REFERENCE_GROUND ele+=elevation(uv*EXTENT); #endif globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0); #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz); #endif #else vec4 world_pos; #ifdef PROJECTION_GLOBE_VIEW vec2 texture_pos=vec2(a_texture_pos);uv=texture_pos/8192.0;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];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);}float ele=u_raster_elevation; #ifdef ELEVATION_REFERENCE_GROUND ele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z; #endif vec4 merc_world_pos=vec4(0.0); v_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,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)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0); #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif #else float ele=0.0;vec2 decodedPos=vec2(a_pos); #ifdef ELEVATION_REFERENCE_GROUND vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt; #else uv=vec2(a_texture_pos)/8192.0; #endif world_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0); #ifdef FOG v_fog_pos=fog_position(decodedPos); #endif #endif float w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w; #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 ELEVATED 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);gl_Position.z-=(gl_Position.w*zbias); #endif #ifdef RENDER_CUTOFF v_depth=gl_Position.z; #endif }`),rasterParticle:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb; #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb; #endif #ifdef FOG highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit)); #endif glFragColor=vec4(out_color*color.a,color.a); #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center; #define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8 in ivec2 a_pos;in uvec2 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=vec2(a_texture_pos)/8192.0;gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w); #ifdef FOG v_fog_pos=fog_position(vec2(a_pos)); #endif #endif v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),rasterParticleDraw:fa("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",`#include "_prelude_raster_particle.glsl" in int 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(float(a_index),u_particle_texture_side_len),float(a_index)/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}`),rasterParticleTexture:fa("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:fa(`#include "_prelude_raster_particle.glsl" uniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow( linearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4) );highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}`,"in ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:fa(`#include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" #define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;uniform lowp float u_scale_factor; #ifdef ICON_TRANSITION uniform float u_icon_transition; #endif #ifdef COLOR_ADJUSTMENT uniform mat4 u_color_adj_mat; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #else #ifdef RENDER_SHADOWS in highp float v_z_offset; #endif #endif in vec2 v_tex_a; #ifdef ICON_TRANSITION in vec2 v_tex_b; #endif in float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity; #ifdef RENDER_TEXT_AND_SYMBOL in float is_sdf;in vec2 v_tex_a_icon; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef USE_PAINT_PROPERTIES_UBO in lowp float v_opacity; #ifdef RENDER_SDF in lowp vec4 v_fill_np_color;in lowp vec4 v_halo_np_color;in lowp float v_halo_width;in lowp float v_halo_blur; #endif #ifdef LIGHTING_3D_MODE in lowp float v_emissive_strength; #endif #else #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 #endif void main() { #ifdef USE_PAINT_PROPERTIES_UBO lowp float opacity=v_opacity;lowp vec4 fill_color=vec4(0.0);lowp vec4 halo_color=vec4(0.0);lowp float halo_width=0.0;lowp float halo_blur=0.0; #ifdef RENDER_SDF fill_color=vec4(v_fill_np_color.rgb*v_fill_np_color.a,v_fill_np_color.a);halo_color=vec4(v_halo_np_color.rgb*v_halo_np_color.a,v_halo_np_color.a);halo_width=v_halo_width;halo_blur=v_halo_blur; #endif lowp float emissive_strength=0.0; #ifdef LIGHTING_3D_MODE emissive_strength=v_emissive_strength; #endif #else #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 #endif 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 vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #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);light=mix(light,1.0,cutout_factors.y); #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,cutout_factors.x); #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 USING_APPEARANCE 1.0 in ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity; #ifdef Z_OFFSET in float a_auto_z_offset; #endif #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_globe_anchor;in vec3 a_globe_normal; #endif #ifdef ICON_TRANSITION in uvec2 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 #ifdef USE_PAINT_PROPERTIES_UBO #ifndef MAX_UBO_SIZE_VEC4 #define MAX_UBO_SIZE_VEC4 1024u #endif #define SPP_HEADER_SIZE_VEC4 3u #define DWORDS_PER_VEC4 4u struct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};struct PropertyType {bool isDataDriven;bool isZoomDependent;uint offsetDwords;};struct SymbolPropertyHeader {uint dataDrivenBlockSizeVec4;PropertyType fill_np_color;PropertyType halo_np_color;PropertyType opacity;PropertyType halo_width;PropertyType halo_blur;PropertyType emissive_strength;PropertyType occlusion_opacity;PropertyType z_offset;PropertyType translate;};uniform float u_zoom;uniform lowp vec4 u_spp_fill_np_color;uniform lowp vec4 u_spp_halo_np_color;uniform lowp float u_spp_opacity;uniform lowp float u_spp_halo_width;uniform lowp float u_spp_halo_blur;uniform lowp float u_spp_emissive_strength;uniform lowp float u_spp_occlusion_opacity;uniform lowp float u_spp_z_offset;uniform lowp vec2 u_spp_translate_rotation;in float a_feature_index;layout(std140) uniform SymbolPaintPropertiesHeaderUniform {uvec4 header[SPP_HEADER_SIZE_VEC4];} u_spp_header;layout(std140) uniform SymbolPaintPropertiesUniform {vec4 properties[MAX_UBO_SIZE_VEC4];} u_spp_properties;layout(std140) uniform SymbolPaintPropertiesIndexUniform {uvec4 block_indices[MAX_UBO_SIZE_VEC4];} u_spp_index;out lowp float v_opacity; #ifdef RENDER_SDF out lowp vec4 v_fill_np_color;out lowp vec4 v_halo_np_color;out lowp float v_halo_width;out lowp float v_halo_blur; #endif #ifdef LIGHTING_3D_MODE out lowp float v_emissive_strength; #endif PropertyType getPropertyType(uint propertyIndex,uint dataDrivenMask,uint zoomDependentMask,uint offsetDwords) {PropertyType type;type.isDataDriven=(dataDrivenMask & (1u << propertyIndex)) !=0u;type.isZoomDependent=(zoomDependentMask & (1u << propertyIndex)) !=0u;type.offsetDwords=offsetDwords;return type;}SymbolPropertyHeader readSymbolPropertiesHeader() {SymbolPropertyHeader header;uint dataDrivenMask=u_spp_header.header[0][0];uint zoomDependentMask=u_spp_header.header[0][1];header.dataDrivenBlockSizeVec4=u_spp_header.header[0][2];header.fill_np_color =getPropertyType(0u,dataDrivenMask,zoomDependentMask,u_spp_header.header[0][3]);header.halo_np_color =getPropertyType(1u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][0]);header.opacity =getPropertyType(2u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][1]);header.halo_width =getPropertyType(3u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][2]);header.halo_blur =getPropertyType(4u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][3]);header.emissive_strength =getPropertyType(5u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][0]);header.occlusion_opacity =getPropertyType(6u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][1]);header.z_offset =getPropertyType(7u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][2]);header.translate =getPropertyType(8u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][3]);return header;}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x : (index==1u) ? v.y : (index==2u) ? v.z : v.w;}float vec4At(vec4 v,uint index) {return (index==0u) ? v.x : (index==1u) ? v.y : (index==2u) ? v.z : v.w;}vec4 readVec4(uint baseOffsetVec4,uint propertyOffsetDwords) {return u_spp_properties.properties[baseOffsetVec4+propertyOffsetDwords/DWORDS_PER_VEC4];}float readFloat(vec4 slot,uint propertyOffsetDwords) {return slot[propertyOffsetDwords % DWORDS_PER_VEC4];}uint readUint(uvec4 slot,uint offset) {return slot[offset % DWORDS_PER_VEC4];}vec2 readVec2(vec4 slot,uint propertyOffsetDwords) {float x=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);float y=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4+1u);return vec2(x,y);}uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {uint featureIndex=uint(a_feature_index);uvec4 slot=u_spp_index.block_indices[featureIndex/DWORDS_PER_VEC4];uint blockIndex=uvec4At(slot,featureIndex % DWORDS_PER_VEC4);return blockIndex*dataDrivenBlockSizeVec4;}vec4 readColorProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 color=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {color=unpack_mix_color(color,u_zoom);} else {vec2 packedColor=readVec2(color,propertyType.offsetDwords);color=decode_color(packedColor);}return color;}vec2 readVec2Property(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {vec2 minVal=slot.xy;vec2 maxVal=slot.zw;return mix(minVal,maxVal,u_zoom);}return readVec2(slot,propertyType.offsetDwords);}float readFloatProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);float value;if (propertyType.isZoomDependent) {vec2 packedValues=readVec2(slot,propertyType.offsetDwords);value=unpack_mix_vec2(packedValues,u_zoom);} else {value=readFloat(slot,propertyType.offsetDwords);}return value;}SymbolPaintProperties readSymbolPaintProperties() {SymbolPropertyHeader header=readSymbolPropertiesHeader();uint sizeVec4=header.dataDrivenBlockSizeVec4;SymbolPaintProperties props;props.fill_np_color =header.fill_np_color.isDataDriven ? readColorProperty(header.fill_np_color,sizeVec4) : u_spp_fill_np_color;props.halo_np_color =header.halo_np_color.isDataDriven ? readColorProperty(header.halo_np_color,sizeVec4) : u_spp_halo_np_color;props.opacity =header.opacity.isDataDriven ? readFloatProperty(header.opacity,sizeVec4) : u_spp_opacity;props.halo_width =header.halo_width.isDataDriven ? readFloatProperty(header.halo_width,sizeVec4) : u_spp_halo_width;props.halo_blur =header.halo_blur.isDataDriven ? readFloatProperty(header.halo_blur,sizeVec4) : u_spp_halo_blur;props.emissive_strength =header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength,sizeVec4) : u_spp_emissive_strength;props.occlusion_opacity =header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity,sizeVec4) : u_spp_occlusion_opacity;props.z_offset =header.z_offset.isDataDriven ? readFloatProperty(header.z_offset,sizeVec4) : u_spp_z_offset;props.translate =header.translate.isDataDriven ? readVec2Property(header.translate,sizeVec4) : vec2(0.0);return props;} #else #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 #endif vec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() { #ifdef USE_PAINT_PROPERTIES_UBO SymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity; #ifdef RENDER_SDF v_fill_np_color=paint_properties.fill_np_color;v_halo_np_color=paint_properties.halo_np_color;v_halo_width=paint_properties.halo_width;v_halo_blur=paint_properties.halo_blur; #endif #ifdef LIGHTING_3D_MODE v_emissive_strength=paint_properties.emissive_strength; #endif lowp float occlusion_opacity=paint_properties.occlusion_opacity;lowp float z_offset=paint_properties.z_offset; #else #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 #endif vec2 a_pos=vec2(a_pos_offset.xy);vec2 a_offset=vec2(a_pos_offset.zw);vec2 a_tex=vec2(a_tex_size.xy);vec2 a_size=vec2(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=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=vec2(a_pixeloffset.xy);vec2 a_min_font_scale=vec2(a_pixeloffset.zw)/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance==USING_APPEARANCE) {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=vec3(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(vec3(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); #ifdef USE_PAINT_PROPERTIES_UBO {vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2( u_spp_translate_rotation.x*tr.x-u_spp_translate_rotation.y*tr.y,u_spp_translate_rotation.y*tr.x+u_spp_translate_rotation.x*tr.y );gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;} #endif 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=vec2(a_texb)/u_texsize; #endif #ifdef RENDER_SHADOWS vec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz; #ifdef NORMAL_OFFSET vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef INDICATOR_CUTOUT v_z_offset=e; #else #ifdef RENDER_SHADOWS v_z_offset=e; #endif #endif }`),terrainRaster:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" uniform sampler2D u_image0; #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS uniform sampler2D u_image1;uniform float u_emissive_texture_available; #endif in vec2 v_pos0; #ifdef FOG in float v_fog_opacity; #endif #ifdef RENDER_SHADOWS in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1; #endif uniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color; #ifdef LIGHTING_3D_MODE const vec3 normal=vec3(0.0,0.0,1.0); #ifdef RENDER_SHADOWS float cutoffOpacity=1.0; #ifdef RENDER_CUTOFF cutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w); #endif #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0; #else float lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity)); #endif #else float lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor); #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0; #endif #endif #else color=image_color; #endif #ifdef FOG #ifdef ZERO_EXAGGERATION color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #else color=fog_dither(fog_apply_from_vert(color,v_fog_opacity)); #endif #endif glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" uniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0; #ifdef FOG out float v_fog_opacity; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1; #endif void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0); #ifdef FOG #ifdef ZERO_EXAGGERATION v_fog_pos=fog_position(decodedPos); #else v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation))); #endif #endif #ifdef RENDER_SHADOWS vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.); #endif }`),terrainDepth:fa("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",`#include "_prelude_terrain.vertex.glsl" uniform mat4 u_matrix;in ivec2 a_pos;out float v_depth;void main() {float elevation=elevation(vec2(a_pos));gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}`),skybox:fa(`#include "_prelude_fog.fragment.glsl" in lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep( cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb; #ifdef FOG sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color); #endif sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity); #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif }`,Gw),skyboxGradient:fa(`#include "_prelude_fog.fragment.glsl" in highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5)); #ifdef FOG color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a; #endif color*=u_opacity;glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif }`,Gw),skyboxCapture:fa(` in highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;precision highp float; #define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6) #define BETA_M vec3(21e-6,21e-6,21e-6) #define MIE_G 0.76 #define DENSITY_HEIGHT_SCALE_R 8000.0 #define DENSITY_HEIGHT_SCALE_M 1200.0 #define PLANET_RADIUS 6360e3 #define ATMOSPHERE_RADIUS 6420e3 #define SAMPLE_STEPS 10 #define DENSITY_STEPS 4 float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}`,"in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform sampler2D u_image0; #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS uniform sampler2D u_image1;uniform float u_emissive_texture_available; #endif uniform float u_far_z_cutoff;in vec2 v_pos0; #ifndef FOG uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport; #endif void main() {vec4 color; #ifdef CUSTOM_ANTIALIASING highp vec2 uv=gl_FragCoord.xy/u_viewport; #ifdef FLIP_Y uv.y=1.0-uv.y; #endif highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0); #ifdef LIGHTING_3D_MODE #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias); #else raster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias); #endif #else color=vec4(raster.rgb*antialias,raster.a*antialias); #endif #else color=texture(u_image0,v_pos0); #ifdef LIGHTING_3D_MODE #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0; #else color=apply_lighting_ground(color); #endif #endif #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif color*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height; #ifdef GLOBE_POLES in vec3 a_globe_pos;in vec2 a_uv; #else in ivec2 a_pos; #endif out vec2 v_pos0;void main() { #ifdef GLOBE_POLES vec3 globe_pos=a_globe_pos;vec2 uv=a_uv; #else float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY); #endif v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale; #ifdef GLOBE_POLES vec3 up_vector=globe_derived_up_vector; #else vec3 up_vector=elevationVector(tile_pos); #endif float height=elevation(tile_pos);globe_pos+=up_vector*height; #ifndef GLOBE_POLES globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z; #endif #ifdef GLOBE_POLES vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0); #else vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0); #endif gl_Position=u_proj_matrix*interpolated_pos; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif }`),globeAtmosphere:fa(`#include "_prelude_fog.fragment.glsl" uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir; #ifdef PROJECTION_GLOBE_VIEW globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) { #ifdef ALPHA_PASS glFragColor=vec4(0,0,0,0);return; #else #ifdef NATIVE glFragColor=vec4(1,1,1,1); #else glFragColor=vec4(0,0,0,1); #endif return; #endif } #endif highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ? 0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle; #ifdef PROJECTION_GLOBE_VIEW highp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ? PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t); #else horizon_angle=horizon_angle_mercator; #endif horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb; #ifdef ALPHA_PASS float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a); #else vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;glFragColor=vec4(c*t,t); #endif }`,`in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix( mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`),model:fa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" uniform float u_opacity; #ifdef DITHERED_DISCARD uniform float u_dithered_discard_threshold; #endif 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 DITHERED_DISCARD if (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}} #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,get_cutout_factors(gl_FragCoord).x); #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 uvec4 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 uvec4 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(vec2(pbr.xy));vec2 e_r_m=unpack_float(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(float(pbr.w))/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x; #endif #ifdef FOG v_fog_pos=fog_position(local_pos); #endif #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); #endif #ifdef TERRAIN_FRAGMENT_OCCLUSION v_depth=gl_Position.z/gl_Position.w; #ifdef CLIP_ZERO_TO_ONE v_depth=-1.0+2.0*v_depth; #endif #endif #ifdef HAS_ATTRIBUTE_a_normal_3f #ifdef MODEL_POSITION_ON_GPU float x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f); #else normal_3f=vec3(normal_matrix*vec4(normal_3f,0)); #endif #endif #ifdef HAS_ATTRIBUTE_a_pbr #ifdef HAS_ATTRIBUTE_a_color_4f v_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0); #endif #endif #ifdef RENDER_SHADOWS vec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0); #ifdef NORMAL_OFFSET #ifdef HAS_ATTRIBUTE_a_normal_3f #ifdef MODEL_POSITION_ON_GPU vec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0(); #else vec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0(); #endif #endif #endif v_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w; #endif }`),modelDepth:fa("void main() {}",`in vec3 a_pos_3f;uniform mat4 u_matrix; #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 }`),stars:fa(`in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv) {float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}`,` in vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_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_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}`),snowParticle:fa("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}",` in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; uniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; uniform float u_horizontalOscillationRate; uniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+ localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}`),rainParticle:fa("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}",` in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; uniform float u_velocity; uniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+ localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}`),vignette:fa("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),occlusion:fa("uniform vec4 u_color;void main() {glFragColor=u_color;}",`#include "_prelude_terrain.vertex.glsl" in highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos; #ifdef TERRAIN float e=elevation(world_pos.xy);world_pos.z+=e; #endif vec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}`)};function Zx(M,m){const v=M.split(` `);for(let E of v){if(E=E.trimStart(),E[0]!=="#"||!E.includes("if")||E.startsWith("#endif"))continue;const D=E.match(FO);if(D)for(const z of D)zO.has(z)||m.add(z)}}function $O(M){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(M)}function fa(M,m){const v=new Set,E=[],D=[];M=M.replace(Ww,(B,W)=>(D.push(W),"")),m=m.replace(Ww,(B,W)=>(E.push(W),""));let z=new Set(q0);Zx(M,z),Zx(m,z);for(const B of[...E,...D])V1[B]||(V1[B]=new Set,Zx(Pp[B],V1[B])),z=new Set([...z,...V1[B]]);return{fragmentSource:M=M.replace(sr,(B,W,te,ne,de)=>(v.add(de),W==="define"?` #ifndef HAS_UNIFORM_u_${de} ${$O(ne)?"flat ":""}in ${te} ${ne} ${de}; #else uniform ${te} ${ne} u_${de}; #endif `:W==="initialize"?` #ifdef HAS_UNIFORM_u_${de} ${te} ${ne} ${de} = u_${de}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${de} in ${te} ${ne} ${de}; #endif `:W==="initialize-attribute"?"":void 0)),vertexSource:m=m.replace(sr,(B,W,te,ne,de)=>{const je=`MATERIAL_ATTRIBUTE_OFFSET_${de}`,be=ne==="float"?"vec2":ne,Me=`GET_ATTRIBUTE_${be}(a_${de}, materialInfo, ${je})`,$e=de.match(/color/)?"color":be;return W==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${de} in ${te} ${ne} a_${de}; #endif `:v.has(de)?W==="define"?` #ifndef HAS_UNIFORM_u_${de} uniform lowp float u_${de}_t; #if !defined(${je}) in ${te} ${be} a_${de}; #endif ${$O(ne)?"flat ":""}out ${te} ${ne} ${de}; #else uniform ${te} ${ne} u_${de}; #endif `:W==="initialize"?$e==="vec4"||$e==="uvec4"?` #ifndef HAS_UNIFORM_u_${de} ${de} = a_${de}; #else ${te} ${ne} ${de} = u_${de}; #endif `:` #if !defined(HAS_UNIFORM_u_${de}) #ifdef ${je} ${de} = unpack_mix_${$e}(${Me}, u_${de}_t); #else ${de} = unpack_mix_${$e}(a_${de}, u_${de}_t); #endif #else ${te} ${ne} ${de} = u_${de}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${de} in ${te} ${ne} a_${de}; out ${te} ${ne} ${de}; #endif `:W==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${de} ${de} = a_${de}; #endif `:void 0:W==="define"?` #ifndef HAS_UNIFORM_u_${de} uniform lowp float u_${de}_t; #if !defined(${je}) in ${te} ${be} a_${de}; #endif #else uniform ${te} ${ne} u_${de}; #endif `:W==="define-instanced"?$e==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${de}0; in vec4 a_${de}1; in vec4 a_${de}2; in vec4 a_${de}3; #else uniform ${te} ${ne} u_${de}; #endif `:` #ifdef INSTANCED_ARRAYS in ${te} ${be} a_${de}; #else uniform ${te} ${ne} u_${de}; #endif `:W==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${de} ${te} ${ne} ${de} = a_${de}; #endif `:$e==="vec4"||$e==="uvec4"?` #ifndef HAS_UNIFORM_u_${de} #ifdef ${je} ${te} ${ne} ${de} = ${Me}; #else ${te} ${ne} ${de} = a_${de}; #endif #else ${te} ${ne} ${de} = u_${de}; #endif `:` #ifndef HAS_UNIFORM_u_${de} #ifdef ${je} ${te} ${ne} ${de} = unpack_mix_${$e}(${Me}, u_${de}_t); #else ${te} ${ne} ${de} = unpack_mix_${$e}(a_${de}, u_${de}_t); #endif #else ${te} ${ne} ${de} = u_${de}; #endif `}),usedDefines:z,vertexIncludes:E,fragmentIncludes:D}}class qO{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(m,v,E,D,z,B,W,te){this.context=m;let ne=this.boundPaintVertexBuffers.length!==D.length;for(let je=0;!ne&&je{const zt=mt.paint.get("hillshade-shadow-color"),bt=mt.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",Dt=mt.paint.get("hillshade-highlight-color"),pt=mt.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",vt=mt.paint.get("hillshade-accent-color"),Tt=mt.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Gt=mt.paint.get("hillshade-emissive-strength");let qt=i.ap(mt.paint.get("hillshade-illumination-direction"));if(mt.paint.get("hillshade-illumination-anchor")==="viewport")qt-=Qe.transform.angle;else if(Qe.style&&Qe.style.enable3dLights()&&Qe.style.directionalLight){const Jt=Qe.style.directionalLight.properties.get("direction"),Ns=i.cP(Jt.x,Jt.y,Jt.z);qt=i.ap(Ns[1])}const ns=!Qe.options.moving;return{u_matrix:nt||Qe.transform.calculateProjMatrix(lt.tileID.toUnwrapped(),ns),u_image:0,u_latrange:YE(0,lt.tileID),u_light:[mt.paint.get("hillshade-exaggeration"),qt],u_shadow:zt.toPremultipliedRenderColor(bt?null:mt.lut),u_highlight:Dt.toPremultipliedRenderColor(pt?null:mt.lut),u_emissive_strength:Gt,u_accent:vt.toPremultipliedRenderColor(Tt?null:mt.lut)}})(M,v,E,M.terrain?m.projMatrix:null);M.uploadCommonUniforms(W,be,m.toUnwrapped());const{tileBoundsBuffer:$e,tileBoundsIndexBuffer:Le,tileBoundsSegments:Je}=M.getTileBoundsBuffers(v);be.draw(M,te.TRIANGLES,D,z,B,Wr.disabled,Me,E.id,$e,Le,Je)}function UO(M,m,v){if(!m.needsDEMTextureUpload)return;const E=M.context,D=E.gl;E.pixelStoreUnpackPremultiplyAlpha.set(!1),m.demTexture=m.demTexture||M.getTileTexture(v.stride);const z=v.getPixels();m.demTexture?m.demTexture.update(z,{premultiply:!1}):m.demTexture=new i.T(E,z,D.R32F,{premultiply:!1}),m.needsDEMTextureUpload=!1}function hpe(M,m,v){const E=M.context,D=E.gl;if(!m.dem)return;const z=m.dem;if(E.activeTexture.set(D.TEXTURE1),UO(M,m,z),!m.demTexture)return;m.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const B=z.dim;E.activeTexture.set(D.TEXTURE0);let W=m.hillshadeFBO;if(!W){const be=new i.T(E,{width:B,height:B,data:null},D.RGBA8);be.bind(D.LINEAR,D.CLAMP_TO_EDGE),W=m.hillshadeFBO=E.createFramebuffer(B,B,1,"renderbuffer"),W.colorAttachment0.set(be.texture)}E.bindFramebuffer.set(W.framebuffer),E.viewport.set([0,0,B,B]);const{tileBoundsBuffer:te,tileBoundsIndexBuffer:ne,tileBoundsSegments:de}=M.getMercatorTileBoundsBuffers(),je=[];M.linearFloatFilteringSupported()&&je.push("TERRAIN_DEM_FLOAT_FORMAT"),M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&je.push("USE_MRT1"),M.getOrCreateProgram("hillshadePrepare",{defines:je}).draw(M,D.TRIANGLES,kr.disabled,sn.disabled,Jr.unblended,Wr.disabled,((be,Me)=>{const $e=Me.stride,Le=i.bb();return i.bT(Le,0,i.an,-i.an,0,0,1),i.bx(Le,Le,[0,-i.an,0]),{u_matrix:Le,u_image:1,u_dimension:[$e,$e],u_zoom:be.overscaledZ}})(m.tileID,z),v.id,te,ne,de),m.needsHillshadePrepare=!1}class ao{constructor(m){this.gl=m.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(m){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class VO extends ao{getDefault(){return i.aq.transparent.toNonPremultipliedRenderColor(null)}set(m){const v=this.current;(m.r!==v.r||m.g!==v.g||m.b!==v.b||m.a!==v.a||this.dirty)&&(this.gl.clearColor(m.r,m.g,m.b,m.a),this.current=m,this.dirty=!1)}}class mpe extends ao{getDefault(){return 1}set(m){(m!==this.current||this.dirty)&&(this.gl.clearDepth(m),this.current=m,this.dirty=!1)}}class KC extends ao{getDefault(){return 0}set(m){(m!==this.current||this.dirty)&&(this.gl.clearStencil(m),this.current=m,this.dirty=!1)}}class ppe extends ao{getDefault(){return[!0,!0,!0,!0]}set(m){const v=this.current;(m[0]!==v[0]||m[1]!==v[1]||m[2]!==v[2]||m[3]!==v[3]||this.dirty)&&(this.gl.colorMask(m[0],m[1],m[2],m[3]),this.current=m,this.dirty=!1)}}class HO extends ao{getDefault(){return!0}set(m){(m!==this.current||this.dirty)&&(this.gl.depthMask(m),this.current=m,this.dirty=!1)}}class XE extends ao{getDefault(){return 255}set(m){(m!==this.current||this.dirty)&&(this.gl.stencilMask(m),this.current=m,this.dirty=!1)}}class ZC extends ao{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(m){const v=this.current;(m.func!==v.func||m.ref!==v.ref||m.mask!==v.mask||this.dirty)&&(this.gl.stencilFunc(m.func,m.ref,m.mask),this.current=m,this.dirty=!1)}}class QE extends ao{getDefault(){const m=this.gl;return[m.KEEP,m.KEEP,m.KEEP]}set(m){const v=this.current;(m[0]!==v[0]||m[1]!==v[1]||m[2]!==v[2]||this.dirty)&&(this.gl.stencilOp(m[0],m[1],m[2]),this.current=m,this.dirty=!1)}}class U0 extends ao{getDefault(){return!1}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;m?v.enable(v.STENCIL_TEST):v.disable(v.STENCIL_TEST),this.current=m,this.dirty=!1}}class V0 extends ao{getDefault(){return[0,1]}set(m){const v=this.current;(m[0]!==v[0]||m[1]!==v[1]||this.dirty)&&(this.gl.depthRange(m[0],m[1]),this.current=m,this.dirty=!1)}}class G1 extends ao{getDefault(){return!1}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;m?v.enable(v.DEPTH_TEST):v.disable(v.DEPTH_TEST),this.current=m,this.dirty=!1}}class Df extends ao{getDefault(){return this.gl.LESS}set(m){(m!==this.current||this.dirty)&&(this.gl.depthFunc(m),this.current=m,this.dirty=!1)}}class GO extends ao{getDefault(){return!1}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;m?v.enable(v.BLEND):v.disable(v.BLEND),this.current=m,this.dirty=!1}}class JE extends ao{getDefault(){const m=this.gl;return[m.ONE,m.ZERO,m.ONE,m.ZERO]}set(m){const v=this.current;(m[0]!==v[0]||m[1]!==v[1]||m[2]!==v[2]||m[3]!==v[3]||this.dirty)&&(this.gl.blendFuncSeparate(m[0],m[1],m[2],m[3]),this.current=m,this.dirty=!1)}}class WO extends ao{getDefault(){return i.aq.transparent.toNonPremultipliedRenderColor(null)}set(m){const v=this.current;(m.r!==v.r||m.g!==v.g||m.b!==v.b||m.a!==v.a||this.dirty)&&(this.gl.blendColor(m.r,m.g,m.b,m.a),this.current=m,this.dirty=!1)}}class W1 extends ao{getDefault(){return this.gl.FUNC_ADD}set(m){(m!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(m,m),this.current=m,this.dirty=!1)}}class YC extends ao{getDefault(){return!1}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;m?v.enable(v.CULL_FACE):v.disable(v.CULL_FACE),this.current=m,this.dirty=!1}}class XC extends ao{getDefault(){return this.gl.BACK}set(m){(m!==this.current||this.dirty)&&(this.gl.cullFace(m),this.current=m,this.dirty=!1)}}class eP extends ao{getDefault(){return this.gl.CCW}set(m){(m!==this.current||this.dirty)&&(this.gl.frontFace(m),this.current=m,this.dirty=!1)}}let QC=class extends ao{getDefault(){return null}set(M){(M!==this.current||this.dirty)&&(this.gl.useProgram(M),this.current=M,this.dirty=!1)}};class Zw extends ao{getDefault(){return this.gl.TEXTURE0}set(m){(m!==this.current||this.dirty)&&(this.gl.activeTexture(m),this.current=m,this.dirty=!1)}}class KO extends ao{getDefault(){const m=this.gl;return[0,0,m.drawingBufferWidth,m.drawingBufferHeight]}set(m){const v=this.current;(m[0]!==v[0]||m[1]!==v[1]||m[2]!==v[2]||m[3]!==v[3]||this.dirty)&&(this.gl.viewport(m[0],m[1],m[2],m[3]),this.current=m,this.dirty=!1)}}class ZO extends ao{getDefault(){return null}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.bindFramebuffer(v.FRAMEBUFFER,m),this.current=m,this.dirty=!1}}class YO extends ao{getDefault(){return null}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.bindRenderbuffer(v.RENDERBUFFER,m),this.current=m,this.dirty=!1}}class K1 extends ao{getDefault(){return null}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.bindTexture(v.TEXTURE_2D,m),this.current=m,this.dirty=!1}}class XO extends ao{getDefault(){return null}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.bindBuffer(v.ARRAY_BUFFER,m),this.current=m,this.dirty=!1}}class fpe extends ao{getDefault(){return null}set(m){const v=this.gl;v.bindBuffer(v.ELEMENT_ARRAY_BUFFER,m),this.current=m,this.dirty=!1}}class xpe extends ao{getDefault(){return null}set(m){this.gl&&(m!==this.current||this.dirty)&&(this.gl.bindVertexArray(m),this.current=m,this.dirty=!1)}}class gpe extends ao{getDefault(){return 4}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.pixelStorei(v.UNPACK_ALIGNMENT,m),this.current=m,this.dirty=!1}}class tP extends ao{getDefault(){return!1}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.pixelStorei(v.UNPACK_PREMULTIPLY_ALPHA_WEBGL,m),this.current=m,this.dirty=!1}}class sP extends ao{getDefault(){return!1}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.pixelStorei(v.UNPACK_FLIP_Y_WEBGL,m),this.current=m,this.dirty=!1}}class Yw extends ao{constructor(m,v){super(m),this.context=m,this.parent=v}getDefault(){return null}}class Z1 extends Yw{constructor(m,v,E=0){super(m,v),this.attachmentPoint=m.gl.COLOR_ATTACHMENT0+E}setDirty(){this.dirty=!0}set(m){if(m===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const v=this.gl;v.framebufferTexture2D(v.FRAMEBUFFER,this.attachmentPoint,v.TEXTURE_2D,m,0),this.current=m,this.dirty=!1}}class rP extends Yw{attachment(){return this.gl.DEPTH_ATTACHMENT}set(m){if(m===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const v=this.gl;v.framebufferRenderbuffer(v.FRAMEBUFFER,this.attachment(),v.RENDERBUFFER,m),this.current=m,this.dirty=!1}}class QO extends Yw{attachment(){return this.gl.DEPTH_ATTACHMENT}set(m){if(m===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const v=this.gl;v.framebufferTexture2D(v.FRAMEBUFFER,this.attachment(),v.TEXTURE_2D,m,0),this.current=m,this.dirty=!1}}class ype extends rP{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const Xw=(M,m,v,E)=>({u_matrix:M,u_image0:0,u_image1:1,u_skirt_height:m,u_ground_shadow_factor:v,u_emissive_texture_available:E}),Y1=(M,m,v,E,D,z,B,W,te,ne,de,je,be,Me,$e,Le,Je)=>({u_proj_matrix:Float32Array.from(M),u_globe_matrix:m,u_normalize_matrix:Float32Array.from(E),u_merc_matrix:v,u_zoom_transition:D,u_merc_center:z,u_image0:0,u_image1:1,u_frustum_tl:B,u_frustum_tr:W,u_frustum_br:te,u_frustum_bl:ne,u_globe_pos:de,u_globe_radius:je,u_viewport:be,u_grid_matrix:Je?Float32Array.from(Je):new Float32Array(9),u_skirt_height:Me,u_far_z_cutoff:$e,u_emissive_texture_available:Le});function nP(M,m){return M!=null&&m!=null&&!(!M.hasData()||!m.hasData())&&M.demTexture!=null&&m.demTexture!=null&&M.tileID.key!==m.tileID.key}const Sd=new class{constructor(){this.operations={}}newMorphing(M,m,v,E,D){if(M in this.operations){const z=this.operations[M];z.to.tileID.key!==v.tileID.key&&(z.queued=v)}else this.operations[M]={startTime:E,phase:0,duration:D,from:m,to:v,queued:null}}getMorphValuesForProxy(M){if(!(M in this.operations))return null;const m=this.operations[M];return{from:m.from,to:m.to,phase:m.phase}}update(M){for(const m in this.operations){const v=this.operations[m];for(v.phase=(M-v.startTime)/v.duration;v.phase>=1||!this._validOp(v);)if(!this._nextOp(v,M)){delete this.operations[m];break}}}_nextOp(M,m){return!!M.queued&&(M.from=M.to,M.to=M.queued,M.queued=null,M.phase=0,M.startTime=m,!0)}_validOp(M){return M.from.hasData()&&M.to.hasData()}},JC={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Qw(M,m,v){if(m===0)return 0;const E=m<1&&v===514?.25/m:1;return 6*Math.pow(1.5,22-M)*Math.max(m,1)*E}function e3(M,m){const v=1<({u_matrix:M});function t2(M,m,v,E,D){if(D>0){const z=i.o.now(),B=(z-M.timeAdded)/D,W=m?(z-m.timeAdded)/D:-1,te=v.getSource(),ne=E.coveringZoomLevel({tileSize:te.tileSize,roundZoom:te.roundZoom}),de=!m||Math.abs(m.tileID.overscaledZ-ne)>Math.abs(M.tileID.overscaledZ-ne),je=de&&M.refreshedUponExpiration?1:i.aC(de?B:1-W,0,1);return m?{opacity:1,mix:1-je,isFading:B<1}:{opacity:je,mix:0,isFading:B<1}}return{opacity:1,mix:0,isFading:!1}}class t3 extends $l{constructor(m){const v={type:"raster-dem",maxzoom:Math.ceil(m.transform.maxZoom)},E=Np("mock-dem",v,m.style.dispatcher,m.style);super("mock-dem",E,null),E.setEventedParent(this),this._sourceLoaded=!0}_loadTile(m,v){m.state="loaded",v(null)}}class aP extends $l{constructor(m){const v=Np("proxy",{type:"geojson",maxzoom:Math.ceil(m.transform.maxZoom)},m.style.dispatcher,m.style);super("proxy",v,null),v.setEventedParent(this),this.map=this.getSource().map=m,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(m,v,E){if(m.freezeTileCoverage)return;this.transform=m;const D=m.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((z,B)=>{if(z[B.key]="",!this._tiles[B.key]){const W=new i.b0(B,this._source.tileSize*B.overscaleFactor(),m.tileZoom,void 0,void 0,this._source.worldview);W.state="loaded",this._tiles[B.key]=W}return z},{});for(const z in this._tiles)z in D||(this.freeFBO(z),this._tiles[z].unloadVectorData(),delete this._tiles[z])}freeFBO(m){const v=this.proxyCachedFBO[m];if(v!==void 0){const E=Object.values(v);this.renderCachePool.push(...E),delete this.proxyCachedFBO[m]}}deallocRenderCache(){this.renderCache.forEach(m=>m.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class s3 extends i.aR{constructor(m,v,E){super(m.overscaledZ,m.wrap,m.canonical.z,m.canonical.x,m.canonical.y),this.proxyTileKey=v,this.projMatrix=E}}class s2 extends i.bu{constructor(m,v){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=m,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[E,D,z]=function(){const te=new i.dB,ne=new i.dC,de=131;te.reserve(17161),ne.reserve(33800);const je=i.an/128,be=i.an+je/2,Me=be+je;for(let Le=-je;Lebe||Le<0||Le>be?24575:0,lt=i.aC(Math.round(Je),0,i.an),mt=i.aC(Math.round(Le),0,i.an);te.emplaceBack(lt+Qe,mt)}const $e=(Le,Je)=>{const Qe=Je*de+Le;ne.emplaceBack(Qe+1,Qe,Qe+de),ne.emplaceBack(Qe+de,Qe+de+1,Qe+1)};for(let Le=1;Le<129;Le++)for(let Je=1;Je<129;Je++)$e(Je,Le);return[0,129].forEach(Le=>{for(let Je=0;Je<130;Je++)$e(Je,Le),$e(Le,Je)}),[te,ne,32768]}(),B=m.context;this.gridBuffer=B.createVertexBuffer(E,i.dx.members),this.gridIndexBuffer=B.createIndexBuffer(D),this.gridSegments=i.dy.simpleSegment(0,0,E.length,D.length),this.gridNoSkirtSegments=i.dy.simpleSegment(0,0,E.length,z),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new aP(v.map),this.orthoMatrix=i.bb(),i.bT(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,i.an,0,i.an,0,1);const W=B.gl;this._overlapStencilMode=new sn({func:W.GEQUAL,mask:255},0,255,W.KEEP,W.KEEP,W.REPLACE),this._previousZoom=m.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=v,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new t3(v.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1}set style(m){m.on("data",this._onStyleDataEvent.bind(this)),this._style=m,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(m,v,E){if(m&&m.terrain){this._style!==m&&(this.style=m,this._evaluationZoom=void 0);const D=m.terrain.properties,z=m.terrain.drapeRenderMode===0,B=m.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=i.o.now();const W=m.terrain&&m.terrain.scope,te=D.get("source"),ne=z?this._mockSourceCache:m.getSourceCache(te,W);if(!ne)return void i.w(`Couldn't find terrain source "${te}".`);if(this.sourceCache=ne,this._attenuationRange=m.terrain.getAttenuationRange(),this._exaggeration=B?this.calculateExaggeration(v):D.get("exaggeration"),!v.projection.requiresDraping&&B&&this._exaggeration===0)return void this._disable();this.enabled=!0;const de=()=>{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 je=this.getScaledDemTileSize();this.sourceCache.update(v,je,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,de(),this._initializing=!0),de(),v.updateElevation(!0,E),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(v),this._emptyDEMTextureDirty=!0,this._previousZoom=v.zoom}else this._disable()}calculateExaggeration(m){if(this._attenuationRange&&m.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(m.zoom);const v=this._previousCameraAltitude,E=m.getFreeCameraOptions().position.z/m.pixelsPerMeter*m.worldSize;this._previousCameraAltitude=E;const D=v!=null?E-v:Number.MAX_VALUE;if(Math.abs(D)<2)return this._exaggeration;const z=m.zoom,B=this._style.terrain;if(!this._previousUpdateTimestamp)return B.getExaggeration(z);let W=z-this._previousZoom;const te=this._previousUpdateTimestamp;let ne=z;this._evaluationZoom!=null&&(ne=this._evaluationZoom,Math.abs(z-ne)>.5&&(W=.5*(z-ne+W)),W*D<0&&(ne+=W)),this._evaluationZoom=ne;const de=B.getExaggeration(ne),je=de===B.getExaggeration(Math.max(0,ne-.1));if(je&&Math.abs(de-this._exaggeration)<.01)return de;let be=Math.min(.1,.00375*(this._updateTimestamp-te));return(je||de<.1||Math.abs(W)<1e-4)&&(be=Math.min(.2,4*be)),i.am(this._exaggeration,de,be)}resetTileLookupCache(m){this._findCoveringTileCache[m]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(m){m.dataType==="source"&&m.coord?this._clearRenderCacheForTile(m.sourceCacheId,m.coord):m.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 m in this._style._mergedSourceCaches)this._style._mergedSourceCaches[m].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(m=>m.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 m=2*this.proxySourceCache.getSource().tileSize;return[m,m]}set useVertexMorphing(m){this._useVertexMorphing=m}updateTileBinding(m){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const v=this.proxySourceCache,E=this.painter.transform;this._initializing&&(this._initializing=E._centerAltitude===0&&this.getAtPointOrZero(i.ag.fromLngLat(E.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const D=this.proxyCoords=v.getIds().map(te=>{const ne=v.getTileByID(te).tileID;return ne.projMatrix=E.calculateProjMatrix(ne.toUnwrapped()),ne});(function(te,ne){const de=ne.transform.pointCoordinate(ne.transform.getCameraPoint()),je=new i.P(de.x,de.y);te.sort((be,Me)=>{if(Me.overscaledZ-be.overscaledZ)return Me.overscaledZ-be.overscaledZ;const $e=new i.P(be.canonical.x+(1<{this.proxyToSource[te.key]={}}),this.terrainTileForTile={};const B=this._style._mergedSourceCaches;for(const te in B){const ne=B[te];if(!ne.used||(ne!==this.sourceCache&&this.resetTileLookupCache(ne.id),this._setupProxiedCoordsForOrtho(ne,m[te],z),ne.usedForTerrain))continue;const de=m[te];(ne.getSource().reparseOverscaled||ne._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(de)}this.proxiedCoords[v.id]=D.map(te=>new s3(te,te.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(z),this.renderingToTexture=!1;const W={};this._visibleDemTiles=[];for(const te of this.proxyCoords){const ne=this.terrainTileForTile[te.key];if(!ne)continue;const de=ne.tileID.key;de in W||(this._visibleDemTiles.push(ne),W[de]=de)}}_assignTerrainTiles(m){this._initializing||m.forEach(v=>{if(this.terrainTileForTile[v.key])return;const E=this._findTileCoveringTileID(v,this.sourceCache);E&&(this.terrainTileForTile[v.key]=E)})}_prepareDEMTextures(){const m=this.painter.context,v=m.gl;for(const E in this.terrainTileForTile){const D=this.terrainTileForTile[E],z=D.dem;!z||D.demTexture&&!D.needsDEMTextureUpload||(m.activeTexture.set(v.TEXTURE1),UO(this.painter,D,z))}}_prepareDemTileUniforms(m,v,E,D){if(!v||v.demTexture==null)return!1;const z=m.tileID.canonical,B=Math.pow(2,v.tileID.canonical.z-z.z),W=D||"";return E[`u_dem_tl${W}`]=[z.x*B%1,z.y*B%1],E[`u_dem_scale${W}`]=B,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let m=0;const v=this._visibleDemTiles.reduce((E,D)=>{if(!D.dem)return E;const z=D.dem.tree.minimums[0];return z>0&&m++,E+z},0);return m?v/m:0}_updateEmptyDEMTexture(){const m=this.painter.context,v=m.gl;m.activeTexture.set(v.TEXTURE2);const E=this._getLoadedAreaMinimum(),D=new i.dz({width:1,height:1},new Float32Array([E]));this._emptyDEMTextureDirty=!1;let z=this._emptyDEMTexture;return z?z.update(D,{premultiply:!1}):z=this._emptyDEMTexture=new i.T(m,D,v.R32F,{premultiply:!1}),z}setupElevationDraw(m,v,E){const D=this.painter.context,z=D.gl,B={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};B.u_exaggeration=this.exaggeration();let W=null,te=null,ne=1;if(E&&E.morphing&&this._useVertexMorphing){const Me=E.morphing.srcDemTile,$e=E.morphing.dstDemTile;ne=E.morphing.phase,Me&&$e&&(this._prepareDemTileUniforms(m,Me,B,"_prev")&&(te=Me),this._prepareDemTileUniforms(m,$e,B)&&(W=$e))}const de=Me=>Me&&Me.demTexture&&this.painter.linearFloatFilteringSupported()?z.LINEAR:z.NEAREST;let je=null;var be;if(this.enabled?te&&W?(je=W.demTexture,D.activeTexture.set(z.TEXTURE4),te.demTexture.bind(de(te),z.CLAMP_TO_EDGE),B.u_dem_lerp=ne):(W=this.terrainTileForTile[m.tileID.key],je=this._prepareDemTileUniforms(m,W,B)?W.demTexture:this.emptyDEMTexture):je=this.emptyDEMTexture,D.activeTexture.set(z.TEXTURE2),je&&(B.u_dem_size=(be=je).size[0]===1?1:be.size[0]-2,je.bind(de(W),z.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(E&&E.useDepthForOcclusion,v,B),E&&E.useMeterToDem&&W){const Me=(1<{if(Qe===Jt)return;const Ns=[JC[Jt],"PROJECTION_GLOBE_VIEW"];mt&&Ns.push("CUSTOM_ANTIALIASING");const Is=ne.isTileAffectedByFog(ns);Je=ne.getOrCreateProgram("globeRaster",{defines:Ns,overrideFog:Is}),Qe=Jt},zt=ne.colorModeForRenderPass(),bt=new kr(Le.LEQUAL,kr.ReadWrite,ne.depthRangeFor3D);Sd.update(Me);const Dt=i.dq(lt),pt=[i.aH(lt.center.lng),i.aL(lt.center.lat)],vt=ne.globeSharedBuffers,Tt=[lt.width*i.o.devicePixelRatio,lt.height*i.o.devicePixelRatio],Gt=Float32Array.from(lt.globeMatrix),qt={useDenormalizedUpVectorScale:!0};{const ns=ne.transform,Jt=Qw(ns.zoom,de.exaggeration(),de.sourceCache._source.tileSize);Qe=-1;const Ns=Le.TRIANGLES;for(const Is of be){const Zt=je.getTile(Is),Ut=sn.disabled,ss=de.prevTerrainTileForTile[Is.key],as=de.terrainTileForTile[Is.key];nP(ss,as)&&Sd.newMorphing(Is.key,ss,as,Me,250),Jw(ne,Zt.emissiveTexture),$e.activeTexture.set(Le.TEXTURE0),Zt.texture&&Zt.texture.bind(Le.LINEAR,Le.CLAMP_TO_EDGE);const ds=Sd.getMorphValuesForProxy(Is.key),Qs=ds?1:0;ds&&Object.assign(qt,{morphing:{srcDemTile:ds.from,dstDemTile:ds.to,phase:i.dn(ds.phase)}});const Gs=i.dr(Is.canonical),Ws=i.ds(Gs.getCenter().lat),Ts=i.dt(Is.canonical,Gs,Ws,ns.worldSize/ns._pixelsPerMercatorPixel),wr=i.du(i.dv(Is.canonical)),Ir=ne.emissiveMode==="mrt-fallback"?1:0,pr=Y1(ns.expandedFarZProjMatrix,Gt,Dt,wr,i.al(ns.zoom),pt,ns.frustumCorners.TL,ns.frustumCorners.TR,ns.frustumCorners.BR,ns.frustumCorners.BL,ns.globeCenterInViewSpace,ns.globeRadius,Tt,Jt,ns._farZ,Ir,Ts);if(nt(Is,Qs),Je&&(de.setupElevationDraw(Zt,Je,qt),ne.uploadCommonUniforms($e,Je,Is.toUnwrapped()),vt)){const[vr,Zr,fn]=vt.getGridBuffers(Ws,Jt!==0);Je.draw(ne,Ns,bt,Ut,zt,Wr.backCCW,pr,"globe_raster",vr,Zr,fn)}}}if(vt&&(ne.renderDefaultNorthPole||ne.renderDefaultSouthPole)){const ns=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];mt&&ns.push("CUSTOM_ANTIALIASING"),Je=ne.getOrCreateProgram("globeRaster",{defines:ns});for(const Jt of be){const{x:Ns,y:Is,z:Zt}=Jt.canonical,Ut=Is===0,ss=Is===(1<vr.draw(ne,Le.TRIANGLES,bt,sn.disabled,zt,Wr.disabled,Y1(lt.expandedFarZProjMatrix,Ts,Ts,wr,0,pt,lt.frustumCorners.TL,lt.frustumCorners.TR,lt.frustumCorners.BR,lt.frustumCorners.BL,lt.globeCenterInViewSpace,lt.globeRadius,Tt,0,lt._farZ,Ir),"globe_pole_raster",Zr,Qs,Gs);de.setupElevationDraw(Ws,Je,qt),ne.uploadCommonUniforms($e,Je,Jt.toUnwrapped()),Ut&&ne.renderDefaultNorthPole&&pr(Je,as),ss&&ne.renderDefaultSouthPole&&(Ts=i.cC(i.bb(),Ts,[1,-1,1]),pr(Je,ds))}}}})(D,z,B,W,te);else{const ne=D.context,de=ne.gl;let je,be;const Me=D.shadowRenderer,$e=ac(D,D.longestCutoffRange),Le=zt=>{if(be===zt)return;const bt=[];bt.push(JC[zt]),$e.shouldRenderCutoff&&bt.push("RENDER_CUTOFF"),Me&&(bt.push("RENDER_SHADOWS"),Me.useNormalOffset&&bt.push("NORMAL_OFFSET")),je=D.getOrCreateProgram("terrainRaster",{defines:bt}),be=zt},Je=D.colorModeForRenderPass(),Qe=new kr(de.LEQUAL,kr.ReadWrite,D.depthRangeFor3D);Sd.update(te);const lt=D.transform,mt=Qw(lt.zoom,z.exaggeration(),z.sourceCache._source.tileSize);let nt=[0,0,0];if(Me){const zt=D.style.directionalLight,bt=D.style.ambientLight;zt&&bt&&(nt=Ep(D.style,zt,bt))}{be=-1;const zt=de.TRIANGLES,[bt,Dt]=[z.gridIndexBuffer,z.gridSegments];for(const pt of W){const vt=B.getTile(pt),Tt=sn.disabled,Gt=z.prevTerrainTileForTile[pt.key],qt=z.terrainTileForTile[pt.key];nP(Gt,qt)&&Sd.newMorphing(pt.key,Gt,qt,te,250),Jw(D,vt.emissiveTexture),ne.activeTexture.set(de.TEXTURE0),vt.texture&&vt.texture.bind(de.LINEAR,de.CLAMP_TO_EDGE);const ns=Sd.getMorphValuesForProxy(pt.key),Jt=ns?1:0;let Ns;ns&&(Ns={morphing:{srcDemTile:ns.from,dstDemTile:ns.to,phase:i.dn(ns.phase)}});const Is=D.emissiveMode==="mrt-fallback"?1:0,Zt=Xw(pt.projMatrix,e3(pt.canonical,lt.renderWorldCopies)?mt/10:mt,nt,Is);if(Le(Jt),!je)continue;z.setupElevationDraw(vt,je,Ns);const Ut=pt.toUnwrapped();Me&&Me.setupShadows(Ut,je),D.uploadCommonUniforms(ne,je,Ut,null,$e),je.draw(D,zt,Qe,Tt,Je,Wr.backCCW,Zt,"terrain_raster",z.gridBuffer,bt,Dt)}}}}(v,this,this.proxySourceCache,m,this._updateTimestamp),this.renderingToTexture=!0,v.gpuTimingDeferredRenderEnd(),m.splice(0,m.length))}renderBatch(m){if(this._drapedRenderBatches.length===0)return m+1;this.renderingToTexture=!0;const v=this.painter,E=this.painter.context,D=this.proxySourceCache,z=this.proxiedCoords[D.id],B=this._drapedRenderBatches.shift(),W=v.style.order,te=[];this._updateFBOs(v.emissiveMode==="mrt-fallback");let ne=0;for(const de of z){const je=D.getTileByID(de.proxyTileKey),be=D.proxyCachedFBO[de.key]?D.proxyCachedFBO[de.key][m]:void 0,Me=be!==void 0?D.renderCache[be]:this.pool[ne++],$e=be!==void 0;if(je.texture=Me.tex,je.emissiveTexture=Me.emissiveTex,$e&&!Me.dirty){te.push(je.tileID);continue}E.bindFramebuffer.set(Me.fb.framebuffer);const Le=E.gl;let Je;Le.drawBuffers(v.emissiveMode==="mrt-fallback"?[Le.COLOR_ATTACHMENT0,Le.COLOR_ATTACHMENT1]:[Le.COLOR_ATTACHMENT0]),this.renderedToTile=!1,Me.dirty&&(E.clear({color:i.aq.transparent,stencil:0}),Me.dirty=!1);for(let Qe=B.start;Qe<=B.end;++Qe){const lt=v.style._mergedLayers[W[Qe]];if(lt.isHidden(v.transform.zoom))continue;const mt=v.style.getLayerSourceCache(lt),nt=mt?this.proxyToSource[de.key][mt.id]:[de];if(!nt)continue;const zt=nt;E.viewport.set([0,0,Me.fb.width,Me.fb.height]),Je!==(mt?mt.id:null)&&(this._setupStencil(Me,nt,lt,mt),Je=mt?mt.id:null),v.renderLayer(v,mt,lt,zt)}if(Le.drawBuffers([Le.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Qe of this._pendingGroundEffectLayers){const lt=v.style._mergedLayers[W[Qe]];if(lt.isHidden(v.transform.zoom))continue;const mt=v.style.getLayerSourceCache(lt),nt=mt?this.proxyToSource[de.key][mt.id]:[de];if(!nt)continue;const zt=nt;E.viewport.set([0,0,Me.fb.width,Me.fb.height]),Je!==(mt?mt.id:null)&&(this._setupStencil(Me,nt,lt,mt),Je=mt?mt.id:null),v.renderLayer(v,mt,lt,zt)}this.renderedToTile?(Me.dirty=!0,te.push(je.tileID)):$e||--ne,ne===5&&(ne=0,this.renderToBackBuffer(te))}return this.renderToBackBuffer(te),this.renderingToTexture=!1,E.bindFramebuffer.set(null),E.viewport.set([0,0,v.width,v.height]),B.end+1}postRender(){}isLayerOrderingCorrect(m){const v=m.order.length;let E=-1,D=v;for(let z=0;zE}getMinElevationBelowMSL(){let m=0;return this._visibleDemTiles.filter(v=>v.dem).forEach(v=>{m=Math.min(m,v.dem.tree.minimums[0])}),m===0?m:(m-30)*this._exaggeration}raycast(m,v,E){if(!this._visibleDemTiles)return null;const D=this._visibleDemTiles.filter(z=>z.dem).map(z=>{const B=z.tileID,W=1<(z.t!==null?z.t:Number.MAX_VALUE)-(B.t!==null?B.t:Number.MAX_VALUE));for(const z of D){if(z.t==null)return null;const B=z.tile.dem.tree.raycast(z.minx,z.miny,z.maxx,z.maxy,m,v,E);if(B!=null)return B}return null}_createFBO(){const m=this.painter.context,v=m.gl,E=this.drapeBufferSize;m.activeTexture.set(v.TEXTURE0);const D=new i.T(m,{width:E[0],height:E[1],data:null},v.RGBA8);D.bind(v.LINEAR,v.CLAMP_TO_EDGE);const z=m.createFramebuffer(E[0],E[1],1,null);let B;return z.colorAttachment0.set(D.texture),this._emissiveTexture&&(B=new i.T(m,{width:E[0],height:E[1],data:null},v.R8),B.bind(v.LINEAR,v.CLAMP_TO_EDGE),z.createColorAttachment(m,1),z.colorAttachment1.set(B.texture)),z.depthAttachment=new ype(m,z.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=m.createRenderbuffer(m.gl.DEPTH_STENCIL,E[0],E[1]),this._stencilRef=0,z.depthAttachment.set(this._sharedDepthStencil),m.clear({stencil:0})):z.depthAttachment.set(this._sharedDepthStencil),m.extTextureFilterAnisotropic&&v.texParameterf(v.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax),{fb:z,tex:D,emissiveTex:B,dirty:!1}}_updateFBOs(m){if(this._emissiveTexture!==m){for(const v of this.pool)this._updateFBO(v,m);for(const v of this.proxySourceCache.renderCache)this._updateFBO(v,m);this._emissiveTexture=m}}_updateFBO(m,v){const E=m.fb,D=this.painter.context,z=D.gl,B=this.drapeBufferSize;if(v){const W=new i.T(D,{width:B[0],height:B[1],data:null},z.R8);W.bind(z.LINEAR,z.CLAMP_TO_EDGE),m.emissiveTex=W,E.createColorAttachment(D,1),E.colorAttachment1.set(W.texture)}else m.emissiveTex=void 0,E.removeColorAttachment(D,1);m.dirty=!0}_initFBOPool(){for(;this.pool.length{const v=this._style._mergedLayers[m],E=v.isHidden(this.painter.transform.zoom);return v.type==="hillshade"||v.type==="custom"?!E&&v.shouldRedrape():!E&&v.hasTransition()})}_clearLineLayersFromRenderCache(){let m=!1;for(const E of this._style.getSources())if(E instanceof Gd){m=!0;break}if(!m)return;const v={};for(let E=0;Ete>W.end)||i.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=E}_setupRenderCache(m){const v=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,v.renderCache.length>v.renderCachePool.length){const B=Object.values(v.proxyCachedFBO);v.proxyCachedFBO={};for(let W=0;W=0;B--){const W=E[B];if(v.getTileByID(W.key),v.proxyCachedFBO[W.key]!==void 0){const te=m[W.key],ne=this.proxyToSource[W.key];let de=0;for(const je in ne){const be=ne[je],Me=te[je];if(!Me||Me.length!==be.length||be.some(($e,Le)=>$e!==Me[Le]||D[je]&&D[je].hasOwnProperty($e.key))){de=-1;break}++de}for(const je in v.proxyCachedFBO[W.key])v.renderCache[v.proxyCachedFBO[W.key][je]].dirty=de<0||de!==Object.values(te).length}}const z=[...this._drapedRenderBatches];z.sort((B,W)=>W.end-W.start-(B.end-B.start));for(const B of z)for(const W of E){if(v.proxyCachedFBO[W.key])continue;let te=v.renderCachePool.pop();te===void 0&&v.renderCache.length<50&&(te=v.renderCache.length,v.renderCache.push(this._createFBO())),te!==void 0&&(v.proxyCachedFBO[W.key]={},v.proxyCachedFBO[W.key][B.start]=te,v.renderCache[te].dirty=!0)}this._tilesDirty={}}_setupStencil(m,v,E,D){if(!D||!this._sourceTilesOverlap[D.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const z=this.painter.context,B=z.gl;if(v.length<=1)return void(this._overlapStencilType=!1);let W;if(E.isTileClipped())W=v.length,this._overlapStencilMode.test={func:B.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(v[0].overscaledZ>v[v.length-1].overscaledZ))return void(this._overlapStencilType=!1);W=1,this._overlapStencilMode.test={func:B.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+W>255&&(z.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=W,this._overlapStencilMode.ref=this._stencilRef,E.isTileClipped()&&this._renderTileClippingMasks(v,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(m){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[m.key]),this._overlapStencilMode):sn.disabled}_renderTileClippingMasks(m,v){const E=this.painter,D=this.painter.context,z=D.gl;E._tileClippingMaskIDs={},D.setColorMode(Jr.disabled),D.setDepthMode(kr.disabled);const B=E.getOrCreateProgram("clippingMask");for(const W of m){const te=E._tileClippingMaskIDs[W.key]=--v;B.draw(E,z.TRIANGLES,kr.disabled,new sn({func:z.ALWAYS,mask:0},te,255,z.KEEP,z.KEEP,z.REPLACE),Jr.disabled,Wr.disabled,e2(W.projMatrix),"$clipping",E.tileExtentBuffer,E.quadTriangleIndexBuffer,E.tileExtentSegments)}}pointCoordinate(m){const v=this.painter.transform;if(m.x<0||m.x>v.width||m.y<0||m.y>v.height)return null;const E=[m.x,m.y,1,1];i.aE(E,E,v.pixelMatrixInverse),i.cu(E,E,1/E[3]),E[0]/=v.worldSize,E[1]/=v.worldSize;const D=v._camera.position,z=i.bU(1,v.center.lat),B=[D[0],D[1],D[2]/z,0],W=i.cV([],E.slice(0,3),B);i.ay(W,W);const te=this.raycast(B,W,this._exaggeration);return te!==null&&te?(i.bg(B,B,W,te),B[3]=B[2],B[2]*=z,B):null}_setupProxiedCoordsForOrtho(m,v,E){if(m.getSource()instanceof i.aV)return this._setupProxiedCoordsForImageSource(m,v,E);this._findCoveringTileCache[m.id]=this._findCoveringTileCache[m.id]||{};const D=this.proxiedCoords[m.id]=[],z=this.proxyCoords;for(let te=0;tede.overscaledZ-ne.overscaledZ)}_setupProxiedCoordsForImageSource(m,v,E){if(!m.getSource().loaded())return;const D=this.proxiedCoords[m.id]=[],z=this.proxyCoords,B=m.getSource(),W=B.tileID;if(!W)return;const te=new i.P(W.x,W.y)._div(1<(je.min.x=Math.min(je.min.x,be.x-te.x),je.min.y=Math.min(je.min.y,be.y-te.y),je.max.x=Math.max(je.max.x,be.x-te.x),je.max.y=Math.max(je.max.y,be.y-te.y),je),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),de=(je,be)=>{const Me=je.wrap+je.canonical.x/(1<Je+ne.max.x||$e+LeQe+ne.max.y};for(let je=0;jeB.key===v.tileID.key);if(z)return z}if(v.tileID.key!==m.key){const z=m.canonical.z-v.tileID.canonical.z;let B,W,te;D=i.bb();const ne=v.tileID.wrap-m.wrap<0?(B=i.an>>z,W=B*((v.tileID.canonical.x<=je){const be=m.canonical.z-je;v.getSource().reparseOverscaled?(W=Math.max(m.canonical.z+2,v.transform.tileZoom),B=new i.aR(W,m.wrap,je,m.canonical.x>>be,m.canonical.y>>be)):be!==0&&(W=je,B=new i.aR(W,m.wrap,je,m.canonical.x>>be,m.canonical.y>>be))}B.key!==m.key&&(ne.push(B.key),E=v.getTile(B))}const de=je=>{ne.forEach(be=>{D[be]=je}),ne.length=0};for(W-=1;W>=te&&(!E||!E.hasData());W--){E&&de(E.tileID.key);const je=B.calculateScaledKey(W);if(E=v.getTileByID(je),E&&E.hasData())break;const be=D[je];if(be===null)break;be===void 0?ne.push(je):E=v.getTileByID(be)}return de(E?E.tileID.key:null),E&&E.hasData()?E:null}findDEMTileFor(m){return this.enabled?this._findTileCoveringTileID(m,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(m,v){let E=this._tilesDirty[m];E||(E=this._tilesDirty[m]={}),E[v.key]=!0}}function iP(M,m,v){const E=function(W,te,ne){const de=i.bi(te,W),je=i.bi(ne,[.2126,.7152,.0722]),be=($e,Le,Je)=>(1-Je)*$e+Je*Le,Me=be(1-.3*Math.min(je,1),1,Math.min(de+1,1));return be(.92,1,Math.asin(i.aC(te[2],-1,1))/Math.PI+.5)*Me}(M,[0,0,1],m),D=[0,0,0];i.bJ(D,v.slice(0,3),E);const z=[0,0,0];i.bJ(z,m.slice(0,3),M[2]);const B=[0,0,0];return i.cT(B,D,z),i.cW(B)}const JO=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],eF=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class H0{static cacheKey(m,v,E,D){const z=[v];D&&z.push(D.cacheKey);for(const B of E)(typeof B=="string"&&B.includes(" ")||m.usedDefines.has(B))&&z.push(B);return z.join("/")}constructor(m,v,E,D,z,B){const W=m.gl;this.program=W.createProgram(),this.configuration=D,this.name=v,this.fixedDefines=[...B];const te=`#version 300 es ${(D?D.defines():[]).concat(B.map(Le=>`#define ${Le}`)).join(` `)}`,ne=[te,H1];for(const Le of E.fragmentIncludes)ne.push(Pp[Le]);ne.push(E.fragmentSource);const de=ne.join(` `),je=[te,dpe];for(const Le of E.vertexIncludes)je.push(Pp[Le]);this.forceManualRenderingForInstanceIDShaders=m.forceManualRenderingForInstanceIDShaders&&E.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&je.push("uniform int u_instanceID;"),je.push(E.vertexSource);let be=je.join(` `);this.forceManualRenderingForInstanceIDShaders&&(be=be.replaceAll("gl_InstanceID","u_instanceID"));const Me=W.createShader(W.FRAGMENT_SHADER);if(W.isContextLost())return void(this.failedToCreate=!0);W.shaderSource(Me,de),W.compileShader(Me),W.attachShader(this.program,Me);const $e=W.createShader(W.VERTEX_SHADER);W.isContextLost()?this.failedToCreate=!0:(W.shaderSource($e,be),W.compileShader($e),W.attachShader(this.program,$e),this.attributes={},W.linkProgram(this.program),W.deleteShader($e),W.deleteShader(Me),this.fixedUniforms=z(m),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(m):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Le=>({u_instanceID:new i.bX(Le)}))(m)),(B.includes("TERRAIN")||B.includes("ELEVATED")||v.includes("symbol")||v.includes("circle"))&&(this.terrainUniforms=(Le=>({u_dem:new i.bX(Le),u_dem_prev:new i.bX(Le),u_dem_tl:new i.b_(Le),u_dem_scale:new i.bZ(Le),u_dem_tl_prev:new i.b_(Le),u_dem_scale_prev:new i.bZ(Le),u_dem_size:new i.bZ(Le),u_dem_lerp:new i.bZ(Le),u_exaggeration:new i.bZ(Le),u_depth:new i.bX(Le),u_depth_size_inv:new i.b_(Le),u_depth_range_unpack:new i.b_(Le),u_occluder_half_size:new i.bZ(Le),u_occlusion_depth_offset:new i.bZ(Le),u_meter_to_dem:new i.bZ(Le),u_label_plane_matrix_inv:new i.b$(Le)}))(m)),B.includes("GLOBE")&&(this.globeUniforms=(Le=>({u_tile_tl_up:new i.bY(Le),u_tile_tr_up:new i.bY(Le),u_tile_br_up:new i.bY(Le),u_tile_bl_up:new i.bY(Le),u_tile_up_scale:new i.bZ(Le)}))(m)),B.includes("FOG")&&(this.fogUniforms=(Le=>({u_fog_matrix:new i.b$(Le),u_fog_range:new i.b_(Le),u_fog_color:new i.cO(Le),u_fog_horizon_blend:new i.bZ(Le),u_fog_vertical_limit:new i.b_(Le),u_fog_temporal_offset:new i.bZ(Le),u_frustum_tl:new i.bY(Le),u_frustum_tr:new i.bY(Le),u_frustum_br:new i.bY(Le),u_frustum_bl:new i.bY(Le),u_globe_pos:new i.bY(Le),u_globe_radius:new i.bZ(Le),u_globe_transition:new i.bZ(Le),u_is_globe:new i.bX(Le),u_viewport:new i.b_(Le)}))(m)),B.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Le=>({u_cutoff_params:new i.cO(Le)}))(m)),B.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Le=>({u_lighting_ambient_color:new i.bY(Le),u_lighting_directional_dir:new i.bY(Le),u_lighting_directional_color:new i.bY(Le),u_ground_radiance:new i.bY(Le)}))(m)),B.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Le=>({u_light_matrix_0:new i.b$(Le),u_light_matrix_1:new i.b$(Le),u_fade_range:new i.b_(Le),u_shadow_normal_offset:new i.bY(Le),u_shadow_intensity:new i.bZ(Le),u_shadow_texel_size:new i.bZ(Le),u_shadow_map_resolution:new i.bZ(Le),u_shadow_direction:new i.bY(Le),u_shadow_bias:new i.bY(Le),u_shadowmap_0:new i.bX(Le),u_shadowmap_1:new i.bX(Le)}))(m)))}getAttributeLocation(m,v){let E=this.attributes[v];return E===void 0&&(E=this.attributes[v]=m.getAttribLocation(this.program,v)),E}setTerrainUniformValues(m,v){if(!this.terrainUniforms)return;const E=this.terrainUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)E[D]&&E[D].set(this.program,D,v[D])}}setGlobeUniformValues(m,v){if(!this.globeUniforms)return;const E=this.globeUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)E[D]&&E[D].set(this.program,D,v[D])}}setFogUniformValues(m,v){if(!this.fogUniforms)return;const E=this.fogUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)E[D].set(this.program,D,v[D])}}setCutoffUniformValues(m,v){if(!this.cutoffUniforms)return;const E=this.cutoffUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)E[D].set(this.program,D,v[D])}}setLightsUniformValues(m,v){if(!this.lightsUniforms)return;const E=this.lightsUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)E[D].set(this.program,D,v[D])}}setShadowUniformValues(m,v){if(this.failedToCreate||!this.shadowUniforms)return;const E=this.shadowUniforms;m.program.set(this.program);for(const D in v)E[D].set(this.program,D,v[D])}_drawDebugWireframe(m,v,E,D,z,B,W,te,ne,de){const je=m.options.wireframe;if(je.terrain===!1&&je.layers2D===!1&&je.layers3D===!1)return;const be=m.context;if(!(!(!je.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!je.layers2D||m._terrain&&m._terrain.renderingToTexture||!JO.includes(this.name))||!(!je.layers3D||!eF.includes(this.name))))return;const Me=be.gl,$e=m.wireframeDebugCache.getLinesFromTrianglesBuffer(m.frameCounter,z,be);if(!$e)return;const Le=[...this.fixedDefines,"DEBUG_WIREFRAME"],Je=m.getOrCreateProgram(this.name,{config:this.configuration,defines:Le});be.program.set(Je.program);const Qe=(nt,zt,bt)=>{if(zt[nt]&&bt[nt])for(const Dt in zt[nt])bt[nt][Dt]&&bt[nt][Dt].set(bt.program,Dt,zt[nt][Dt].current)};ne&&ne.setUniforms(Je.program,be,Je.binderUniforms,W,{zoom:te}),Qe("fixedUniforms",this,Je),Qe("terrainUniforms",this,Je),Qe("globeUniforms",this,Je),Qe("fogUniforms",this,Je),Qe("lightsUniforms",this,Je),Qe("shadowUniforms",this,Je),$e.bind(),be.setColorMode(new Jr([Me.ONE,Me.ONE_MINUS_SRC_ALPHA,Me.ZERO,Me.ONE],i.aq.transparent,[!0,!0,!0,!1])),be.setDepthMode(new kr(v.func===Me.LESS?Me.LEQUAL:v.func,kr.ReadOnly,v.range)),be.setStencilMode(sn.disabled);const lt=3*B.primitiveLength*2,mt=3*B.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const nt=de||1;for(let zt=0;zt1?Me.drawElementsInstanced(Me.LINES,lt,Me.UNSIGNED_SHORT,mt,de):Me.drawElements(Me.LINES,lt,Me.UNSIGNED_SHORT,mt);z.bind(),be.program.set(this.program),be.setDepthMode(v),be.setStencilMode(E),be.setColorMode(D)}checkUniforms(m,v,E){if(this.fixedDefines.includes(v)){for(const D of Object.keys(E))if(!E[D].initialized)throw new Error(`Program '${this.name}', from draw '${m}': uniform ${D} not set but required by ${v} being defined`)}}draw(m,v,E,D,z,B,W,te,ne,de,je,be,Me,$e,Le,Je){const Qe=m.context,lt=Qe.gl;if(this.failedToCreate)return;Qe.program.set(this.program),Qe.setDepthMode(E),Qe.setStencilMode(D),Qe.setColorMode(z),Qe.setCullFace(B);for(const[pt,vt]of this.fixedUniformsEntries)vt.set(this.program,pt,W[pt]);$e&&$e.setUniforms(this.program,Qe,this.binderUniforms,be,{zoom:Me});const mt={[lt.POINTS]:1,[lt.LINES]:2,[lt.TRIANGLES]:3,[lt.LINE_STRIP]:1}[v];this.checkUniforms(te,"RENDER_SHADOWS",this.shadowUniforms);const nt=Le||[],zt=$e?$e.getPaintVertexBuffers():[],bt=v===lt.TRIANGLES&&de,Dt=Je&&Je>0?1:void 0;for(const pt of je.get()){const vt=pt.vaos||(pt.vaos={});if((vt[te]||(vt[te]=new qO)).bind(Qe,this,ne,zt,de,pt.vertexOffset,nt,Dt),this.forceManualRenderingForInstanceIDShaders){const Tt=Je||1;for(let Gt=0;Gt1?lt.drawElementsInstanced(v,pt.primitiveLength*mt,lt.UNSIGNED_SHORT,pt.primitiveOffset*mt*2,Je):de?lt.drawElements(v,pt.primitiveLength*mt,lt.UNSIGNED_SHORT,pt.primitiveOffset*mt*2):lt.drawArrays(v,pt.vertexOffset,pt.vertexLength);bt&&this._drawDebugWireframe(m,E,D,z,de,pt,be,Me,$e,Je)}}}function tF(M,m,v=0){const E=Math.pow(2,m.tileID.overscaledZ),D=m.tileSize*Math.pow(2,M.transform.tileZoom)/E,z=D*(m.tileID.canonical.x+m.tileID.wrap*E),B=D*m.tileID.canonical.y;return{u_image:0,u_texsize:m.imageAtlasTexture?m.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/i.aA(m,1,M.transform.tileZoom),u_pixel_coord_upper:[z>>16,B>>16],u_pixel_coord_lower:[65535&z,65535&B],u_pattern_transition:v}}const r3={terrain:0,flat:1},vpe=i.bb(),sF=(M,m,v,E,D,z,B,W,te,ne,de,je,be,Me,$e,Le,Je,Qe,lt=[0,0,1])=>{const mt=m.style.light,nt=mt.properties.get("position"),zt=[nt.x,nt.y,nt.z],bt=i.dE();mt.properties.get("anchor")==="viewport"&&(i.dF(bt,-m.transform.angle),i.dG(zt,zt,bt));const Dt=mt.properties.get("color").toPremultipliedRenderColor(null),pt=m.transform,vt={u_matrix:M,u_lightpos:zt,u_lightintensity:mt.properties.get("intensity"),u_lightcolor:[Dt.r,Dt.g,Dt.b],u_vertical_gradient:+v,u_opacity:E,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:vpe,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:r3[ne],u_base_type:r3[de],u_ao:D,u_edge_radius:z,u_width_scale:B,u_flood_light_color:$e,u_vertical_scale:Le,u_flood_light_intensity:Je,u_ground_shadow_factor:Qe,u_front_cutoff_params:lt};return pt.projection.name==="globe"&&(vt.u_tile_id=[W.canonical.x,W.canonical.y,1<({u_matrix:M,u_edge_radius:m,u_width_scale:v,u_vertical_scale:E,u_height_type:r3[D],u_base_type:r3[z]}),bpe=(M,m,v,E,D,z,B,W,te,ne,de,je,be,Me,$e,Le,Je,Qe)=>{const lt=sF(M,m,v,E,D,z,B,W,ne,de,je,be,Me,$e,Le,Je,1,[0,0,0]),mt={u_height_factor:-Math.pow(2,W.overscaledZ)/te.tileSize/8};return Object.assign(lt,tF(m,te,Qe),mt)},n3=(M,m,v)=>({u_matrix:M,u_emissive_strength:m,u_ground_shadow_factor:v}),a3=(M,m,v,E,D,z=0)=>Object.assign(n3(M,m,D),tF(v,E,z)),rF=(M,m,v,E)=>({u_matrix:M,u_world:v,u_emissive_strength:m,u_ground_shadow_factor:E}),X1=(M,m,v,E,D,z,B=0)=>Object.assign(a3(M,m,v,E,z,B),{u_world:D}),nF=(M,m)=>({u_matrix:M,u_depth_bias:m}),aF=(M,m)=>({u_matrix:M,u_ground_shadow_factor:m}),r2=(M,m,v,E,D)=>({u_matrix:M,u_camera_pos:[m[0],m[1],m[2]],u_depth_bias:v,u_height_scale:E,u_reset_depth:D}),i3=(M,m,v)=>({u_image:M,u_opacity:m,u_blend_mode:v}),oy=(M,m,v,E,D,z,B,W,te,ne=[0,0,1])=>({u_matrix:M,u_normal_matrix:m,u_opacity:v,u_faux_facade_ao_intensity:E,u_camera_pos:D,u_tile_to_meter:z,u_facade_emissive_chance:B,u_flood_light_color:W,u_flood_light_intensity:te,u_front_cutoff_params:ne}),o3=M=>({u_matrix:M}),l3=M=>({u_matrix:M}),iF=(M,m,v,E,D,z,B,W)=>{const te=i.an/z.tileSize;return{u_matrix:M,u_inv_rot_matrix:m,u_camera_to_center_distance:v.getCameraToCenterDistance(W),u_extrude_scale:[v.pixelsToGLUnits[0]/te,v.pixelsToGLUnits[1]/te],u_zoom_transition:E,u_tile_id:B,u_merc_center:D}},ly=(M,m,v,E)=>({u_matrix:M,u_inv_matrix:m,u_camera_to_center_distance:v.getCameraToCenterDistance(E),u_viewport_size:[v.width,v.height]}),n2=(M,m,v=1)=>({u_matrix:M,u_color:m,u_overlay:0,u_overlay_scale:v}),c3=i.bb(),oF=(M,m,v,E,D,z,B)=>{const W=M.transform,te=W.projection.name==="globe",ne=te?i.dH(W.zoom,m.canonical)*W._pixelsPerMercatorPixel:i.aA(v,1,z),de={u_matrix:m.projMatrix,u_extrude_scale:ne,u_intensity:B,u_inv_rot_matrix:c3,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(te){de.u_inv_rot_matrix=E,de.u_merc_center=D,de.u_tile_id=[m.canonical.x,m.canonical.y,1<({u_matrix:m,u_normalize_matrix:v,u_globe_matrix:E,u_merc_matrix:D,u_grid_matrix:z,u_tl_parent:B,u_scale_parent:de,u_fade_t:je.mix,u_opacity:je.opacity*be.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:be.paint.get("raster-brightness-min"),u_brightness_high:be.paint.get("raster-brightness-max"),u_saturation_factor:i.dJ(be.paint.get("raster-saturation")),u_contrast_factor:i.dI(be.paint.get("raster-contrast")),u_spin_weights:cF(be.paint.get("raster-hue-rotate")),u_perspective_transform:Me,u_raster_elevation:$e,u_zoom_transition:W,u_merc_center:te,u_cutoff_params:ne,u_colorization_mix:oP(i.dK,Je,lt),u_colorization_offset:d3(i.dK,Qe,lt),u_color_ramp:Le,u_texture_offset:[nt/(mt+2*nt),mt/(mt+2*nt)],u_texture_res:[mt+2*nt,mt+2*nt],u_emissive_strength:zt,u_zbias_factor:lP(M)});function cF(M){M*=Math.PI/180;const m=Math.sin(M),v=Math.cos(M);return[(2*v+1)/3,(-Math.sqrt(3)*m-v+1)/3,(Math.sqrt(3)*m-v+1)/3]}const Rf=.05,wpe=(M,m,v,E,D,z,B,W,te,ne,de,je)=>({u_matrix:M,u_normalize_matrix:m,u_globe_matrix:v,u_merc_matrix:E,u_grid_matrix:D,u_tl_parent:z,u_scale_parent:ne,u_fade_t:de.mix,u_opacity:de.opacity,u_image0:0,u_image1:1,u_raster_elevation:je,u_zoom_transition:B,u_merc_center:W,u_cutoff_params:te}),jpe=(M,m,v,E,D,z,B,W,te,ne)=>({u_particle_texture:M,u_particle_texture_side_len:m,u_tile_offset:v,u_velocity:E,u_color_ramp:z,u_velocity_res:D,u_max_speed:B,u_uv_offset:W,u_data_scale:[255*te[0],255*te[1]],u_data_offset:ne,u_particle_pos_scale:1.1,u_particle_pos_offset:[Rf,Rf]}),dF=(M,m,v,E,D,z,B,W,te,ne)=>({u_particle_texture:M,u_particle_texture_side_len:m,u_velocity:v,u_velocity_res:E,u_max_speed:D,u_speed_factor:z,u_reset_rate:B,u_rand_seed:Math.random(),u_uv_offset:W,u_data_scale:[255*te[0],255*te[1]],u_data_offset:ne,u_particle_pos_scale:1.1,u_particle_pos_offset:[Rf,Rf]}),uF=i.bb(),u3=(M,m,v,E,D,z,B,W,te,ne,de,je,be,Me,$e,Le,Je,Qe,lt,mt,nt,zt,bt,Dt)=>{const pt=D.transform,vt={u_is_size_zoom_constant:+(M==="constant"||M==="source"),u_is_size_feature_constant:+(M==="constant"||M==="camera"),u_size_t:m?m.uSizeT:0,u_size:m?m.uSize:0,u_camera_to_center_distance:pt.getCameraToCenterDistance(lt),u_rotate_symbol:+v,u_aspect_ratio:pt.width/pt.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:z,u_label_plane_matrix:B,u_coord_matrix:W,u_is_text:+ne,u_elevation_from_sea:te?1:0,u_pitch_with_map:+E,u_texsize:de,u_texsize_icon:je,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:uF,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:uF,u_up_vector:[0,-1,0],u_color_adj_mat:zt,u_icon_transition:bt||0,u_gamma_scale:E?D.transform.getCameraToCenterDistance(lt)*Math.cos(D.terrain?0:D.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:Dt||1,u_ground_shadow_factor:mt,u_inv_matrix:i.b7(i.bb(),B),u_normal_scale:nt,u_lutTexture:10,u_zoom:pt.zoom-Math.floor(pt.zoom),u_spp_fill_np_color:[0,0,0,1],u_spp_halo_np_color:[0,0,0,0],u_spp_opacity:1,u_spp_halo_width:0,u_spp_halo_blur:0,u_spp_emissive_strength:0,u_spp_occlusion_opacity:1,u_spp_z_offset:0,u_spp_translate_rotation:[1,0]};return lt.name==="globe"&&(vt.u_tile_id=[Me.canonical.x,Me.canonical.y,1<({u_matrix:M,u_emissive_strength:m,u_opacity:v,u_color:E}),cy=(M,m,v,E,D,z,B,W,te)=>Object.assign(function(ne,de,je,be,Me,$e){const{width:Le,height:Je}=be.imageManager.getPixelSize(de),Qe=Math.pow(2,$e.tileID.overscaledZ),lt=$e.tileSize*Math.pow(2,be.transform.tileZoom)/Qe,mt=lt*($e.tileID.canonical.x+$e.tileID.wrap*Qe),nt=lt*$e.tileID.canonical.y;return{u_image:0,u_pattern_tl:je.tl,u_pattern_br:je.br,u_texsize:[Le,Je],u_pattern_size:je.displaySize,u_pattern_units_to_pixels:Me?[be.transform.width,-1*be.transform.height]:[1/i.aA($e,1,be.transform.tileZoom),1/i.aA($e,1,be.transform.tileZoom)],u_pixel_coord_upper:[mt>>16,nt>>16],u_pixel_coord_lower:[65535&mt,65535&nt]}}(0,z,B,E,W,te),{u_matrix:M,u_emissive_strength:m,u_opacity:v}),Q1=new Float32Array(i.b9([])),G0=(M,m,v,E,D,z,B,W,te,ne,de,je,be,Me=[0,0,0],$e,Le,Je)=>{const Qe=D.style.light,lt=Qe.properties.get("position"),mt=[-lt.x,-lt.y,lt.z],nt=i.dE();Qe.properties.get("anchor")==="viewport"&&(i.dF(nt,-D.transform.angle),i.dG(mt,mt,nt));const zt=de.alphaMode==="MASK",bt=Qe.properties.get("color").toNonPremultipliedRenderColor(null),Dt=be.paint.get("model-ambient-occlusion-intensity"),pt=be.paint.get("model-color").constantOr(i.aq.white).toNonPremultipliedRenderColor(null);return pt.a=be.paint.get("model-color-mix-intensity").constantOr(0),Je&&(pt.r=Je[0],pt.g=Je[1],pt.b=Je[2],pt.a=Je[3]),Le&&(pt.r=Le.color.r,pt.g=Le.color.g,pt.b=Le.color.b,pt.a=Le.colorMix,je=Le.emissionStrength,z*=Le.opacity),{u_matrix:M,u_lighting_matrix:m,u_normal_matrix:v,u_node_matrix:E||Q1,u_lightpos:mt,u_lightintensity:Qe.properties.get("intensity"),u_lightcolor:[bt.r,bt.g,bt.b],u_camera_pos:Me,u_opacity:z,u_baseTextureIsAlpha:0,u_alphaMask:+zt,u_alphaCutoff:de.alphaCutoff,u_baseColorFactor:B.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:W.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:te,u_roughnessFactor:ne,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:pt.toArray01(),u_aoIntensity:Dt,u_emissive_strength:je,u_occlusionTextureTransform:$e||[0,0,0,0]}},cP=(M,m=Q1,v=Q1)=>({u_matrix:M,u_instance:m,u_node_matrix:v}),h3={fillExtrusion:M=>({u_matrix:new i.b$(M),u_lightpos:new i.bY(M),u_lightintensity:new i.bZ(M),u_lightcolor:new i.bY(M),u_vertical_gradient:new i.bZ(M),u_opacity:new i.bZ(M),u_edge_radius:new i.bZ(M),u_width_scale:new i.bZ(M),u_ao:new i.b_(M),u_height_type:new i.bX(M),u_base_type:new i.bX(M),u_tile_id:new i.bY(M),u_zoom_transition:new i.bZ(M),u_inv_rot_matrix:new i.b$(M),u_merc_center:new i.b_(M),u_up_dir:new i.bY(M),u_height_lift:new i.bZ(M),u_flood_light_color:new i.bY(M),u_vertical_scale:new i.bZ(M),u_flood_light_intensity:new i.bZ(M),u_ground_shadow_factor:new i.bY(M),u_front_cutoff_params:new i.bY(M)}),fillExtrusionDepth:M=>({u_matrix:new i.b$(M),u_edge_radius:new i.bZ(M),u_width_scale:new i.bZ(M),u_vertical_scale:new i.bZ(M),u_height_type:new i.bX(M),u_base_type:new i.bX(M)}),fillExtrusionPattern:M=>({u_matrix:new i.b$(M),u_lightpos:new i.bY(M),u_lightintensity:new i.bZ(M),u_lightcolor:new i.bY(M),u_vertical_gradient:new i.bZ(M),u_height_factor:new i.bZ(M),u_edge_radius:new i.bZ(M),u_width_scale:new i.bZ(M),u_ao:new i.b_(M),u_height_type:new i.bX(M),u_base_type:new i.bX(M),u_tile_id:new i.bY(M),u_zoom_transition:new i.bZ(M),u_inv_rot_matrix:new i.b$(M),u_merc_center:new i.b_(M),u_up_dir:new i.bY(M),u_height_lift:new i.bZ(M),u_image:new i.bX(M),u_texsize:new i.b_(M),u_pixel_coord_upper:new i.b_(M),u_pixel_coord_lower:new i.b_(M),u_tile_units_to_pixels:new i.bZ(M),u_opacity:new i.bZ(M),u_pattern_transition:new i.bZ(M)}),fillExtrusionGroundEffect:M=>({u_matrix:new i.b$(M),u_opacity:new i.bZ(M),u_ao_pass:new i.bZ(M),u_meter_to_tile:new i.bZ(M),u_ao:new i.b_(M),u_flood_light_intensity:new i.bZ(M),u_flood_light_color:new i.bY(M),u_attenuation:new i.bZ(M),u_edge_radius:new i.bZ(M),u_fb:new i.bX(M),u_fb_size:new i.bZ(M),u_dynamic_offset:new i.bZ(M)}),fill:M=>({u_matrix:new i.b$(M),u_emissive_strength:new i.bZ(M),u_ground_shadow_factor:new i.bY(M)}),fillPattern:M=>({u_matrix:new i.b$(M),u_emissive_strength:new i.bZ(M),u_image:new i.bX(M),u_texsize:new i.b_(M),u_pixel_coord_upper:new i.b_(M),u_pixel_coord_lower:new i.b_(M),u_tile_units_to_pixels:new i.bZ(M),u_ground_shadow_factor:new i.bY(M),u_pattern_transition:new i.bZ(M)}),fillOutline:M=>({u_matrix:new i.b$(M),u_emissive_strength:new i.bZ(M),u_world:new i.b_(M),u_ground_shadow_factor:new i.bY(M)}),fillOutlinePattern:M=>({u_matrix:new i.b$(M),u_emissive_strength:new i.bZ(M),u_world:new i.b_(M),u_image:new i.bX(M),u_texsize:new i.b_(M),u_pixel_coord_upper:new i.b_(M),u_pixel_coord_lower:new i.b_(M),u_tile_units_to_pixels:new i.bZ(M),u_ground_shadow_factor:new i.bY(M),u_pattern_transition:new i.bZ(M)}),lineBlendComposite:M=>({u_image:new i.bX(M),u_opacity:new i.bZ(M),u_blend_mode:new i.bX(M)}),building:M=>({u_matrix:new i.b$(M),u_normal_matrix:new i.b$(M),u_opacity:new i.bZ(M),u_faux_facade_ao_intensity:new i.bZ(M),u_camera_pos:new i.bY(M),u_tile_to_meter:new i.bZ(M),u_facade_emissive_chance:new i.bZ(M),u_flood_light_color:new i.bY(M),u_flood_light_intensity:new i.bZ(M),u_front_cutoff_params:new i.bY(M)}),buildingBloom:M=>({u_matrix:new i.b$(M)}),buildingDepth:M=>({u_matrix:new i.b$(M)}),elevatedStructuresDepth:M=>({u_matrix:new i.b$(M),u_depth_bias:new i.bZ(M)}),elevatedStructures:M=>({u_matrix:new i.b$(M),u_ground_shadow_factor:new i.bY(M)}),elevatedStructuresDepthReconstruct:M=>({u_matrix:new i.b$(M),u_camera_pos:new i.bY(M),u_depth_bias:new i.bZ(M),u_height_scale:new i.bZ(M),u_reset_depth:new i.bZ(M)}),circle:i.dO,collisionBox:M=>({u_matrix:new i.b$(M),u_inv_rot_matrix:new i.b$(M),u_camera_to_center_distance:new i.bZ(M),u_extrude_scale:new i.b_(M),u_zoom_transition:new i.bZ(M),u_merc_center:new i.b_(M),u_tile_id:new i.bY(M)}),collisionCircle:M=>({u_matrix:new i.b$(M),u_inv_matrix:new i.b$(M),u_camera_to_center_distance:new i.bZ(M),u_viewport_size:new i.b_(M)}),debug:M=>({u_color:new i.dl(M),u_matrix:new i.b$(M),u_overlay:new i.bX(M),u_overlay_scale:new i.bZ(M)}),clippingMask:M=>({u_matrix:new i.b$(M)}),heatmap:M=>({u_extrude_scale:new i.bZ(M),u_intensity:new i.bZ(M),u_matrix:new i.b$(M),u_inv_rot_matrix:new i.b$(M),u_merc_center:new i.b_(M),u_tile_id:new i.bY(M),u_zoom_transition:new i.bZ(M),u_up_dir:new i.bY(M)}),heatmapTexture:M=>({u_image:new i.bX(M),u_color_ramp:new i.bX(M),u_opacity:new i.bZ(M)}),hillshade:M=>({u_matrix:new i.b$(M),u_image:new i.bX(M),u_latrange:new i.b_(M),u_light:new i.b_(M),u_shadow:new i.dl(M),u_highlight:new i.dl(M),u_emissive_strength:new i.bZ(M),u_accent:new i.dl(M)}),hillshadePrepare:M=>({u_matrix:new i.b$(M),u_image:new i.bX(M),u_dimension:new i.b_(M),u_zoom:new i.bZ(M)}),line:i.dN,linePattern:i.dM,raster:M=>({u_matrix:new i.b$(M),u_normalize_matrix:new i.b$(M),u_globe_matrix:new i.b$(M),u_merc_matrix:new i.b$(M),u_grid_matrix:new i.dm(M),u_tl_parent:new i.b_(M),u_scale_parent:new i.bZ(M),u_fade_t:new i.bZ(M),u_opacity:new i.bZ(M),u_image0:new i.bX(M),u_image1:new i.bX(M),u_brightness_low:new i.bZ(M),u_brightness_high:new i.bZ(M),u_saturation_factor:new i.bZ(M),u_contrast_factor:new i.bZ(M),u_spin_weights:new i.bY(M),u_perspective_transform:new i.b_(M),u_raster_elevation:new i.bZ(M),u_zoom_transition:new i.bZ(M),u_merc_center:new i.b_(M),u_cutoff_params:new i.cO(M),u_colorization_mix:new i.cO(M),u_colorization_offset:new i.bZ(M),u_color_ramp:new i.bX(M),u_texture_offset:new i.b_(M),u_texture_res:new i.b_(M),u_emissive_strength:new i.bZ(M),u_zbias_factor:new i.bZ(M)}),rasterParticle:M=>({u_matrix:new i.b$(M),u_normalize_matrix:new i.b$(M),u_globe_matrix:new i.b$(M),u_merc_matrix:new i.b$(M),u_grid_matrix:new i.dm(M),u_tl_parent:new i.b_(M),u_scale_parent:new i.bZ(M),u_fade_t:new i.bZ(M),u_opacity:new i.bZ(M),u_image0:new i.bX(M),u_image1:new i.bX(M),u_raster_elevation:new i.bZ(M),u_zoom_transition:new i.bZ(M),u_merc_center:new i.b_(M),u_cutoff_params:new i.cO(M)}),rasterParticleTexture:M=>({u_texture:new i.bX(M),u_opacity:new i.bZ(M)}),rasterParticleDraw:M=>({u_particle_texture:new i.bX(M),u_particle_texture_side_len:new i.bZ(M),u_tile_offset:new i.b_(M),u_velocity:new i.bX(M),u_color_ramp:new i.bX(M),u_velocity_res:new i.b_(M),u_max_speed:new i.bZ(M),u_uv_offset:new i.b_(M),u_data_scale:new i.b_(M),u_data_offset:new i.bZ(M),u_particle_pos_scale:new i.bZ(M),u_particle_pos_offset:new i.b_(M)}),rasterParticleUpdate:M=>({u_particle_texture:new i.bX(M),u_particle_texture_side_len:new i.bZ(M),u_velocity:new i.bX(M),u_velocity_res:new i.b_(M),u_max_speed:new i.bZ(M),u_speed_factor:new i.bZ(M),u_reset_rate:new i.bZ(M),u_rand_seed:new i.bZ(M),u_uv_offset:new i.b_(M),u_data_scale:new i.b_(M),u_data_offset:new i.bZ(M),u_particle_pos_scale:new i.bZ(M),u_particle_pos_offset:new i.b_(M)}),symbol:M=>({u_is_size_zoom_constant:new i.bX(M),u_is_size_feature_constant:new i.bX(M),u_size_t:new i.bZ(M),u_size:new i.bZ(M),u_camera_to_center_distance:new i.bZ(M),u_rotate_symbol:new i.bX(M),u_aspect_ratio:new i.bZ(M),u_fade_change:new i.bZ(M),u_matrix:new i.b$(M),u_label_plane_matrix:new i.b$(M),u_coord_matrix:new i.b$(M),u_is_text:new i.bX(M),u_elevation_from_sea:new i.bX(M),u_pitch_with_map:new i.bX(M),u_texsize:new i.b_(M),u_texsize_icon:new i.b_(M),u_texture:new i.bX(M),u_texture_icon:new i.bX(M),u_gamma_scale:new i.bZ(M),u_device_pixel_ratio:new i.bZ(M),u_tile_id:new i.bY(M),u_zoom_transition:new i.bZ(M),u_inv_rot_matrix:new i.b$(M),u_merc_center:new i.b_(M),u_camera_forward:new i.bY(M),u_tile_matrix:new i.b$(M),u_up_vector:new i.bY(M),u_ecef_origin:new i.bY(M),u_is_halo:new i.bX(M),u_icon_transition:new i.bZ(M),u_color_adj_mat:new i.b$(M),u_scale_factor:new i.bZ(M),u_ground_shadow_factor:new i.bY(M),u_inv_matrix:new i.b$(M),u_normal_scale:new i.bZ(M),u_lutTexture:new i.bX(M),u_zoom:new i.bZ(M),u_spp_fill_np_color:new i.cO(M),u_spp_halo_np_color:new i.cO(M),u_spp_opacity:new i.bZ(M),u_spp_halo_width:new i.bZ(M),u_spp_halo_blur:new i.bZ(M),u_spp_emissive_strength:new i.bZ(M),u_spp_occlusion_opacity:new i.bZ(M),u_spp_z_offset:new i.bZ(M),u_spp_translate_rotation:new i.b_(M)}),background:M=>({u_matrix:new i.b$(M),u_emissive_strength:new i.bZ(M),u_opacity:new i.bZ(M),u_color:new i.dl(M)}),backgroundPattern:M=>({u_matrix:new i.b$(M),u_emissive_strength:new i.bZ(M),u_opacity:new i.bZ(M),u_image:new i.bX(M),u_pattern_tl:new i.b_(M),u_pattern_br:new i.b_(M),u_texsize:new i.b_(M),u_pattern_size:new i.b_(M),u_pixel_coord_upper:new i.b_(M),u_pixel_coord_lower:new i.b_(M),u_pattern_units_to_pixels:new i.b_(M)}),terrainRaster:M=>({u_matrix:new i.b$(M),u_image0:new i.bX(M),u_image1:new i.bX(M),u_skirt_height:new i.bZ(M),u_ground_shadow_factor:new i.bY(M),u_emissive_texture_available:new i.bZ(M)}),skybox:M=>({u_matrix:new i.b$(M),u_sun_direction:new i.bY(M),u_cubemap:new i.bX(M),u_opacity:new i.bZ(M),u_temporal_offset:new i.bZ(M)}),skyboxGradient:M=>({u_matrix:new i.b$(M),u_color_ramp:new i.bX(M),u_center_direction:new i.bY(M),u_radius:new i.bZ(M),u_opacity:new i.bZ(M),u_temporal_offset:new i.bZ(M)}),skyboxCapture:M=>({u_matrix_3f:new i.dm(M),u_sun_direction:new i.bY(M),u_sun_intensity:new i.bZ(M),u_color_tint_r:new i.cO(M),u_color_tint_m:new i.cO(M),u_luminance:new i.bZ(M)}),globeRaster:M=>({u_proj_matrix:new i.b$(M),u_globe_matrix:new i.b$(M),u_normalize_matrix:new i.b$(M),u_merc_matrix:new i.b$(M),u_zoom_transition:new i.bZ(M),u_merc_center:new i.b_(M),u_image0:new i.bX(M),u_image1:new i.bX(M),u_grid_matrix:new i.dm(M),u_skirt_height:new i.bZ(M),u_far_z_cutoff:new i.bZ(M),u_frustum_tl:new i.bY(M),u_frustum_tr:new i.bY(M),u_frustum_br:new i.bY(M),u_frustum_bl:new i.bY(M),u_globe_pos:new i.bY(M),u_globe_radius:new i.bZ(M),u_viewport:new i.b_(M),u_emissive_texture_available:new i.bZ(M)}),globeAtmosphere:M=>({u_frustum_tl:new i.bY(M),u_frustum_tr:new i.bY(M),u_frustum_br:new i.bY(M),u_frustum_bl:new i.bY(M),u_horizon:new i.bZ(M),u_transition:new i.bZ(M),u_fadeout_range:new i.bZ(M),u_atmosphere_fog_color:new i.cO(M),u_high_color:new i.cO(M),u_space_color:new i.cO(M),u_temporal_offset:new i.bZ(M),u_horizon_angle:new i.bZ(M)}),model:M=>({u_matrix:new i.b$(M),u_lighting_matrix:new i.b$(M),u_normal_matrix:new i.b$(M),u_node_matrix:new i.b$(M),u_lightpos:new i.bY(M),u_lightintensity:new i.bZ(M),u_lightcolor:new i.bY(M),u_camera_pos:new i.bY(M),u_opacity:new i.bZ(M),u_baseColorFactor:new i.cO(M),u_emissiveFactor:new i.cO(M),u_metallicFactor:new i.bZ(M),u_roughnessFactor:new i.bZ(M),u_baseTextureIsAlpha:new i.bX(M),u_alphaMask:new i.bX(M),u_alphaCutoff:new i.bZ(M),u_baseColorTexture:new i.bX(M),u_metallicRoughnessTexture:new i.bX(M),u_normalTexture:new i.bX(M),u_occlusionTexture:new i.bX(M),u_emissionTexture:new i.bX(M),u_lutTexture:new i.bX(M),u_color_mix:new i.cO(M),u_aoIntensity:new i.bZ(M),u_emissive_strength:new i.bZ(M),u_occlusionTextureTransform:new i.cO(M)}),modelDepth:M=>({u_matrix:new i.b$(M),u_instance:new i.b$(M),u_node_matrix:new i.b$(M)}),groundShadow:M=>({u_matrix:new i.b$(M),u_ground_shadow_factor:new i.bY(M)}),stars:M=>({u_matrix:new i.b$(M),u_up:new i.bY(M),u_right:new i.bY(M),u_intensity_multiplier:new i.bZ(M)}),snowParticle:M=>({u_modelview:new i.b$(M),u_projection:new i.b$(M),u_time:new i.bZ(M),u_cam_pos:new i.bY(M),u_velocityConeAperture:new i.bZ(M),u_velocity:new i.bZ(M),u_horizontalOscillationRadius:new i.bZ(M),u_horizontalOscillationRate:new i.bZ(M),u_boxSize:new i.bZ(M),u_billboardSize:new i.bZ(M),u_simpleShapeParameters:new i.b_(M),u_screenSize:new i.b_(M),u_thinningCenterPos:new i.b_(M),u_thinningShape:new i.bY(M),u_thinningAffectedRatio:new i.bZ(M),u_thinningParticleOffset:new i.bZ(M),u_particleColor:new i.cO(M),u_direction:new i.bY(M)}),rainParticle:M=>({u_modelview:new i.b$(M),u_projection:new i.b$(M),u_time:new i.bZ(M),u_cam_pos:new i.bY(M),u_texScreen:new i.bX(M),u_velocityConeAperture:new i.bZ(M),u_velocity:new i.bZ(M),u_boxSize:new i.bZ(M),u_rainDropletSize:new i.b_(M),u_distortionStrength:new i.bZ(M),u_rainDirection:new i.bY(M),u_color:new i.cO(M),u_screenSize:new i.b_(M),u_thinningCenterPos:new i.b_(M),u_thinningShape:new i.bY(M),u_thinningAffectedRatio:new i.bZ(M),u_thinningParticleOffset:new i.bZ(M),u_shapeDirectionalPower:new i.bZ(M),u_shapeNormalPower:new i.bZ(M),u_mode:new i.bZ(M)}),vignette:M=>({u_vignetteShape:new i.bY(M),u_vignetteColor:new i.cO(M)}),occlusion:M=>({u_matrix:new i.b$(M),u_anchorPos:new i.bY(M),u_screenSizePx:new i.b_(M),u_occluderSizePx:new i.b_(M),u_color:new i.cO(M)})};class Ip{constructor(m,v,E,D){this.id=Ip.uniqueIdxCounter,Ip.uniqueIdxCounter++,this.context=m;const z=m.gl;this.buffer=z.createBuffer(),this.dynamicDraw=!!E,this.context.unbindVAO(),m.bindElementBuffer.set(this.buffer),z.bufferData(z.ELEMENT_ARRAY_BUFFER,v.arrayBuffer,this.dynamicDraw?z.DYNAMIC_DRAW:z.STATIC_DRAW),this.dynamicDraw||D||v.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(m){this.id=Ip.uniqueIdxCounter,Ip.uniqueIdxCounter++;const v=this.context.gl;this.context.unbindVAO(),this.bind(),v.bufferSubData(v.ELEMENT_ARRAY_BUFFER,0,m.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Ip.uniqueIdxCounter=0;const dP={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class hF{constructor(m,v,E,D,z,B){this.length=v.length,this.attributes=E,this.itemSize=v.bytesPerElement,this.dynamicDraw=D,this.instanceCount=B,this.context=m;const W=m.gl;this.buffer=W.createBuffer(),m.bindVertexBuffer.set(this.buffer),W.bufferData(W.ARRAY_BUFFER,v.arrayBuffer,this.dynamicDraw?W.DYNAMIC_DRAW:W.STATIC_DRAW),this.dynamicDraw||z||v.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(m){const v=this.context.gl;this.bind(),v.bufferSubData(v.ARRAY_BUFFER,0,m.arrayBuffer)}enableAttributes(m,v){for(const E of this.attributes){const D=v.getAttributeLocation(m,E.name);D!==-1&&m.enableVertexAttribArray(D)}}setVertexAttribPointers(m,v,E){for(const D of this.attributes){const z=v.getAttributeLocation(m,D.name);if(z!==-1){const B=D.offset+this.itemSize*(E||0);D.type==="Float32"?m.vertexAttribPointer(z,D.components,m.FLOAT,!1,this.itemSize,B):m.vertexAttribIPointer(z,D.components,m[dP[D.type]],this.itemSize,B)}}}setVertexAttribDivisor(m,v,E){for(let D=0;D0&&m.vertexAttribDivisor(z,E)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class i2{constructor(m,v,E,D,z){this.context=m,this.width=v,this.height=E;const B=this.framebuffer=m.gl.createFramebuffer();D>0&&(this.colorAttachment0=new Z1(m,B,0)),D>1&&(this.colorAttachment1=new Z1(m,B,1)),z&&(this.depthAttachmentType=z,this.depthAttachment=z==="renderbuffer"?new rP(m,B):new QO(m,B))}static createWithTexture(m,v,E,D,z){const B=m.gl;if(m.activeTexture.set(B.TEXTURE1),m.viewport.set([0,0,E,D]),v&&v.width===E&&v.height===D)return B.bindTexture(B.TEXTURE_2D,v.colorAttachment0.get()),m.bindFramebuffer.set(v.framebuffer),v;v&&v.destroy();const W=new i.T(m,{width:E,height:D,data:null},m.extRenderToTextureHalfFloat?m.gl.RGBA16F:m.gl.RGBA8);W.bind(B.LINEAR,B.CLAMP_TO_EDGE);const te=m.createFramebuffer(E,D,1,null);if(te.colorAttachment0.set(W.texture),z){const ne=m.createRenderbuffer(B.DEPTH24_STENCIL8,E,D);m.bindFramebuffer.set(te.framebuffer),B.framebufferRenderbuffer(B.FRAMEBUFFER,B.DEPTH_STENCIL_ATTACHMENT,B.RENDERBUFFER,ne),te._stencilRbo=ne}return te}createColorAttachment(m,v){v===0?this.colorAttachment0=new Z1(m,this.framebuffer,0):v===1&&(this.colorAttachment1=new Z1(m,this.framebuffer,1))}removeColorAttachment(m,v){const E=this.context.gl;let D;v===0?(D=this.colorAttachment0.get(),this.colorAttachment0=void 0):v===1&&(D=this.colorAttachment1.get(),this.colorAttachment1=void 0),D&&E.deleteTexture(D)}destroy(){const m=this.context.gl;if(this.colorAttachment0){const v=this.colorAttachment0.get();v&&m.deleteTexture(v)}if(this.colorAttachment1){const v=this.colorAttachment1.get();v&&m.deleteTexture(v)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const v=this.depthAttachment.get();v&&m.deleteRenderbuffer(v)}else{const v=this.depthAttachment.get();v&&m.deleteTexture(v)}this._stencilRbo&&(m.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),m.deleteFramebuffer(this.framebuffer)}}class J1{constructor(m,v){this.gl=m,this.clearColor=new VO(this),this.clearDepth=new mpe(this),this.clearStencil=new KC(this),this.colorMask=new ppe(this),this.depthMask=new HO(this),this.stencilMask=new XE(this),this.stencilFunc=new ZC(this),this.stencilOp=new QE(this),this.stencilTest=new U0(this),this.depthRange=new V0(this),this.depthTest=new G1(this),this.depthFunc=new Df(this),this.blend=new GO(this),this.blendFunc=new JE(this),this.blendColor=new WO(this),this.blendEquation=new W1(this),this.cullFace=new YC(this),this.cullFaceSide=new XC(this),this.frontFace=new eP(this),this.program=new QC(this),this.activeTexture=new Zw(this),this.viewport=new KO(this),this.bindFramebuffer=new ZO(this),this.bindRenderbuffer=new YO(this),this.bindTexture=new K1(this),this.bindVertexBuffer=new XO(this),this.bindElementBuffer=new fpe(this),this.bindVertexArrayOES=new xpe(this),this.pixelStoreUnpack=new gpe(this),this.pixelStoreUnpackPremultiplyAlpha=new tP(this),this.pixelStoreUnpackFlipY=new sP(this),this.options=v?Object.assign({},v):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=m.getExtension("EXT_texture_filter_anisotropic")||m.getExtension("MOZ_EXT_texture_filter_anisotropic")||m.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=m.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=m.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=m.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=m.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=v&&!!v.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.indexOf("PowerVR")!==-1,this.disableSymbolUBO=v&&!!v.forceDisableSymbolUBO,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=m.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=m.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=m.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=m.getParameter(m.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(m.getParameter(m.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=m.getParameter(m.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=m.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(m,v,E){return new Ip(this,m,v,E)}createVertexBuffer(m,v,E,D,z){return new hF(this,m,v,E,D,z)}createRenderbuffer(m,v,E){const D=this.gl,z=D.createRenderbuffer();return this.bindRenderbuffer.set(z),D.renderbufferStorage(D.RENDERBUFFER,m,v,E),this.bindRenderbuffer.set(null),z}createFramebuffer(m,v,E,D){return new i2(this,m,v,E,D)}clear({color:m,depth:v,stencil:E,colorMask:D}){const z=this.gl;let B=0;m&&(B|=z.COLOR_BUFFER_BIT,this.clearColor.set(m.toNonPremultipliedRenderColor(null)),this.colorMask.set(D||[!0,!0,!0,!0])),v!==void 0&&(B|=z.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(v),this.depthMask.set(!0)),E!==void 0&&(B|=z.STENCIL_BUFFER_BIT,this.clearStencil.set(E),this.stencilMask.set(255)),z.clear(B)}setCullFace(m){m.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(m.mode),this.frontFace.set(m.frontFace))}setDepthMode(m){m.func!==this.gl.ALWAYS||m.mask?(this.depthTest.set(!0),this.depthFunc.set(m.func),this.depthMask.set(m.mask),this.depthRange.set(m.range)):this.depthTest.set(!1)}setStencilMode(m){m.test.func!==this.gl.ALWAYS||m.mask?(this.stencilTest.set(!0),this.stencilMask.set(m.mask),this.stencilOp.set([m.fail,m.depthFail,m.pass]),this.stencilFunc.set({func:m.test.func,ref:m.ref,mask:m.test.mask})):this.stencilTest.set(!1)}setColorMode(m){i.b6(m.blendFunction,Jr.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(m.blendFunction),this.blendColor.set(m.blendColor),m.blendEquation?this.blendEquation.set(m.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(m.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let W0;function gr(M,m,v,E,D,z,B){const W=M.context,te=W.gl,ne=M.transform,de=[i.aH(ne.center.lng),i.aL(ne.center.lat)],je=v.layout.get("symbol-placement"),be=v.layout.get("text-variable-anchor"),Me=v.layout.get("icon-rotation-alignment")==="map",$e=v.layout.get("text-rotation-alignment")==="map",Le=je!=="point",Je=[];let Qe=0,lt=0;for(let pt=0;pt0){const Ir=i.bb(),pr=Gs;i.cz(Ir,Gt.placementInvProjMatrix,ne.glCoordMatrix),i.cz(Ir,Ir,Gt.placementViewportMatrix),Je.push({circleArray:Ts,circleOffset:lt,transform:pr,invTransform:Ir,projection:Gt.getProjection()}),Qe+=Ts.length/4,lt=Qe}if(!Ws)continue;M.terrain&&M.terrain.setupElevationDraw(Tt,Qs);const wr=as?[vt.canonical.x,vt.canonical.y,1<=0&&(Me[mt.associatedIconIndex]={x:qt,y:ns,z:Jt,angle:ss})}else F1(bt,je)}if(ne){be.clear();const lt=M.icon.placedSymbolArray;for(let mt=0;mt{let wn=[0,0,0];if(za){const $i=M.style.directionalLight,mi=M.style.ambientLight;$i&&mi&&(wn=Ep(M.style,$i,mi))}return wn},qn=za=>{if(M.context.disableSymbolUBO)return;za.push("USE_PAINT_PROPERTIES_UBO");const wn=Math.floor(M.context.maxUniformBlockSize/4),$i=Math.floor(wn/4);za.push(`MAX_UBO_SIZE_VEC4 ${$i}u`)},ln=za=>{vt.depthOcclusionForSymbolsAndCircles&&(v.hasOcclusionOpacityProperties||M.terrain)&&(za.push("DEPTH_D24"),za.push("DEPTH_OCCLUSION"))},Ta=za=>{v.lut&&!bt&&(v.lut.texture||(v.lut.texture=new i.dR(M.context,v.lut.image,[v.lut.image.height,v.lut.image.height,v.lut.image.height],Dt.gl.RGBA8)),Dt.activeTexture.set(Dt.gl.TEXTURE0+10),v.lut.texture&&v.lut.texture.bind(Dt.gl.LINEAR,Dt.gl.CLAMP_TO_EDGE),za.push("APPLY_LUT_ON_GPU"))},hi=()=>{const za=Tt&&v.layout.get("symbol-placement")!=="point",wn=[];ln(wn),Ta(wn);const $i=za||fn,mi=Ts.elevationType==="road",Ho=M.shadowRenderer,sa=mi&&qt&&!!Ho&&Ho.enabled,_i=Ur(sa),ll=mi&&qt&&!M.terrain?Zt:Is,od=v.paint.get("icon-image-cross-fade");M.terrainRenderModeElevated()&&qt&&wn.push("PITCH_WITH_MAP_TERRAIN"),wr&&(wn.push("PROJECTION_GLOBE_VIEW"),$i&&wn.push("PROJECTED_POS_ON_VIEWPORT")),od>0&&Ts.hasAnySecondaryIcon&&wn.push("ICON_TRANSITION"),!Ts.icon.zOffsetVertexBuffer||mi&&M.terrain||wn.push("Z_OFFSET"),Qe===0&<===0&&mt===0&&nt===1||wn.push("COLOR_ADJUSTMENT"),Ts.sdfIcons&&wn.push("RENDER_SDF"),sa&&wn.push("RENDER_SHADOWS","NORMAL_OFFSET"),mi&&qt&&!M.terrain&&Ts.icon.orientationVertexBuffer&&wn.push("ELEVATED_ROADS"),qn(wn);const Sl=Dt.disableSymbolUBO?Ts.icon.programConfigurations.get(v.id):null,Mc=M.getOrCreateProgram("symbol",{config:Sl,defines:wn}),vh=Ws.imageAtlasTexture?Ws.imageAtlasTexture.size:[0,0],Ja=Ts.iconSizeData,em=i.bj(Ja,vt.zoom),tm=qt||!vt.isOrthographic,Ci=jt(pr,Ws.tileID.canonical,qt,Tt,vt,Ts.getProjection(),vr),Pi=nr(pr,Ws.tileID.canonical,qt,Tt,vt,Ts.getProjection(),vr),li=Ts.icon.uboBinder&&Ts.icon.uboBinder.cachedHeader&&256&Ts.icon.uboBinder.cachedHeader.dataDrivenMask?[0,0]:W,Fo=M.translatePosMatrix(Pi,Ws,li,ne,!0),Cd=M.translatePosMatrix(pr,Ws,li,ne),mo=$i?o2:Ci,_h=Tt&&!qt&&!za;let uy=Qs;!as&&!vt.mercatorFromTransition||Tt||(uy=Yx(vt));const tv=wr?uy:Qs,sv=v.getColorAdjustmentMatrix(Qe,lt,mt,nt),a_=u3(Ja.kind,em,_h,qt,M,Cd,mo,Fo,zt,!1,vh,[0,0],0,Gs,Ir,Ut,on,tv,Ts.getProjection(),_i,$n,sv,od,null),sg=Ws.imageAtlasTexture?Ws.imageAtlasTexture:null,$f=v.layout.get("icon-size").constantOr(0)!==1||Ts.iconsNeedLinear,i_=Ts.sdfIcons||M.options.rotating||M.options.zooming||$f||tm?pt.LINEAR:pt.NEAREST,Gu=Ts.sdfIcons&&v.paint.get("icon-halo-width").constantOr(1)!==0,hy=M.terrain&&qt&&za?i.b7(i.bb(),Ci):o2;if(za&&Ts.icon){const my=i.bu.getAtTileOffsetFunc(Gs,vt.center.lat,vt.worldSize,Ts.getProjection()),py=Ps(pr,Ws.tileID.canonical,qt,Tt,vt,Ts.getProjection(),vr),R3=v.layout.get("icon-size-scale-range"),o_=i.aC(M.scaleFactor,R3[0],R3[1]);Bn(Ts,pr,M,!1,py,Pi,qt,Le,my,Gs,o_)}return{program:Mc,buffers:Ts.icon,uniformValues:a_,atlasTexture:sg,atlasTextureIcon:null,atlasInterpolation:i_,atlasInterpolationIcon:null,isSDF:Ts.sdfIcons,hasHalo:Gu,depthMode:ll,tile:Ws,renderWithShadows:sa,labelPlaneMatrixInv:hy}},Zi=()=>{const za=Gt&&v.layout.get("symbol-placement")!=="point",wn=[],$i=za||ss||fn,mi=Ts.elevationType==="road",Ho=M.shadowRenderer,sa=mi&&ns&&!!Ho&&Ho.enabled,_i=Ur(sa),ll=mi&&ns&&!M.terrain?Zt:Is;M.terrainRenderModeElevated()&&ns&&wn.push("PITCH_WITH_MAP_TERRAIN"),wr&&(wn.push("PROJECTION_GLOBE_VIEW"),$i&&wn.push("PROJECTED_POS_ON_VIEWPORT")),!Ts.text.zOffsetVertexBuffer||mi&&M.terrain||wn.push("Z_OFFSET"),Ts.iconsInText&&wn.push("RENDER_TEXT_AND_SYMBOL"),wn.push("RENDER_SDF"),sa&&wn.push("RENDER_SHADOWS","NORMAL_OFFSET"),mi&&ns&&!M.terrain&&Ts.text.orientationVertexBuffer&&wn.push("ELEVATED_ROADS"),ln(wn),qn(wn);const od=Dt.disableSymbolUBO?Ts.text.programConfigurations.get(v.id):null,Sl=M.getOrCreateProgram("symbol",{config:od,defines:wn});let Mc,vh=[0,0],Ja=null;const em=Ts.textSizeData;Ts.iconsInText&&(vh=Ws.imageAtlasTexture?Ws.imageAtlasTexture.size:[0,0],Ja=Ws.imageAtlasTexture?Ws.imageAtlasTexture:null,Mc=ns||!vt.isOrthographic||M.options.rotating||M.options.zooming||em.kind==="composite"||em.kind==="camera"?pt.LINEAR:pt.NEAREST);const tm=Ws.glyphAtlasTexture?Ws.glyphAtlasTexture.size:[0,0],Ci=v.layout.get("text-size-scale-range"),Pi=i.aC(M.scaleFactor,Ci[0],Ci[1]),li=i.bj(em,vt.zoom,Pi),Fo=jt(pr,Ws.tileID.canonical,ns,Gt,vt,Ts.getProjection(),vr),Cd=nr(pr,Ws.tileID.canonical,ns,Gt,vt,Ts.getProjection(),vr),mo=Ts.text.uboBinder&&Ts.text.uboBinder.cachedHeader&&256&Ts.text.uboBinder.cachedHeader.dataDrivenMask?[0,0]:te,_h=M.translatePosMatrix(Cd,Ws,mo,de,!0),uy=M.translatePosMatrix(pr,Ws,mo,de),tv=$i?o2:Fo,sv=Gt&&!ns&&!za;let a_=Qs;!as&&!vt.mercatorFromTransition||Gt||(a_=Yx(vt));const sg=u3(em.kind,li,sv,ns,M,uy,tv,_h,zt,!0,tm,vh,0,Gs,Ir,Ut,on,wr?a_:Qs,Ts.getProjection(),_i,$n,null,null,Pi),$f=Ws.glyphAtlasTexture?Ws.glyphAtlasTexture:null,i_=pt.LINEAR,Gu=v.paint.get("text-halo-width").constantOr(1)!==0,hy=M.terrain&&ns&&za?i.b7(i.bb(),Fo):o2;if(za&&Ts.text){const my=i.bu.getAtTileOffsetFunc(Gs,vt.center.lat,vt.worldSize,Ts.getProjection()),py=Ps(pr,Ws.tileID.canonical,ns,Gt,vt,Ts.getProjection(),vr);Bn(Ts,pr,M,!0,py,Cd,ns,Je,my,Gs,Pi)}return{program:Sl,buffers:Ts.text,uniformValues:sg,atlasTexture:$f,atlasTextureIcon:Ja,atlasInterpolation:i_,atlasInterpolationIcon:Mc,isSDF:!0,hasHalo:Gu,depthMode:ll,tile:Ws,renderWithShadows:sa,labelPlaneMatrixInv:hy}},ji=Ts.icon.segments.get().length,Fa=Ts.text.segments.get().length,In=ji&&!B.onlyText?hi():null,Ln=Fa&&!B.onlyIcons?Zi():null,Ni=v.paint.get("icon-opacity").constantOr(1),Qi=v.paint.get("text-opacity").constantOr(1);if(Jt&&Ts.canOverlap){Ns=!0;const za=Ni&&!B.onlyText?Ts.icon.segments.get():[],wn=Qi&&!B.onlyIcons?Ts.text.segments.get():[];for(const $i of za)ds.push({segments:new i.dy([$i]),sortKey:$i.sortKey,state:In});for(const $i of wn)ds.push({segments:new i.dy([$i]),sortKey:$i.sortKey,state:Ln})}else B.onlyText||ds.push({segments:Ni?Ts.icon.segments:new i.dy([]),sortKey:0,state:In}),B.onlyIcons||ds.push({segments:Qi?Ts.text.segments:new i.dy([]),sortKey:0,state:Ln})}Ns&&ds.sort((Gs,Ws)=>Gs.sortKey-Ws.sortKey);for(const Gs of ds){const Ws=Gs.state;if(Ws)if(M.terrain?M.terrain.setupElevationDraw(Ws.tile,Ws.program,{useDepthForOcclusion:vt.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Ws.labelPlaneMatrixInv}):M.setupDepthForOcclusion(vt.depthOcclusionForSymbolsAndCircles,Ws.program),Dt.activeTexture.set(pt.TEXTURE0),Ws.atlasTexture&&Ws.atlasTexture.bind(Ws.atlasInterpolation,pt.CLAMP_TO_EDGE,!0),Ws.atlasTextureIcon&&(Dt.activeTexture.set(pt.TEXTURE1),Ws.atlasTextureIcon&&Ws.atlasTextureIcon.bind(Ws.atlasInterpolationIcon,pt.CLAMP_TO_EDGE,!0)),Ws.renderWithShadows&&M.shadowRenderer.setupShadows(Ws.tile.tileID.toUnwrapped(),Ws.program,"vector-tile"),M.uploadCommonLightUniforms(M.context,Ws.program),Ws.hasHalo){const Ts=Ws.uniformValues;Ts.u_is_halo=1,p3(Ws.buffers,Gs.segments,v,M,Ws.program,Ws.depthMode,D,z,Ts,2),Ts.u_is_halo=0}else{if(Ws.isSDF){const Ts=Ws.uniformValues;Ws.hasHalo&&(Ts.u_is_halo=1,p3(Ws.buffers,Gs.segments,v,M,Ws.program,Ws.depthMode,D,z,Ts,1)),Ts.u_is_halo=0}p3(Ws.buffers,Gs.segments,v,M,Ws.program,Ws.depthMode,D,z,Ws.uniformValues,1)}}}function p3(M,m,v,E,D,z,B,W,te,ne){const de=E.context,je=de.gl,be=[M.dynamicLayoutVertexBuffer,M.opacityVertexBuffer,M.iconTransitioningVertexBuffer,M.globeExtVertexBuffer,M.zOffsetVertexBuffer,M.orientationVertexBuffer];M.featureIdBuffer&&be.push(M.featureIdBuffer);const Me=M.uboBinder?null:M.programConfigurations.get(v.id);if(M.uboBinder){M.uboBinder.layer=v;const Je=E.transform.zoom,Qe=E.style.getBrightness?E.style.getBrightness():null,lt=M.uboBinder.getConstantUniformValues(Je,Qe);te.u_spp_fill_np_color=lt.fill_np_color,te.u_spp_halo_np_color=lt.halo_np_color,te.u_spp_opacity=lt.opacity,te.u_spp_halo_width=lt.halo_width,te.u_spp_halo_blur=lt.halo_blur,te.u_spp_emissive_strength=lt.emissive_strength,te.u_spp_occlusion_opacity=lt.occlusion_opacity,te.u_spp_z_offset=lt.z_offset;const mt=v.paint.get(M.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),nt=M.uboBinder.cachedHeader&&256&M.uboBinder.cachedHeader.dataDrivenMask&&mt==="map"?E.transform.angle:0;te.u_spp_translate_rotation=[Math.cos(nt),Math.sin(nt)]}const{batchIndices:$e,batchSegments:Le}=M.getBatchGrouping(m);for(const Je of $e){const Qe=Le.get(Je);M.uboBinder&&M.uboBinder.bind(de,D.program,Je),D.draw(E,je.TRIANGLES,z,B,W,Wr.disabled,te,v.id,M.layoutVertexBuffer,M.indexBuffer,Qe,v.paint,E.transform.zoom,Me,be,ne)}}function f3(M,m,v,E,D,z){const B=v.paint.get("line-width"),W=v.paint.get("line-emissive-strength").isConstant(),te=v.paint.get("line-emissive-strength").constantOr(0),ne=v.paint.get("line-occlusion-opacity"),de=v.layout.get("line-elevation-reference"),je=v.layout.get("line-width-unit")==="meters",be=de==="sea",Me=!(!M.terrain||!M.terrain.enabled),$e=M.context,Le=$e.gl;if(v.hasElevatedBuckets&&M.transform.projection.name==="globe")return;const Je=v.layout.get("line-cross-slope"),Qe=Je!==void 0,lt=Je<1,mt=D||M.colorModeForDrapableLayerRenderPass(W?te:null),nt=M.terrain&&M.terrain.renderingToTexture||z,zt=nt?1:i.o.devicePixelRatio,bt=v.paint.get("line-dasharray"),Dt=bt.constantOr(1),pt=v.layout.get("line-cap"),vt=bt.constantOr(null),Tt=pt.constantOr(null),Gt=v.paint.get("line-pattern"),qt=Gt.constantOr(1),ns=v.paint.get("line-pattern-cross-fade"),Jt=Gt.constantOr(null),Ns=v.paint.get("line-opacity").constantOr(1);let Is=!qt&&Ns!==1||M.depthOcclusion&&ne>0&&ne<1;const Zt=v.paint.get("line-gradient"),Ut=qt?"linePattern":"line",ss=i.dU(v);let as;if(nt&&M.terrain&&M.terrain.clipOrMaskOverlapStencilType()&&(Is=!1),ne!==0&&M.depthOcclusion){const Ts=v.paint._values["line-opacity"];Ts&&Ts.value&&Ts.value.kind==="constant"?as=Ts.value:i.w(`Occlusion opacity for layer ${v.id} is supported only when line-opacity isn't data-driven.`)}B.value.kind!=="constant"&&B.value.isLineProgressConstant===!1&&ss.push("VARIABLE_LINE_WIDTH"),nt&&(M.emissiveMode!=="dual-source-blending"||W?M.emissiveMode==="mrt-fallback"&&ss.push("USE_MRT1"):ss.push("DUAL_SOURCE_BLENDING"));const ds={},Qs=(Ts,wr,Ir,pr,vr,Zr)=>{for(const fn of Ts){const on=m.getTile(fn);if(qt&&!on.patternsLoaded())continue;const $n=on.getBucket(v);if(!$n||$n.elevationType!=="none"&&!vr||$n.elevationType==="none"&&vr)continue;M.prepareDrawTile();const Ur=[...wr],qn=M.shadowRenderer,ln=$n.elevationType==="road"&&!!qn&&qn.enabled;let Ta=[0,0,0];if(ln){const sa=M.style.directionalLight,_i=M.style.ambientLight;sa&&_i&&(Ta=Ep(M.style,sa,_i)),Ur.push("RENDER_SHADOWS","NORMAL_OFFSET")}const hi=$n.programConfigurations.get(v.id);let Zi=!1;if(Jt&&on.imageAtlas){const sa=i.dV.from(Jt),_i=sa.getPrimary().scaleSelf(zt).toString(),ll=on.imageAtlas.patternPositions.get(_i),od=sa.getSecondary(),Sl=od?on.imageAtlas.patternPositions.get(od.scaleSelf(zt).toString()):null;Zi=!!ll&&!!Sl,ll&&hi.setConstantPatternPositions(ll,Sl)}ns>0&&(Zi||hi.getPatternTransitionVertexBuffer("line-pattern"))&&Ur.push("LINE_PATTERN_TRANSITION"),$n.elevationGroundScaleVertexBuffer&&Ur.push("ELEVATION_GROUND_SCALE");const ji=M.isTileAffectedByFog(fn),Fa=M.getOrCreateProgram(Ut,{config:hi,defines:Ur,overrideFog:ji});if(!qt&&vt&&Tt&&on.lineAtlas){const sa=on.lineAtlas.getDash(vt,Tt);sa&&hi.setConstantPatternPositions(sa)}ln&&qn.setupShadows(on.tileID.toUnwrapped(),Fa,"vector-tile");let[In,Ln]=v.paint.get("line-trim-offset");(Tt==="round"||Tt==="square")&&In!==Ln&&(In===0&&(In-=1),Ln===1&&(Ln+=1));const Ni=nt?fn.projMatrix:null,Qi=je?1/$n.tileToMeter/i.aA(on,1,M.transform.zoom):1,za=je?1/$n.tileToMeter/i.aA(on,1,Math.floor(M.transform.zoom)):1,wn=Dt?v.paint._values["line-floorwidth"]:null;let $i;if(wn&&wn.value.kind==="constant"){const sa=$n.zoom;sa in ds||(ds[sa]=Math.max(.01,v.widthExpression().evaluate({zoom:sa}))),$i=wn.value.value;const _i=Math.floor(M.transform.zoom);wn.value.value=ds[sa]*Math.pow(2,_i-on.tileID.overscaledZ)}const mi=qt?i.dW(M,on,v,Ni,zt,Qi,za,[In,Ln],Ta,ns):i.dX(M,on,v,Ni,$n.lineClipsArray.length,zt,Qi,za,[In,Ln],Ta);if(Zt){const sa=$n.gradients[v.id];let _i=sa.texture;if(v.gradientVersion!==sa.version){let ll=256;if(v.stepInterpolant){const od=m.getSource().maxzoom,Sl=fn.canonical.z===od?Math.ceil(1<{as!=null&&(as.value=Ns*ne),Fa.draw(M,Le.TRIANGLES,Ir,sa,mt,Wr.disabled,mi,v.id,$n.layoutVertexBuffer,$n.indexBuffer,$n.segments,v.paint,M.transform.zoom,hi,[$n.layoutVertexBuffer2,$n.patternVertexBuffer,$n.zOffsetVertexBuffer,$n.elevationGroundScaleVertexBuffer]),as!=null&&(as.value=Ns)};if(Is&&!vr){const sa=M.stencilModeForClipping(fn).ref;sa===0&&nt&&$e.clear({stencil:0});const _i={func:Le.EQUAL,mask:255};mi.u_alpha_discard_threshold=.8,Ho(new sn(_i,sa,255,Le.KEEP,Le.KEEP,Le.INVERT)),mi.u_alpha_discard_threshold=0,Ho(new sn(_i,sa,255,Le.KEEP,Le.KEEP,Le.KEEP))}else mi.u_alpha_discard_threshold=Is&&vr&&Zr?.8:0,Ho(vr?pr:M.stencilModeForClipping(fn));$i!==void 0&&(wn.value.value=$i)}};let Gs=M.depthModeForSublayer(0,kr.ReadOnly);const Ws=new kr(M.depthOcclusion?Le.GREATER:Le.LEQUAL,kr.ReadOnly,M.depthRangeFor3D);if(v.hasNonElevatedBuckets){const Ts=!nt&&M.terrain;ne!==0&&Ts?i.w(`Occlusion opacity for layer ${v.id} is supported on terrain only if the layer has line-z-offset enabled.`):Ts?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${v.id}.`):Qs(E,ss,Gs,sn.disabled,!1,!0)}if(v.hasElevatedBuckets){de==="hd-road-markup"?Me||(Gs=Ws,ss.push("ELEVATED_ROADS")):(ss.push("ELEVATED"),Gs=Ws,Qe&&ss.push(lt?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),be&&ss.push("ELEVATION_REFERENCE_SEA"));const Ts=Is?M.stencilModeFor3D():sn.disabled;M.forceTerrainMode=!0,Qs(E,ss,Gs,Ts,!0,!0),Is&&Qs(E,ss,Gs,Ts,!0,!1),M.forceTerrainMode=!1}Is&&(M.resetStencilClippingMasks(),nt&&$e.clear({stencil:0})),ne===0||M.depthOcclusion||nt||M.layersWithOcclusionOpacity.push(M.currentLayer)}const Xx={additive:{clearColor:new i.aq(0,0,0,0),colorMode:Jr.additive,compositeUniformValue:1},multiply:{clearColor:new i.aq(1,1,1,1),colorMode:Jr.multiply,compositeUniformValue:0}};function uP(M,m){const v=1<=B0?1:Me.pitch/B0))),2*$e}(M.transform),ne=M.transform.getFreeCameraOptions().position,de="elevatedStructuresDepthReconstruct",je=M.getOrCreateProgram(de,{defines:["DEPTH_RECONSTRUCTION"]}),be=M.getOrCreateProgram(de);for(const Me of E){const $e=m.getTile(Me),Le=$e.getBucket(v);if(!Le)continue;const Je=Le.elevatedStructures;if(!Je)continue;const Qe=Le.elevationBufferData.heightRange,lt=uP(Me.toUnwrapped(),ne),mt=M.translatePosMatrix(Me.projMatrix,$e,v.paint.get("fill-translate"),v.paint.get("fill-translate-anchor"));let nt,zt,bt,Dt;if(D==="initialize"){if(!Qe||Qe.min>=1||Je.depthSegments.segments[0].primitiveLength===0)continue;nt=r2(mt,lt,te,1,0),zt=B,bt=Je.depthSegments,Dt=je}else if(D==="reset"){if(!Qe||Qe.min>=0||Je.maskSegments.segments[0].primitiveLength===0)continue;nt=r2(mt,lt,0,0,1),zt=W,bt=Je.maskSegments,Dt=je}else if(D==="geometry"){if(Je.depthSegments.segments[0].primitiveLength===0)continue;nt=r2(mt,lt,te,1,0),zt=B,bt=Je.depthSegments,Dt=be}Dt.draw(M,z.TRIANGLES,zt,sn.disabled,Jr.disabled,Wr.disabled,nt,v.id,Je.vertexBuffer,Je.indexBuffer,bt,v.paint,M.transform.zoom)}}function c2(M,m,v,E){const{painter:D,sourceCache:z,layer:B,coords:W,colorMode:te,elevationType:ne,terrainEnabled:de,pass:je}=M,be=D.context.gl,Me=B.paint.get("fill-pattern"),$e=B.paint.get("fill-pattern-cross-fade"),Le=Me.constantOr(null);let Je=ne;ne!=="road"||m&&!de||(Je="none");const Qe=Je==="road",lt=M.painter.shadowRenderer,mt=Qe&&!!lt&<.enabled,nt=new kr(D.context.gl.LEQUAL,kr.ReadOnly,D.depthRangeFor3D);let zt=[0,0,0];if(mt){const vt=D.style.directionalLight,Tt=D.style.ambientLight;vt&&Tt&&(zt=Ep(D.style,vt,Tt))}const bt=Me&&Me.constantOr(1),Dt=D.terrain&&D.terrain.renderingToTexture,pt=(vt,Tt)=>{let Gt,qt,ns,Jt,Ns;Tt?(Gt=bt&&!B.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",ns=be.LINES):(Gt=bt?"fillPattern":"fill",ns=be.TRIANGLES);for(const Is of W){const Zt=z.getTile(Is);if(bt&&!Zt.patternsLoaded())continue;const Ut=Zt.getBucket(B);if(!Ut)continue;const ss=m?Ut.elevationBufferData:Ut.bufferData;if(ss.isEmpty())continue;D.prepareDrawTile();const as=ss.programConfigurations.get(B.id),ds=D.isTileAffectedByFog(Is),Qs=[],Gs=[];Qe&&(Qs.push("ELEVATED_ROADS"),Gs.push(ss.elevatedLayoutVertexBuffer)),mt&&Qs.push("RENDER_SHADOWS","NORMAL_OFFSET"),Dt&&v&&Qs.push("USE_MRT1"),bt&&(D.context.activeTexture.set(be.TEXTURE0),Zt.imageAtlasTexture&&Zt.imageAtlasTexture.bind(be.LINEAR,be.CLAMP_TO_EDGE),as.updatePaintBuffers());let Ws=!1;if(Le&&Zt.imageAtlas){const vr=Zt.imageAtlas,Zr=i.dV.from(Le),fn=Zr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),on=Zr.getSecondary(),$n=vr.patternPositions.get(fn),Ur=on?vr.patternPositions.get(on.scaleSelf(i.o.devicePixelRatio).toString()):null;Ws=!!$n&&!!Ur,$n&&as.setConstantPatternPositions($n,Ur)}$e>0&&(Ws||as.getPatternTransitionVertexBuffer("fill-pattern"))&&Qs.push("FILL_PATTERN_TRANSITION");const Ts=D.getOrCreateProgram(Gt,{config:as,overrideFog:ds,defines:Qs}),wr=D.translatePosMatrix(Is.projMatrix,Zt,B.paint.get("fill-translate"),B.paint.get("fill-translate-anchor"));mt&<.setupShadows(Zt.tileID.toUnwrapped(),Ts,"vector-tile");const Ir=B.paint.get("fill-emissive-strength");if(Tt){Jt=ss.lineIndexBuffer,Ns=ss.lineSegments;const vr=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[be.drawingBufferWidth,be.drawingBufferHeight];qt=Gt==="fillOutlinePattern"&&bt?X1(wr,Ir,D,Zt,vr,zt,$e):rF(wr,Ir,vr,zt)}else Jt=ss.indexBuffer,Ns=ss.triangleSegments,qt=bt?a3(wr,Ir,D,Zt,zt,$e):n3(wr,Ir,zt);D.uploadCommonUniforms(D.context,Ts,Is.toUnwrapped());let pr=vt;(ne==="road"&&!de||ne==="offset")&&(pr=nt),Ts.draw(D,ns,pr,E||D.stencilModeForClipping(Is),te,Wr.disabled,qt,B.id,ss.layoutVertexBuffer,Jt,Ns,B.paint,D.transform.zoom,as,Gs)}};D.renderPass===je&&pt(D.depthModeForSublayer(1,D.renderPass==="opaque"?kr.ReadWrite:kr.ReadOnly),!1),Je==="none"&&D.renderPass==="translucent"&&B.paint.get("fill-antialias")&&pt(D.depthModeForSublayer(B.getPaintProperty("fill-outline-color")?2:0,kr.ReadOnly),!0)}function K0(M,m,v,E,D,z,B,W){v.resetLayerRenderingStats(M);const te=M.context,ne=te.gl,de=M.transform,je=v.paint.get("fill-extrusion-pattern"),be=v.paint.get("fill-extrusion-pattern-cross-fade"),Me=je.constantOr(null),$e=je.constantOr(1),Le=v.paint.get("fill-extrusion-opacity"),Je=M.style.enable3dLights(),Qe=v.paint.get(Je&&!$e?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),lt=[v.paint.get("fill-extrusion-ambient-occlusion-intensity"),Qe],mt=v.layout.get("fill-extrusion-edge-radius"),nt=mt>0&&!v.paint.get("fill-extrusion-rounded-roof"),zt=nt?0:mt,bt=de.projection.name==="globe"?i.e1():0,Dt=de.projection.name==="globe",pt=Dt?i.al(de.zoom):0,vt=[i.aH(de.center.lng),i.aL(de.center.lat)],Tt=v.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Gt=v.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Tt?null:v.lut).toArray01().slice(0,3),qt=v.paint.get("fill-extrusion-flood-light-intensity"),ns=v.paint.get("fill-extrusion-vertical-scale"),Jt=v.paint.get("fill-extrusion-line-width").constantOr(1)!==0,Ns=v.paint.get("fill-extrusion-height-alignment"),Is=v.paint.get("fill-extrusion-base-alignment"),Zt=ac(M,v.paint.get("fill-extrusion-cutoff-fade-range")),Ut=v.paint.get("fill-extrusion-front-cutoff"),ss=x3(de.pitch,Ut,!!M.terrain),as=ss[2]<1;as&&(M.maxFrontCutoffRawStart=Math.max(M.maxFrontCutoffRawStart,Ut[0]));const ds=[];let Qs;Dt&&ds.push("PROJECTION_GLOBE_VIEW"),lt[0]>0&&ds.push("FAUX_AO"),nt&&ds.push("ZERO_ROOF_RADIUS"),W&&ds.push("HAS_CENTROID"),qt>0&&ds.push("FLOOD_LIGHT"),Zt.shouldRenderCutoff&&ds.push("RENDER_CUTOFF"),as&&ds.push("RENDER_FRONT_CUTOFF"),Jt&&ds.push("RENDER_WALL_MODE");const Gs=M.renderPass==="shadow",Ws=M.shadowRenderer,Ts=Gs&&!!Ws,wr=Gs?Wr.disabled:Wr.backCCW;M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0);let Ir=[0,0,0];if(Ws){const Zr=M.style.directionalLight,fn=M.style.ambientLight;Zr&&fn&&(Ir=Ep(M.style,Zr,fn)),Gs||(ds.push("RENDER_SHADOWS"),Ws.useNormalOffset&&ds.push("NORMAL_OFFSET")),Qs=ds.concat(["SHADOWS_SINGLE_CASCADE"])}const pr=Ts?"fillExtrusionDepth":$e?"fillExtrusionPattern":"fillExtrusion",vr=v.getLayerRenderingStats();for(const Zr of E){const fn=m.getTile(Zr),on=fn.getBucket(v);if(!on||on.projection.name!==de.projection.name)continue;let $n=!1;Ws&&($n=Ws.getMaxCascadeForTile(Zr.toUnwrapped())===0);const Ur=M.isTileAffectedByFog(Zr),qn=on.programConfigurations.get(v.id);let ln=!1;if(Me&&fn.imageAtlas){const Ln=fn.imageAtlas,Ni=i.dV.from(Me),Qi=Ni.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),za=Ni.getSecondary(),wn=Ln.patternPositions.get(Qi),$i=za?Ln.patternPositions.get(za.scaleSelf(i.o.devicePixelRatio).toString()):null;ln=!!wn&&!!$i,wn&&qn.setConstantPatternPositions(wn,$i)}be>0&&(ln||qn.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&ds.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Ta=M.getOrCreateProgram(pr,{config:qn,defines:$n?Qs:ds,overrideFog:Ur});if(M.terrain&&M.terrain.setupElevationDraw(fn,Ta,{useMeterToDem:!0}),!on.centroidVertexBuffer){const Ln=Ta.getAttributeLocation(ne,"a_centroid_pos");Ln!==-1&&ne.vertexAttribI4ui(Ln,0,0,0,0)}!Gs&&Ws&&Ws.setupShadows(fn.tileID.toUnwrapped(),Ta,"vector-tile"),$e&&(M.context.activeTexture.set(ne.TEXTURE0),fn.imageAtlasTexture&&fn.imageAtlasTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),qn.updatePaintBuffers());const hi=v.paint.get("fill-extrusion-vertical-gradient"),Zi=1/on.tileToMeter;let ji;if(Gs&&Ws){if(g3(fn.tileID,on.maxHeight,M))continue;const Ln=Ws.calculateShadowPassMatrixFromTile(fn.tileID.toUnwrapped());ji=_pe(Ln,zt,Zi,ns,Ns,Is)}else{const Ln=M.translatePosMatrix(Zr.expandedProjMatrix,fn,v.paint.get("fill-extrusion-translate"),v.paint.get("fill-extrusion-translate-anchor")),Ni=de.projection.createInversionMatrix(de,Zr.canonical);ji=$e?bpe(Ln,M,hi,Le,lt,zt,Zi,Zr,fn,bt,Ns,Is,pt,vt,Ni,Gt,ns,be):sF(Ln,M,hi,Le,lt,zt,Zi,Zr,bt,Ns,Is,pt,vt,Ni,Gt,ns,qt,Ir,ss)}M.uploadCommonUniforms(te,Ta,Zr.toUnwrapped(),null,Zt);let Fa=on.segments;if(de.projection.name==="mercator"&&!Gs&&(Fa=on.getVisibleSegments(fn.tileID,M.terrain,M.transform.getFrustum(0)),!Fa.get().length))continue;if(vr)if(Gs)for(const Ln of Fa.get())vr.numRenderedVerticesInShadowPass+=Ln.primitiveLength;else for(const Ln of Fa.get())vr.numRenderedVerticesInTransparentPass+=Ln.primitiveLength;const In=[];(M.terrain||W)&&In.push(on.centroidVertexBuffer),Dt&&In.push(on.layoutVertexExtBuffer),Jt&&In.push(on.wallVertexBuffer),Ta.draw(M,te.gl.TRIANGLES,D,z,B,wr,ji,v.id,on.layoutVertexBuffer,on.indexBuffer,Fa,v.paint,M.transform.zoom,qn,In)}M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!1)}class hP{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function x3(M,m,v){if(!(m[2]<1)||v)return[0,0,1];const E=180*M/Math.PI;if(E<15)return[-.5,m[1],m[2]];const D=Math.min(1,Math.max(0,(E-15)/5)),z=D*D*(3-2*D);return[-.5*(1-z)+m[0]*z,m[1],m[2]]}function Of(M,m,v,E,D,z,B,W,te,ne,de,je,be,Me,$e,Le,Je,Qe,lt,mt,nt){const zt=m.context,bt=zt.gl,Dt=m.transform,pt=m.transform.zoom,vt=[],Tt=M.translate,Gt=M.translateAnchor,qt=M.edgeRadius,ns=ac(m,M.cutoffFadeRange);de==="clear"?(vt.push("CLEAR_SUBPASS"),mt&&(vt.push("CLEAR_FROM_TEXTURE"),zt.activeTexture.set(bt.TEXTURE0),mt.bind(bt.LINEAR,bt.CLAMP_TO_EDGE))):de==="sdf"?vt.push("SDF_SUBPASS"):de==="emissive"&&(vt.push("USE_MRT1"),zt.activeTexture.set(bt.TEXTURE0),mt.bind(bt.LINEAR,bt.CLAMP_TO_EDGE)),Qe&&vt.push("HAS_CENTROID"),ns.shouldRenderCutoff&&vt.push("RENDER_CUTOFF");const Jt=(Ns,Is,Zt,Ut,ss)=>{let as=vt;Is.groundRadiusBuffer!=null&&(as=vt.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const ds=Is.programConfigurations.get(E.id),Qs=m.isTileAffectedByFog(Ns),Gs=m.getOrCreateProgram("fillExtrusionGroundEffect",{config:ds,defines:as,overrideFog:Qs}),Ws=((wr,Ir,pr,vr,Zr,fn,on,$n,Ur,qn,ln)=>({u_matrix:Ir,u_opacity:pr,u_ao_pass:vr?1:0,u_meter_to_tile:Zr,u_ao:fn,u_flood_light_intensity:on,u_flood_light_color:$n,u_attenuation:Ur,u_edge_radius:qn,u_fb:0,u_fb_size:ln,u_dynamic_offset:1}))(0,Ut,je,ne,ss,[be,Me*ss],$e,Le,Je,pt>=17?0:qt*ss,mt?mt.size[0]:0),Ts=[];Qe&&Ts.push(Is.hiddenByLandmarkVertexBuffer),Is.groundRadiusBuffer!=null&&Ts.push(Is.groundRadiusBuffer),m.uploadCommonUniforms(zt,Gs,Ns.toUnwrapped(),null,ns),Gs.draw(m,zt.gl.TRIANGLES,z,B,W,te,Ws,E.id,Is.vertexBuffer,Is.indexBuffer,Zt,E.paint,pt,ds,Ts)};for(const Ns of D){const Is=v.getTile(Ns),Zt=Is.getBucket(E);if(!Zt||Zt.projection.name!==Dt.projection.name||!Zt.groundEffect||Zt.groundEffect&&!Zt.groundEffect.hasData())continue;const Ut=Zt.groundEffect,ss=1/Zt.tileToMeter;{const as=m.translatePosMatrix(Ns.projMatrix,Is,Tt,Gt),ds=Ut.getDefaultSegment();Jt(Ns,Ut,ds,as,ss)}if(lt)for(let as=0;as<4;as++){const ds=i.d$[as](Ns),Qs=v.getTile(ds);if(!Qs)continue;const Gs=Qs.getBucket(E);if(!Gs||Gs.projection.name!==Dt.projection.name||!Gs.groundEffect||Gs.groundEffect&&!Gs.groundEffect.hasData())continue;const Ws=Gs.groundEffect;let Ts,wr;as===0?(Ts=[-i.an,0,0],wr=1):as===1?(Ts=[i.an,0,0],wr=0):as===2?(Ts=[0,-i.an,0],wr=3):(Ts=[0,i.an,0],wr=2);const Ir=Ws.regionSegments[wr];if(!Ir)continue;const pr=new Float32Array(16);i.bx(pr,Ns.projMatrix,Ts),Jt(Ns,Ws,Ir,m.translatePosMatrix(pr,Is,Tt,Gt),ss)}}}function pF(M,m,v,E,D,z,B){E.centroidVertexArray.length===0&&E.createCentroidsBuffer();const W=z?z.findDEMTileFor(v):null;if(!(W&&W.dem||B))return;z&&W&&W.dem&&E.selfDEMTileTimestamp!==W.dem._timestamp&&(E.borderDoneWithNeighborZ=[-1,-1,-1,-1],E.selfDEMTileTimestamp=W.dem._timestamp);const te=(Qe,lt)=>{(Qe.flags|lt.flags)&i.e3?(Qe.flags|=i.e3,lt.flags|=i.e3):(Qe.flags&=~i.e3,lt.flags&=~i.e3)},ne=Qe=>new i.P(Math.ceil((Qe+i.e4)*i.e5),0),de=(Qe,lt,mt)=>{const nt=Math.ceil((Qe+i.e4)*i.e5),zt=Math.floor(Math.max(0,Math.min(i.an-1,mt))/4);return new i.P(nt,zt<<5|(3<)<<3|7)},je=Qe=>{const lt=m.getSource().minzoom,mt=zt=>{const bt=m.getTileByID(zt);if(bt&&bt.hasData())return bt.getBucket(D)},nt=[0,-1,1];for(const zt of nt){if(Qe.overscaledZ+zt(be[0]=Math.min(Qe.min.y,lt.min.y),be[1]=Math.max(Qe.max.y,lt.max.y),be[2]=i.an-lt.min.x>Qe.max.x?lt.min.x-i.an:Qe.max.x,be),$e=(Qe,lt)=>(be[0]=Math.min(Qe.min.x,lt.min.x),be[1]=Math.max(Qe.max.x,lt.max.x),be[2]=i.an-lt.min.y>Qe.max.y?lt.min.y-i.an:Qe.max.y,be),Le=[(Qe,lt)=>Me(Qe,lt),(Qe,lt)=>Me(lt,Qe),(Qe,lt)=>$e(Qe,lt),(Qe,lt)=>$e(lt,Qe)],Je=(Qe,lt,mt,nt,zt,bt,Dt)=>{if(!z)return 0;const pt=[[bt?mt:Qe,bt?Qe:mt,0],[bt?mt:lt,bt?lt:mt,0]],vt=Dt<0?i.an+Dt:Dt,Tt=[bt?vt:(Qe+lt)/2,bt?(Qe+lt)/2:vt,0];return mt===0&&Dt<0||mt!==0&&Dt>0?z.getForTilePoints(zt,[Tt],!0,nt):pt.push(Tt),z.getForTilePoints(v,pt,!0,W),Math.max(pt[0][2],pt[1][2],Tt[2])/z.exaggeration()};for(let Qe=0;Qe<4;Qe++){const lt=E.borderFeatureIndices[Qe];if(lt.length===0)continue;const mt=i.d$[Qe](v),nt=je(mt);if(!(nt&&nt instanceof i.e0))continue;const zt=z?z.findDEMTileFor(mt):null;if(!(zt&&zt.dem||B)||(z&&zt&&zt.dem&&E.borderDEMTileTimestamp[Qe]!==zt.dem._timestamp&&(E.borderDoneWithNeighborZ[Qe]=-1,E.borderDEMTileTimestamp[Qe]=zt.dem._timestamp),E.borderDoneWithNeighborZ[Qe]===nt.canonical.z))continue;nt.centroidVertexArray.length===0&&nt.createCentroidsBuffer();const bt=(Qe<2?1:5)-Qe,Dt=nt.borderDoneWithNeighborZ[bt]!==E.canonical.z,pt=nt.borderFeatureIndices[bt];let vt=0;if(E.canonical.z!==nt.canonical.z){for(const ns of lt)E.showCentroid(E.featuresOnBorder[ns]);if(Dt)for(const ns of pt)nt.showCentroid(nt.featuresOnBorder[ns]);E.borderDoneWithNeighborZ[Qe]=nt.canonical.z,nt.borderDoneWithNeighborZ[bt]=E.canonical.z;continue}const Tt=new Map,Gt=new Set,qt=new Set;for(let ns=0;ns1||Zt.intersectsCount()>1;{let Gs=0;if(zt&&zt.dem&&!Qs){const Ws=Le[Qe](Ns,Ut),Ts=Qe%2?i.an-1:0;Gs=Je(Ws[0],Math.min(i.an-1,Ws[1]),Ts,zt,mt,Qe<2,Ws[2])}Ns.centroidXY=de(Gs,Qe,ds),Ut.centroidXY=de(Gs,bt,ds)}if(E.writeCentroidToBuffer(Ns),nt.writeCentroidToBuffer(Ut),Jt.buildingId!==void 0){for(const Gs of E.centroidData)Gs.buildingId===Jt.buildingId&&Gs!==Ns&&(Gs.centroidXY=Ns.centroidXY,E.writeCentroidToBuffer(Gs));for(const Gs of nt.centroidData)Gs.buildingId===Jt.buildingId&&Gs!==Ut&&(Gs.centroidXY=Ut.centroidXY,nt.writeCentroidToBuffer(Gs))}}for(const ns of lt){if(Gt.has(ns))continue;const Jt=E.featuresOnBorder[ns],Ns=E.centroidData[Jt.centroidDataIndex],Is=Jt.borders[Qe];let Zt;for(;vtIs[0]+3||Ut[0]>Is[0]-3)break;nt.showCentroid(Zt),vt++}if(Zt&&vtIs[1]-3||(ss++,++vt===pt.length))break;Zt=nt.featuresOnBorder[pt[vt]]}for(;Ut=pt.length){E.showCentroid(Jt);continue}Zt=nt.featuresOnBorder[pt[Ut]];let as=!1;if(ss>=1){const Gs=Zt.borders[bt];Math.abs(Is[0]-Gs[0])<3&&Math.abs(Is[1]-Gs[1])<3&&(ss=1,as=!0,vt=Ut+1)}else if(ss===0){E.showCentroid(Jt);continue}const ds=nt.centroidData[Zt.centroidDataIndex];B&&as&&te(Ns,ds);const Qs=Jt.intersectsCount()>1||Zt.intersectsCount()>1;if(ss>1)vt=Ut,Ns.centroidXY=ds.centroidXY=new i.P(0,0);else if(zt&&zt.dem&&!Qs){const Gs=Le[Qe](Ns,ds),Ws=Qe%2?i.an-1:0,Ts=Je(Gs[0],Math.min(i.an-1,Gs[1]),Ws,zt,mt,Qe<2,Gs[2]);Ns.centroidXY=ds.centroidXY=ne(Ts)}else Qs?Ns.centroidXY=ds.centroidXY=new i.P(0,0):(Ns.centroidXY=E.encodeBorderCentroid(Jt),ds.centroidXY=nt.encodeBorderCentroid(Zt));E.writeCentroidToBuffer(Ns),nt.writeCentroidToBuffer(ds)}else E.showCentroid(Jt)}E.borderDoneWithNeighborZ[Qe]=nt.canonical.z,nt.borderDoneWithNeighborZ[bt]=E.canonical.z}(E.needsCentroidUpdate||!E.centroidVertexBuffer&&E.centroidVertexArray.length!==0)&&E.uploadCentroid(M)}const fF=[1,0,0],xF=[0,1,0],mP=[0,0,1];function g3(M,m,v){const E=v.transform,D=v.shadowRenderer;if(!D)return!0;const z=M.toUnwrapped(),B=E.tileSize*D._cascades[v.currentShadowCascade].scale;let W=m;if(E.elevation){const $e=E.elevation.getMinMaxForTile(M);$e&&(W+=$e.max)}const te=E.scaleZoom(B);W/=i.e2(E.center.lat,te);const ne=[...D.shadowDirection];ne[2]=-ne[2];const de=D.computeSimplifiedTileShadowVolume(z,W,B,ne);if(!de)return!1;const je=[fF,xF,mP,ne,[ne[0],0,ne[2]],[0,ne[1],ne[2]]],be=i.cl.fromInvProjectionMatrix(E.invProjMatrix,E.worldSize,te,E.projection.name!=="globe"),Me=D.getCurrentCascadeFrustum();return be.intersectsPrecise(de.vertices,de.planes,je)===0||Me.intersectsPrecise(de.vertices,de.planes,je)===0}function d2(M){const{painter:m,source:v,layer:E,coords:D}=M;let z=M.defines;const B=m.context,W=m.renderPass==="shadow",te=m.renderPass==="light-beam",ne=m.shadowRenderer,de=i.e2(m.transform.center.lat,m.transform.zoom),je=ac(m,E.paint.get("building-cutoff-fade-range"));je.shouldRenderCutoff&&(z=z.concat("RENDER_CUTOFF"));const be=E.paint.get("building-front-cutoff"),Me=be[2]<1&&!m.terrain,$e=x3(m.transform.pitch,be,!!m.terrain);Me&&(z=z.concat("RENDER_FRONT_CUTOFF"),m.maxFrontCutoffRawStart=Math.max(m.maxFrontCutoffRawStart,be[0])),M.floodLightIntensity>0&&(z=z.concat("FLOOD_LIGHT"));for(const Le of D){const Je=v.getTile(Le),Qe=Je.getBucket(E);if(!Qe)continue;ne&&ne.getMaxCascadeForTile(Le.toUnwrapped())===0&&(z=z.concat("SHADOWS_SINGLE_CASCADE"));const lt=Qe.programConfigurations.get(E.id);let mt,nt,zt,bt=m.translatePosMatrix(Le.expandedProjMatrix,Je,[0,0],"map");if(bt=i.cC(i.bb(),bt,[1,1,M.verticalScale]),W&&ne){if(g3(Je.tileID,Qe.maxHeight*de,m))continue;let pt=ne.calculateShadowPassMatrixFromTile(Je.tileID.toUnwrapped());pt=i.cC(i.bb(),pt,[1,1,M.verticalScale]),zt=l3(pt),mt=nt=m.getOrCreateProgram("buildingDepth",{config:lt,defines:z,overrideFog:!1})}else if(te)mt=nt=m.getOrCreateProgram("buildingBloom",{config:lt,defines:z,overrideFog:!1}),zt=o3(bt);else{const pt=m.transform.calculatePosMatrix(Le.toUnwrapped(),m.transform.worldSize);i.cC(pt,pt,[1,1,M.verticalScale]);const vt=i.bb();i.cC(vt,pt,[1,-1,1/de]),i.b7(vt,vt),i.e6(vt,vt);const Tt=m.transform.getFreeCameraOptions().position,Gt=1<{if(te){const Tt=pt.entranceBloom;vt.draw(m,B.gl.TRIANGLES,M.depthMode,sn.disabled,M.blendMode,Wr.disabled,zt,E.id,Tt.layoutVertexBuffer,Tt.indexBuffer,Tt.segmentsBucket,E.paint,m.transform.zoom,lt,[Tt.layoutAttenuationBuffer,Tt.layoutColorBuffer])}else{const Tt=pt.segmentsBucket;let Gt=[pt.layoutNormalBuffer,pt.layoutCentroidBuffer,pt.layoutColorBuffer,pt.layoutFloodLightDataBuffer];pt.layoutFacadePaintBuffer&&(Gt=Gt.concat([pt.layoutFacadeDataBuffer,pt.layoutFacadeVerticalRangeBuffer,pt.layoutFacadePaintBuffer])),vt.draw(m,B.gl.TRIANGLES,M.depthMode,sn.disabled,M.blendMode,W?Wr.disabled:Wr.backCW,zt,E.id,pt.layoutVertexBuffer,pt.indexBuffer,Tt,E.paint,m.transform.zoom,lt,Gt)}};m.uploadCommonUniforms(B,nt,Le.toUnwrapped(),null,je),Qe.buildingWithoutFacade&&Dt(Qe.buildingWithoutFacade,nt),Qe.buildingWithFacade&&(mt!==nt&&m.uploadCommonUniforms(B,mt,Le.toUnwrapped(),null,je),Dt(Qe.buildingWithFacade,mt))}}function pP(M,m,v,E,D,z,B,W,te,ne,de,je,be,Me){const $e=M.context.gl,Le=M.depthModeForSublayer(1,kr.ReadOnly,$e.LEQUAL,!0),Je=.1*(1-(Qe=de))+3*Qe;var Qe;const lt=M._showOverdrawInspector,mt=je,nt=new hP;lt||Of(nt,M,m,v,E,Le,new sn({func:$e.ALWAYS,mask:255},255,255,$e.KEEP,$e.KEEP,$e.REPLACE),new Jr([$e.ONE,$e.ONE,$e.ONE,$e.ONE],i.aq.transparent,[!1,!1,!1,!0],$e.MIN),Wr.disabled,D,"sdf",z,B,W,te,ne,Je,mt,!1,void 0);{const zt=lt?sn.disabled:new sn({func:$e.EQUAL,mask:255},255,255,$e.KEEP,$e.DECR,$e.DECR),bt=lt?M.colorModeForRenderPass():new Jr([$e.ONE_MINUS_DST_ALPHA,$e.DST_ALPHA,$e.ONE,$e.ONE],i.aq.transparent,[!0,!0,!0,!0]);Of(nt,M,m,v,E,Le,zt,bt,Wr.disabled,D,"color",z,B,W,te,ne,Je,mt,!1,void 0)}}function fP(M){return[M[0]*i.e7,M[1]*i.e7,M[2]*i.e7,0]}function y3(M,m,v,E,D,z,B,W,te){const ne=E.getSource(),de=v.globeSharedBuffers;if(!de)return;let je,be,Me;if(m&&(je=E.getTile(m)),ne instanceof i.aV?(be=ne.texture,Me=i.dw(0,0,v.transform)):je&&m&&(be=je.texture,Me=i.dw(m.canonical.z,m.canonical.x,v.transform)),!be||!Me)return;M||(Me=i.cC(i.bb(),Me,[1,-1,1]));const $e=v.context,Le=$e.gl,Je=D.paint.get("raster-resampling")==="nearest"?Le.NEAREST:Le.LINEAR,Qe=v.colorModeForDrapableLayerRenderPass(z),lt=B.defines;lt.push("GLOBE_POLES");const mt=new kr(Le.LEQUAL,kr.ReadWrite,v.depthRangeFor3D),nt=Float32Array.from(v.transform.expandedFarZProjMatrix),zt=Float32Array.from(i.du(i.dv(new i.cn(0,0,0))));v.terrain&&v.terrain.prepareDrawTile(),$e.activeTexture.set(Le.TEXTURE0),be.bind(Je,Le.CLAMP_TO_EDGE),$e.activeTexture.set(Le.TEXTURE1),be.bind(Je,Le.CLAMP_TO_EDGE),"useMipmap"in be&&$e.extTextureFilterAnisotropic&&v.transform.pitch>20&&Le.texParameterf(Le.TEXTURE_2D,$e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,$e.extTextureFilterAnisotropicMax);const[bt,Dt,pt,vt]=m?de.getPoleBuffers(m.canonical.z,!1):de.getPoleBuffers(0,!0),Tt=D.paint.get("raster-elevation");let Gt;M?(Gt=bt,v.renderDefaultNorthPole=Tt!==0):(Gt=Dt,v.renderDefaultSouthPole=Tt!==0);const qt=fP(B.mix),ns=((Ns,Is,Zt,Ut,ss,as,ds,Qs,Gs,Ws,Ts,wr,Ir,pr)=>lF(Ns,Is,Zt,Ut,new Float32Array(16),new Float32Array(9),[0,0],ss,[0,0],[0,0,0,0],1,{opacity:1,mix:0},ds,[0,0],Gs,2,Ts,wr,Ir,1,0,pr))(v,nt,zt,Me,i.al(v.transform.zoom),0,D,0,Tt,0,qt,B.offset,B.range,z),Jt=v.getOrCreateProgram("raster",{defines:lt});v.uploadCommonUniforms($e,Jt,null),Jt.draw(v,Le.TRIANGLES,mt,te,Qe,W,ns,D.id,Gt,pt,vt)}function xP(M){if(M.isOrthographic)return[0,0,0,0];const m=M._nearZ,v=M.projection.farthestPixelDistance(M),E=v-m,D=.2*M.height,z=m+D;return[m,v,(z-D-m)/E,(z-m)/E]}function gF(M,m,v,E){if(M)return m instanceof Ux&&M instanceof nc?m.getTextureDescriptor(M,v,!0):{texture:M.texture,mix:fP(E.mix),offset:E.offset,buffer:0,tileSize:1}}var gP=i.e8([{name:"a_index",type:"Int16",components:1}]);class yF{constructor(m,v,E,D){const z={width:E[0],height:E[1],data:null},B=m.gl;this.targetColorTexture=new i.T(m,z,B.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new i.T(m,z,B.RGBA8,{useMipmap:!1}),this.context=m,this.updateParticleTexture(v,D),this.lastInvalidatedAt=0}updateParticleTexture(m,v){if(this.particleTextureDimension===v.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const E=this.context.gl,D=v.width*v.height;this.particleTexture0=new i.T(this.context,v,E.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,v,E.RGBA8,{premultiply:!1,useMipmap:!1});const z=new i.e9;z.reserve(D);for(let B=0;B0){const qt=i.ec(v.canonical,te),ns=i.ed(qt);be=i.aD(new Float32Array(16),te.globeMatrix,ns),i.aD(be,te.projMatrix,be)}const Me=i.bb();Me[12]+=2*D/(i.o.devicePixelRatio*te.width),Me[13]+=2*z/(i.o.devicePixelRatio*te.height),i.aD(be,Me,be);const $e=M.getOrCreateProgram("debug",{defines:je}),Le=m.getTileByID(v.key);M.terrain&&M.terrain.setupElevationDraw(Le,$e);const Je=kr.disabled,Qe=sn.disabled,lt=M.colorModeForRenderPass(),mt="$debug";W.activeTexture.set(ne.TEXTURE0),M.emptyTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),de?Le._makeGlobeTileDebugBuffers(M.context,te):Le._makeDebugTileBoundsBuffers(M.context,te.projection);const nt=Le._tileDebugBuffer||M.debugBuffer,zt=Le._tileDebugIndexBuffer||M.debugIndexBuffer,bt=Le._tileDebugSegments||M.debugSegments;if($e.draw(M,ne.LINE_STRIP,Je,Qe,lt,Wr.disabled,n2(be,E.toPremultipliedRenderColor(null)),mt,nt,zt,bt,null,null,null,[Le._globeTileDebugBorderBuffer]),B){const qt=Le.latestRawTileData,ns=Math.floor((qt&&qt.byteLength||0)/1024);let Jt=v.canonical.toString();v.overscaledZ!==v.canonical.z&&(Jt+=` => ${v.overscaledZ}`),Jt+=` ${Le.state}`,Jt+=` ${ns}kb`,function(Ns,Is){Ns.initDebugOverlayCanvas();const Zt=Ns.debugOverlayCanvas,Ut=Ns.context.gl,ss=Ns.debugOverlayCanvas.getContext("2d");ss.clearRect(0,0,Zt.width,Zt.height),ss.shadowColor="white",ss.shadowBlur=2,ss.lineWidth=1.5,ss.strokeStyle="white",ss.textBaseline="top",ss.font="bold 36px Open Sans, sans-serif",ss.fillText(Is,5,5),ss.strokeText(Is,5,5),Ns.debugOverlayTexture.update(Zt),Ns.debugOverlayTexture.bind(Ut.LINEAR,Ut.CLAMP_TO_EDGE)}(M,Jt)}const Dt=m.getTile(v).tileSize,pt=512/Math.min(Dt,512)*(v.overscaledZ/te.zoom)*.5,vt=Le._tileDebugTextBuffer||M.debugBuffer,Tt=Le._tileDebugTextIndexBuffer||M.quadTriangleIndexBuffer,Gt=Le._tileDebugTextSegments||M.debugSegments;$e.draw(M,ne.TRIANGLES,Je,Qe,Jr.alphaBlended,Wr.disabled,n2(be,i.aq.transparent.toPremultipliedRenderColor(null),pt),mt,vt,Tt,Gt,null,null,null,[Le._globeTileDebugTextBuffer])}function _F(M,m,v,E){v3(M,0,m+v/2,M.transform.width,v,E)}function wP(M,m,v,E){v3(M,m-v/2,0,v,M.transform.height,E)}function v3(M,m,v,E,D,z){const B=M.context,W=B.gl;W.enable(W.SCISSOR_TEST),W.scissor(m*i.o.devicePixelRatio,v*i.o.devicePixelRatio,E*i.o.devicePixelRatio,D*i.o.devicePixelRatio),B.clear({color:z}),W.disable(W.SCISSOR_TEST)}const Cpe=i.e8([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:gh}=Cpe;function Ff(M,m,v,E){M.emplaceBack(m,v,E)}class Zd{constructor(m){this.vertexArray=new i.ee,this.indices=new i.dC,Ff(this.vertexArray,-1,-1,1),Ff(this.vertexArray,1,-1,1),Ff(this.vertexArray,-1,1,1),Ff(this.vertexArray,1,1,1),Ff(this.vertexArray,-1,-1,-1),Ff(this.vertexArray,1,-1,-1),Ff(this.vertexArray,-1,1,-1),Ff(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=m.createVertexBuffer(this.vertexArray,gh),this.indexBuffer=m.createIndexBuffer(this.indices),this.segment=i.dy.simpleSegment(0,0,36,12)}}function Xh(M,m,v,E,D,z){const B=M.context.gl,W=m.paint.get("sky-atmosphere-color"),te=m.paint.get("sky-atmosphere-halo-color"),ne=m.paint.get("sky-atmosphere-sun-intensity"),de=((je,be,Me,$e,Le)=>({u_matrix_3f:je,u_sun_direction:be,u_sun_intensity:Me,u_color_tint_r:[$e.r,$e.g,$e.b,$e.a],u_color_tint_m:[Le.r,Le.g,Le.b,Le.a],u_luminance:5e-5}))(i.eg(i.dE(),E),D,ne,W.toPremultipliedRenderColor(null),te.toPremultipliedRenderColor(null));B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+z,m.skyboxTexture,0),v.draw(M,B.TRIANGLES,kr.disabled,sn.disabled,Jr.unblended,Wr.frontCW,de,"skyboxCapture",m.skyboxGeometry.vertexBuffer,m.skyboxGeometry.indexBuffer,m.skyboxGeometry.segment)}const bF=i.e8([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class jP{constructor(m){const v=new i.eh;v.emplaceBack(-1,1,1,0,0),v.emplaceBack(1,1,1,1,0),v.emplaceBack(1,-1,1,1,1),v.emplaceBack(-1,-1,1,0,1);const E=new i.dC;E.emplaceBack(0,1,2),E.emplaceBack(2,3,0),this.vertexBuffer=m.createVertexBuffer(v,bF.members),this.indexBuffer=m.createIndexBuffer(E),this.segments=i.dy.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const NP=i.e8([{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_opacity",components:1}]);class kP{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class wF{constructor(m){this.colorModeAlphaBlendedWriteRGB=new Jr([1,Oo,1,Oo],i.aq.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Jr([1,0,1,0],i.aq.transparent,[!1,!1,!1,!0]),this.params=new kP,this.updateNeeded=!0}update(m){const v=m.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new jP(v);const E=this.params.sizeRange,D=this.params.intensityRange,z=function(de){const je=i.em(30),be=[];for(let Me=0;Me{const pt=z.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];Dt&&pt.push("ALPHA_PASS");const vt=m.getOrCreateProgram("globeAtmosphere",{defines:pt}),Tt=((qt,ns,Jt,Ns,Is,Zt,Ut,ss,as,ds,Qs,Gs)=>({u_frustum_tl:qt,u_frustum_tr:ns,u_frustum_br:Jt,u_frustum_bl:Ns,u_horizon:Is,u_transition:Zt,u_fadeout_range:Ut,u_atmosphere_fog_color:ss.toArray01(),u_high_color:as.toArray01(),u_space_color:ds.toArray01(),u_temporal_offset:Qs,u_horizon_angle:Gs}))(z.frustumCorners.TL,z.frustumCorners.TR,z.frustumCorners.BR,z.frustumCorners.BL,z.frustumCorners.horizon,W,Je,de,be,$e,lt,zt);m.uploadCommonUniforms(E,vt);const Gt=this.atmosphereBuffer;Gt&&vt.draw(m,D.TRIANGLES,B,sn.disabled,Dt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Wr.backCW,Tt,Dt?"atmosphere_glow_alpha":"atmosphere_glow",Gt.vertexBuffer,Gt.indexBuffer,Gt.segments)};bt(!1),bt(!0)}drawStars(m,v){const E=i.aC(v.properties.get("star-intensity"),0,1);if(E===0)return;const D=m.context,z=D.gl,B=m.transform,W=m.getOrCreateProgram("stars"),te=i.bL([]);i.bN(te,te,-B._pitch),i.bM(te,te,-B.angle),i.bN(te,te,i.ap(B._center.lat)),i.ek(te,te,-i.ap(B._center.lng));const ne=i.bR(new Float32Array(16),te),de=i.aD([],B.starsProjMatrix,ne),je=i.eg([],ne),be=i.el([],je),Me=[0,1,0];i.dG(Me,Me,be),i.bJ(Me,Me,this.params.sizeMultiplier);const $e=[1,0,0];i.dG($e,$e,be),i.bJ($e,$e,this.params.sizeMultiplier);const Le=(Je=Me,Qe=$e,lt=E,{u_matrix:Float32Array.from(de),u_up:Je,u_right:Qe,u_intensity_multiplier:lt});var Je,Qe,lt;m.uploadCommonUniforms(D,W),this.starsVx&&this.starsIdx&&W.draw(m,z.TRIANGLES,kr.disabled,sn.disabled,this.colorModeAlphaBlendedWriteRGB,Wr.disabled,Le,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class Qx{constructor(){this.visibleTiles=[]}updateBorders(m,v){const E=[],D=[],z=m._getRenderableCoordinates(!1,!0);for(const te of z){const ne=m.getTile(te);if(!ne.hasData())continue;const de=ne.getBucket(v);de&&(de.isEmpty()||(E.push(te.key),D.push({bucket:de,tileID:te.canonical})))}let B=E.length!==this.visibleTiles.length;if(!B){E.sort();for(let te=0;tete.tileID.z-ne.tileID.z||te.tileID.x-ne.tileID.x||te.tileID.y-ne.tileID.y);for(const te of D){const ne=new Array,de=new Array,je=te.bucket;for(const be of je.featuresOnBorder)W.has(be.featureId)?de.push(be.footprintIndex):(W.add(be.featureId),ne.push(be.footprintIndex));je.updateFootprintHiddenFlags(ne,i.en,!1),je.updateFootprintHiddenFlags(de,i.en,!0)}}}function jF(M,m){const v=[...M],E=m.cameraWorldSizeForFog/m.worldSize,D=i.b9([]);return i.cC(D,D,[E,E,1]),i.aD(v,D,v),i.aD(v,m.worldToFogMatrix,v),v}function Ga(M,m,v,E,D){const z=v.material,B=E.context,{baseColorTexture:W,metallicRoughnessTexture:te}=z.pbrMetallicRoughness,{normalTexture:ne,occlusionTexture:de,emissionTexture:je}=z;function be($e,Le,Je){if($e&&(M.push(Le),B.activeTexture.set(B.gl.TEXTURE0+Je),$e.gfxTexture)){const{minFilter:Qe,magFilter:lt,wrapS:mt,wrapT:nt}=$e.sampler;$e.gfxTexture.bindExtraParam(Qe,lt,mt,nt)}}be(W,"HAS_TEXTURE_u_baseColorTexture",5),be(te,"HAS_TEXTURE_u_metallicRoughnessTexture",6),be(ne,"HAS_TEXTURE_u_normalTexture",7),be(de,"HAS_TEXTURE_u_occlusionTexture",8),be(je,"HAS_TEXTURE_u_emissionTexture",9),D&&(D.texture||(D.texture=new i.dR(E.context,D.image,[D.image.height,D.image.height,D.image.height],B.gl.RGBA8)),B.activeTexture.set(B.gl.TEXTURE0+10),D.texture&&D.texture.bind(B.gl.LINEAR,B.gl.CLAMP_TO_EDGE),M.push("APPLY_LUT_ON_GPU")),v.texcoordBuffer&&(M.push("HAS_ATTRIBUTE_a_uv_2f"),m.push(v.texcoordBuffer)),v.colorBuffer&&(M.push(v.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),m.push(v.colorBuffer)),v.normalBuffer&&(M.push("HAS_ATTRIBUTE_a_normal_3f"),m.push(v.normalBuffer)),v.pbrBuffer&&(M.push("HAS_ATTRIBUTE_a_pbr"),M.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),m.push(v.pbrBuffer)),z.alphaMode!=="OPAQUE"&&z.alphaMode!=="MASK"||M.push("UNPREMULT_TEXTURE_IN_SHADER"),z.defined||M.push("DIFFUSE_SHADED");const Me=E.shadowRenderer;Me&&(M.push("RENDER_SHADOWS"),Me.useNormalOffset&&M.push("NORMAL_OFFSET"))}function e_(M,m,v,E,D,z){const B=M.modelOpacity,W=m.context,te=new kr(m.context.gl.LEQUAL,M.isLightMesh?kr.ReadOnly:kr.ReadWrite,m.depthRangeFor3D),ne=m.transform,de=M.mesh,je=de.material,be=je.pbrMetallicRoughness,Me=m.style.fog;let $e;$e=m.transform.projection.zAxisUnit==="pixels"?[...M.nodeModelMatrix]:i.aD([],E.zScaleMatrix,M.nodeModelMatrix),i.aD($e,E.negCameraPosMatrix,$e);const Le=i.b7([],$e);i.e6(Le,Le);const Je=v.paint.get("model-color-use-theme").constantOr("default")==="none",Qe=v.paint.get("model-emissive-strength").constantOr(0),lt=G0(new Float32Array(M.worldViewProjection),new Float32Array($e),new Float32Array(Le),null,m,B,be.baseColorFactor,je.emissiveFactor,be.metallicFactor,be.roughnessFactor,je,Qe,v,void 0,void 0,M.materialOverride,M.modelColor),mt={defines:[]},nt=[],zt=m.shadowRenderer;zt&&(zt.useNormalOffset=!1),Ga(mt.defines,nt,de,m,Je?null:v.lut);let bt=null;if(Me){const vt=jF(M.nodeModelMatrix,m.transform);if(bt=new Float32Array(vt),ne.projection.name!=="globe"){const Tt=de.aabb.min,Gt=de.aabb.max,[qt,ns]=Me.getOpacityForBounds(vt,Tt[0],Tt[1],Gt[0],Gt[1]);mt.overrideFog=qt>=Zn||ns>=Zn}}const Dt=ac(m,v.paint.get("model-cutoff-fade-range"));Dt.shouldRenderCutoff&&mt.defines.push("RENDER_CUTOFF");const pt=m.getOrCreateProgram("model",mt);m.uploadCommonUniforms(W,pt,null,bt,Dt),m.renderPass!=="shadow"&&zt&&zt.setupShadowsFromMatrix(M.nodeModelMatrix,pt),pt.draw(m,W.gl.TRIANGLES,te,D,z,de.material.doubleSided?Wr.disabled:Wr.backCCW,lt,v.id,de.vertexBuffer,de.indexBuffer,de.segments,v.paint,m.transform.zoom,void 0,nt)}function _3(M,m){return M.style._importedAsBasemap?"basemap":m.scope}function b3(M,m,v,E,D,z,B,W,te,ne){const de=M.transform,je=!!m.isGeometryBloom&&m.isGeometryBloom;if(je&&M.renderPass==="shadow")return;const be=de.projection.name==="globe"?i.ev(v,de):[...v];i.aD(be,be,m.globalMatrix);const Me=i.aD([],E,be);if(m.meshes)for(const $e of m.meshes){const Le=W.get($e.material.name);if(Le&&Le.opacity<=0)continue;if($e.material.alphaMode!=="BLEND"){B.push({mesh:$e,depth:0,modelIndex:D,worldViewProjection:Me,nodeModelMatrix:be,isLightMesh:je,materialOverride:Le,modelOpacity:te,modelColor:ne,node:m,modelMatrix:v});continue}const Je=i.ah([],$e.centroid,Me);!de.isOrthographic&&Je[2]<=0||z.push({mesh:$e,depth:Je[2],modelIndex:D,worldViewProjection:Me,nodeModelMatrix:be,isLightMesh:je,materialOverride:Le,modelOpacity:te,modelColor:ne,node:m,modelMatrix:v})}if(m.children)for(const $e of m.children)b3(M,$e,v,E,D,z,B,W,te,ne)}function t_(M,m,v,E){const D=v.shadowRenderer;if(!D)return;const z=D.getShadowPassDepthMode(),B=D.calculateShadowPassMatrixFromMatrix(m),W=cP(B);v.getOrCreateProgram("modelDepth").draw(v,v.context.gl.TRIANGLES,z,sn.disabled,Jr.disabled,Wr.disabled,W,E.id,M.vertexBuffer,M.indexBuffer,M.segments,E.paint,v.transform.zoom,void 0,void 0)}function SP(M,m,v,E){const D=function(de,je){if(je.footprintDebugMesh)return je.footprintDebugMesh;if(!je.footprint)return null;const be=de.context,Me=je.footprint.vertices,$e=je.footprint.indices,Le=new i.dB;Le.reserve(Me.length);for(const Tt of Me)Le.emplaceBack(Tt.x,Tt.y);const Je=new i.dC;Je.reserve($e.length);for(let Tt=0;Tt<$e.length;Tt+=3)Je.emplaceBack($e[Tt],$e[Tt+1],$e[Tt+2]);const Qe=be.createVertexBuffer(Le,i.dx.members),lt=be.createIndexBuffer(Je),mt=i.dy.simpleSegment(0,0,Me.length,$e.length),nt=je.id||je.name||"footprint";let zt;const bt=parseInt(nt,10);zt=isNaN(bt)?function(Tt){let Gt=0;for(let qt=0;qt0){const be=z.terrain,Me=be.findDEMTileFor(W);Me&&Me.dem?te=i.ex.create(be,W,Me):je=0}if(je===0&&(B.terrainElevationMin=0,B.terrainElevationMax=0),je===B.validForExaggeration&&(je===0||te&&te._demTile&&te._demTile.tileID===B.validForDEMTile.id&&te._dem._timestamp===B.validForDEMTile.timestamp))return!1;for(const be in B.instancesPerModel){const Me=B.instancesPerModel[be];for(let $e=0;$ene&&(ne=Me.max)}const de=i.aC(E.x,z,B)-E.x,je=i.aC(E.y,W,te)-E.y,be=i.bU(ne,m.center.lat)-E.z;return m._zoomFromMercatorZ(Math.sqrt(de*de+je*je+be*be))}function Xi(M,m,v,E,D,z,B){const W=M.context,te=M.renderPass==="shadow",ne=M.shadowRenderer,de=te&&ne?ne.getShadowPassDepthMode():new kr(W.gl.LEQUAL,kr.ReadWrite,M.depthRangeFor3D),je=M.isTileAffectedByFog(z),be=M.transform.projection.name==="globe";if(v.meshes)for(const Me of v.meshes){const $e=be?[]:["MODEL_POSITION_ON_GPU"],Le=[];let Je,Qe,lt;const mt=!be&&E.instancedDataArray.length>20;mt&&$e.push("INSTANCED_ARRAYS");const nt=ac(M,m.paint.get("model-cutoff-fade-range"));if(nt.shouldRenderCutoff&&$e.push("RENDER_CUTOFF"),te&&ne)Je=M.getOrCreateProgram("modelDepth",{defines:$e}),Qe=cP(B.shadowTileMatrix,B.shadowTileMatrix,Float32Array.from(v.globalMatrix)),lt=Jr.disabled;else{Ga($e,Le,Me,M,m.paint.get("model-color-use-theme").constantOr("default")==="none"?null:m.lut),Je=M.getOrCreateProgram("model",{defines:$e,overrideFog:je});const bt=Me.material,Dt=bt.pbrMetallicRoughness,pt=m.paint.get("model-opacity").constantOr(1),vt=m.paint.get("model-emissive-strength").constantOr(0);Qe=G0(z.expandedProjMatrix,Float32Array.from(v.globalMatrix),new Float32Array(16),null,M,pt,Dt.baseColorFactor,bt.emissiveFactor,Dt.metallicFactor,Dt.roughnessFactor,bt,vt,m,D),ne&&(B.shadowUniformsInitialized?Je.setShadowUniformValues(W,ne.getShadowUniformValues()):(ne.setupShadows(z.toUnwrapped(),Je,"model-tile"),B.shadowUniformsInitialized=!0)),lt=nt.shouldRenderCutoff||pt<1||bt.alphaMode!=="OPAQUE"?Jr.alphaBlended:Jr.unblended}M.uploadCommonUniforms(W,Je,z.toUnwrapped(),null,nt);const zt=Me.material.doubleSided?Wr.disabled:Wr.backCCW;if(mt)Le.push(E.instancedDataBuffer),Je.draw(M,W.gl.TRIANGLES,de,sn.disabled,lt,zt,Qe,m.id,Me.vertexBuffer,Me.indexBuffer,Me.segments,m.paint,M.transform.zoom,void 0,Le,E.instancedDataArray.length);else{const bt=te?"u_instance":"u_normal_matrix";for(let Dt=0;Dtte[1]?B:te,z[0]=v.max[0],B=i.aE(i.bE(),z,D),W=B[1]te[1]?B:te,z[1]=v.min[1],B=i.aE(i.bE(),z,D),W=B[1]te[1]?B:te;const ne=i.aC(E[0],0,1),de=100*m.pixelsPerMeter*i.aC(E[1],0,1),je=i.aC(E[2],0,1),be=i.ey(i.bE(),W,te,ne),Me=Math.tan(.5*m.fovX),$e=-be[2]*Me;if(de===0)return be[1]<-Math.abs($e)?je:1;const Le=(-Math.abs($e)-be[1])/de,Je=(lt,mt,nt)=>(1-nt)*lt+nt*mt,Qe=i.aC(Je(1,je,Le),je,1);return Je(1,Qe,i.aC((m.pitch-20)/20,0,1))}class j3{}class kF{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(m,v,E){{const je=this._storage.get(v.id);if(je)return je.lastUsedFrameIdx=m,je.buf}const D=E.gl,z=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),B=new ArrayBuffer(z),W=new Int16Array(B);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array(B));const te=new i.eA;for(let je=0;je30&&(E.buf.destroy(),this._storage.delete(v))}destroy(){for(const[m,v]of this._storage)v.buf.destroy(),this._storage.delete(m)}}class SF{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const r_=i.e8([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class CF{constructor(m){this.revealStart=11,this.revealRange=2}}const Mpe=i.e8([{type:"Float32",name:"a_pos_2f",components:2}]);class MF{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(m,v){const E=m.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const B=new i.eB,W=new i.dC;B.emplaceBack(-1,-1),B.emplaceBack(1,-1),B.emplaceBack(1,1),B.emplaceBack(-1,1),W.emplaceBack(0,1,2),W.emplaceBack(0,2,3),this.vignetteVx=m.context.createVertexBuffer(B,Mpe.members),this.vignetteIdx=m.context.createIndexBuffer(W)}const D=i.dy.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){m.uploadCommonUniforms(m.context,E);const B={u_vignetteShape:(z={vignetteShape:[v.start,v.range,Math.pow(10,v.fadePower)],vignetteColor:[v.color.r,v.color.g,v.color.b,v.color.a*v.strength]}).vignetteShape,u_vignetteColor:z.vignetteColor};E.draw(m,m.context.gl.TRIANGLES,kr.disabled,sn.disabled,Jr.alphaBlended,Wr.disabled,B,"vignette",this.vignetteVx,this.vignetteIdx,D)}var z}}class N3{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(m,v){const E=m.getFreeCameraOptions().position,D=E.toAltitude(),z=E.toLngLat(),B=i.ap(z.lng),W=i.ap(z.lat),te=m.pixelsPerMeter/v,ne=B*i.eD,de=i.eD*Math.log(Math.tan(Math.PI/4+W/2));if(this._offsetXPrev===void 0)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const je=-this._offsetYPrev+de,be=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+ne)*te,this._accumulatedOffsetY+=je*te,this._accumulatedElevation+=be*te,this._offsetXPrev=ne,this._offsetYPrev=de,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function k3(M,m){return[-(M[0]-Math.floor(M[0]/m)*m),-(M[1]-Math.floor(M[1]/m)*m),-(M[2]-Math.floor(M[2]/m)*m)]}function TP(M){const m=i.em(1323123451230),v=[];for(let E=0;E Rain"),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3}update(m){const v=m.context;if(!this.particlesVx){const E=TP(this.particlesCount),D=new i.eE,z=new i.dC;let B=0;const W=i.em(1323123451230);for(let te=0;teE)return;const D=eg(0,1,v.revealStart,v.revealStart+v.revealRange,E);if(!this.particlesVx||!this.particlesIdx)return;const z=structuredClone(this._params);let B=[-z.direction.x,z.direction.y,-100];i.ay(B,B);const W=structuredClone(this._vignetteParams);W.strength*=D,z.overrideStyleParameters||(z.intensity=m.style.rain.state.density,z.timeFactor=m.style.rain.state.intensity,z.color=structuredClone(m.style.rain.state.color),B=structuredClone(m.style.rain.state.direction),z.screenThinning.intensity=m.style.rain.state.centerThinning,z.dropletSizeX=m.style.rain.state.dropletSize[0],z.dropletSizeYScale=m.style.rain.state.dropletSize[1]/m.style.rain.state.dropletSize[0],z.distortionStrength=100*m.style.rain.state.distortionStrength,W.strength=1,W.color=structuredClone(m.style.rain.state.vignetteColor));const te=this.updateOnRender(m,z.timeFactor),ne=m.context,de=ne.gl,je=m.transform;this.screenTexture&&this.screenTexture.size[0]===m.width&&this.screenTexture.size[1]===m.height||(this.screenTexture=new i.T(ne,{width:m.width,height:m.height,data:null},de.RGBA8)),z.distortionStrength>0&&(ne.activeTexture.set(de.TEXTURE0),this.screenTexture.bind(de.LINEAR,de.CLAMP_TO_EDGE),de.copyTexSubImage2D(de.TEXTURE_2D,0,0,0,0,0,m.width,m.height));const be=m.getOrCreateProgram("rainParticle");m.uploadCommonUniforms(ne,be),ne.activeTexture.set(de.TEXTURE0),this.screenTexture.bind(de.LINEAR,de.CLAMP_TO_EDGE);const Me=[z.color.r,z.color.g,z.color.b,z.color.a],$e=(Le,Je)=>{const Qe=k3(this._movement.getPosition(),Le),lt=z.dropletSizeX,mt=z.dropletSizeX*z.dropletSizeYScale,nt=m.width/2,zt=m.height/2,bt=eg(0,z.screenThinning.start,0,1,z.screenThinning.intensity),Dt=eg(.001,z.screenThinning.range,0,1,z.screenThinning.intensity),pt=eg(0,z.screenThinning.particleOffset,0,1,z.screenThinning.intensity),vt=(Tt={modelview:te.modelviewMatrix,projection:te.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Qe,velocityConeAperture:z.velocityConeAperture,velocity:z.velocity,boxSize:Le,rainDropletSize:[lt,mt],distortionStrength:z.distortionStrength,rainDirection:B,color:Me,screenSize:[je.width,je.height],thinningCenterPos:[nt,zt],thinningShape:[bt,Dt,Math.pow(10,z.screenThinning.fadePower)],thinningAffectedRatio:z.screenThinning.affectedRatio,thinningParticleOffset:pt,shapeDirectionalPower:z.shapeDirPower,shapeNormalPower:z.shapeNormalPower,mode:Je?0:1},{u_modelview:Float32Array.from(Tt.modelview),u_projection:Float32Array.from(Tt.projection),u_time:Tt.time,u_cam_pos:Tt.camPos,u_texScreen:0,u_velocityConeAperture:Tt.velocityConeAperture,u_velocity:Tt.velocity,u_boxSize:Tt.boxSize,u_rainDropletSize:Tt.rainDropletSize,u_distortionStrength:Tt.distortionStrength,u_rainDirection:Tt.rainDirection,u_color:Tt.color,u_screenSize:Tt.screenSize,u_thinningCenterPos:Tt.thinningCenterPos,u_thinningShape:Tt.thinningShape,u_thinningAffectedRatio:Tt.thinningAffectedRatio,u_thinningParticleOffset:Tt.thinningParticleOffset,u_shapeDirectionalPower:Tt.shapeDirectionalPower,u_shapeNormalPower:Tt.shapeNormalPower,u_mode:Tt.mode});var Tt;const Gt=Math.round(z.intensity*this.particlesCount),qt=i.dy.simpleSegment(0,0,4*Gt,2*Gt);be.draw(m,de.TRIANGLES,kr.disabled,sn.disabled,Jr.alphaBlended,Wr.disabled,vt,"rain_particles",this.particlesVx,this.particlesIdx,qt)};z.distortionStrength>0&&$e(z.boxSize,!0),$e(z.boxSize,!1),this._vignette.draw(m,W)}}const X0=i.e8([{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 TF extends u2{constructor(m){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 CF("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(m){const v=m.context;if(!this.particlesVx){const E=TP(this.particlesCount),D=new i.eF,z=new i.dC;let B=0;const W=i.em(1323123451230);for(let te=0;teB)return;const W=eg(0,1,z.revealStart,z.revealStart+z.revealRange,B);D.strength*=W,v.overrideStyleParameters||(v.intensity=m.style.snow.state.density,v.timeFactor=m.style.snow.state.intensity,v.color=structuredClone(m.style.snow.state.color),E=structuredClone(m.style.snow.state.direction),v.screenThinning.intensity=m.style.snow.state.centerThinning,v.billboardSize=2.79*m.style.snow.state.flakeSize,D.strength=1,D.color=structuredClone(m.style.snow.state.vignetteColor));const te=this.updateOnRender(m,v.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const ne=m.context,de=ne.gl,je=m.transform,be=m.getOrCreateProgram("snowParticle");m.uploadCommonUniforms(ne,be),((Me,$e,Le)=>{const Je=k3(this._movement.getPosition(),Me),Qe=je.width/2,lt=je.height/2,mt=eg(0,Le.screenThinning.start,0,1,Le.screenThinning.intensity),nt=eg(.001,Le.screenThinning.range,0,1,Le.screenThinning.intensity),zt=eg(0,Le.screenThinning.particleOffset,0,1,Le.screenThinning.intensity),bt=(Dt={modelview:te.modelviewMatrix,projection:te.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Je,velocityConeAperture:Le.velocityConeAperture,velocity:Le.velocity,horizontalOscillationRadius:Le.horizontalOscillationRadius,horizontalOscillationRate:Le.horizontalOscillationRate,boxSize:Me,billboardSize:1*Le.billboardSize,simpleShapeParameters:[Le.shapeFadeStart,Le.shapeFadePower],screenSize:[je.width,je.height],thinningCenterPos:[Qe,lt],thinningShape:[mt,nt,Math.pow(10,Le.screenThinning.fadePower)],thinningAffectedRatio:Le.screenThinning.affectedRatio,thinningParticleOffset:zt,color:[Le.color.r,Le.color.g,Le.color.b,Le.color.a],direction:E},{u_modelview:Float32Array.from(Dt.modelview),u_projection:Float32Array.from(Dt.projection),u_time:Dt.time,u_cam_pos:Dt.camPos,u_velocityConeAperture:Dt.velocityConeAperture,u_velocity:Dt.velocity,u_horizontalOscillationRadius:Dt.horizontalOscillationRadius,u_horizontalOscillationRate:Dt.horizontalOscillationRate,u_boxSize:Dt.boxSize,u_billboardSize:Dt.billboardSize,u_simpleShapeParameters:Dt.simpleShapeParameters,u_screenSize:Dt.screenSize,u_thinningCenterPos:Dt.thinningCenterPos,u_thinningShape:Dt.thinningShape,u_thinningAffectedRatio:Dt.thinningAffectedRatio,u_thinningParticleOffset:Dt.thinningParticleOffset,u_particleColor:Dt.color,u_direction:Dt.direction});var Dt;const pt=Math.round(Le.intensity*this.particlesCount),vt=i.dy.simpleSegment(0,0,4*pt,2*pt);this.particlesVx&&this.particlesIdx&&be.draw(m,de.TRIANGLES,kr.disabled,sn.disabled,Jr.alphaBlended,Wr.disabled,bt,"snow_particles",this.particlesVx,this.particlesIdx,vt)})(v.boxSize,0,v),this._vignette.draw(m,D)}}const AF={symbol:function(M,m,v,E,D){if(M.renderPass!=="translucent")return;const z=sn.disabled,B=M.colorModeForRenderPass(),W=v.layout.get("text-variable-anchor"),te=v.layout.get("text-size-scale-range"),ne=i.aC(M.scaleFactor,te[0],te[1]);W&&function(be,Me,$e,Le,Je,Qe,lt,mt){const nt=Me.transform,zt=Je==="map",bt=Qe==="map";for(const Dt of be){const pt=Le.getTile(Dt),vt=pt.getBucket($e);if(!vt||!vt.text||!vt.text.segments.get().length)continue;const Tt=i.bj(vt.textSizeData,nt.zoom,mt),Gt=Gx(Dt,vt.getProjection(),nt),qt=nt.calculatePixelsToTileUnitsMatrix(pt),ns=jt(Gt,pt.tileID.canonical,bt,zt,nt,vt.getProjection(),qt),Jt=vt.hasIconTextFit()&&vt.hasIconData();Tt&&mF(vt,zt,bt,lt,nt,ns,Dt,Math.pow(2,nt.zoom-pt.tileID.overscaledZ),Tt,Jt)}}(E,M,v,m,v.layout.get("text-rotation-alignment"),v.layout.get("text-pitch-alignment"),D,ne);const de=v.paint.get("icon-opacity").constantOr(1)!==0,je=v.paint.get("text-opacity").constantOr(1)!==0;v.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(de||je)?m3(M,m,v,E,z,B):(de&&m3(M,m,v,E,z,B,{onlyIcons:!0}),je&&m3(M,m,v,E,z,B,{onlyText:!0})),m.map.showCollisionBoxes&&(gr(M,m,v,E,v.paint.get("text-translate"),v.paint.get("text-translate-anchor"),!0),gr(M,m,v,E,v.paint.get("icon-translate"),v.paint.get("icon-translate-anchor"),!1))},circle:function(M,m,v,E){if(M.renderPass!=="translucent")return;const D=v.paint.get("circle-opacity"),z=v.paint.get("circle-stroke-width"),B=v.paint.get("circle-stroke-opacity"),W=v.layout.get("circle-sort-key").constantOr(1)!==void 0,te=v.paint.get("circle-emissive-strength");if(D.constantOr(1)===0&&(z.constantOr(1)===0||B.constantOr(1)===0))return;const ne=M.context,de=ne.gl,je=M.transform,be=!(!M.terrain||!M.terrain.enabled),Me=v.layout.get("circle-elevation-reference"),$e=M.depthModeForSublayer(0,kr.ReadOnly),Le=new kr(M.context.gl.LEQUAL,kr.ReadOnly,M.depthRangeFor3D),Je=Me==="none"||be?$e:Le,Qe=sn.disabled,lt=M.colorModeForDrapableLayerRenderPass(te),mt=je.projection.name==="globe",nt=[i.aH(je.center.lng),i.aL(je.center.lat)],zt=[];for(let Dt=0;DtDt.sortKey-pt.sortKey);const bt={useDepthForOcclusion:je.depthOcclusionForSymbolsAndCircles};for(const Dt of zt){const{programConfiguration:pt,program:vt,layoutVertexBuffer:Tt,dynamicBuffers:Gt,indexBuffer:qt,uniformValues:ns,tile:Jt}=Dt.state,Ns=Dt.segments;M.terrain&&M.terrain.setupElevationDraw(Jt,vt,bt),M.uploadCommonUniforms(ne,vt,Jt.tileID.toUnwrapped()),vt.draw(M,de.TRIANGLES,Je,Qe,lt,Wr.disabled,ns,v.id,Tt,qt,Ns,v.paint,je.zoom,pt,Gt)}},heatmap:function(M,m,v,E){if(v.paint.get("heatmap-opacity")!==0)if(M.renderPass==="offscreen"){const D=M.context,z=D.gl,B=sn.disabled,W=new Jr([z.ONE,z.ONE,z.ONE,z.ONE],i.aq.transparent,[!0,!0,!0,!0]),te=M.transform.projection.name==="globe"?.5:.25;v.heatmapFbo=i2.createWithTexture(D,v.heatmapFbo,M.width*te,M.height*te),D.clear({color:i.aq.transparent});const ne=M.transform,de=ne.projection.name==="globe",je=de?["PROJECTION_GLOBE_VIEW"]:[],be=de?Wr.frontCCW:Wr.disabled,Me=[i.aH(ne.center.lng),i.aL(ne.center.lat)];for(let $e=0;$e({u_image:0,u_color_ramp:1,u_opacity:je.paint.get("heatmap-opacity")}))(0,z),z.id,D.viewportBuffer,D.quadTriangleIndexBuffer,D.viewportSegments,z.paint,D.transform.zoom)}(M,v))},line:function(M,m,v,E){const D=v.paint.get("line-opacity"),z=v.paint.get("line-width");if(D.constantOr(1)===0||z.constantOr(1)===0)return;const B=v.paint.get("line-blend-mode");if(B!=="default"&&M.transform.projection.name!=="globe")return M.terrain&&M.terrain.renderingToTexture?void function(W,te,ne,de,je){if(W.renderPass!=="translucent")return;const be=W.context,Me=be.gl,$e=W.terrain;if(!$e)return;const Le=be.bindFramebuffer.current,Je=W.emissiveMode==="mrt-fallback";ne.lineBlendDrapeFbo=i2.createWithTexture(be,ne.lineBlendDrapeFbo,$e.drapeBufferSize[0],$e.drapeBufferSize[1],!0),ne.lineBlendDrapeStencil=ne.lineBlendDrapeFbo._stencilRbo,Je&&Me.drawBuffers([Me.COLOR_ATTACHMENT0]),be.clear({color:Xx[je].clearColor,depth:1,stencil:0});const Qe=W.currentStencilSource,lt=W._tileClippingMaskIDs,mt=W.nextStencilID;W.currentStencilSource=void 0,W._tileClippingMaskIDs={},W.nextStencilID=1;const nt=W._terrain;W._terrain=null,W._renderTileClippingMasks(ne,te,de),f3(W,te,ne,de,Xx[je].colorMode,!0),W._terrain=nt,W.currentStencilSource=Qe,W._tileClippingMaskIDs=lt,W.nextStencilID=mt,be.bindFramebuffer.set(Le),Je&&Me.drawBuffers([Me.COLOR_ATTACHMENT0,Me.COLOR_ATTACHMENT1]);const zt=$e.drapeBufferSize;be.viewport.set([0,0,zt[0],zt[1]]);const bt=ne.lineBlendDrapeFbo;if(!bt)return;be.activeTexture.set(Me.TEXTURE0),Me.bindTexture(Me.TEXTURE_2D,bt.colorAttachment0.get());const Dt=je==="additive"?1:ne.paint.get("line-opacity").constantOr(1),pt=ne.paint.get("line-emissive-strength").constantOr(0),vt=je==="additive"?W.colorModeForDrapableLayerRenderPass(pt):Xx[je].colorMode;W.getOrCreateProgram("lineBlendComposite").draw(W,Me.TRIANGLES,kr.disabled,sn.disabled,vt,Wr.disabled,i3(0,Dt,Xx[je].compositeUniformValue),ne.id,W.viewportBuffer,W.quadTriangleIndexBuffer,W.viewportSegments,ne.paint,W.transform.zoom)}(M,m,v,E,B):M.renderPass==="offscreen"?void function(W,te,ne,de,je){const be=W.context,Me=Math.ceil(W.width),$e=Math.ceil(W.height);ne.lineBlendFbo=i2.createWithTexture(be,ne.lineBlendFbo,Me,$e,!0),ne.lineBlendStencil=ne.lineBlendFbo._stencilRbo,be.clear({color:Xx[je].clearColor,depth:1,stencil:0});const Le=W.currentStencilSource,Je=W._tileClippingMaskIDs,Qe=W.nextStencilID;W.currentStencilSource=void 0,W._tileClippingMaskIDs={},W.nextStencilID=1,W._renderTileClippingMasks(ne,te,de);const lt=W.renderPass;W.renderPass="translucent",f3(W,te,ne,de,Xx[je].colorMode),W.renderPass=lt,W.currentStencilSource=Le,W._tileClippingMaskIDs=Je,W.nextStencilID=Qe,be.viewport.set([0,0,W.width,W.height])}(M,m,v,E,B):M.renderPass==="translucent"?void function(W,te,ne){const de=W.context,je=de.gl,be=te.lineBlendFbo;if(!be)return;de.activeTexture.set(je.TEXTURE0),je.bindTexture(je.TEXTURE_2D,be.colorAttachment0.get());const Me=ne==="additive"?1:te.paint.get("line-opacity").constantOr(1),$e=ne==="additive"?W.colorModeForDrapableLayerRenderPass(te.paint.get("line-emissive-strength").constantOr(0)):Xx[ne].colorMode;W.getOrCreateProgram("lineBlendComposite").draw(W,je.TRIANGLES,kr.disabled,sn.disabled,$e,Wr.disabled,i3(0,Me,Xx[ne].compositeUniformValue),te.id,W.viewportBuffer,W.quadTriangleIndexBuffer,W.viewportSegments,te.paint,W.transform.zoom)}(M,v,B):void 0;M.renderPass==="translucent"&&f3(M,m,v,E)},fill:function(M,m,v,E){const D=v.paint.get("fill-color"),z=v.paint.get("fill-opacity");if(z.constantOr(1)===0)return;const B=v.paint.get("fill-emissive-strength"),W=M.colorModeForDrapableLayerRenderPass(B),te=v.paint.get("fill-pattern"),ne=M.opaquePassEnabledForLayer()&&!te.constantOr(1)&&D.constantOr(i.aq.transparent).a===1&&z.constantOr(0)===1?"opaque":"translucent";let de="none";v.layout.get("fill-elevation-reference")!=="none"?de="road":v.paint.get("fill-z-offset").constantOr(1)!==0&&(de="offset");const je=!(!M.terrain||!M.terrain.enabled),be={painter:M,sourceCache:m,layer:v,coords:E,colorMode:W,elevationType:de,terrainEnabled:je,pass:ne};if(M.renderPass==="shadow")return void(M.shadowRenderer&&de==="road"&&!je&&function($e){const{painter:Le,sourceCache:Je,layer:Qe,coords:lt}=$e,mt=Le.context.gl,nt=$e.painter.shadowRenderer;for(const zt of lt){const bt=Je.getTile(zt),Dt=bt.getBucket(Qe);if(!Dt)continue;const pt=Dt.elevatedStructures;if(!pt||!pt.shadowCasterSegments||pt.shadowCasterSegments.segments[0].primitiveLength===0)continue;Le.prepareDrawTile();const vt=Dt.bufferData.programConfigurations.get(Qe.id),Tt=Le.isTileAffectedByFog(zt),Gt=Le.getOrCreateProgram("elevatedStructuresDepth",{config:vt,overrideFog:Tt}),qt=nt.calculateShadowPassMatrixFromTile(bt.tileID.toUnwrapped());Le.uploadCommonUniforms(Le.context,Gt,zt.toUnwrapped());const ns=nF(qt,0);Gt.draw(Le,mt.TRIANGLES,nt.getShadowPassDepthMode(),sn.disabled,Jr.disabled,Wr.disabled,ns,Qe.id,pt.vertexBuffer,pt.indexBuffer,pt.shadowCasterSegments,Qe.paint,Le.transform.zoom,vt)}}(be));const Me=M.emissiveMode==="mrt-fallback";if(de!=="offset"){if(c2(be,!1,Me),de==="road"){const $e=!je&&M.renderPass==="translucent";$e&&l2(M,m,v,E,"geometry"),c2(be,!0,Me,sn.disabled),$e&&function(Le){const{painter:Je,sourceCache:Qe,layer:lt,coords:mt,colorMode:nt}=Le,zt=Je.context.gl,bt=Le.painter.shadowRenderer,Dt=!!bt&&bt.enabled,pt=new kr(Je.context.gl.LEQUAL,kr.ReadOnly,Je.depthRangeFor3D);let vt=[0,0,0];if(Dt){const Gt=Je.style.directionalLight,qt=Je.style.ambientLight;Gt&&qt&&(vt=Ep(Je.style,Gt,qt))}const Tt=Gt=>{for(const qt of mt){const ns=Qe.getTile(qt),Jt=ns.getBucket(lt);if(!Jt)continue;const Ns=Jt.elevatedStructures;if(!Ns)continue;let Is,Zt;if(Gt?(Is=Ns.renderableBridgeSegments,Zt=Ns.bridgeProgramConfigurations.get(lt.id)):(Is=Ns.renderableTunnelSegments,Zt=Ns.tunnelProgramConfigurations.get(lt.id)),!Is||Is.segments[0].primitiveLength===0)continue;Zt.updatePaintBuffers(),Je.prepareDrawTile();const Ut=Je.isTileAffectedByFog(qt),ss=[];Dt&&ss.push("RENDER_SHADOWS","NORMAL_OFFSET");const as=Je.getOrCreateProgram("elevatedStructures",{config:Zt,overrideFog:Ut,defines:ss}),ds=Je.translatePosMatrix(qt.projMatrix,ns,lt.paint.get("fill-translate"),lt.paint.get("fill-translate-anchor"));Dt&&bt.setupShadows(ns.tileID.toUnwrapped(),as,"vector-tile");const Qs=aF(ds,vt);Je.uploadCommonUniforms(Je.context,as,qt.toUnwrapped()),as.draw(Je,zt.TRIANGLES,pt,sn.disabled,nt,Wr.backCCW,Qs,lt.id,Ns.vertexBuffer,Ns.indexBuffer,Is,lt.paint,Je.transform.zoom,Zt,[Ns.vertexBufferNormal])}};Tt(!0),Tt(!1)}(be)}}else c2(be,!1,Me,M.stencilModeFor3D())},"fill-extrusion":function(M,m,v,E){const D=v.paint.get("fill-extrusion-opacity"),z=M.context,B=z.gl,W=M.terrain,te=W&&W.renderingToTexture;if(D===0)return;const ne=M.emissiveMode==="mrt-fallback",de=M.conflationActive&&M.style.isLayerClipped(v,m.getSource()),je=M.style.order.indexOf(v.fqid);if(de&&function(be,Me,$e,Le,Je){for(const Qe of Le){const lt=Me.getTile(Qe).getBucket($e);lt&&(lt.updateReplacement(Qe,be.replacementSource,Je),lt.uploadCentroid(be.context))}}(M,m,v,E,je),W||de)for(const be of E){const Me=m.getTile(be).getBucket(v);Me&&pF(M.context,m,be,Me,v,W,de)}if(M.renderPass==="shadow"&&M.shadowRenderer){if(W&&D<.65&&v._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.af)return;const be=M.shadowRenderer.getShadowPassDepthMode();K0(M,m,v,E,be,sn.disabled,Jr.disabled,de)}else if(M.renderPass==="translucent"){const be=!v.paint.get("fill-extrusion-pattern").constantOr(1),Me=v.paint.get("fill-extrusion-color").constantOr(i.aq.white);if(!te&&Me.a!==0){const $e=new kr(M.context.gl.LEQUAL,kr.ReadWrite,M.depthRangeFor3D);D===1&&be?K0(M,m,v,E,$e,sn.disabled,Jr.unblended,de):(K0(M,m,v,E,$e,sn.disabled,Jr.disabled,de),K0(M,m,v,E,$e,M.stencilModeFor3D(),M.colorModeForRenderPass(),de),M.resetStencilClippingMasks())}if(M.style.enable3dLights()&&be&&(!W&&M.transform.projection.name!=="globe"||te)){const $e=v.paint.get("fill-extrusion-opacity"),Le=v.paint.get("fill-extrusion-ambient-occlusion-intensity"),Je=v.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Qe=v.paint.get("fill-extrusion-flood-light-intensity"),lt=v.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",mt=v.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(lt?null:v.lut).toArray01().slice(0,3),nt=Le>0&&Je>0,zt=Qe>0,bt=(vt,Tt,Gt)=>(1-Gt)*vt+Gt*Tt,Dt=new hP;Dt.translate=v.paint.get("fill-extrusion-translate"),Dt.translateAnchor=v.paint.get("fill-extrusion-translate-anchor"),Dt.edgeRadius=v.layout.get("fill-extrusion-edge-radius"),Dt.cutoffFadeRange=v.paint.get("fill-extrusion-cutoff-fade-range");const pt=vt=>{const Tt=M.depthModeForSublayer(1,kr.ReadOnly,B.LEQUAL,!0),Gt=v.paint.get(vt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),qt=bt(.1,3,Gt),ns=M._showOverdrawInspector;if(!ns){const Jt=new sn({func:B.ALWAYS,mask:255},255,255,B.KEEP,B.KEEP,B.REPLACE),Ns=new Jr([B.ONE,B.ONE,B.ONE,B.ONE],i.aq.transparent,[!1,!1,!1,!0],B.MIN);Of(Dt,M,m,v,E,Tt,Jt,Ns,Wr.disabled,vt,"sdf",$e,Le,Je,Qe,mt,qt,de,!1)}{const Jt=ns?sn.disabled:new sn({func:B.EQUAL,mask:255},255,255,B.KEEP,B.DECR,B.DECR),Ns=ns?M.colorModeForRenderPass():new Jr([B.ONE_MINUS_DST_ALPHA,B.DST_ALPHA,B.ONE,B.ONE],i.aq.transparent,[!0,!0,!0,!0]);Of(Dt,M,m,v,E,Tt,Jt,Ns,Wr.disabled,vt,"color",$e,Le,Je,Qe,mt,qt,de,!1)}};if(te){const vt=()=>{const Gt=W.drapeBufferSize[0],qt=W.drapeBufferSize[1];let ns=W.framebufferCopyTexture;return ns&&(!ns||ns.size[0]===Gt&&ns.size[1]===qt)||(ns&&ns.destroy(),ns=W.framebufferCopyTexture=new i.T(z,new i.q({width:Gt,height:qt}),B.RGBA8)),ns.bind(B.LINEAR,B.CLAMP_TO_EDGE),B.copyTexSubImage2D(B.TEXTURE_2D,0,0,0,0,0,Gt,qt),ns},Tt=(Gt,qt,ns)=>{const Jt=M.depthModeForSublayer(1,kr.ReadOnly,B.LEQUAL,!1),Ns=v.paint.get(Gt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Is=bt(.1,3,Ns);{const Zt=new Jr([B.ONE,B.ONE,B.ONE,B.ONE],i.aq.transparent,[!1,!1,!1,!0]);Of(Dt,M,m,v,E,Jt,sn.disabled,Zt,Wr.disabled,Gt,"clear",$e,Le,Je,Qe,mt,Is,de,qt)}{const Zt=new sn({func:B.ALWAYS,mask:255},255,255,B.KEEP,B.KEEP,B.REPLACE),Ut=new Jr([B.ONE,B.ONE,B.ONE,B.ONE],i.aq.transparent,[!1,!1,!1,!0],B.MIN);Of(Dt,M,m,v,E,Jt,Zt,Ut,Wr.disabled,Gt,"sdf",$e,Le,Je,Qe,mt,Is,de,qt)}ne&&!Gt&&(ns=vt());{const Zt=Gt?B.ZERO:B.ONE_MINUS_DST_ALPHA,Ut=new sn({func:B.EQUAL,mask:255},255,255,B.KEEP,B.DECR,B.DECR),ss=new Jr([Zt,B.DST_ALPHA,B.ONE_MINUS_DST_ALPHA,B.ZERO],i.aq.transparent,[!0,!0,!0,!0]);Of(Dt,M,m,v,E,Jt,Ut,ss,Wr.disabled,Gt,"color",$e,Le,Je,Qe,mt,Is,de,qt)}if(!ne||Gt){const Zt=new Jr([B.ONE,B.ONE,B.ONE,Gt?B.ZERO:B.ONE],i.aq.transparent,[!1,!1,!1,!0],Gt?B.FUNC_ADD:B.MAX);Of(Dt,M,m,v,E,Jt,sn.disabled,Zt,Wr.disabled,Gt,"clear",$e,Le,Je,Qe,mt,Is,de,qt,ns)}else{B.drawBuffers([B.NONE,B.COLOR_ATTACHMENT1]);const Zt=new sn({func:B.EQUAL,mask:255},254,255,B.KEEP,B.DECR,B.DECR),Ut=new Jr([B.ONE,B.ONE,B.ONE,B.ONE],i.aq.transparent,[!0,!1,!1,!1],B.MAX);Of(Dt,M,m,v,E,Jt,Zt,Ut,Wr.disabled,Gt,"emissive",$e,Le,Je,Qe,mt,Is,de,qt,ns),B.drawBuffers([B.COLOR_ATTACHMENT0])}};if(nt||zt){let Gt;M.prepareDrawTile(),ne&&!nt||(Gt=vt()),nt&&Tt(!0,!1,Gt),zt&&Tt(!1,!0,Gt)}}else nt&&pt(!0),zt&&pt(!1),(nt||zt)&&M.resetStencilClippingMasks()}}},building:function(M,m,v,E){M.currentLayer0&&z>0,ne=!0;const de=v.paint.get("building-vertical-scale");if(de<=0)return;M.shadowRenderer||(ne=!1);const je=M.conflationActive&&M.style.isLayerClipped(v,m.getSource()),be=M.style.order.indexOf(v.fqid);if(function(Me,$e,Le,Je,Qe,lt){for(const mt of lt){const nt=$e.getTile(mt).getBucket(Le);nt&&(Qe&&nt.updateReplacement(mt,Me.replacementSource,Je),nt.uploadUpdatedIndexBuffer(Me.context))}}(M,m,v,be,je,E),function(Me,$e,Le,Je){for(const Qe of Je){const lt=$e.getTile(Qe).getBucket(Le);lt&<.needsEvaluation()&<.uploadUpdatedColorBuffer(Me.context)}}(M,m,v,E),v.resetLayerRenderingStats(M),M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0),M.renderPass==="shadow"&&M.shadowRenderer){const Me=[],$e=M.shadowRenderer.getShadowPassDepthMode();d2({painter:M,source:m,layer:v,coords:E,defines:Me,blendMode:Jr.disabled,depthMode:$e,opacity:W,verticalScale:de,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(M.renderPass==="translucent"){let Me=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];ne&&(Me=Me.concat("RENDER_SHADOWS")),M.shadowRenderer&&M.shadowRenderer.useNormalOffset&&(Me=Me.concat("NORMAL_OFFSET"));const $e=v.paint.get("building-facade-emissive-chance"),Le=v.paint.get("building-ambient-occlusion-intensity"),Je=v.paint.get("building-flood-light-intensity"),Qe=v.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",lt=v.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(Qe?null:v.lut).toArray01().slice(0,3),mt=v.paint.get("building-flood-light-ground-attenuation"),nt=Je>0,zt=new kr(M.context.gl.LEQUAL,kr.ReadWrite,M.depthRangeFor3D);W<1&&d2({painter:M,source:m,layer:v,coords:E,defines:Me,blendMode:Jr.disabled,depthMode:zt,opacity:W,verticalScale:de,facadeEmissiveChance:$e,facadeAOIntensity:Le,floodLightIntensity:Je,floodLightColor:lt,depthOnly:!0});const bt=M.colorModeForRenderPass();d2({painter:M,source:m,layer:v,coords:E,defines:Me,blendMode:bt,depthMode:zt,opacity:W,verticalScale:de,facadeEmissiveChance:$e,facadeAOIntensity:Le,floodLightIntensity:Je,floodLightColor:lt});const Dt=v.paint.get("building-front-cutoff");x3(M.transform.pitch,Dt,!!M.terrain),te&&pP(M,m,v,E,!0,W,D,z,Je,lt,B,je),nt&&pP(M,m,v,E,!1,W,D,z,Je,lt,mt,je)}else if(M.renderPass==="light-beam"){const Me=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],$e=new kr(M.context.gl.LEQUAL,kr.ReadOnly,M.depthRangeFor3D);d2({painter:M,source:m,layer:v,coords:E,defines:Me,blendMode:Jr.alphaBlended,depthMode:$e,opacity:W,verticalScale:de,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!1),M.resetStencilClippingMasks()},hillshade:function(M,m,v,E){if(M.renderPass!=="offscreen"&&M.renderPass!=="translucent"||M.style.disableElevatedTerrain)return;const D=M.context,z=M.terrain&&M.terrain.renderingToTexture,[B,W]=M.renderPass!=="translucent"||z?[{},E]:M.stencilConfigForOverlap(E);for(const te of W){const ne=m.getTile(te);if(ne.needsHillshadePrepare&&M.renderPass==="offscreen")hpe(M,ne,v);else if(M.renderPass==="translucent"){const de=M.depthModeForSublayer(0,kr.ReadOnly),je=v.paint.get("hillshade-emissive-strength"),be=M.colorModeForDrapableLayerRenderPass(je),Me=z&&M.terrain?M.terrain.stencilModeForRTTOverlap(te):B[te.overscaledZ];upe(M,te,ne,v,de,Me,be)}}D.viewport.set([0,0,M.width,M.height]),M.resetStencilClippingMasks()},raster:function(M,m,v,E,D,z){if(M.renderPass!=="translucent")return;const B=v.paint.get("raster-opacity");if(B===0)return;const W=M.transform.projection.name==="globe",te=v.paint.get("raster-elevation")!==0,ne=te&&W,de=M.terrain&&M.terrain.exaggeration()>0&&te&&v.paint.get("raster-elevation-reference")==="ground",je=!W&&de;if(M.renderElevatedRasterBackface&&!ne)return;const be=M.context,Me=be.gl,$e=m.getSource(),Le=function(vt,Tt,Gt,qt,ns){const Jt=Tt.paint.get("raster-color"),Ns=vt.type==="raster-array",Is=[],Zt=Tt.paint.get("raster-resampling"),Ut=Tt.paint.get("raster-color-mix");let ss=Tt.paint.get("raster-color-range");const as=[Ut[0],Ut[1],Ut[2],0],ds=Ut[3];let Qs=Zt==="nearest"?qt.NEAREST:qt.LINEAR;if(Ns&&(Is.push("RASTER_ARRAY"),Jt||Is.push("RASTER_COLOR"),Zt==="linear"&&Is.push("RASTER_ARRAY_LINEAR"),Qs=qt.NEAREST,!ss&&vt.rasterLayers)){const Gs=vt.rasterLayers.find(({id:Ws})=>Ws===Tt.sourceLayer);Gs&&Gs.fields&&Gs.fields.range&&(ss=Gs.fields.range)}if(ss=ss||[0,1],Jt){Is.push("RASTER_COLOR"),Gt.activeTexture.set(qt.TEXTURE2),Tt.updateColorRamp(ss);let Gs=Tt.colorRampTexture;Gs||(Gs=Tt.colorRampTexture=new i.T(Gt,Tt.colorRamp,qt.RGBA8)),Gs.bind(Qs,qt.CLAMP_TO_EDGE)}return ns&&Is.push("USE_MRT1"),{mix:as,range:ss,offset:ds,defines:Is,resampling:Qs}}($e,v,be,Me,M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback");if($e instanceof i.aV&&!E.length&&!W)return;const Je=v.paint.get("raster-emissive-strength"),Qe=M.colorModeForDrapableLayerRenderPass(Je),lt=M.terrain&&M.terrain.renderingToTexture,mt=!M.options.moving,nt=v.paint.get("raster-resampling")==="nearest"?Me.NEAREST:Me.LINEAR;if($e instanceof i.aV&&!E.length&&($e.onNorthPole||$e.onSouthPole)){const vt=te?M.stencilModeFor3D():sn.disabled;return void y3(!!$e.onNorthPole,null,M,m,v,Je,Le,Wr.disabled,vt)}if(!E.length)return;const[zt,bt]=$e instanceof i.aV||lt?[{},E]:M.stencilConfigForOverlap(E),Dt=bt[bt.length-1].overscaledZ;ne&&Le.defines.push("PROJECTION_GLOBE_VIEW"),te&&Le.defines.push("RENDER_CUTOFF","ELEVATED"),de&&Le.defines.push("ELEVATION_REFERENCE_GROUND");const pt=(vt,Tt,Gt)=>{for(const qt of vt){const ns=qt.toUnwrapped(),Jt=m.getTile(qt);if(lt&&(!Jt||!Jt.hasData()))continue;be.activeTexture.set(Me.TEXTURE0);const Ns=gF(Jt,$e,v,Le);if(!Ns||!Ns.texture)continue;const{texture:Is,mix:Zt,offset:Ut,tileSize:ss,buffer:as}=Ns;let ds,Qs;lt?(ds=kr.disabled,Qs=qt.projMatrix):te?(ds=new kr(Me.LEQUAL,kr.ReadWrite,M.depthRangeFor3D),Qs=W?Float32Array.from(M.transform.expandedFarZProjMatrix):M.transform.calculateProjMatrix(ns,mt)):(ds=M.depthModeForSublayer(qt.overscaledZ-Dt,B===1?kr.ReadWrite:kr.ReadOnly,Me.LESS),Qs=M.transform.calculateProjMatrix(ns,mt));const Gs=M.terrain&<?M.terrain.stencilModeForRTTOverlap(qt):zt[qt.overscaledZ],Ws=z?0:v.paint.get("raster-fade-duration");Jt.registerFadeDuration(Ws);const Ts=m.findLoadedParent(qt,0),wr=t2(Jt,Ts,m,M.transform,Ws);let Ir,pr;!wr.isFading&&Jt.refreshedUponExpiration&&(Jt.refreshedUponExpiration=!1),M.terrain&&M.terrain.prepareDrawTile(),be.activeTexture.set(Me.TEXTURE0),Is.bind(nt,Me.CLAMP_TO_EDGE),be.activeTexture.set(Me.TEXTURE1),Ts?(Ts.texture&&Ts.texture.bind(nt,Me.CLAMP_TO_EDGE),Ir=Math.pow(2,Ts.tileID.overscaledZ-Jt.tileID.overscaledZ),pr=[Jt.tileID.canonical.x*Ir%1,Jt.tileID.canonical.y*Ir%1]):Is.bind(nt,Me.CLAMP_TO_EDGE),"useMipmap"in Is&&be.extTextureFilterAnisotropic&&M.transform.pitch>20&&Me.texParameterf(Me.TEXTURE_2D,be.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,be.extTextureFilterAnisotropicMax);const vr=M.transform;let Zr;const fn=te?xP(vr):[0,0,0,0];let on,$n,Ur,qn,ln,Ta=0;if(ne&&$e instanceof i.aV&&$e.coordinates.length>3)on=Float32Array.from(i.du(i.dv(new i.cn(0,0,0)))),$n=Float32Array.from(vr.globeMatrix),Ur=Float32Array.from(i.dq(vr)),qn=[i.aH(vr.center.lng),i.aL(vr.center.lat)],Zr=$e.elevatedGlobePerspectiveTransform,ln=$e.elevatedGlobeGridMatrix||new Float32Array(9);else if(ne){const Fa=i.dr(qt.canonical);Ta=i.ds(Fa.getCenter().lat),on=Float32Array.from(i.du(i.dv(qt.canonical))),$n=Float32Array.from(vr.globeMatrix),Ur=Float32Array.from(i.dq(vr)),qn=[i.aH(vr.center.lng),i.aL(vr.center.lat)],Zr=[0,0],ln=Float32Array.from(i.dt(qt.canonical,Fa,Ta,vr.worldSize/vr._pixelsPerMercatorPixel))}else Zr=$e instanceof i.aV?$e.perspectiveTransform:[0,0],on=new Float32Array(16),$n=new Float32Array(9),Ur=new Float32Array(16),qn=[0,0],ln=new Float32Array(9);const hi=lF(M,Qs,on,$n,Ur,ln,pr||[0,0],i.al(M.transform.zoom),qn,fn,Ir||1,wr,v,Zr,te?v.paint.get("raster-elevation"):0,2,Zt,Ut,Le.range,ss,as,Je),Zi=M.isTileAffectedByFog(qt),ji=M.getOrCreateProgram("raster",{defines:Le.defines,overrideFog:Zi});if(M.uploadCommonUniforms(be,ji,ns),$e instanceof i.aV){const Fa=$e.elevatedGlobeVertexBuffer,In=$e.elevatedGlobeIndexBuffer;if(lt||!W)$e.boundsBuffer&&$e.boundsSegments&&ji.draw(M,Me.TRIANGLES,ds,sn.disabled,Qe,Wr.disabled,hi,v.id,$e.boundsBuffer,M.quadTriangleIndexBuffer,$e.boundsSegments);else if(Fa&&In){const Ln=vr.zoom<=i.cJ?$e.elevatedGlobeSegments:$e.getSegmentsForLongitude(vr.center.lng);Ln&&ji.draw(M,Me.TRIANGLES,ds,sn.disabled,Qe,Tt,hi,v.id,Fa,In,Ln)}}else if(ne){ds=new kr(Me.LEQUAL,kr.ReadOnly,M.depthRangeFor3D);const Fa=M.globeSharedBuffers;if(Fa){de&&(M.terrain.setupElevationDraw(Jt,ji),M.uploadCommonUniforms(be,ji,Jt.tileID.toUnwrapped()));const[In,Ln,Ni]=Fa.getGridBuffers(Ta,!1),Qi=ji.getAttributeLocation(Me,"a_texture_pos");Qi!==-1&&Me.vertexAttribI4ui(Qi,0,0,0,0),ji.draw(M,Me.TRIANGLES,ds,Gt||Gs,M.colorModeForRenderPass(),Tt,hi,v.id,In,Ln,Ni)}}else if(je)ds=new kr(Me.LEQUAL,kr.ReadWrite,M.depthRangeFor3D),M.terrain.setupElevationDraw(Jt,ji),M.uploadCommonUniforms(be,ji,Jt.tileID.toUnwrapped()),vr.pitch>20&&ji.draw(M,Me.TRIANGLES,ds,sn.disabled,Jr.disabled,Wr.frontCCW,hi,v.id,M.terrain.gridBuffer,M.terrain.gridIndexBuffer,M.terrain.gridSegments),ji.draw(M,Me.TRIANGLES,ds,Gs,Qe,Wr.backCCW,hi,v.id,M.terrain.gridBuffer,M.terrain.gridIndexBuffer,M.terrain.gridSegments);else{const{tileBoundsBuffer:Fa,tileBoundsIndexBuffer:In,tileBoundsSegments:Ln}=M.getTileBoundsBuffers(Jt);ji.draw(M,Me.TRIANGLES,ds,Gs,Qe,Wr.disabled,hi,v.id,Fa,In,Ln)}}if(!($e instanceof i.aV)&&ne)for(const qt of vt){const ns=qt.canonical.y===(1<i.d$[as](ns));Zt.push(ns);const Ut=ns.canonical.x,ss=ns.canonical.y;for(const as of Zt){const ds=nt.getTile(Tt?as.wrapped():as);if(!ds)continue;const Qs=ds.rasterParticleState;if(!Qs)continue;const Gs=as.canonical.x+(1<Dt.tileID)),Me&&(ne.activeTexture.set(de.TEXTURE0),M.imageManager.bind(M.context,v.scope));const bt=[];if(M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&bt.push("USE_MRT1"),te){const Dt=M.getOrCreateProgram(mt,{overrideFog:!1,overrideRtt:!0,defines:bt}),pt=new Float32Array(i.b9([])),vt=new i.aR(0,0,0,0,0),Tt=Me?cy(pt,W,B,M,0,v.scope,$e,te,{tileID:vt,tileSize:be}):a2(pt,W,B,D.toPremultipliedRenderColor(z?null:v.lut));return void Dt.draw(M,de.TRIANGLES,Qe,Je,lt,Wr.disabled,Tt,v.id,M.viewportBuffer,M.quadTriangleIndexBuffer,M.viewportSegments)}for(const Dt of zt){const pt=M.isTileAffectedByFog(Dt),vt=M.getOrCreateProgram(mt,{overrideFog:pt,defines:bt}),Tt=Dt.toUnwrapped(),Gt=E?Dt.projMatrix:M.transform.calculateProjMatrix(Tt);M.prepareDrawTile();const qt=m?m.getTile(Dt):nt?nt[Dt.key]:new i.b0(Dt,be,je.zoom,M),ns=Me?cy(Gt,W,B,M,0,v.scope,$e,te,{tileID:Dt,tileSize:be}):a2(Gt,W,B,D.toPremultipliedRenderColor(z?null:v.lut));M.uploadCommonUniforms(ne,vt,Tt);const{tileBoundsBuffer:Jt,tileBoundsIndexBuffer:Ns,tileBoundsSegments:Is}=M.getTileBoundsBuffers(qt);vt.draw(M,de.TRIANGLES,Qe,Je,lt,Wr.disabled,ns,v.id,Jt,Ns,Is)}},sky:function(M,m,v){const E=M._atmosphere?i.al(M.transform.zoom):1,D=v.paint.get("sky-opacity")*E;if(D===0)return;const z=M.context,B=v.paint.get("sky-type"),W=new kr(z.gl.LEQUAL,kr.ReadOnly,[0,1]),te=M.frameCounter/1e3%1;B==="atmosphere"?M.renderPass==="offscreen"?v.needsSkyboxCapture(M)&&(function(ne,de){const je=ne.context,be=je.gl;let Me=de.skyboxFbo;if(!Me){Me=de.skyboxFbo=je.createFramebuffer(32,32,1,null),de.skyboxGeometry=new Zd(je),de.skyboxTexture=je.gl.createTexture(),be.bindTexture(be.TEXTURE_CUBE_MAP,de.skyboxTexture),be.texParameteri(be.TEXTURE_CUBE_MAP,be.TEXTURE_WRAP_S,be.CLAMP_TO_EDGE),be.texParameteri(be.TEXTURE_CUBE_MAP,be.TEXTURE_WRAP_T,be.CLAMP_TO_EDGE),be.texParameteri(be.TEXTURE_CUBE_MAP,be.TEXTURE_MIN_FILTER,be.LINEAR),be.texParameteri(be.TEXTURE_CUBE_MAP,be.TEXTURE_MAG_FILTER,be.LINEAR);for(let Qe=0;Qe<6;++Qe)be.texImage2D(be.TEXTURE_CUBE_MAP_POSITIVE_X+Qe,0,be.RGBA,32,32,0,be.RGBA,be.UNSIGNED_BYTE,null)}je.bindFramebuffer.set(Me.framebuffer),je.viewport.set([0,0,32,32]);const $e=de.getCenter(ne,!0),Le=ne.getOrCreateProgram("skyboxCapture"),Je=new Float64Array(16);i.b9(Je),i.ef(Je,Je,.5*-Math.PI),Xh(ne,de,Le,Je,$e,0),i.b9(Je),i.ef(Je,Je,.5*Math.PI),Xh(ne,de,Le,Je,$e,1),i.b9(Je),i.cE(Je,Je,.5*-Math.PI),Xh(ne,de,Le,Je,$e,2),i.b9(Je),i.cE(Je,Je,.5*Math.PI),Xh(ne,de,Le,Je,$e,3),i.b9(Je),Xh(ne,de,Le,Je,$e,4),i.b9(Je),i.ef(Je,Je,Math.PI),Xh(ne,de,Le,Je,$e,5),je.viewport.set([0,0,ne.width,ne.height])}(M,v),v.markSkyboxValid(M)):M.renderPass==="sky"&&function(ne,de,je,be,Me){const $e=ne.context,Le=$e.gl,Je=ne.transform,Qe=ne.getOrCreateProgram("skybox");$e.activeTexture.set(Le.TEXTURE0),Le.bindTexture(Le.TEXTURE_CUBE_MAP,de.skyboxTexture);const lt=((mt,nt,zt,bt,Dt)=>({u_matrix:mt,u_sun_direction:nt,u_cubemap:0,u_opacity:bt,u_temporal_offset:Dt}))(Je.skyboxMatrix,de.getCenter(ne,!1),0,be,Me);ne.uploadCommonUniforms($e,Qe),Qe.draw(ne,Le.TRIANGLES,je,sn.disabled,ne.colorModeForRenderPass(),Wr.backCW,lt,"skybox",de.skyboxGeometry.vertexBuffer,de.skyboxGeometry.indexBuffer,de.skyboxGeometry.segment)}(M,v,W,D,te):B==="gradient"&&M.renderPass==="sky"&&function(ne,de,je,be,Me){const $e=ne.context,Le=$e.gl,Je=ne.transform,Qe=ne.getOrCreateProgram("skyboxGradient");de.skyboxGeometry||(de.skyboxGeometry=new Zd($e)),$e.activeTexture.set(Le.TEXTURE0);let lt=de.colorRampTexture;lt||(lt=de.colorRampTexture=new i.T($e,de.colorRamp,Le.RGBA8)),lt.bind(Le.LINEAR,Le.CLAMP_TO_EDGE);const mt=((nt,zt,bt,Dt,pt)=>({u_matrix:nt,u_color_ramp:0,u_center_direction:zt,u_radius:i.ap(bt),u_opacity:Dt,u_temporal_offset:pt}))(Je.skyboxMatrix,de.getCenter(ne,!1),de.paint.get("sky-gradient-radius"),be,Me);ne.uploadCommonUniforms($e,Qe),Qe.draw(ne,Le.TRIANGLES,je,sn.disabled,ne.colorModeForRenderPass(),Wr.backCW,mt,"skyboxGradient",de.skyboxGeometry.vertexBuffer,de.skyboxGeometry.indexBuffer,de.skyboxGeometry.segment)}(M,v,W,D,te)},custom:function(M,m,v,E){const D=M.context,z=v.implementation;if(!M.transform.projection.unsupportedLayers||!M.transform.projection.unsupportedLayers.includes("custom")||M.terrain&&(M.terrain.renderingToTexture||M.renderPass==="offscreen")&&v.isDraped(m)){if(M.renderPass==="offscreen"){const B=z.prerender;if(B){if(M.setCustomLayerDefaults(),D.setColorMode(M.colorModeForRenderPass()),M.transform.projection.name==="globe"){const W=M.transform.pointMerc;B.call(z,D.gl,M.transform.customLayerMatrix(),M.transform.getProjection(),M.transform.globeToMercatorMatrix(),i.al(M.transform.zoom),[W.x,W.y],M.transform.pixelsPerMeterRatio)}else B.call(z,D.gl,M.transform.customLayerMatrix());D.setDirty(),M.setBaseState()}}else if(M.renderPass==="translucent"){if(M.terrain&&M.terrain.renderingToTexture){const W=z.renderToTile;if(W){const te=E[0].canonical,ne={x:te.x+E[0].wrap*(z.wrapTileId?0:1<{ne&&(ne.useNormalOffset=!0,de||(ne.enabled=!0))},be=m.getSource();if(M.renderPass==="light-beam"&&be.type!=="batched-model")return;if(be.type==="vector"||be.type==="geojson")return function(nt,zt,bt,Dt,pt){const vt=nt.transform,Tt=vt.projection.name==="globe",Gt=vt.getFreeCameraOptions().position;if(!nt.modelManager)return;const qt=nt.modelManager;bt.modelManager=qt;const ns=nt.shadowRenderer;if(!bt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const Jt=bt._unevaluatedLayout._values["model-id"],Ns=Object.assign({},bt.layout.get("model-id").parameters),Is=nt.style.order.indexOf(bt.fqid),Zt=bt.paint.get("model-opacity").constantOr(1);for(const Ut of Dt){const ss=zt.getTile(Ut).getBucket(bt);if(!ss||ss.projection.name!==vt.projection.name)continue;const as=ss.getModelUris();if(as&&!ss.modelsRequested&&(qt.addModelsFromBucket(as,pt),ss.modelsRequested=!0),Tt)Ns.zoom=Ut.overscaledZ;else{const pr=s_(Ut,vt);Ns.zoom=pr}const ds=Jt.possiblyEvaluate(Ns);if(Ys(nt,ss,Ut),Hs.shadowUniformsInitialized=!1,Hs.useSingleShadowCascade=!!ns&&ns.getMaxCascadeForTile(Ut.toUnwrapped())===0,nt.renderPass==="shadow"&&ns){if(nt.currentShadowCascade===1&&ss.isInsideFirstShadowMapFrustum)continue;const pr=vt.calculatePosMatrix(Ut.toUnwrapped(),vt.worldSize);if(Hs.tileMatrix.set(pr),Hs.shadowTileMatrix=Float32Array.from(ns.calculateShadowPassMatrixFromMatrix(pr)),Hs.aabb.min=[0,0,0],Hs.aabb.max[0]=Hs.aabb.max[1]=i.an,Hs.aabb.max[2]=0,NF(ss,Hs,nt,bt.scope))continue}const Qs=1<0&&nt.style.isLayerClipped(bt,zt.getSource())&&ss.updateReplacement(Ut,nt.replacementSource,Is,bt.scope)&&(ss.uploaded=!1,ss.upload(nt.context));let Ws=0;const Ts=new Array,wr=new Array,Ir=new Array;for(let pr in ss.instancesPerModel){const vr=ss.instancesPerModel[pr];vr.features.length>0&&!Tt&&(pr=ds.evaluate(vr.features[0].feature,{}));const Zr=qt.getModel(pr,pt);if(Zr||qt.hasURLBeenRequested(pr)||ss.modelUris.includes(pr)||(ss.modelUris.push(pr),ss.modelsRequested=!1),Zr&&Zr.uploaded)if(Tt){const fn=i.bJ([],[Gt.x,Gt.y,Gt.z],nt.transform.worldSize);i.eo(fn,fn);for(let on=0;on0&&qn.elevationUpdate(pr.terrain,on,Ur,Zr.source),qn.needsReEvaluation(pr,$n,Zr)&&qn.evaluate(Zr))}})(nt,zt,bt,Dt),function(){const pr=new Map;let vr,Zr,fn;Ts?(vr=Dt.length-1,Zr=-1,fn=-1):(vr=0,Zr=Dt.length,fn=1);const on=new Float64Array(16),$n=i.ce(),Ur=new i.P(0,0);for(let qn=vr;qn!==Zr;qn+=fn){const ln=Dt[qn],Ta=zt.getTile(ln).getBucket(bt);if(!Ta||!Ta.uploaded)continue;let hi=!1;Gt&&(hi=Gt.getMaxCascadeForTile(ln.toUnwrapped())===0);const Zi=vt.calculatePosMatrix(ln.toUnwrapped(),vt.worldSize),ji=Ta.modelTraits;!Qs&&Ts&&(i.b7(on,Zi),i.ah($n,ns,on),Ur.x=$n[0],Ur.y=$n[1]);const Fa=[];Ta.setFilter(bt.filter);for(const In of Ta.getNodesInfo()){if(In.hiddenByReplacement||!In.node.meshes)continue;const Ln=In.node;let Ni=0;nt.terrain&&Ln.elevation&&(Ni=Ln.elevation*nt.terrain.exaggeration());const Qi=(()=>{const Mc=In.aabb;return ds.min=[...Mc.min],ds.max=[...Mc.max],ds.min[2]+=Ni,ds.max[2]+=Ni,i.ah(ds.min,ds.min,Zi),i.ah(ds.max,ds.max,Zi),ds})(),za=In.evaluatedScale;if(za[0]<=1&&za[1]<=1&&za[2]<=1&&Qi.intersects(Gs)===0)continue;if(!Qs&&Ts){const Mc=.16666666666666666;In.cameraCollisionOpacity=ns[0]>Qi.min[0]&&ns[0]Qi.min[1]&&ns[1]!Ts||In.opacity===1&&Ln.opacity===1?In.depthLn.depth?-1:1);for(const In of Fa){const Ln=In.nodeInfo,Ni=Ln.node;if(nt._debugParams.show3DModelFootprints&&Ni.footprint){const sa=Ni.id||Ni.name||"footprint";pr.has(sa)||pr.set(sa,{node:Ni,mvp:In.wvpForTile})}let Qi=i.aD([],Zt,In.tileModelMatrix);i.aD(Qi,Ns,Qi);const za=i.b7([],Qi);i.e6(za,za),i.cC(za,za,Ht),Qi=i.aD(Qi,Qi,Ni.globalMatrix);const wn=nt.renderPass==="light-beam",$i=bt.paint.get("model-color-use-theme").constantOr("default")==="none",mi=ji&i.ez.HasMapboxMeshFeatures,Ho=mi?0:Ln.evaluatedRMEA[0][2];for(let sa=0;sa=Zn||_h>=Zn}}const Ja=_i.material;let em;Ja.occlusionTexture&&Ja.occlusionTexture.offsetScale&&(em=Ja.occlusionTexture.offsetScale,Sl.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const tm=nt.getOrCreateProgram("model",Sl);!Qs&&Gt&&Gt.setupShadowsFromMatrix(In.tileModelMatrix,tm,Gt.useNormalOffset),nt.uploadCommonUniforms(pt,tm,null,vh);const Ci=Ja.pbrMetallicRoughness;Ci.metallicFactor=.9,Ci.roughnessFactor=.5;const Pi=G0(new Float32Array(od),new Float32Array(Qi),new Float32Array(za),new Float32Array(Ni.globalMatrix),nt,In.opacity,Ci.baseColorFactor,Ja.emissiveFactor,Ci.metallicFactor,Ci.roughnessFactor,Ja,Ho,bt,[0,0,0],em);!ll&&(Ln.hasTranslucentParts||In.opacity<1)&&tm.draw(nt,pt.gl.TRIANGLES,ss,sn.disabled,Jr.disabled,Wr.backCCW,Pi,bt.id,_i.vertexBuffer,_i.indexBuffer,_i.segments,bt.paint,nt.transform.zoom,void 0,Mc),tm.draw(nt,pt.gl.TRIANGLES,ll?as:ss,sn.disabled,ll||In.opacity<1||Ln.hasTranslucentParts?Jr.alphaBlended:Jr.unblended,Wr.backCCW,Pi,bt.id,_i.vertexBuffer,_i.indexBuffer,_i.segments,bt.paint,nt.transform.zoom,void 0,Mc)}}}if(nt._debugParams.show3DModelFootprints&&pr.size>0){const qn=Array.from(pr.keys()).sort();for(const ln of qn){const{node:Ta,mvp:hi}=pr.get(ln);SP(nt,0,Ta,hi)}}}()}(M,m,v,E),void je();if(be.type!=="model")return;const Me=be.getModels(),$e=[],Le=M.transform.getFreeCameraOptions().position,Je=i.bJ([],[Le.x,Le.y,Le.z],M.transform.worldSize);i.eo(Je,Je);const Qe=[],lt=[];let mt=0;for(const nt of Me){const zt=m.getFeatureState("",nt.id),bt={type:"Unknown",id:nt.id,properties:nt.featureProperties},Dt=v.paint.get("model-rotation").evaluate(bt,zt),pt=v.paint.get("model-scale").evaluate(bt,zt),vt=v.paint.get("model-translation").evaluate(bt,zt),Tt=v.paint.get("model-opacity").evaluate(bt,zt);CP(v,nt.id,zt,nt.featureProperties,nt.nodeOverrideNames,nt.nodeOverrides),Y0(v,nt.id,zt,nt.featureProperties,nt.materialOverrideNames,nt.materialOverrides),nt.nodeOverrides.size>0&&nt.computeBoundsAndApplyParent(),nt.computeModelMatrix(M,Dt,pt,vt,W,B,!1);const Gt=i.b9([]),qt=i.e2(nt.position.lat,M.transform.zoom),ns=i.bP([],[1,1,1/qt]);i.bx(Gt,Gt,Je),$e.push({zScaleMatrix:ns,negCameraPosMatrix:Gt});for(const Jt of nt.nodes)b3(M,Jt,nt.matrix,M.transform.expandedFarZProjMatrix,mt,Qe,lt,nt.materialOverrides,Tt);mt++}if(Qe.sort((nt,zt)=>zt.depth-nt.depth),M.renderPass!=="shadow"){if(M._debugParams.show3DModelFootprints){const nt=M.transform.projMatrix,zt=new Map,bt=(pt,vt)=>{if(pt.footprint){const Tt=pt.id||pt.name||"footprint";if(!zt.has(Tt)){const Gt=i.aD([],nt,vt);zt.set(Tt,{node:pt,mvp:Gt})}}};for(const pt of lt)bt(pt.node,pt.modelMatrix);for(const pt of Qe)bt(pt.node,pt.modelMatrix);const Dt=Array.from(zt.keys()).sort();for(const pt of Dt){const{node:vt,mvp:Tt}=zt.get(pt);SP(M,0,vt,Tt)}}Jx(M,v,Qe,lt,$e),je()}else{for(const nt of lt)t_(nt.mesh,nt.nodeModelMatrix,M,v);for(const nt of Qe)t_(nt.mesh,nt.nodeModelMatrix,M,v);je()}}},AP={line:function(M,m,v){if(M.hasElevatedBuckets=!1,M.hasNonElevatedBuckets=!1,M._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||M._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(m){const E=m.getVisibleCoordinates();for(const D of E){const z=m.getTile(D).getBucket(M);if(z&&(z.elevationType!=="none"?M.hasElevatedBuckets=!0:M.hasNonElevatedBuckets=!0,M.hasElevatedBuckets&&M.hasNonElevatedBuckets))break}}}else M.hasNonElevatedBuckets=!0},model:function(M,m,v){const E=m.getSource();if(!E.loaded())return;if(E.type==="vector"||E.type==="geojson")return void(v.modelManager&&v.modelManager.upload(v,_3(v,M)));if(E.type==="batched-model"||E.type!=="model")return;const D=E.getModels();for(const z of D)z.upload(v.context)},raster:function(M,m,v){const E=m.getSource();if(!(E instanceof Ux&&E.loaded()))return;const D=M.sourceLayer||E.rasterLayerIds&&E.rasterLayerIds[0];if(!D)return;const z=M.paint.get("raster-array-band")||E.getInitialBand(D);if(z==null)return;const B=m.getIds().map(W=>m.getTileByID(W));for(const W of B)W.updateNeeded(M.id,z)&&E.prepareTile(W,D,M.id,z)},"raster-particle":function(M,m,v){const E=m.getSource();if(!(E instanceof Ux&&E.loaded()))return;const D=M.sourceLayer||E.rasterLayerIds&&E.rasterLayerIds[0];if(!D)return;const z=M.paint.get("raster-particle-array-band")||E.getInitialBand(D);if(z==null)return;const B=m.getIds().map(W=>m.getTileByID(W));for(const W of B)W.updateNeeded(M.id,z)&&E.prepareTile(W,D,M.id,z)}},EP={fill:l2},PP={fill:function(M,m,v,E){if(!v.layout||v.layout.get("fill-elevation-reference")==="none"||v.paint.get("fill-opacity").constantOr(1)===0)return;const D=M.context.gl,z=new kr(D.LEQUAL,kr.ReadOnly,M.depthRangeFor3D),B=new sn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),W=M.transform.getFreeCameraOptions().position,te=M.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const ne of E){const de=m.getTile(ne),je=de.getBucket(v);if(!je)continue;const be=je.elevatedStructures;if(!be||be.depthSegments.segments[0].primitiveLength===0)continue;const Me=uP(ne.toUnwrapped(),W),$e=M.translatePosMatrix(ne.projMatrix,de,v.paint.get("fill-translate"),v.paint.get("fill-translate-anchor")),Le=r2($e,Me,0,1,0);te.draw(M,D.TRIANGLES,z,B,Jr.disabled,Wr.disabled,Le,v.id,be.vertexBuffer,be.indexBuffer,be.depthSegments,v.paint,M.transform.zoom)}}};class Tpe{constructor(m,v,E,D,z){this.context=new J1(m,v),this.transform=E,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,show3DModelFootprints:!1,enabledLayers:{}};const B=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const te of B)this._debugParams.enabledLayers[te]=!0;for(const te of B);this.occlusionParams=new SF,this.setup(),this.numSublayers=$l.maxUnderzooming+$l.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.eG,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new Uw(this),this._wireframeDebugCache=new kF,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const W=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,W,m.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=D,this.maxFrontCutoffRawStart=0,this.worldview=z,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(m,v){const E=!!m&&!!m.terrain&&this.transform.projection.supportsTerrain;if(!(E||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new s2(this,m));const D=this._terrain;this.transform.elevation=E?D:null,D.update(m,this.transform,v),this.transform.elevation&&!D.enabled&&(this.transform.elevation=null)}_updateFog(m){const v=m.fog;if(!v||this.transform.projection.name==="globe"||v.getOpacity(this.transform.pitch)<1||v.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[E,D]=v.getFovAdjustedRange(this.transform._fov);if(E>D)return void(this.transform.fogCullDistSq=null);const z=E+.78*(D-E);this.transform.fogCullDistSq=z*z}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(m){m&&!this._terrain&&(this._terrain=new s2(this,this.style)),this._forceTerrainMode=m}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(m,v){if(this.width=m*i.o.devicePixelRatio,this.height=v*i.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const E of this.style.order)this.style._mergedLayers[E].resize()}setup(){const m=this.context,v=new i.dB;v.emplaceBack(0,0),v.emplaceBack(i.an,0),v.emplaceBack(0,i.an),v.emplaceBack(i.an,i.an),this.tileExtentBuffer=m.createVertexBuffer(v,i.dx.members),this.tileExtentSegments=i.dy.simpleSegment(0,0,4,2);const E=new i.dB;E.emplaceBack(0,0),E.emplaceBack(i.an,0),E.emplaceBack(0,i.an),E.emplaceBack(i.an,i.an),this.debugBuffer=m.createVertexBuffer(E,i.dx.members),this.debugSegments=i.dy.simpleSegment(0,0,4,5);const D=new i.dB;D.emplaceBack(-1,-1),D.emplaceBack(1,-1),D.emplaceBack(-1,1),D.emplaceBack(1,1),this.viewportBuffer=m.createVertexBuffer(D,i.dx.members),this.viewportSegments=i.dy.simpleSegment(0,0,4,2);const z=new i.eH;z.emplaceBack(0,0,0,0),z.emplaceBack(i.an,0,i.an,0),z.emplaceBack(0,i.an,0,i.an),z.emplaceBack(i.an,i.an,i.an,i.an),this.mercatorBoundsBuffer=m.createVertexBuffer(z,i.eI.members),this.mercatorBoundsSegments=i.dy.simpleSegment(0,0,4,2);const B=new i.dC;B.emplaceBack(0,1,2),B.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=m.createIndexBuffer(B);const W=new i.eJ;for(const ne of[0,1,3,2,0])W.emplaceBack(ne);this.debugIndexBuffer=m.createIndexBuffer(W),this.emptyTexture=new i.T(m,new i.q({width:1,height:1},Uint8Array.of(0,0,0,0)),m.gl.RGBA8),this.identityMat=i.bb();const te=this.context.gl;this.stencilClearMode=new sn({func:te.ALWAYS,mask:0},0,255,te.ZERO,te.ZERO,te.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(m){return m._makeTileBoundsBuffers(this.context,this.transform.projection),m._tileBoundsBuffer?{tileBoundsBuffer:m._tileBoundsBuffer,tileBoundsIndexBuffer:m._tileBoundsIndexBuffer,tileBoundsSegments:m._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const m=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,m.TRIANGLES,kr.disabled,this.stencilClearMode,Jr.disabled,Wr.disabled,e2(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(m,v,E){if(!v||this.currentStencilSource===v.id||!m.isTileClipped()||!E||E.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let W=!1;for(const te of E)if(this._tileClippingMaskIDs[te.key]===void 0){W=!0;break}if(!W)return}this.currentStencilSource=v.id;const D=this.context,z=D.gl;this.nextStencilID+E.length>256&&this.clearStencil(),D.setColorMode(Jr.disabled),D.setDepthMode(kr.disabled);const B=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const W of E){const te=v.getTile(W),ne=this._tileClippingMaskIDs[W.key]=this.nextStencilID++,{tileBoundsBuffer:de,tileBoundsIndexBuffer:je,tileBoundsSegments:be}=this.getTileBoundsBuffers(te);B.draw(this,z.TRIANGLES,kr.disabled,new sn({func:z.ALWAYS,mask:0},ne,255,z.KEEP,z.KEEP,z.REPLACE),Jr.disabled,Wr.disabled,e2(W.projMatrix),"$clipping",de,je,be)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const m=this.nextStencilID++,v=this.context.gl;return new sn({func:v.NOTEQUAL,mask:255},m,255,v.KEEP,v.KEEP,v.REPLACE)}stencilModeForClipping(m){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(m);const v=this.context.gl;return new sn({func:v.EQUAL,mask:255},this._tileClippingMaskIDs[m.key],0,v.KEEP,v.KEEP,v.REPLACE)}stencilConfigForOverlap(m){const v=this.context.gl,E=m.sort((B,W)=>W.overscaledZ-B.overscaledZ),D=E[E.length-1].overscaledZ,z=E[0].overscaledZ-D+1;if(z>1){this.currentStencilSource=void 0,this.nextStencilID+z>256&&this.clearStencil();const B={};for(let W=0;Wthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((m,v)=>m+v/this._fpsHistory.length,0))}render(m,v){const E=i.o.now();this._dt=E-this._timeStamp,this._timeStamp=E,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=m.map.repaint,this.style=m,this.options=v;const D=this.style._mergedLayers,z=!(!this.terrain||!this.terrain.enabled),B=()=>this.style._getOrder(z).filter(Zt=>{const Ut=D[Zt];return!(Ut.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Ut.type]});let W=B(),te=!1,ne=!1,de=null,je=0,be=!1;for(const Zt of W){const Ut=D[Zt];Ut.visibility!=="none"&&(Ut.type==="circle"?te=!0:Ut.type==="building"?(de=Ut,++je):Ut.type==="symbol"&&(Ut.hasOcclusionOpacityProperties?ne=!0:te=!0))}this.updateEmissiveMode();let Me=W.map(Zt=>D[Zt]);const $e=this.style._mergedSourceCaches;this.imageManager=m.imageManager,this.modelManager=m.modelManager,this.symbolFadeChange=m.placement.symbolFadeChange(i.o.now()),this.imageManager.beginFrame();for(const Zt in $e){const Ut=$e[Zt];Ut.used&&(Ut.prepare(this.context),Ut.getSource().usedInConflation&&++je)}let Le=!1;for(const Zt of Me)Zt.isHidden(this.transform.zoom)||(Zt.type==="clip"&&(Le=!0),this.prepareLayer(Zt));const Je={},Qe={},lt={},mt={},nt={};for(const Zt in $e){const Ut=$e[Zt];Je[Zt]=Ut.getVisibleCoordinates(),Qe[Zt]=Je[Zt].slice().reverse(),lt[Zt]=Ut.getVisibleCoordinates(!0).reverse(),mt[Zt]=Ut.getShadowCasterCoordinates(),nt[Zt]=Ut.sortCoordinatesByDistance(Je[Zt])}const zt=Zt=>{const Ut=this.style.getLayerSourceCache(Zt);return Ut&&Ut.used?Ut.getSource():null};if(je||Le||this._clippingActiveLastFrame){const Zt=[],Ut=[];let ss=0;for(const as of Me)this.isSourceForClippingOrConflation(as,zt(as))&&(Zt.push(as),Ut.push(ss)),ss++;if(Zt&&(Le||Zt.length>1)||this._clippingActiveLastFrame){Le=!1;const as=[];for(let ds=0;ds0){const as=zt(Ut);as&&(this.minCutoffZoom=Math.max(as.minzoom,this.minCutoffZoom)),Ut.minzoom&&(this.minCutoffZoom=Math.max(Ut.minzoom,this.minCutoffZoom))}Ut.is3D(z)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Zt),this._lastOcclusionLayer=Zt)}const bt=this.style&&this.style.fog;bt?(this._fogVisible=bt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=bt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(lt),this.opaquePassCutoff=0,W=B(),Me=W.map(Zt=>D[Zt]));const Dt=this._shadowRenderer;if(Dt){Dt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Zt in $e)for(const Ut of Je[Zt]){let ss={min:0,max:0};this.terrain&&(ss=this.terrain.getMinMaxForTile(Ut)||ss),Dt.addShadowReceiver(Ut.toUnwrapped(),ss.min,ss.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new i.eL(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new wF(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const pt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),vt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(pt&&!this._snow&&(this._snow=new TF(this)),!pt&&this._snow&&(this._snow.destroy(),delete this._snow),vt&&!this._rain&&(this._rain=new h2(this)),!vt&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),de){this.buildingTileBorderManager||(this.buildingTileBorderManager=new Qx);const Zt=this.style.getLayerSourceCache(de);this.buildingTileBorderManager.updateBorders(Zt,de)}if(!st.has(this.context.gl))return;this.renderPass="offscreen";for(const Zt of Me){const Ut=m.getLayerSourceCache(Zt);if(!Zt.hasOffscreenPass()||Zt.isHidden(this.transform.zoom))continue;const ss=Ut?Qe[Ut.id]:void 0;(Zt.type==="custom"||Zt.type==="raster"||Zt.type==="raster-particle"||Zt.isSky()||ss&&ss.length)&&this.renderLayer(this,Ut,Zt,ss)}this.depthRangeFor3D=[0,1-(Me.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,mt)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Tt=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Gt=(()=>{if(v.showOverdrawInspector)return i.aq.black;const Zt=this.style.fog;if(Zt&&this.transform.projection.supportsFog){const Ut=this.style.getLut(Zt.scope);if(!Tt){const ss=Zt.properties.get("color-use-theme")==="none",as=Zt.properties.get("color").toNonPremultipliedRenderColor(ss?null:Ut).toArray01();return new i.aq(...as)}if(Tt){const ss=Zt.properties.get("space-color-use-theme")==="none",as=Zt.properties.get("space-color").toNonPremultipliedRenderColor(ss?null:Ut).toArray01();return new i.aq(...as)}}return i.aq.transparent})();if(this.context.clear({color:Gt,depth:1}),this.clearStencil(),this._showOverdrawInspector=v.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Tt&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=W.length-1;this.currentLayer>=0;this.currentLayer--){const Zt=Me[this.currentLayer],Ut=m.getLayerSourceCache(Zt);if(Zt.isSky())continue;const ss=Ut?(Zt.is3D(z)?nt:Qe)[Ut.id]:void 0;this._renderTileClippingMasks(Zt,Ut,ss),this.renderLayer(this,Ut,Zt,ss)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Tt&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||i.al(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const ss=this.currentLayer;this.depthOcclusion=!0;for(const as of this.layersWithOcclusionOpacity){this.currentLayer=as;const ds=Me[this.currentLayer],Qs=m.getLayerSourceCache(ds),Gs=Qs?Qe[Qs.id]:void 0;this.terrain||this._renderTileClippingMasks(ds,Qs,Qs?Je[Qs.id]:void 0),this.renderLayer(this,Qs,ds,Gs)}this.depthOcclusion=!1,this.currentLayer=ss,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 Zt=null;Me.forEach(Ut=>{const ss=m.getLayerSourceCache(Ut);ss&&!Ut.isHidden(this.transform.zoom)&&ss.getVisibleCoordinates().length&&(!Zt||Zt.getSource().maxzoom0?v.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(m,v,E){const D=E===void 0?this.terrain&&this.terrain.renderingToTexture:E,z=[];return this.style&&this.style.enable3dLights()&&(m==="globeRaster"||m==="terrainRaster"?(z.push("LIGHTING_3D_MODE"),z.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):D||z.push("LIGHTING_3D_MODE")),this.terrainRenderModeElevated()&&(z.push("TERRAIN"),this.linearFloatFilteringSupported()&&z.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&z.push("GLOBE"),!this._fogVisible||D||v!==void 0&&!v||z.push("FOG"),D&&z.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&z.push("OVERDRAW_INSPECTOR"),z}getOrCreateProgram(m,v){this.cache=this.cache||{};const E=v&&v.defines||[],D=v&&v.config,z=this.currentGlobalDefines(m,v&&v.overrideFog,v&&v.overrideRtt).concat(E),B=H0.cacheKey(BO[m],m,z,D);return this.cache[B]||(this.cache[B]=new H0(this.context,m,BO[m],D,h3[m],z)),this.cache[B]}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 m=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(m.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(m,v){if(this.style.enable3dLights()){const E=this.style.directionalLight,D=this.style.ambientLight;if(E&&D){const z=((B,W,te)=>{const ne=B.properties.get("direction"),de=B.properties.get("color-use-theme")==="none",je=B.properties.get("color").toNonPremultipliedRenderColor(de?null:te.getLut(B.scope)).toArray01(),be=B.properties.get("intensity"),Me=W.properties.get("color-use-theme")==="none",$e=W.properties.get("color").toNonPremultipliedRenderColor(Me?null:te.getLut(W.scope)).toArray01(),Le=W.properties.get("intensity"),Je=[ne.x,ne.y,ne.z],Qe=i.dD($e,Le),lt=i.dD(je,be);return{u_lighting_ambient_color:Qe,u_lighting_directional_dir:Je,u_lighting_directional_color:lt,u_ground_radiance:iP(Je,lt,Qe)}})(E,D,this.style);v.setLightsUniformValues(m,z)}}}uploadCommonUniforms(m,v,E,D,z){if(this.uploadCommonLightUniforms(m,v),this.terrain&&this.terrain.renderingToTexture)return;const B=this.style.fog;if(B){const W=B.getOpacity(this.transform.pitch),te=((ne,de,je,be,Me,$e,Le,Je,Qe,lt,mt,nt)=>{const zt=ne.transform,bt=de.properties.get("color-use-theme")==="none",Dt=de.properties.get("color").toNonPremultipliedRenderColor(bt?null:ne.style.getLut(de.scope)).toArray01();Dt[3]=be;const pt=ne.frameCounter/1e3%1,[vt,Tt]=de.properties.get("vertical-range");return{u_fog_matrix:je?zt.calculateFogTileMatrix(je):nt||ne.identityMat,u_fog_range:de.getFovAdjustedRange(zt._fov),u_fog_color:Dt,u_fog_horizon_blend:de.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(vt,Tt),Tt],u_fog_temporal_offset:pt,u_frustum_tl:Me,u_frustum_tr:$e,u_frustum_br:Le,u_frustum_bl:Je,u_globe_pos:Qe,u_globe_radius:lt,u_viewport:mt,u_globe_transition:i.al(zt.zoom),u_is_globe:+(zt.projection.name==="globe")}})(this,B,E,W,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*i.o.devicePixelRatio,this.transform.height*i.o.devicePixelRatio],D);v.setFogUniformValues(m,te)}z&&v.setCutoffUniformValues(m,z.uniformValues)}setTileLoadedFlag(m){this.tileLoaded=m}saveCanvasCopy(){const m=this.canvasCopy();m&&(this.frameCopies.push(m),this.tileLoaded=!1)}canvasCopy(){const m=this.context.gl,v=m.createTexture();return m.bindTexture(m.TEXTURE_2D,v),m.copyTexImage2D(m.TEXTURE_2D,0,m.RGBA,0,0,m.drawingBufferWidth,m.drawingBufferHeight,0),v}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const m=this.style&&this.style.fog;return!!m&&m.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const m=this._backgroundTiles,v=this._backgroundTiles={},E=this.transform.coveringTiles({tileSize:512});for(const D of E)v[D.key]=m[D.key]||new i.b0(D,512,this.transform.tileZoom,this,void 0,this.worldview);return v}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(m,v){return!(!m.is3D(!(!this.terrain||!this.terrain.enabled))||m.type!=="clip"&&m.type!=="building"&&(m.minzoom&&m.minzoom>this.transform.zoom||(this.style._clipLayerPresent||m.sourceLayer!=="building"&&m.sourceLayer!=="procedural_buildings")&&(!v||v.type!=="batched-model")))}isTileAffectedByFog(m){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let v=this._cachedTileFogOpacities[m.key];return v||(this._cachedTileFogOpacities[m.key]=v=this.style.fog.getOpacityForTile(m)),v[0]>=Zn||v[1]>=Zn}setupDepthForOcclusion(m,v,E){const D=this.context,z=D.gl,B=!!E;var W;E||(E={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(z.TEXTURE3),m&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(z.NEAREST,z.CLAMP_TO_EDGE),E.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],E.u_depth_range_unpack=[2/((W=this.depthRangeFor3D)[1]-W[0]),-1-2*W[0]/(W[1]-W[0])],E.u_occluder_half_size=.5*this.occlusionParams.occluderSize,E.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(z.NEAREST,z.CLAMP_TO_EDGE),D.activeTexture.set(z.TEXTURE0),B||v.setTerrainUniformValues(D,E)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const m=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=m?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function IP(M,m){let v=!1,E=null;const D=()=>{E=null,v&&(M(),E=setTimeout(D,m),v=!1)};return()=>(v=!0,E||D(),E)}class Ape{constructor(m){this._hashName=m&&encodeURIComponent(m),i.aZ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=IP(this._updateHashUnthrottled.bind(this),300)}addTo(m){return this._map=m,window.addEventListener("hashchange",this._onHashChange,!1),m.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 m=this._map;if(!m)return"";const v=Yd(m);if(this._hashName){const E=this._hashName;let D=!1;const z=location.hash.slice(1).split("&").map(B=>{const W=B.split("=")[0];return W===E?(D=!0,`${W}=${v}`):B}).filter(B=>B);return D||z.push(`${E}=${v}`),`#${z.join("&")}`}return`#${v}`}_getCurrentHash(){const m=location.hash.replace("#","");if(this._hashName){let v;return m.split("&").map(E=>E.split("=")).forEach(E=>{E[0]===this._hashName&&(v=E)}),(v&&v[1]||"").split("/")}return m.split("/")}_onHashChange(){const m=this._map;if(!m)return!1;const v=this._getCurrentHash();if(v.length>=3&&!v.some(E=>isNaN(Number(E)))){const E=m.dragRotate.isEnabled()&&m.touchZoomRotate.isEnabled()?+(v[3]||0):m.getBearing();return m.jumpTo({center:[+v[2],+v[1]],zoom:+v[0],bearing:E,pitch:+(v[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function Yd(M,m){const v=M.getCenter(),E=Math.round(100*M.getZoom())/100,D=Math.ceil((E*Math.LN2+Math.log(512/360/.5))/Math.LN10),z=Math.pow(10,D),B=Math.round(v.lng*z)/z,W=Math.round(v.lat*z)/z,te=M.getBearing(),ne=M.getPitch();let de=m?`/${B}/${W}/${E}`:`${E}/${W}/${B}`;return(te||ne)&&(de+="/"+Math.round(10*te)/10),ne&&(de+=`/${Math.round(ne)}`),de}const S3={linearity:.3,easing:i.eN(0,0,.3,1)},m2=Object.assign({deceleration:2500,maxSpeed:1400},S3),Epe=Object.assign({deceleration:20,maxSpeed:1400},S3),Di=Object.assign({deceleration:1e3,maxSpeed:360},S3),ia=Object.assign({deceleration:1e3,maxSpeed:90},S3);class EF{constructor(m){this._map=m,this.clear()}clear(){this._inertiaBuffer=[]}record(m){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.o.now(),settings:m})}_drainInertiaBuffer(){const m=this._inertiaBuffer,v=i.o.now();for(;m.length>0&&v-m[0].time>160;)m.shift()}_onMoveEnd(m){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const v={zoom:0,bearing:0,pitch:0,pan:new i.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:z}of this._inertiaBuffer)v.zoom+=z.zoomDelta||0,v.bearing+=z.bearingDelta||0,v.pitch+=z.pitchDelta||0,z.panDelta&&v.pan._add(z.panDelta),z.around&&(v.around=z.around),z.pinchAround&&(v.pinchAround=z.pinchAround);const E=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,D={};if(v.pan.mag()){const z=zf(v.pan.mag(),E,Object.assign({},m2,m||{}));D.offset=v.pan.mult(z.amount/v.pan.mag()),D.center=this._map.transform.center,yh(D,z)}if(v.zoom){const z=zf(v.zoom,E,Epe);D.zoom=this._map.transform.zoom+z.amount,yh(D,z)}if(v.bearing){const z=zf(v.bearing,E,Di);D.bearing=this._map.transform.bearing+i.aC(z.amount,-179,179),yh(D,z)}if(v.pitch){const z=zf(v.pitch,E,ia);D.pitch=this._map.transform.pitch+z.amount,yh(D,z)}if(D.zoom||D.bearing){const z=v.pinchAround===void 0?v.around:v.pinchAround;D.around=z?this._map.unproject(z):this._map.getCenter()}return this.clear(),D.noMoveStart=!0,D}}function yh(M,m){(!M.duration||M.durationv.unproject(te)),W=z.reduce((te,ne,de,je)=>te.add(ne.div(je.length)),new i.P(0,0));super(m,{points:z,point:W,lngLats:B,lngLat:v.unproject(W),originalEvent:E}),this._defaultPrevented=!1}}class LP extends i.C{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(m,v){super("wheel",{originalEvent:v}),this._defaultPrevented=!1}}class DP{constructor(m,v){this._map=m,this._clickTolerance=v.clickTolerance}reset(){this._mousedownPos=void 0}wheel(m){return this._firePreventable(new LP(this._map,m))}mousedown(m,v){return this._mousedownPos=v,this._firePreventable(new id(m.type,this._map,m))}mouseup(m){this._map.fire(new id(m.type,this._map,m))}preclick(m){const v=new MouseEvent("preclick",m);this._map.fire(new id(v.type,this._map,v))}click(m,v){this._mousedownPos&&this._mousedownPos.dist(v)>=this._clickTolerance||(this.preclick(m),this._map.fire(new id(m.type,this._map,m)))}dblclick(m){return this._firePreventable(new id(m.type,this._map,m))}mouseover(m){this._map.fire(new id(m.type,this._map,m))}mouseout(m){this._map.fire(new id(m.type,this._map,m))}touchstart(m){return this._firePreventable(new Qh(m.type,this._map,m))}touchmove(m){this._map.fire(new Qh(m.type,this._map,m))}touchend(m){this._map.fire(new Qh(m.type,this._map,m))}touchcancel(m){this._map.fire(new Qh(m.type,this._map,m))}_firePreventable(m){if(this._map.fire(m),m.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class RP{constructor(m){this._map=m}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(m){this._map.fire(new id(m.type,this._map,m))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new id("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(m){this._delayContextMenu?this._contextMenuEvent=m:this._map.fire(new id(m.type,this._map,m)),this._map.listens("contextmenu")&&m.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class OP{constructor(m,v){this._map=m,this._el=m.getCanvasContainer(),this._container=m.getContainer(),this._clickTolerance=v.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(m,v){this.isEnabled()&&m.shiftKey&&m.button===0&&(I(),this._startPos=this._lastPos=v,this._active=!0)}mousemoveWindow(m,v){if(!this._active)return;const E=v,D=this._startPos,z=this._lastPos;if(!D||!z||z.equals(E)||!this._box&&E.dist(D){this._box&&(this._box.style.transform=`translate(${B}px,${te}px)`,this._box.style.width=W-B+"px",this._box.style.height=ne-te+"px")})}mouseupWindow(m,v){if(!this._active)return;const E=this._startPos,D=v;if(E&&m.button===0){if(this.reset(),U(),E.x!==D.x||E.y!==D.y)return this._map.fire(new i.C("boxzoomend",{originalEvent:m})),{cameraAnimation:z=>z.fitScreenCoordinates(E,D,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",m)}}keydown(m){this._active&&m.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",m))}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(m,v){return this._map.fire(new i.C(m,{originalEvent:v}))}}function p2(M,m){const v={};for(let E=0;Ethis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=m.timeStamp),E.length===this.numTouches&&(this.centroid=function(D){const z=new i.P(0,0);for(const B of D)z._add(B);return z.div(D.length)}(v),this.touches=p2(E,v)))}touchmove(m,v,E){if(this.aborted||!this.centroid)return;const D=p2(E,v);for(const z in this.touches){const B=D[z];(!B||B.dist(this.touches[z])>30)&&(this.aborted=!0)}}touchend(m,v,E){if((!this.centroid||m.timeStamp-this.startTime>500)&&(this.aborted=!0),E.length===0){const D=!this.aborted&&this.centroid;if(this.reset(),D)return D}}}class Bf{constructor(m){this.singleTap=new Um(m),this.numTaps=m.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(m,v,E){this.singleTap.touchstart(m,v,E)}touchmove(m,v,E){this.singleTap.touchmove(m,v,E)}touchend(m,v,E){const D=this.singleTap.touchend(m,v,E);if(D){const z=m.timeStamp-this.lastTime<500,B=!this.lastTap||this.lastTap.dist(D)<30;if(z&&B||this.reset(),this.count++,this.lastTime=m.timeStamp,this.lastTap=D,this.count===this.numTaps)return this.reset(),D}}}class n_{constructor(){this._zoomIn=new Bf({numTouches:1,numTaps:2}),this._zoomOut=new Bf({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(m,v,E){this._zoomIn.touchstart(m,v,E),this._zoomOut.touchstart(m,v,E)}touchmove(m,v,E){this._zoomIn.touchmove(m,v,E),this._zoomOut.touchmove(m,v,E)}touchend(m,v,E){const D=this._zoomIn.touchend(m,v,E),z=this._zoomOut.touchend(m,v,E);return D?(this._active=!0,m.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:B=>B.easeTo({duration:300,zoom:B.getZoom()+1,around:B.unproject(D)},{originalEvent:m})}):z?(this._active=!0,m.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:B=>B.easeTo({duration:300,zoom:B.getZoom()-1,around:B.unproject(z)},{originalEvent:m})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const C3=0,FP=2,zP={[C3]:1,[FP]:2},tg={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class f2{constructor(m){this.reset(),this._clickTolerance=m.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(m,v){return!1}_move(m,v){return{}}mousedown(m,v){if(this._lastPoint)return;const E=V(m);this._correctButton(m,E)&&(this._lastPoint=v,this._eventButton=E)}mousemoveWindow(m,v){const E=this._lastPoint;if(E){if(m.preventDefault(),this._eventButton!=null&&function(D,z){const B=zP[z];return D.buttons===void 0||(D.buttons&B)!==B}(m,this._eventButton))this.reset();else if(this._moved||!(v.dist(E)0&&(this._active=!0);const D=p2(E,v),z=new i.P(0,0),B=new i.P(0,0);let W=0;for(const ne in D){const de=D[ne],je=this._touches[ne];je&&(z._add(de),B._add(de.sub(je)),W++,D[ne]=de)}if(this._touches=D,W{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class g2{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(m){}_move(m,v,E){return{}}touchstart(m,v,E){this._firstTwoTouches||E.length<2||(this._firstTwoTouches=[E[0].identifier,E[1].identifier],this._start([v[0],v[1]]))}touchmove(m,v,E){const D=this._firstTwoTouches;if(!D)return;m.preventDefault();const[z,B]=D,W=Ao(E,v,z),te=Ao(E,v,B);if(!W||!te)return;const ne=this._aroundCenter?null:W.add(te).div(2);return this._move([W,te],ne,m)}touchend(m,v,E){if(!this._firstTwoTouches)return;const[D,z]=this._firstTwoTouches,B=Ao(E,v,D),W=Ao(E,v,z);B&&W||(this._active&&U(),this.reset())}touchcancel(){this.reset()}enable(m){this._enabled=!0,this._aroundCenter=!!m&&m.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ao(M,m,v){for(let E=0;EMath.abs(M.x)}class qP extends g2{constructor(m){super(),this._map=m}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(m){this._lastPoints=m,y2(m[0].sub(m[1]))&&(this._valid=!1)}_move(m,v,E){const D=this._lastPoints;if(!D)return;const z=m[0].sub(D[0]),B=m[1].sub(D[1]);return this._map._cooperativeGestures&&!i.eO()&&E.touches.length<3||(this._valid=this.gestureBeginsVertically(z,B,E.timeStamp),!this._valid)?void 0:(this._lastPoints=m,this._active=!0,{pitchDelta:(z.y+B.y)/2*-.5})}gestureBeginsVertically(m,v,E){if(this._valid!==void 0)return this._valid;const D=m.mag()>=2,z=v.mag()>=2;if(!D&&!z)return;if(!D||!z)return this._firstMove==null&&(this._firstMove=E),E-this._firstMove<100&&void 0;const B=m.y>0==v.y>0;return y2(m)&&y2(v)&&B}}const UP={panStep:100,bearingStep:15,pitchStep:10};class J0{constructor(){const m=UP;this._panStep=m.panStep,this._bearingStep=m.bearingStep,this._pitchStep=m.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(m){if(m.altKey||m.ctrlKey||m.metaKey)return;let v=0,E=0,D=0,z=0,B=0;switch(m.keyCode){case 61:case 107:case 171:case 187:v=1;break;case 189:case 109:case 173:v=-1;break;case 37:m.shiftKey?E=-1:(m.preventDefault(),z=-1);break;case 39:m.shiftKey?E=1:(m.preventDefault(),z=1);break;case 38:m.shiftKey?D=1:(m.preventDefault(),B=-1);break;case 40:m.shiftKey?D=-1:(m.preventDefault(),B=1);break;default:return}return this._rotationDisabled&&(E=0,D=0),{cameraAnimation:W=>{const te=W.getZoom();W.easeTo({duration:300,easeId:"keyboardHandler",easing:VP,zoom:v?Math.round(te)+v*(m.shiftKey?2:1):te,bearing:W.getBearing()+E*this._bearingStep,pitch:W.getPitch()+D*this._pitchStep,offset:[-z*this._panStep,-B*this._panStep],center:W.getCenter()},{originalEvent:m})}}}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 VP(M){return M*(2-M)}const ev=4.000244140625,HP=1/450;class E3{constructor(m,v){this._map=m,this._el=m.getCanvasContainer(),this._handler=v,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=HP,i.aZ(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(m){this._defaultZoomRate=m}setWheelZoomRate(m){this._wheelZoomRate=m}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(m){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!m&&m.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(m){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(m.ctrlKey||m.metaKey||this.isZooming()||i.eO()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let v=m.deltaMode===WheelEvent.DOM_DELTA_LINE?40*m.deltaY:m.deltaY;const E=i.o.now(),D=E-(this._lastWheelEventTime||0);this._lastWheelEventTime=E,v!==0&&v%ev===0?this._type="wheel":v!==0&&Math.abs(v)<4?this._type="trackpad":D>400?(this._type=null,this._lastValue=v,this._timeout=window.setTimeout(this._onTimeout,40,m)):this._type||(this._type=Math.abs(D*v)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,v+=this._lastValue)),m.shiftKey&&v&&(v/=4),this._type&&(this._lastWheelEvent=m,this._delta-=v,this._active||this._start(m)),m.preventDefault()}_onTimeout(m){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(m)}_start(m){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 v=q(this._el,m);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:v,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 m=this._map.transform;this._type==="wheel"&&m.projection.wrap&&(m._center.lng>=180||m._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const v=()=>m._terrainEnabled()&&this._aroundCoord?m.computeZoomRelativeTo(this._aroundCoord):m.zoom;if(this._delta!==0){const ne=this._type==="wheel"&&Math.abs(this._delta)>ev?this._wheelZoomRate:this._defaultZoomRate;let de=2/(1+Math.exp(-Math.abs(this._delta*ne)));this._delta<0&&de!==0&&(de=1/de);const je=v(),be=Math.pow(2,je),Me=typeof this._targetZoom=="number"?m.zoomScale(this._targetZoom):be;this._targetZoom=Math.min(m.maxZoom,Math.max(m.minZoom,m.scaleZoom(Me*de))),this._type==="wheel"&&(this._startZoom=je,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const E=typeof this._targetZoom=="number"?this._targetZoom:v(),D=this._startZoom,z=this._easing;let B,W=!1;if(this._type==="wheel"&&D&&z){const ne=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),de=z(ne);B=i.am(D,E,de),ne<1?this._frameId||(this._frameId=!0):W=!0}else B=E,W=!0;this._active=!0,W&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let te=B-v();return te*this._lastDelta<0&&(te=0),{noInertia:!0,needsRenderFrame:!W,zoomDelta:te,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(m){let v=i.eP;if(this._prevEase){const E=this._prevEase,D=(i.o.now()-E.start)/E.duration,z=E.easing(D+.01)-E.easing(D),B=.27/Math.sqrt(z*z+1e-4)*.01,W=Math.sqrt(.0729-B*B);v=i.eN(B,W,.25,1)}return this._prevEase={start:i.o.now(),duration:m,easing:v},v}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=N("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 P3{constructor(m,v){this._clickZoom=m,this._tapZoom=v}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 I3{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(m,v){return m.preventDefault(),{cameraAnimation:E=>{E.easeTo({duration:300,zoom:E.getZoom()+(m.shiftKey?-1:1),around:E.unproject(v)},{originalEvent:m})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class PF{constructor(){this._tap=new Bf({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(m,v,E){this._swipePoint||(this._tapTime&&m.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?E.length>0&&(this._swipePoint=v[0],this._swipeTouch=E[0].identifier):this._tap.touchstart(m,v,E))}touchmove(m,v,E){if(this._tapTime){if(this._swipePoint){if(E[0].identifier!==this._swipeTouch)return;const D=v[0],z=D.y-this._swipePoint.y;return this._swipePoint=D,m.preventDefault(),this._active=!0,{zoomDelta:z/128}}}else this._tap.touchmove(m,v,E)}touchend(m,v,E){this._tapTime?this._swipePoint&&E.length===0&&this.reset():this._tap.touchend(m,v,E)&&(this._tapTime=m.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class GP{constructor(m,v,E){this._el=m,this._mousePan=v,this._touchPan=E}enable(m){this._inertiaOptions=m||{},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 IF{constructor(m,v,E){this._pitchWithRotate=m.pitchWithRotate,this._mouseRotate=v,this._mousePitch=E}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 LF{constructor(m,v,E,D){this._el=m,this._touchZoom=v,this._touchRotate=E,this._tapDragZoom=D,this._rotationDisabled=!1,this._enabled=!0}enable(m){this._touchZoom.enable(m),this._rotationDisabled||this._touchRotate.enable(m),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 v2=M=>M.zoom||M.drag||M.pitch||M.rotate;class DF extends i.C{}class RF{constructor(){this.constants=[1,1,.01],this.radius=0}setup(m,v){const E=i.ax([],v,m);this.radius=i.ai(E[2]<0?i.eR([],E,this.constants):[E[0],E[1],0])}projectRay(m){i.eR(m,m,this.constants),i.ay(m,m),i.eS(m,m,this.constants);const v=i.bJ([],m,this.radius);if(v[2]>0){const E=i.bJ([],[0,0,1],i.bi(v,[0,0,1])),D=i.bJ([],i.ay([],[v[0],v[1],0]),this.radius),z=i.cT([],v,i.bJ([],i.ax([],i.cT([],D,E),v),2));v[0]=z[0],v[1]=z[1]}return v}}function _2(M){return M.panDelta&&M.panDelta.mag()||M.zoomDelta||M.bearingDelta||M.pitchDelta}class OF{constructor(m,v){this._map=m,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new EF(m),this._bearingSnap=v.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new RF,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(v),i.aZ(["handleEvent","handleWindowEvent"],this);const E=this._el;this._listeners=[[E,"touchstart",{passive:!0}],[E,"touchmove",{passive:!1}],[E,"touchend",void 0],[E,"touchcancel",void 0],[E,"mousedown",void 0],[E,"mousemove",void 0],[E,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[E,"mouseover",void 0],[E,"mouseout",void 0],[E,"dblclick",void 0],[E,"click",void 0],[E,"keydown",{capture:!1}],[E,"keyup",void 0],[E,"wheel",{passive:!1}],[E,"contextmenu",void 0],[window,"blur",void 0]];for(const[D,z,B]of this._listeners){const W=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(z,W,B)}}destroy(){for(const[m,v,E]of this._listeners){const D=m===document?this.handleWindowEvent:this.handleEvent;m.removeEventListener(v,D,E)}}_addDefaultHandlers(m){const v=this._map,E=v.getCanvasContainer();this._add("mapEvent",new DP(v,m));const D=v.boxZoom=new OP(v,m);this._add("boxZoom",D);const z=new n_,B=new I3;v.doubleClickZoom=new P3(B,z),this._add("tapZoom",z),this._add("clickZoom",B);const W=new PF;this._add("tapDragZoom",W);const te=v.touchPitch=new qP(v);this._add("touchPitch",te);const ne=new M3(m),de=new x2(m);v.dragRotate=new IF(m,ne,de),this._add("mouseRotate",ne,["mousePitch"]),this._add("mousePitch",de,["mouseRotate"]);const je=new Vm(m),be=new BP(v,m);v.dragPan=new GP(E,je,be),this._add("mousePan",je),this._add("touchPan",be,["touchZoom","touchRotate"]);const Me=new Q0,$e=new $P;v.touchZoomRotate=new LF(E,$e,Me,W),this._add("touchRotate",Me,["touchPan","touchZoom"]),this._add("touchZoom",$e,["touchPan","touchRotate"]),this._add("blockableMapEvent",new RP(v));const Le=v.scrollZoom=new E3(v,this);this._add("scrollZoom",Le,["mousePan"]);const Je=v.keyboard=new J0;this._add("keyboard",Je);for(const Qe of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])m.interactive&&m[Qe]&&v[Qe].enable(m[Qe])}_add(m,v,E){this._handlers.push({handlerName:m,handler:v,allowed:E}),this._handlersById[m]=v}stop(m){if(!this._updatingCamera){for(const{handler:v}of this._handlers)v.reset();this._inertia.clear(),this._fireEvents({},{},m),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:m}of this._handlers)if(m.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!v2(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(m,v,E){for(const D in m)if(D!==E&&(!v||v.indexOf(D)<0))return!0;return!1}handleWindowEvent(m){this.handleEvent(m,`${m.type}Window`)}_getMapTouches(m){const v=[];for(const E of m)this._el.contains(E.target)&&v.push(E);return v}handleEvent(m,v){this._updatingCamera=!0;const E=m.type==="renderFrame",D=E?void 0:m,z={needsRenderFrame:!1},B={},W={},te=m.touches?this._getMapTouches(m.touches):void 0,ne=te?$(this._el,te):E?void 0:q(this._el,m);for(const{handlerName:be,handler:Me,allowed:$e}of this._handlers){if(!Me.isEnabled())continue;let Le;this._blockedByActive(W,$e,be)?Me.reset():Me[v||m.type]&&(Le=Me[v||m.type](m,ne,te),this.mergeHandlerResult(z,B,Le,be,D),Le&&Le.needsRenderFrame&&this._triggerRenderFrame()),(Le||Me.isActive())&&(W[be]=Me)}const de={};for(const be in this._previousActiveHandlers)W[be]||(de[be]=D);this._previousActiveHandlers=W,(Object.keys(de).length||_2(z))&&(this._changes.push([z,B,de]),this._triggerRenderFrame()),(Object.keys(W).length||_2(z))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:je}=z;je&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],je(this._map))}mergeHandlerResult(m,v,E,D,z){if(!E)return;Object.assign(m,E);const B={handlerName:D,originalEvent:E.originalEvent||z};E.zoomDelta!==void 0&&(v.zoom=B),E.panDelta!==void 0&&(v.drag=B),E.pitchDelta!==void 0&&(v.pitch=B),E.bearingDelta!==void 0&&(v.rotate=B)}_applyChanges(){const m={},v={},E={};for(const[D,z,B]of this._changes)D.panDelta&&(m.panDelta=(m.panDelta||new i.P(0,0))._add(D.panDelta)),D.zoomDelta&&(m.zoomDelta=(m.zoomDelta||0)+D.zoomDelta),D.bearingDelta&&(m.bearingDelta=(m.bearingDelta||0)+D.bearingDelta),D.pitchDelta&&(m.pitchDelta=(m.pitchDelta||0)+D.pitchDelta),D.around!==void 0&&(m.around=D.around),D.aroundCoord!==void 0&&(m.aroundCoord=D.aroundCoord),D.pinchAround!==void 0&&(m.pinchAround=D.pinchAround),D.noInertia&&(m.noInertia=D.noInertia),Object.assign(v,z),Object.assign(E,B);this._updateMapTransform(m,v,E),this._changes=[]}_updateMapTransform(m,v,E){const D=this._map,z=D.transform,B=lt=>[lt.x,lt.y,lt.z];if((()=>{const lt=this._eventsInProgress.drag;return lt&&!this._handlersById[lt.handlerName].isActive()})()&&!_2(m)){const lt=z.zoom;z.cameraElevationReference="sea",this._originalZoom!=null&&z._orthographicProjectionAtLowPitch&&z.projection.name!=="globe"&&z.pitch===0?(z.cameraElevationReference="ground",z.zoom=this._originalZoom):(z.recenterOnTerrain(),z.cameraElevationReference="ground"),lt!==z.zoom&&this._map._update(!0)}if(z._isCameraConstrained&&D._stop(!0),!_2(m))return void this._fireEvents(v,E,!0);let{panDelta:W,zoomDelta:te,bearingDelta:ne,pitchDelta:de,around:je,aroundCoord:be,pinchAround:Me}=m;z._isCameraConstrained&&(te>0&&(te=0),z._isCameraConstrained=!1),Me!==void 0&&(je=Me),(te||(lt=>v[lt]&&!this._eventsInProgress[lt])("drag"))&&je&&(this._dragOrigin=B(z.pointCoordinate3D(je)),this._originalZoom=z.zoom,this._trackingEllipsoid.setup(z._camera.position,this._dragOrigin)),z.cameraElevationReference="sea",D._stop(!0),je=je||D.transform.centerPoint,ne&&(z.bearing+=ne),de&&(z.pitch+=de),z._updateCameraState();const $e=[0,0,0];if(W)if(z.projection.name==="mercator"){const lt=this._trackingEllipsoid.projectRay(z.screenPointToMercatorRay(je).dir),mt=this._trackingEllipsoid.projectRay(z.screenPointToMercatorRay(je.sub(W)).dir);$e[0]=mt[0]-lt[0],$e[1]=mt[1]-lt[1]}else{const lt=z.pointCoordinate(je);if(z.projection.name==="globe"){W=W.rotate(-z.angle);const mt=z._pixelsPerMercatorPixel/z.worldSize;$e[0]=-W.x*i.eQ(i.bV(lt.y))*mt,$e[1]=-W.y*i.eQ(z.center.lat)*mt}else{const mt=z.pointCoordinate(je.sub(W));lt&&mt&&($e[0]=mt.x-lt.x,$e[1]=mt.y-lt.y)}}const Le=z.zoom,Je=[0,0,0];if(te){const lt=B(be||z.pointCoordinate3D(je)),mt={dir:i.ay([],i.ax([],lt,z._camera.position))};if(mt.dir[2]<0){const nt=z.zoomDeltaToMovement(lt,te);i.bJ(Je,mt.dir,nt)}}const Qe=i.cT($e,$e,Je);z._translateCameraConstrained(Qe),te&&Math.abs(z.zoom-Le)>1e-4&&z.recenterOnTerrain(),z.cameraElevationReference="ground",this._map._update(),m.noInertia||this._inertia.record(m),this._fireEvents(v,E,!0)}_fireEvents(m,v,E){const D=v2(this._eventsInProgress),z=v2(m),B={};for(const de in m){const{originalEvent:je}=m[de];this._eventsInProgress[de]||(B[`${de}start`]=je),this._eventsInProgress[de]=m[de]}!D&&z&&this._fireEvent("movestart",z.originalEvent);for(const de in B)this._fireEvent(de,B[de]);z&&this._fireEvent("move",z.originalEvent);for(const de in m){const{originalEvent:je}=m[de];this._fireEvent(de,je)}const W={};let te;for(const de in this._eventsInProgress){const{handlerName:je,originalEvent:be}=this._eventsInProgress[de];this._handlersById[je].isActive()||(delete this._eventsInProgress[de],te=v[je]||be,W[`${de}end`]=te)}for(const de in W)this._fireEvent(de,W[de]);const ne=v2(this._eventsInProgress);if(E&&(D||z)&&!ne){this._updatingCamera=!0;const de=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),je=be=>be!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new DF("renderFrame",{timeStamp:m})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const WP="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class FF extends i.E{constructor(m,v){super(),this._moving=!1,this._zooming=!1,this.transform=m,this._bearingSnap=v.bearingSnap,this._respectPrefersReducedMotion=v.respectPrefersReducedMotion!==!1,i.aZ(["_renderFrameCallback"],this)}getCenter(){return new i.aU(this.transform.center.lng,this.transform.center.lat)}setCenter(m,v){return this.jumpTo({center:m},v)}panBy(m,v,E){return m=i.P.convert(m).mult(-1),this.panTo(this.transform.center,Object.assign({offset:m},v),E)}panTo(m,v,E){return this.easeTo(Object.assign({center:m},v),E)}getZoom(){return this.transform.zoom}setZoom(m,v){return this.jumpTo({zoom:m},v),this}zoomTo(m,v,E){return this.easeTo(Object.assign({zoom:m},v),E)}zoomIn(m,v){return this.zoomTo(this.getZoom()+1,m,v),this}zoomOut(m,v){return this.zoomTo(this.getZoom()-1,m,v),this}getBearing(){return this.transform.bearing}setBearing(m,v){return this.jumpTo({bearing:m},v),this}getPadding(){return this.transform.padding}setPadding(m,v){return this.jumpTo({padding:m},v),this}rotateTo(m,v,E){return this.easeTo(Object.assign({bearing:m},v),E)}resetNorth(m,v){return this.rotateTo(0,Object.assign({duration:1e3},m),v),this}resetNorthPitch(m,v){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},m),v),this}snapToNorth(m,v){return Math.abs(this.getBearing())m.aspect?E/(2*Math.tan(.5*m.fovX)*m.aspect):D/(2*Math.tan(.5*m.fovY)*m.aspect)}_cameraForBoundsOnGlobe(m,v,E,D,z,B){const W=m.clone(),te=this._extendCameraOptions(B);W.bearing=D,W.pitch=z;const ne=i.aU.convert(v),de=i.aU.convert(E),je=.5*(ne.lat+de.lat),be=.5*(ne.lng+de.lng),Me=i.eT(je,be),$e=i.ay([],Me),Le=i.ay([],i.bh([],$e,[0,1,0])),Je=i.bh([],Le,$e),Qe=[Le[0],Le[1],Le[2],0,Je[0],Je[1],Je[2],0,$e[0],$e[1],$e[2],0,0,0,0,1],lt=[Me,i.eT(ne.lat,ne.lng),i.eT(de.lat,ne.lng),i.eT(de.lat,de.lng),i.eT(ne.lat,de.lng),i.eT(je,ne.lng),i.eT(je,de.lng),i.eT(ne.lat,be),i.eT(de.lat,be)];let mt=i.cU.fromPoints(lt.map(as=>[i.bi(Le,as),i.bi(Je,as),i.bi($e,as)]));const nt=i.ah([],mt.center,Qe);i.eU(nt)===0&&i.eV(nt,0,0,1),i.ay(nt,nt),i.bJ(nt,nt,i.aF),W.center=i.eW(nt);const zt=W.getWorldToCameraMatrix(),bt=i.b7(new Float64Array(16),zt);mt=i.cU.applyTransform(mt,i.aD([],zt,Qe));const Dt=this._extendAABB(mt,W,te,D);if(!Dt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");mt=Dt,i.ah(nt,nt,zt);const pt=.5*(mt.max[2]-mt.min[2]),vt=this._minimumAABBFrustumDistance(W,mt),Tt=i.bJ([],[0,0,1],pt),Gt=i.cT(Tt,nt,Tt),qt=vt+(W.pitch===0?0:i.bf(nt,Gt)),ns=W.globeCenterInViewSpace,Jt=i.ax([],nt,[ns[0],ns[1],ns[2]]);i.ay(Jt,Jt),i.bJ(Jt,Jt,qt);const Ns=i.cT([],nt,Jt);i.ah(Ns,Ns,bt);const Is=i.eD/i.aF,Zt=i.ai(Ns),Ut=i.bU(Math.max(Zt*Is-i.eD,Number.EPSILON),0),ss=Math.min(W.zoomFromMercatorZAdjusted(Ut),te.maxZoom);return ss>.5*(i.cJ+i.cv)?(W.setProjection({name:"mercator"}),W.zoom=ss,this._cameraForBounds(W,v,E,D,z,B)):{center:W.center,zoom:ss,bearing:D,pitch:z}}_extendAABB(m,v,E,D){const z=.5*((E.padding.left||0)+(E.padding.right||0)),B=.5*((E.padding.top||0)+(E.padding.bottom||0)),W=B,te=z,ne=z,de=B,je=v.width-(te+ne),be=v.height-(W+de),Me=i.ax([],m.max,m.min),$e=Math.min(je/Me[0],be/Me[1]),Le=Math.min(v.scaleZoom(v.scale*$e),E.maxZoom);if(isNaN(Le))return null;const Je=v.scale/v.zoomScale(Le),Qe=new i.cU([m.min[0]-te*Je,m.min[1]-de*Je,m.min[2]],[m.max[0]+ne*Je,m.max[1]+W*Je,m.max[2]]),lt=(typeof E.offset.x=="number"&&typeof E.offset.y=="number"?new i.P(E.offset.x,E.offset.y):i.P.convert(E.offset)).rotate(-i.ap(D));return Qe.center[0]-=lt.x*Je,Qe.center[1]+=lt.y*Je,Qe}queryTerrainElevation(m,v){const E=this.transform.elevation;return E?(v=Object.assign({},{exaggerated:!0},v),E.getAtPoint(i.ag.fromLngLat(m),null,v.exaggerated)):null}_cameraForBounds(m,v,E,D,z,B){if(m.projection.name==="globe")return this._cameraForBoundsOnGlobe(m,v,E,D,z,B);const W=m.clone(),te=this._extendCameraOptions(B);W.bearing=D,W.pitch=z;const ne=i.aU.convert(v),de=i.aU.convert(E),je=new i.aU(ne.lng,de.lat),be=new i.aU(de.lng,ne.lat),Me=W.project(ne),$e=W.project(de),Le=this.queryTerrainElevation(ne),Je=this.queryTerrainElevation(de),Qe=this.queryTerrainElevation(je),lt=this.queryTerrainElevation(be),mt=[[Me.x,Me.y,Math.min(Le||0,Je||0,Qe||0,lt||0)],[$e.x,$e.y,Math.max(Le||0,Je||0,Qe||0,lt||0)]];let nt=i.cU.fromPoints(mt);const zt=W.getWorldToCameraMatrix(),bt=i.b7(new Float64Array(16),zt);nt=i.cU.applyTransform(nt,zt);const Dt=this._extendAABB(nt,W,te,D);if(!Dt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");nt=Dt;const pt=.5*i.ax([],nt.max,nt.min)[2],vt=this._minimumAABBFrustumDistance(W,nt),Tt=[0,0,1,0];i.aE(Tt,Tt,zt),i.eX(Tt,Tt);const Gt=i.bJ([],Tt,vt+pt),qt=i.cT([],nt.center,Gt);i.ah(nt.center,nt.center,bt),i.ah(qt,qt,bt);const ns=W.unproject(new i.P(nt.center[0],nt.center[1])),Jt=i.eY(W.projection,ns),Ns=Math.pow(2,Jt),Is=Math.min(W._zoomFromMercatorZ(qt[2]*W.pixelsPerMeter*Ns/W.worldSize),te.maxZoom);return W.mercatorFromTransition&&Is<.5*(i.cJ+i.cv)?(W.setProjection({name:"globe"}),W.zoom=Is,this._cameraForBounds(W,v,E,D,z,B)):{center:ns,zoom:Is,bearing:D,pitch:z}}fitBounds(m,v,E){const D=this.cameraForBounds(m,v);return this._fitInternal(D,v,E)}fitScreenCoordinates(m,v,E,D,z){const B=i.P.convert(m),W=i.P.convert(v),te=new i.P(Math.min(B.x,W.x),Math.min(B.y,W.y)),ne=new i.P(Math.max(B.x,W.x),Math.max(B.y,W.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(B,W))return this;const de=this.transform.pointLocation3D(te),je=this.transform.pointLocation3D(ne),be=this.transform.pointLocation3D(new i.P(te.x,ne.y)),Me=this.transform.pointLocation3D(new i.P(ne.x,te.y)),$e=[Math.min(de.lng,je.lng,be.lng,Me.lng),Math.min(de.lat,je.lat,be.lat,Me.lat)],Le=[Math.max(de.lng,je.lng,be.lng,Me.lng),Math.max(de.lat,je.lat,be.lat,Me.lat)],Je=D&&D.pitch?D.pitch:this.getPitch(),Qe=this._cameraForBounds(this.transform,$e,Le,E,Je,D);return this._fitInternal(Qe,D,z)}_fitInternal(m,v,E){return m?(v=Object.assign(m,v)).linear?this.easeTo(v,E):this.flyTo(v,E):this}jumpTo(m,v){this.stop();const E=m.preloadOnly?this.transform.clone():this.transform;let D=!1,z=!1,B=!1;"zoom"in m&&E.zoom!==+m.zoom&&(D=!0,E.zoom=+m.zoom),m.center!==void 0&&(E.center=i.aU.convert(m.center)),"bearing"in m&&E.bearing!==+m.bearing&&(z=!0,E.bearing=+m.bearing),"pitch"in m&&E.pitch!==+m.pitch&&(B=!0,E.pitch=+m.pitch);const W=typeof m.padding=="number"?this._extendPadding(m.padding):m.padding;if(m.padding!=null&&!E.isPaddingEqual(W))if(m.retainPadding===!1){const te=E.clone();te.padding=W,E.setLocationAtPoint(E.center,te.centerPoint)}else E.padding=W;return m.preloadOnly?(this._preloadTiles(E),this):(this.fire(new i.C("movestart",v)).fire(new i.C("move",v)),D&&this.fire(new i.C("zoomstart",v)).fire(new i.C("zoom",v)).fire(new i.C("zoomend",v)),z&&this.fire(new i.C("rotatestart",v)).fire(new i.C("rotate",v)).fire(new i.C("rotateend",v)),B&&this.fire(new i.C("pitchstart",v)).fire(new i.C("pitch",v)).fire(new i.C("pitchend",v)),this.fire(new i.C("moveend",v)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||i.w(WP),this.transform.getFreeCameraOptions()}setFreeCameraOptions(m,v){const E=this.transform;if(!E.projection.supportsFreeCamera)return i.w(WP),this;this.stop();const D=E.zoom,z=E.pitch,B=E.bearing;E.setFreeCameraOptions(m);const W=D!==E.zoom,te=z!==E.pitch,ne=B!==E.bearing;return this.fire(new i.C("movestart",v)).fire(new i.C("move",v)),W&&this.fire(new i.C("zoomstart",v)).fire(new i.C("zoom",v)).fire(new i.C("zoomend",v)),ne&&this.fire(new i.C("rotatestart",v)).fire(new i.C("rotate",v)).fire(new i.C("rotateend",v)),te&&this.fire(new i.C("pitchstart",v)).fire(new i.C("pitch",v)).fire(new i.C("pitchend",v)),this.fire(new i.C("moveend",v)),this}easeTo(m,v){this._stop(!1,m.easeId),((m=Object.assign({offset:[0,0],duration:500,easing:i.eP},m)).animate===!1||this._prefersReducedMotion(m))&&(m.duration=0);const E=this.transform,D=this.getZoom(),z=this.getBearing(),B=this.getPitch(),W=this.getPadding(),te="zoom"in m?+m.zoom:D,ne="bearing"in m?this._normalizeBearing(m.bearing,z):z,de="pitch"in m?+m.pitch:B,je=this._extendPadding(m.padding),be=i.P.convert(m.offset);let Me,$e,Le;if(E.projection.name==="globe"){const Tt=i.ag.fromLngLat(E.center),Gt=be.rotate(-E.angle);Tt.x+=Gt.x/E.worldSize,Tt.y+=Gt.y/E.worldSize;const qt=Tt.toLngLat(),ns=i.aU.convert(m.center||qt);this._normalizeCenter(ns),Me=E.centerPoint.add(Gt),$e=new i.P(Tt.x,Tt.y).mult(E.worldSize),Le=new i.P(i.aH(ns.lng),i.aL(ns.lat)).mult(E.worldSize).sub($e)}else{Me=E.centerPoint.add(be);const Tt=E.pointLocation(Me),Gt=i.aU.convert(m.center||Tt);this._normalizeCenter(Gt),$e=E.project(Tt),Le=E.project(Gt).sub($e)}const Je=E.zoomScale(te-D);let Qe,lt;m.around&&(Qe=i.aU.convert(m.around),lt=E.locationPoint(Qe));const mt=this._zooming||te!==D,nt=this._rotating||z!==ne,zt=this._pitching||de!==B,bt=!E.isPaddingEqual(je),Dt=m.retainPadding===!1?E.clone():E,pt=Tt=>Gt=>{if(mt&&(Tt.zoom=i.am(D,te,Gt)),nt&&(Tt.bearing=i.am(z,ne,Gt)),zt&&(Tt.pitch=i.am(B,de,Gt)),bt&&(Dt.interpolatePadding(W,je,Gt),Me=Dt.centerPoint.add(be)),Qe)Tt.setLocationAtPoint(Qe,lt);else{const qt=Tt.zoomScale(Tt.zoom-D),ns=te>D?Math.min(2,Je):Math.max(.5,Je),Jt=Math.pow(ns,1-Gt),Ns=Tt.unproject($e.add(Le.mult(Gt*Jt)).mult(qt));Tt.setLocationAtPoint(Tt.renderWorldCopies?Ns.wrap():Ns,Me)}return m.preloadOnly||this._fireMoveEvents(v),Tt};if(m.preloadOnly){const Tt=this._emulate(pt,m.duration,E);return this._preloadTiles(Tt),this}const vt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=mt,this._rotating=nt,this._pitching=zt,this._padding=bt,this._easeId=m.easeId,this._prepareEase(v,m.noMoveStart,vt),this._ease(pt(E),Tt=>{E.cameraElevationReference==="sea"&&E.recenterOnTerrain(),this._afterEase(v,Tt)},m),this}_prepareEase(m,v,E={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),v||E.moving||this.fire(new i.C("movestart",m)),this._zooming&&!E.zooming&&this.fire(new i.C("zoomstart",m)),this._rotating&&!E.rotating&&this.fire(new i.C("rotatestart",m)),this._pitching&&!E.pitching&&this.fire(new i.C("pitchstart",m))}_fireMoveEvents(m){this.fire(new i.C("move",m)),this._zooming&&this.fire(new i.C("zoom",m)),this._rotating&&this.fire(new i.C("rotate",m)),this._pitching&&this.fire(new i.C("pitch",m))}_afterEase(m,v){if(this._easeId&&v&&this._easeId===v)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const E=this._zooming,D=this._rotating,z=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,E&&this.fire(new i.C("zoomend",m)),D&&this.fire(new i.C("rotateend",m)),z&&this.fire(new i.C("pitchend",m)),this.fire(new i.C("moveend",m))}flyTo(m,v){if(this._prefersReducedMotion(m)){const as=i.aJ(m,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(as,v)}this.stop(),m=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:i.eP},m);const E=this.transform,D=this.getZoom(),z=this.getBearing(),B=this.getPitch(),W=this.getPadding(),te="zoom"in m?i.aC(+m.zoom,E.minZoom,E.maxZoom):D,ne="bearing"in m?this._normalizeBearing(m.bearing,z):z,de="pitch"in m?+m.pitch:B,je=this._extendPadding(m.padding),be=E.zoomScale(te-D),Me=i.P.convert(m.offset);let $e=E.centerPoint.add(Me);const Le=E.pointLocation($e),Je=i.aU.convert(m.center||Le);this._normalizeCenter(Je);const Qe=E.project(Le),lt=E.project(Je).sub(Qe);let mt=m.curve;const nt=Math.max(E.width,E.height),zt=nt/be,bt=lt.mag();if("minZoom"in m){const as=i.aC(Math.min(m.minZoom,D,te),E.minZoom,E.maxZoom),ds=nt/E.zoomScale(as-D);mt=Math.sqrt(ds/bt*2)}const Dt=mt*mt;function pt(as){const ds=(zt*zt-nt*nt+(as?-1:1)*Dt*Dt*bt*bt)/(2*(as?zt:nt)*Dt*bt);return Math.log(Math.sqrt(ds*ds+1)-ds)}function vt(as){return(Math.exp(as)-Math.exp(-as))/2}function Tt(as){return(Math.exp(as)+Math.exp(-as))/2}const Gt=pt(0);let qt=function(as){return Tt(Gt)/Tt(Gt+mt*as)},ns=function(as){return nt*((Tt(Gt)*(vt(ds=Gt+mt*as)/Tt(ds))-vt(Gt))/Dt)/bt;var ds},Jt=(pt(1)-Gt)/mt;if(Math.abs(bt)<1e-6||!isFinite(Jt)){if(Math.abs(nt-zt)<1e-6)return this.easeTo(m,v);const as=ztm.maxDuration&&(m.duration=0);const Ns=z!==ne,Is=de!==B,Zt=!E.isPaddingEqual(je),Ut=m.retainPadding===!1?E.clone():E,ss=as=>ds=>{const Qs=ds*Jt,Gs=1/qt(Qs);as.zoom=ds===1?te:D+as.scaleZoom(Gs),Ns&&(as.bearing=i.am(z,ne,ds)),Is&&(as.pitch=i.am(B,de,ds)),Zt&&(Ut.interpolatePadding(W,je,ds),$e=Ut.centerPoint.add(Me));const Ws=ds===1?Je:as.unproject(Qe.add(lt.mult(ns(Qs))).mult(Gs));return as.setLocationAtPoint(as.renderWorldCopies?Ws.wrap():Ws,$e),as._updateCameraOnTerrain(),m.preloadOnly||this._fireMoveEvents(v),as};if(m.preloadOnly){const as=this._emulate(ss,m.duration,E);return this._preloadTiles(as),this}return this._zooming=!0,this._rotating=Ns,this._pitching=Is,this._padding=Zt,this._prepareEase(v,!1),this._ease(ss(E),()=>this._afterEase(v),m),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(m){}_cancelRenderFrame(m){}_stop(m,v){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const E=this._onEaseEnd;this._onEaseEnd=void 0,E.call(this,v)}if(!m){const E=this.handlers;E&&E.stop(!1)}return this}_ease(m,v,E){E.animate===!1||E.duration===0?(m(1),v()):(this._easeStart=i.o.now(),this._easeOptions=E,this._onEaseFrame=m,this._onEaseEnd=v,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const m=Math.min((i.o.now()-this._easeStart)/this._easeOptions.duration,1),v=this._onEaseFrame;v&&v(this._easeOptions.easing(m)),m<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(m,v){m=i.bs(m,-180,180);const E=Math.abs(m-v);return Math.abs(m-360-v)180?-360:E<-180?360:0}_prefersReducedMotion(m){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(m&&m.essential)}_emulate(m,v,E){const D=Math.ceil(15*v/1e3),z=[],B=m(E.clone());for(let W=0;W<=D;W++){const te=B(W/D);z.push(te.clone())}return z}_preloadTiles(m,v){}}class KP{constructor(m={}){this.options=m,i.aZ(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(m){const v=this.options&&this.options.compact,E=m._getUIString("AttributionControl.ToggleAttribution");this._map=m,this._container=N("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=N("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",E);const D=N("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",E),this._innerContainer=N("div","mapboxgl-ctrl-attrib-inner",this._container),v&&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),v===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 m=this._editLink;m||(m=this._editLink=this._container.querySelector(".mapbox-improve-map"));const v=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||i.g.ACCESS_TOKEN}];if(m){const E=v.reduce((D,z,B)=>(z.value&&(D+=`${z.key}=${z.value}${BD.length-z.length),m=m.filter((D,z)=>{for(let B=z+1;B=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?m=[...this.options.customAttribution,...m]:m.unshift(this.options.customAttribution));const E=m.map(D=>function(z){const B=new DOMParser().parseFromString(z,"text/html");return Array.from(B.body.querySelectorAll("*")).reverse().forEach(W=>{const te=W.textContent||"";if(W.tagName!=="A")return void W.replaceWith(...W.childNodes);const ne=W.getAttribute("href");if(!ne||!/^(https?:|mailto:)/i.test(ne))return void W.replaceWith(B.createTextNode(te));const de=B.createElement("a");de.href=ne,de.textContent=te,de.rel="noopener nofollow";const je=W.getAttribute("class");je&&(de.className=je),W.replaceWith(de)}),B.body.innerHTML}(D)).join(" | ");E!==this._attribHTML&&(this._attribHTML=E,m.length?(this._innerContainer.innerHTML=E,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 ZP{constructor(){i.aZ(["_updateLogo","_updateCompact"],this)}onAdd(m){this._map=m,this._container=N("div","mapboxgl-ctrl");const v=N("a","mapboxgl-ctrl-logo");return v.target="_blank",v.rel="noopener nofollow",v.href="https://www.mapbox.com/",v.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),v.setAttribute("rel","noopener nofollow"),this._container.appendChild(v),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(m){m&&m.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const m=this._map.style._sourceCaches;if(Object.entries(m).length===0)return!0;for(const v in m){const E=m[v].getSource();if(E.hasOwnProperty("mapbox_logo")&&!E.mapbox_logo)return!1}return!0}_updateCompact(){const m=this._container.children;if(m.length){const v=m[0];this._map.getCanvasContainer().offsetWidth<250?v.classList.add("mapboxgl-compact"):v.classList.remove("mapboxgl-compact")}}}class zF{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(m){const v=++this._id;return this._queue.push({callback:m,id:v,cancelled:!1}),v}remove(m){const v=this._currentlyRunning,E=v?this._queue.concat(v):this._queue;for(const D of E)if(D.id===m)return void(D.cancelled=!0)}run(m=0){const v=this._currentlyRunning=this._queue;this._queue=[];for(const E of v)if(!E.cancelled&&(E.callback(m),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class Ppe{constructor(m){this.jumpTo(m)}getValue(m){if(m<=this._startTime)return this._start;if(m>=this._endTime)return this._end;const v=i.dn((m-this._startTime)/(this._endTime-this._startTime));return this._start*(1-v)+this._end*v}isEasing(m){return m>=this._startTime&&m<=this._endTime}jumpTo(m){this._startTime=-1/0,this._endTime=-1/0,this._start=m,this._end=m}easeTo(m,v,E){this._start=this.getValue(v),this._end=m,this._startTime=v,this._endTime=v+E}}const Ipe={"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 wi extends i.C{constructor(m,v,E,D){const{point:z,lngLat:B,originalEvent:W,target:te}=m;super(m.type,{point:z,lngLat:B,originalEvent:W,target:te}),this.preventDefault=()=>{m.preventDefault()},this.id=v,this.interaction=E,this.feature=D}}class L3{constructor(m){this.map=m,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(m,v){if(this.typeById.has(m))throw new Error(`Interaction id "${m}" already exists.`);const E=v.filter;let D=v.type;E&&this.filters.set(m,i.dg(E)),D==="mouseover"&&(D="mouseenter"),D==="mouseout"&&(D="mouseleave");const z=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(m,v)):z.size===0&&this.map.on(D,this.handleType),z.size===0&&this.interactionsByType.set(D,z),z.set(m,v),this.typeById.set(m,D)}get(m){const v=this.typeById.get(m);if(!v)return;const E=this.interactionsByType.get(v);return E?E.get(m):void 0}remove(m){const v=this.typeById.get(m);if(!v)return;this.typeById.delete(m),this.filters.delete(m);const E=this.interactionsByType.get(v);E&&(E.delete(m),v==="mouseenter"||v==="mouseleave"?(this.delegatedInteractions.delete(m),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):E.size===0&&this.map.off(v,this.handleType))}queryTargets(m,v){const E=[];for(const[D,z]of v)z.target&&E.push({targetId:D,target:z.target,filter:this.filters.get(D)});return this.map.style.queryRenderedTargets(m,E,this.map.transform)}handleMove(m){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const v=this.queryTargets(m.point,Array.from(this.delegatedInteractions).reverse());v.length&&(m.type="mouseenter",this.handleType(m,v));const E=new Map;for(const[D,{feature:z}]of this.prevHoveredFeatures)this.hoveredFeatures.has(D)||E.set(z.id,z);E.size&&(m.type="mouseleave",this.handleType(m,Array.from(E.values())))}handleOut(m){const v=Array.from(this.hoveredFeatures.values()).map(({feature:E})=>E);v.length&&(m.type="mouseleave",this.handleType(m,v)),this.hoveredFeatures.clear()}handleType(m,v){const E=m.type==="mouseenter";if(E&&!this.interactionsByType.has(m.type))return void i.w("mouseenter interaction required for mouseleave to work.");const D=Array.from(this.interactionsByType.get(m.type)).reverse(),z=!!v;v=v||this.queryTargets(m.point,D);let B=!1;const W=new Set;for(const te of v){for(const[ne,de]of D){if(!de.target)continue;const je=te.variants?te.variants[ne]:null;if(je){for(const be of je){if(Wd(be,te,W,ne))continue;const Me=new i.di(te,be),$e=Ef(be,te,ne);z&&Me.id!==void 0&&(Me.state=this.map.getFeatureState(Me));const Le=E?this.prevHoveredFeatures.get($e):null,Je=new wi(m,ne,de,Me),Qe=Le?Le.stop:de.handler(Je);if(E&&this.hoveredFeatures.set($e,{feature:te,stop:Qe}),Qe!==!1){B=!0;break}}if(B)break}}if(B)break}if(!B)for(const[te,ne]of D){const{handler:de,target:je}=ne;if(!je&&de(new wi(m,te,ne,null))!==!1)break}}}function Lpe(M,m){if(Array.isArray(M)&&Array.isArray(m)){const v=new Set(M),E=new Set(m);return v.size===E.size&&M.every(D=>E.has(D))}return i.b6(M,m)}const Dpe={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,useServerFontComposition:!0,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1},Rpe={showCompass:!0,showZoom:!0,visualizePitch:!1};class b2{constructor(m,v,E=!1){this._clickTolerance=10,this.element=v,this.mouseRotate=new M3({clickTolerance:m.dragRotate._mouseRotate._clickTolerance}),this.map=m,E&&(this.mousePitch=new x2({clickTolerance:m.dragRotate._mousePitch._clickTolerance})),i.aZ(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),v.addEventListener("mousedown",this.mousedown),v.addEventListener("touchstart",this.touchstart,{passive:!1}),v.addEventListener("touchmove",this.touchmove),v.addEventListener("touchend",this.touchend),v.addEventListener("touchcancel",this.reset)}down(m,v){this.mouseRotate.mousedown(m,v),this.mousePitch&&this.mousePitch.mousedown(m,v),I()}move(m,v){const E=this.map,D=this.mouseRotate.mousemoveWindow(m,v),z=D&&D.bearingDelta;if(z&&E.setBearing(E.getBearing()+z),this.mousePitch){const B=this.mousePitch.mousemoveWindow(m,v),W=B&&B.pitchDelta;W&&E.setPitch(E.getPitch()+W)}}off(){const m=this.element;m.removeEventListener("mousedown",this.mousedown),m.removeEventListener("touchstart",this.touchstart),m.removeEventListener("touchmove",this.touchmove),m.removeEventListener("touchend",this.touchend),m.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){L(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(m){this.down(Object.assign({},m,{button:m.button,type:m.type,ctrlKey:!0,preventDefault:()=>m.preventDefault()}),q(this.element,m)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(m){this.move(m,q(this.element,m))}mouseup(m){this.mouseRotate.mouseupWindow(m),this.mousePitch&&this.mousePitch.mouseupWindow(m),this.offTemp()}touchstart(m){m.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=$(this.element,m.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>m.preventDefault()},this._startPos))}touchmove(m){m.targetTouches.length!==1?this.reset():(this._lastPos=$(this.element,m.targetTouches)[0],this.move({buttons:1,preventDefault:()=>m.preventDefault()},this._lastPos))}touchend(m){m.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)v.width||m.y>v.height;v.locationPoint3D(E).distSqr(m)180;){const E=v.locationPoint3D(M);if(E.x>=0&&E.y>=0&&E.x<=v.width&&E.y<=v.height)break;M.lng>v.center.lng?M.lng-=360:M.lng+=360}return M}const w2={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%)"},Jh={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Hm extends i.E{constructor(m,v){super(),(m instanceof HTMLElement||v)&&(m=Object.assign({element:m},v)),i.aZ(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:E="center",color:D="#3FB1CE",scale:z=1,draggable:B=!1,clickTolerance:W=0,rotation:te=Jh.rotation,rotationAlignment:ne=Jh.rotationAlignment,pitchAlignment:de=Jh.pitchAlignment,occludedOpacity:je=Jh.occludedOpacity,altitude:be=Jh.altitude}=m||{};this._anchor=E,this._color=D,this._scale=z,this._draggable=B,this._clickTolerance=W,this._rotation=te,this._rotationAlignment=ne,this._pitchAlignment=de,this._occludedOpacity=je,this._altitude=be,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),m&&m.element?(this._element=m.element,this._offset=i.P.convert(m&&m.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=i.P.convert(m&&m.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",Le=>{Le.preventDefault()}),this._element.addEventListener("mousedown",Le=>{Le.preventDefault()});const Me=this._element.classList;for(const Le in w2)Me.remove(`mapboxgl-marker-anchor-${Le}`);Me.add(`mapboxgl-marker-anchor-${this._anchor}`);const $e=m&&m.className?m.className.trim().split(/\s+/):[];Me.add(...$e),this._popup=null}_createDefaultMarker(){const m=N("div"),v=w("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},m);if(this._altitude===0){const E=w("radialGradient",{id:"shadowGradient"},w("defs",{},v));w("stop",{offset:"10%","stop-opacity":.4},E),w("stop",{offset:"100%","stop-opacity":.05},E),w("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},v)}return w("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},v),w("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},v),w("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},v),m}addTo(m){return m===this._map||(this.remove(),this._map=m,m.getCanvasContainer().appendChild(this._element),m.on("move",this._updateMoving),m.on("moveend",this._update),m.on("remove",this._clearFadeTimer),m._addMarker(this),this.setDraggable(this._draggable),this._update(),m.on("click",this._onMapClick)),this}remove(){const m=this._map;return m&&(m.off("click",this._onMapClick),m.off("move",this._updateMoving),m.off("moveend",this._update),m.off("mousedown",this._addDragHandler),m.off("touchstart",this._addDragHandler),m.off("mouseup",this._onUp),m.off("touchend",this._onUp),m.off("mousemove",this._onMove),m.off("touchmove",this._onMove),m.off("remove",this._clearFadeTimer),m._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(m){return this._lngLat=i.aU.convert(m),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(m){return m===this._altitude||(this._defaultMarker&&(this._altitude===0&&m!==0||this._altitude!==0&&m===0)&&(this._element=this._createDefaultMarker()),this._altitude=m||Jh.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(m){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")),m){if(!("offset"in m.options)){const D=Math.sqrt(Math.pow(13.5,2)/2);m.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=m,m._marker=this,m._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(m){const v=m.code,E=m.charCode||m.keyCode;v!=="Space"&&v!=="Enter"&&E!==32&&E!==13||this.togglePopup()}_onMapClick(m){const v=m.originalEvent.target,E=this._element;this._popup&&(v===E||E.contains(v))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const m=this._popup;return m?(m.isOpen()?(m.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(m.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const m=this._map,v=this._pos;if(!m||!v)return!1;const E=m.unproject(v,this._altitude),D=m.getFreeCameraOptions();if(!D.position)return!1;const z=D.position.toLngLat();return z.distanceTo(E)<.9*z.distanceTo(this._lngLat)}_evaluateOpacity(){const m=this._map;if(!m)return;const v=this._pos;if(!v||v.x<0||v.x>m.transform.width||v.y<0||v.y>m.transform.height)return void this._clearFadeTimer();const E=m.unproject(v,this._altitude);let D;m._showingGlobe()&&i.e$(m.transform,this._lngLat)?D=0:(D=1-m._queryFogOpacity(E),m.transform._terrainEnabled()&&m.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 m=this._pos;if(!m||!this._map)return;const v=this._offset.mult(this._scale);this._element.style.transform=` translate(${m.x}px,${m.y}px) ${w2[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${v.x}px,${v.y}px) `}_calculateXYTransform(){const m=this._pos,v=this._map,E=this.getPitchAlignment();if(!v||!m||E!=="map")return"";if(!v._showingGlobe()){const te=v.getPitch();return te?`rotateX(${te}deg)`:""}const D=i.cH(i.f0(v.transform,this._lngLat)),z=m.sub(i.f1(v.transform)),B=Math.abs(z.x)+Math.abs(z.y);if(B===0)return"";const W=D/B;return`rotateX(${-z.y*W}deg) rotateY(${z.x*W}deg)`}_calculateZTransform(){const m=this._pos,v=this._map;if(!v||!m)return"";let E=0;const D=this.getRotationAlignment();if(D==="map")if(v._showingGlobe()){const z=v.project(new i.aU(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),B=v.project(new i.aU(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(z);E=i.cH(Math.atan2(B.y,B.x))-90}else E=-v.getBearing();else if(D==="horizon"){const z=i.aj(4,6,v.getZoom()),B=i.f1(v.transform);B.y+=z*v.transform.height;const W=m.sub(B),te=i.cH(Math.atan2(W.y,W.x));E=(te>90?te-270:te+90)*(1-z)}return E+=this._rotation,E?`rotateZ(${E}deg)`:""}_update(m){cancelAnimationFrame(this._updateFrameId);const v=this._map;v&&(v.transform.renderWorldCopies&&(this._lngLat=YP(this._lngLat,this._pos,v.transform)),this._pos=v.project(this._lngLat,this._altitude),m===!0?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),v._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(v._showingGlobe()||v.getTerrain()||v.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(m){return this._offset=i.P.convert(m),this._update(),this}addClassName(m){return this._element.classList.add(m),this}removeClassName(m){return this._element.classList.remove(m),this}toggleClassName(m){return this._element.classList.toggle(m)}_onMove(m){const v=this._map;if(!v)return;const E=this._pointerdownPos,D=this._positionDelta;if(E&&D){if(!this._isDragging){const z=this._clickTolerance||v._clickTolerance;if(m.point.dist(E)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");M.antialias&&i.eZ(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 qw(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 zF,this._domRenderTaskQueue=new zF,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.r(),this._locale=Object.assign({},Ipe,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._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Ppe(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=M.scaleFactor,this._requestManager=new Y(M.transformRequest,M.accessToken,M.testMode);const v=fe(M.accessToken||i.g.ACCESS_TOKEN);if(v&&"atlas"in v&&typeof v.atlas=="number"&&(this._tokenExpiration=v.atlas),this._silenceAuthErrors=!!M.testMode,this._contextCreateOptions=M.contextCreateOptions?Object.assign({},M.contextCreateOptions):{},typeof M.container=="string"){const E=document.getElementById(M.container);if(!E)throw new Error(`Container '${M.container.toString()}' not found.`);this._container=E}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="auto",i.aZ(["_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 OF(this,M),this._localFontFamily=M.localFontFamily,this._localIdeographFontFamily=M.localIdeographFontFamily,this._useServerFontComposition=M.useServerFontComposition,(M.style||!M.testMode)&&this.setStyle(M.style||i.g.DEFAULT_STYLE,{config:M.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,useServerFontComposition:this._useServerFontComposition}),M.projection&&this.setProjection(M.projection),M.hash&&(this._hash=new Ape(typeof M.hash=="string"&&M.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){m.center==null&&m.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:M.center,zoom:M.zoom,bearing:M.bearing,pitch:M.pitch});const E=M.bounds;E&&(this.resize(),this.fitBounds(E,Object.assign({},M.fitBoundsOptions,{duration:0})))}this.resize(),M.attributionControl&&this.addControl(new KP({customAttribution:M.customAttribution})),this._logoControl=new ZP,this.addControl(this._logoControl,M.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent()}),this.on("data",E=>{this._update(E.dataType==="style"),this.fire(new i.C(`${E.dataType}data`,E))}),this.on("dataloading",E=>{this.fire(new i.C(`${E.dataType}dataloading`,E))}),this._interactions=new L3(this)}_getMapId(){return this._mapId}addControl(M,m){if(m===void 0&&(m=M.getDefaultPosition?M.getDefaultPosition():"top-right"),!M||!M.onAdd)return this.fire(new i.B(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const v=M.onAdd(this);this._controls.push(M);const E=this._controlPositions[m];return m.indexOf("bottom")!==-1?E.insertBefore(v,E.firstChild):E.appendChild(v),this}removeControl(M){if(!M||!M.onRemove)return this.fire(new i.B(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const m=this._controls.indexOf(M);return m>-1&&this._controls.splice(m,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 m=!this._moving;return m&&this.fire(new i.C("movestart",M)).fire(new i.C("move",M)),this.fire(new i.C("resize",M)),m&&this.fire(new i.C("moveend",M)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(M){return this.transform.setMaxBounds(i.aK.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.C("zoomstart")).fire(new i.C("zoom")).fire(new i.C("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.C("pitchstart")).fire(new i.C("pitch")).fire(new i.C("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.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(m=>m.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(m=>m==="auto"?navigator.language:m):M}setLanguage(M){const m=this._parseLanguage(M);if(!this.style||m===this._language)return this;this._language=m,this.style.reloadSources();for(const v of this._controls)v._setLanguage&&v._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.setWorldview(M),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,m=M.projection.name;let v;m==="globe"&&M.zoom>=i.cv?(M.setMercatorFromTransition(),v=!0):m==="mercator"&&M.zoom=i.cv?this.transform.setMercatorFromTransition():this.transform.setProjection(M),this.style.applyProjectionUpdate();const E=this.transform.getProjection().name==="mercator"&&v!==this.transform.mercatorFromTransition;return(m||E)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(M,m){return this.transform.locationPoint3D(i.aU.convert(M),m)}unproject(M,m){return this.transform.pointLocation3D(i.P.convert(M),m)}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,m,v){const E=D=>{let z=[];if(Array.isArray(m)){const B=m.filter(W=>this.getLayer(W));z=B.length?this.queryRenderedFeatures(D,{layers:B}):[]}else z=this.queryRenderedFeatures(D,{target:m});return z};if(M==="mouseenter"||M==="mouseover"){let D=!1;return{listener:v,targets:m,delegates:{mousemove:B=>{const W=E(B.point);W.length?D||(D=!0,v.call(this,new id(M,this,B.originalEvent,{features:W}))):D=!1},mouseout:()=>{D=!1}}}}if(M==="mouseleave"||M==="mouseout"){let D=!1;return{listener:v,targets:m,delegates:{mousemove:W=>{E(W.point).length?D=!0:D&&(D=!1,v.call(this,new id(M,this,W.originalEvent)))},mouseout:W=>{D&&(D=!1,v.call(this,new id(M,this,W.originalEvent)))}}}}{const D=z=>{const B=E(z.point);B.length&&(z.features=B,v.call(this,z),delete z.features)};return{listener:v,targets:m,delegates:{[M]:D}}}}on(M,m,v){if(typeof m=="function"||v===void 0)return super.on(M,m);if(typeof m=="string"&&(m=[m]),!this._areTargetsValid(m))return this;const E=this._createDelegatedListener(M,m,v);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[M]=this._delegatedListeners[M]||[],this._delegatedListeners[M].push(E);for(const D in E.delegates)this.on(D,E.delegates[D]);return this}once(M,m,v){if(typeof m=="function"||v===void 0)return super.once(M,m);if(typeof m=="string"&&(m=[m]),!this._areTargetsValid(m))return this;const E=this._createDelegatedListener(M,m,v);for(const D in E.delegates)this.once(D,E.delegates[D]);return this}off(M,m,v){if(typeof m=="function"||v===void 0)return super.off(M,m);if(typeof m=="string"&&(m=[m]),!this._areTargetsValid(m))return this;const E=this._delegatedListeners?this._delegatedListeners[M]:void 0;return E&&(D=>{for(let z=0;z{if(v){const D=typeof v=="string"?v:v instanceof Error?v.message:v.error;i.w(`Unable to perform style diff: ${D}. Rebuilding the style from scratch.`),this._updateStyle(M,m)}else E&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=m.localIdeographFontFamily,this._localFontFamily=m.localFontFamily,this._updateStyle(M,m))}_getUIString(M){const m=this._locale[M];if(m==null)throw new Error(`Missing UI string '${M}'`);return m}_updateStyle(M,m){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),M){const v=Object.assign({},m);m&&m.config&&(v.initialConfig=m.config,delete v.config),this.style=new qm(this,v).load(M),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new qm(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.B(new Error("IDs can't be empty."))),!1):!i.db(M)||(this.fire(new i.B(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 m of M)if(!this._isValidId(m))return!1;return!0}return this._isTargetValid(M)}addSource(M,m){return this._isValidId(M)?(this._lazyInitEmptyStyle(),this.style.addSource(M,m),this._update(!0)):this}isSourceLoaded(M){return!!this._isValidId(M)&&!!this.style&&this.style._isSourceCacheLoaded(M)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(M,m,v){this._lazyInitEmptyStyle(),this.style.addSourceType(M,m,v)}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,m,{pixelRatio:v=1,sdf:E=!1,stretchX:D,stretchY:z,content:B}={}){this._lazyInitEmptyStyle();const W=i.I.from(M);if(m instanceof HTMLImageElement||ImageBitmap&&m instanceof ImageBitmap){const{width:te,height:ne,data:de}=i.o.getImageData(m);this.style.addImage(W,{data:new i.q({width:te,height:ne},de),pixelRatio:v,stretchX:D,stretchY:z,content:B,sdf:E,version:0,usvg:!1})}else if(m.width===void 0||m.height===void 0)this.fire(new i.B(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:te,height:ne}=m,de=m;this.style.addImage(W,{data:new i.q({width:te,height:ne},new Uint8Array(de.data)),pixelRatio:v,stretchX:D,stretchY:z,content:B,sdf:E,usvg:!1,version:0,userImage:de}),de.onAdd&&de.onAdd(this,M)}}updateImage(M,m){this._lazyInitEmptyStyle();const v=i.I.from(M),E=this.style.getImage(v);if(!E)return void this.fire(new i.B(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const D=m instanceof HTMLImageElement||ImageBitmap&&m instanceof ImageBitmap?i.o.getImageData(m):m,{width:z,height:B,data:W}=D;if(z===void 0||B===void 0)return void this.fire(new i.B(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(z!==(E.usvg?E.icon.usvg_tree.width:E.data.width)||B!==(E.usvg?E.icon.usvg_tree.height:E.data.height))return void this.fire(new i.B(new Error(`The width and height of the updated image (${z}, ${B}) must be that same as the previous version of the image (${E.data.width}, ${E.data.height})`)));const te=!(m instanceof HTMLImageElement||ImageBitmap&&m instanceof ImageBitmap);let ne=!1;E.usvg?(E.data=new i.q({width:z,height:B},new Uint8Array(W)),E.usvg=!1,E.icon=void 0,ne=!0):E.data.replace(W,te),this.style.updateImage(v,E,ne)}hasImage(M){return M?!!this.style&&!!this.style.getImage(i.I.from(M)):(this.fire(new i.B(new Error("Missing required image id"))),!1)}removeImage(M){this.style.removeImage(i.I.from(M))}loadImage(M,m){i.n(this._requestManager.transformRequest(M,i.R.Image),(v,E)=>{m(v,E)})}listImages(){return this.style.listImages().map(M=>M.name)}addModel(M,m){this._lazyInitEmptyStyle(),this.style.addModel(M,m)}hasModel(M){return M?this.style.hasModel(M):(this.fire(new i.B(new Error("Missing required model id"))),!1)}removeModel(M){this.style.removeModel(M)}listModels(){return this.style.listModels()}addLayer(M,m){return this._isValidId(M.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(M,m),this._update(!0)):this}getSlot(M){const m=this.getLayer(M);return m&&m.slot||null}setSlot(M,m){return this.style.setSlot(M,m),this.style.mergeLayers(),this._update(!0)}addImport(M,m){return this.style.addImport(M,m).catch(v=>this.fire(new i.B(new Error("Failed to add import",v)))),this}updateImport(M,m){return typeof m!="string"&&m.id!==M?(this.removeImport(M),this.addImport(m)):(this.style.updateImport(M,m),this._update(!0))}removeImport(M){return this.style.removeImport(M),this}moveImport(M,m){return this.style.moveImport(M,m),this._update(!0)}moveLayer(M,m){return this._isValidId(M)?(this.style.moveLayer(M,m),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 m=this.style.getOwnLayer(M);return m?m.type==="custom"?m.implementation:m.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(M,m,v){return this._isValidId(M)?(this.style.setLayerZoomRange(M,m,v),this._update(!0)):this}setFilter(M,m,v={}){return this._isValidId(M)?(this.style.setFilter(M,m,v),this._update(!0)):this}getFilter(M){return this._isValidId(M)?this.style.getFilter(M):null}setPaintProperty(M,m,v,E={}){return this._isValidId(M)?(this.style.setPaintProperty(M,m,v,E),this._update(!0)):this}getPaintProperty(M,m){return this._isValidId(M)?this.style.getPaintProperty(M,m):null}setLayoutProperty(M,m,v,E={}){return this._isValidId(M)?(this.style.setLayoutProperty(M,m,v,E),this._update(!0)):this}getLayoutProperty(M,m){return this._isValidId(M)?this.style.getLayoutProperty(M,m):null}setLayerProperty(M,m,v,E={}){return this._isValidId(M)?(m==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(M,m,v,E),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,m){return this.style.setSchema(M,m),this._update(!0)}getConfig(M){return this.style.getConfig(M)}setConfig(M,m){return this.style.setConfig(M,m),this._update(!0)}getConfigProperty(M,m){return this.style.getConfigProperty(M,m)}setConfigProperty(M,m,v){return this.style.setConfigProperty(M,m,v),this._update(!0)}getFeaturesetDescriptors(M){return this.style.getFeaturesetDescriptors(M)}setLights(M){if(this._lazyInitEmptyStyle(),M&&M.length===1&&M[0].type==="flat"){const m=M[0];m.properties?this.style.setFlatLight(m.properties,m.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,m={}){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,m){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(M,m),this._update(!0)}setCamera(M){return this.style.setCamera(M),this._triggerCameraUpdate(M)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(M){const m=this.transform.nearClipOffset!==M;return this.transform.nearClipOffset=M,this._update(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.aU.convert(M),this.transform):0}setFeatureState(M,m){return M.source&&!this._isValidId(M.source)?this:(this.style.setFeatureState(M,m),this._update())}removeFeatureState(M,m){return M.source&&!this._isValidId(M.source)?this:(this.style.removeFeatureState(M,m),this._update())}getFeatureState(M){return M.source&&!this._isValidId(M.source)?null:this.style.getFeatureState(M)}_selectIndoorFloor(M){this.style.indoorManager.selectFloor(M)}_setIndoorActiveFloorsVisibility(M){this.style.indoorManager.setActiveFloorsVisibility(M)}getIndoorTileOptions(M,m){return this.style.isIndoorEnabled()?this.style.indoorManager.getIndoorTileOptions(M,m):null}_updateContainerDimensions(){if(!this._container)return;const M=this._container.getBoundingClientRect().width||400,m=this._container.getBoundingClientRect().height||300;let v,E,D,z=this._container;for(;z&&(!E||!D);){const B=window.getComputedStyle(z).transform;B&&B!=="none"&&(v=B.match(/matrix.*\((.+)\)/)[1].split(", "),v[0]&&v[0]!=="0"&&v[0]!=="1"&&(E=v[0]),v[3]&&v[3]!=="0"&&v[3]!=="1"&&(D=v[3])),z=z.parentElement}this._containerWidth=E?Math.abs(M/E):M,this._containerHeight=D?Math.abs(m/D):m}_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/.")}_setupContainer(){const M=this._container;M.classList.add("mapboxgl-map"),(this._missingCSSCanary=N("div","mapboxgl-canary",M)).style.visibility="hidden",this._detectMissingCSS();const m=this._canvasContainer=N("div","mapboxgl-canvas-container",M);this._canvas=N("canvas","mapboxgl-canvas",m),this._interactive&&(m.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 v=this._controlContainer=N("div","mapboxgl-control-container",M),E=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{E[D]=N("div",`mapboxgl-ctrl-${D}`,v)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(M,m){const v=i.o.devicePixelRatio||1;this._canvas.width=v*Math.ceil(M),this._canvas.height=v*Math.ceil(m),this._canvas.style.width=`${M}px`,this._canvas.style.height=`${m}px`}_addMarker(M){this._markers.push(M)}_removeMarker(M){const m=this._markers.indexOf(M);m!==-1&&this._markers.splice(m,1)}_addPopup(M){this._popups.push(M)}_removePopup(M){const m=this._popups.indexOf(M);m!==-1&&this._popups.splice(m,1)}_setupPainter(){const M=Object.assign({},b.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),m=this._canvas.getContext("webgl2",M);m?(Ce(m,!0),this.painter=new Tpe(m,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",v=>{if(v.dataType==="source"){const E=this.transform.elevation?this.transform.elevation._source():null;E&&v.sourceCacheId===E.id&&this.style&&this.style._setLabelPlacementStale(),this.painter.setTileLoadedFlag(!0)}}),i.k.testSupport(m)):this.fire(new i.B(new Error("Failed to initialize WebGL")))}_contextLost(M){M.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.C("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.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new i.C("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 m;this.fire(new i.C("renderstart")),++this._frameId;const v=this.painter.context.extTimerQuery,E=i.o.now(),D=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(m=D.createQuery(),D.beginQuery(v.TIME_ELAPSED_EXT,m)),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 z=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const te=this.transform.zoom,ne=this.transform.pitch,de=i.o.now(),je=new i.ae(te,{now:de,fadeDuration:z,pitch:ne,transition:this.style.transition,worldview:this._worldview});this.style.update(je)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let B=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),B=this._updateAverageElevation(E),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):B=this._updateAverageElevation(E),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,z,this._crossSourceCollisions,this.painter.replacementSource)),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:z,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.C("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.mark(u.load),this.fire(new i.C("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(),m){const te=i.o.now()-E;D.endQuery(v.TIME_ELAPSED_EXT),setTimeout(()=>{const ne=D.getQueryParameter(m,D.QUERY_RESULT)/1e6;D.deleteQuery(m),this.fire(new i.C("gpu-timing-frame",{cpuTime:te,gpuTime:ne}))},50)}if(this.listens("gpu-timing-layer")){const te=this.painter.collectGpuTimers();setTimeout(()=>{const ne=this.painter.queryGpuTimers(te);this.fire(new i.C("gpu-timing-layer",{layerTimes:ne}))},50)}if(this.listens("gpu-timing-deferred-render")){const te=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const ne=this.painter.queryGpuTimeDeferredRender(te);this.fire(new i.C("gpu-timing-deferred-render",{gpuTime:ne}))},50)}const W=this._sourcesDirty||this._styleDirty||this._placementDirty||B;if(W||this._repaint)this.triggerRepaint();else{const te=this.idle();if(te&&(B=this._updateAverageElevation(E,!0)),B)this.triggerRepaint();else if(this._triggerFrame(!1),te&&(this.fire(new i.C("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const ne=this._calculateSpeedIndex();this.fire(new i.C("speedindexcompleted",{speedIndex:ne})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||W||(this._fullyLoaded=!0,p.mark(u.fullLoad),this._performanceMetricsCollection&&pe(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 m of this._markers)M&&!this.getRenderWorldCopies()&&(m._lngLat=m._lngLat.wrap()),m._update();for(const m of this._popups)!M||this.getRenderWorldCopies()||m._trackPointer||(m._lngLat=m._lngLat.wrap()),m._update()}_updateAverageElevation(M,m=!1){const v=D=>(this.transform.averageElevation=D,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&v(0);const E=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(E||(m||M-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(M)){const D=this.transform.averageElevation;let z=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(z)?z=0:this._averageElevationLastSampledAt=M;const B=Math.abs(D-z);if(B>1){if(this._isInitialLoad||E)return this._averageElevation.jumpTo(z),v(z);this._averageElevation.easeTo(z,M,300)}else if(B>1e-4)return this._averageElevation.jumpTo(z),v(z)}return!!this._averageElevation.isEasing(M)&&v(this._averageElevation.getValue(M))}_isTokenExpired(){return this._tokenExpiration!=null&&Date.now()>this._tokenExpiration}_revokeAuth(){const M=this.painter.context.gl;Ce(M,!1),this._logoControl instanceof ZP&&this._logoControl._updateLogo(),M&&M.clear(M.DEPTH_BUFFER_BIT|M.COLOR_BUFFER_BIT|M.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new i.B(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/")))}_authenticate(){tt(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,M=>{M&&(M.message!==J&&M.status!==401||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),Ae(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Ee(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Re(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){ye(this._requestManager._customAccessToken)}_updateTerrain(){const M=this._isDragging();this.painter.updateTerrain(this.style,M)}_calculateSpeedIndex(){const M=this.painter.canvasCopy(),m=this.painter.getCanvasCopiesAndTimestamps();m.timeStamps.push(performance.now());const v=this.painter.context.gl,E=v.createFramebuffer();function D(z){v.framebufferTexture2D(v.FRAMEBUFFER,v.COLOR_ATTACHMENT0,v.TEXTURE_2D,z,0);const B=new Uint8Array(v.drawingBufferWidth*v.drawingBufferHeight*4);return v.readPixels(0,0,v.drawingBufferWidth,v.drawingBufferHeight,v.RGBA,v.UNSIGNED_BYTE,B),B}return v.bindFramebuffer(v.FRAMEBUFFER,E),this._canvasPixelComparison(D(M),m.canvasCopies.map(D),m.timeStamps)}_canvasPixelComparison(M,m,v){let E=v[1]-v[0];const D=M.length/4;for(let z=0;z{const v=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,v&&this._render(m)}))}_preloadTiles(M){const m=this.style?this.style.getSourceCaches():[];return i.t(m,(v,E)=>v._preloadTiles(M,E),()=>{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,m){i.e_(M,m)}get version(){return d}},NavigationControl:class{constructor(M={}){this.options=Object.assign({},Rpe,M),this._container=N("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",m=>m.preventDefault()),this.options.showZoom&&(i.aZ(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",m=>{this._map&&this._map.zoomIn({},{originalEvent:m})}),N("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",m=>{this._map&&this._map.zoomOut({},{originalEvent:m})}),N("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.aZ(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",m=>{const v=this._map;v&&(this.options.visualizePitch?v.resetNorthPitch({},{originalEvent:m}):v.resetNorth({},{originalEvent:m}))}),this._compassIcon=N("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const M=this._map;if(!M)return;const m=M.getZoom(),v=m===M.getMaxZoom(),E=m===M.getMinZoom();this._zoomInButton.disabled=v,this._zoomOutButton.disabled=E,this._zoomInButton.setAttribute("aria-disabled",v.toString()),this._zoomOutButton.setAttribute("aria-disabled",E.toString())}_rotateCompassArrow(){const M=this._map;if(!M)return;const m=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=m)})}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 b2(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,m){const v=N("button",M,this._container);return v.type="button",v.addEventListener("click",m),v}_setButtonTitle(M,m){if(!this._map)return;const v=this._map._getUIString(`NavigationControl.${m}`);M.setAttribute("aria-label",v),M.firstElementChild&&M.firstElementChild.setAttribute("title",v)}},GeolocateControl:class extends i.E{constructor(M={}){super();const m=navigator.geolocation;this.options=Object.assign({geolocation:m},j2,M),i.aZ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=IP(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(M){return this._map=M,this._container=N("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),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 m=(v=!!this.options.geolocation)=>{this._supportsGeolocation=v,M(v)};this._supportsGeolocation!==void 0?M(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(v=>m(v.state!=="denied")).catch(()=>m()):m()}_isOutOfMapMaxBounds(M){const m=this._map.getMaxBounds(),v=M.coords;return!!m&&(v.longitudem.getEast()||v.latitudem.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._clearRequestTimeout(),this._isOutOfMapMaxBounds(M))return this._setErrorState(),this.fire(new i.C("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._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this.options.followUserLocation?(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active")):(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"));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.followUserLocation&&(!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.C("geolocate",Object.assign({coords:M.coords,timestamp:M.timestamp},M.toJSON?{toJSON:M.toJSON.bind(M)}:{}))),this._finish()}}_updateCamera(M){const m=new i.aU(M.coords.longitude,M.coords.latitude),v=M.coords.accuracy,E=this._map.getBearing(),D=Object.assign({bearing:E},this.options.fitBoundsOptions);this._map.fitBounds(m.toBounds(v),D,{geolocateSource:!0})}_updateMarker(M){if(M){const m=new i.aU(M.coords.longitude,M.coords.latitude);this._accuracyCircleMarker.setLngLat(m).addTo(this._map),this._userLocationDotMarker.setLngLat(m).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,m=i.bU(1,M._center.lat)*M.worldSize,v=Math.ceil(2*this._accuracy*m);this._circleElement.style.width=`${v}px`,this._circleElement.style.height=`${v}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._clearRequestTimeout(),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 m=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",m),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",m),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.C("error",{code:M.code,message:M.message,PERMISSION_DENIED:M.PERMISSION_DENIED,POSITION_UNAVAILABLE:M.POSITION_UNAVAILABLE,TIMEOUT:M.TIMEOUT})),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_startRequestTimeout(){this._clearRequestTimeout();const M=this.options.positionOptions.timeout;M&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"})},M))}_clearRequestTimeout(){this._requestTimeoutId!==void 0&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0)}_setupUI(M){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",m=>m.preventDefault()),this._geolocateButton=N("button","mapboxgl-ctrl-geolocate",this._container),N("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 m=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",m),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",m)}else{const m=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",m),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",m)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=N("div","mapboxgl-user-location"),this._dotElement.appendChild(N("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(N("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Hm({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=N("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Hm({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.showButton||(this._container.style.display="none"),this.options.trackUserLocation&&this._map.on("movestart",m=>{m.geolocateSource||this._watchState!=="ACTIVE_LOCK"||m.originalEvent&&m.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.C("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.C("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.C("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.C("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._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}setFollowUserLocation(M){return this.options.followUserLocation=M??j2.followUserLocation,this.options.trackUserLocation&&this._watchState!=="OFF"&&(this.options.followUserLocation?this._watchState!=="BACKGROUND"&&this._watchState!=="BACKGROUND_ERROR"||(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.C("trackuserlocationstart"))):this._watchState!=="ACTIVE_LOCK"&&this._watchState!=="ACTIVE_ERROR"||(this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this.fire(new i.C("trackuserlocationend")))),this}_addDeviceOrientationListener(){const M=()=>{const m="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(m,this._onDeviceOrientation)};typeof DeviceOrientationEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(m=>{m==="granted"&&M()}).catch(console.error):M()}_clearWatch(){this._clearRequestTimeout(),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:KP,ScaleControl:class{constructor(M={}){this.options=Object.assign({},kl,M),i.aZ(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const M=this.options.maxWidth||100,m=this._map,v=m._containerHeight/2,E=m._containerWidth/2-M/2,D=m.unproject([E,v]),z=m.unproject([E+M,v]),B=D.distanceTo(z);if(this.options.unit==="imperial"){const W=3.2808*B;W>5280?this._setScale(M,W/5280,"mile"):this._setScale(M,W,"foot")}else this.options.unit==="nautical"?this._setScale(M,B/1852,"nautical-mile"):B>=1e3?this._setScale(M,B/1e3,"kilometer"):this._setScale(M,B,"meter")}_setScale(M,m,v){this._map._requestDomTask(()=>{const E=function(z){const B=Math.pow(10,`${Math.floor(z)}`.length-1);let W=z/B;return W=W>=10?10:W>=5?5:W>=3?3:W>=2?2:W>=1?1:function(te){const ne=Math.pow(10,Math.ceil(-Math.log(te)/Math.LN10));return Math.round(te*ne)/ne}(W),B*W}(m),D=E/m;this._container.innerHTML=v!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:v}).format(E):`${E} ${Gm[v]}`,this._container.style.width=M*D+"px"})}onAdd(M){return this._map=M,this._language=M.getLanguage(),this._container=N("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.aZ(["_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=N("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=N("button","mapboxgl-ctrl-fullscreen",this._controlContainer);N("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:class{constructor(){i.aZ(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null}onAdd(M){return this._map=M,this._container=N("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection()}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){const M=this._map.style.indoorManager;M.off("selector-update",this._onIndoorUpdate),M.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(M.getControlState())}}_createButton(M,m){const v=N("button",M,this._container);return v.type="button",v.addEventListener("click",m),v}_setButtonTitle(M,m){M.setAttribute("aria-label",m),M.textContent=m}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.style&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"top-right"}_onIndoorUpdate(M){if(!M||!M.floors||M.floors.length===0)return this._model=M,void(this._container.style.display="none");const m=this._model;this._model=M,this._container.style.display="inline-block";const v=!m||m.floors.length!==M.floors.length||m.floors.some((E,D)=>E.id!==M.floors[D].id);if(v&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),M.selectedFloorId){if(M.selectedFloorId!==this._lastSelectedFloorId||v){const E=M.floors.findIndex(D=>D.id===M.selectedFloorId);if(E!==-1){const D=M.floors.length;let z,B;D<=5?(z=0,B=D-1):this._visibleFloorStart===0?(z=0,B=3):this._visibleFloorStart>=D-3?(z=D-3-1,B=D-1):(z=this._visibleFloorStart,B=this._visibleFloorStart+3-1),EB&&(this._visibleFloorStart=E-2)}}this._lastSelectedFloorId=M.selectedFloorId}this._render()}_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const M=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);N("span","mapboxgl-ctrl-icon",M).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||M.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(M);const m=this._model.floors,v=m.length;if(v<=5)return void m.forEach(B=>this._createFloorButton(B));const E=this._visibleFloorStart===0,D=this._visibleFloorStart>=v-3;if(E)this._createFloorButton(m[0]);else{const B=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);N("span","mapboxgl-ctrl-icon",B).setAttribute("aria-hidden","true"),this._container.appendChild(B)}let z=[];if(z=E?m.slice(1,4):D?m.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):m.slice(this._visibleFloorStart,this._visibleFloorStart+3),z.forEach(B=>this._createFloorButton(B)),D)this._createFloorButton(m[v-1]);else{const B=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);N("span","mapboxgl-ctrl-icon",B).setAttribute("aria-hidden","true"),this._container.appendChild(B)}}_createFloorButton(M){const m=this._createButton("mapboxgl-ctrl-level-button",()=>{const z=M.id;this._model&&this._model.selectedFloorId===z&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(z))}),v=(M.name||"").trim(),E=M.zIndex.toString(),D=v?Array.from(v).slice(0,3).join(""):E;this._setButtonTitle(m,D),this._model&&this._model.activeFloorsVisible&&M.id===this._model.selectedFloorId&&m.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(m)}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1)}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,this._visibleFloorStart===1&&(this._visibleFloorStart=0);const M=this._model&&this._model.floors||[];if(M.length>3){const m=M.length-3;this._visibleFloorStart===m-1&&(this._visibleFloorStart=m-2)}this._render()}}_scrollDown(){if(this._model&&this._model.floors){const M=this._model.floors.length-3;this._visibleFloorStartM&&(this._visibleFloorStart=M),this._render())}}},Popup:class extends i.E{constructor(M){super(),this.options=Object.assign(Object.create(N2),M),this._altitude=this.options.altitude,i.aZ(["_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.C("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.C("close")),this}getLngLat(){return this._lngLat}setLngLat(M){this._lngLat=i.aU.convert(M),this._pos=null,this._trackPointer=!1,this._update();const m=this._map;return m&&(m.on("move",this._update),m.off("mousemove",this._onMouseEvent),m._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 m=document.createDocumentFragment(),v=document.createElement("body");let E;for(v.innerHTML=M;E=v.firstChild,E;)m.appendChild(E);return this.setDOMContent(m)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(M){return this.options.maxWidth=M,this._update(),this}setDOMContent(M){let m=this._content;if(m)for(;m.hasChildNodes();)m.firstChild&&m.removeChild(m.firstChild);else m=this._content=N("div","mapboxgl-popup-content",this._container||void 0);if(m.appendChild(M),this.options.closeButton){const v=this._closeButton=N("button","mapboxgl-popup-close-button",m);v.type="button",v.setAttribute("aria-label","Close popup"),v.innerHTML='',v.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 m;return this._classList.delete(M)?m=!1:(this._classList.add(M),m=!0),this._updateClassList(),m}_onMouseEvent(M){this._update(M.point)}_getAnchor(M){if(this.options.anchor)return this.options.anchor;const m=this._map,v=this._container,E=this._pos;if(!m||!v||!E)return"bottom";const D=v.offsetWidth,z=v.offsetHeight,B=E.xm.transform.width-D/2;if(E.y+Mm.transform.height-z){if(B)return"bottom-left";if(W)return"bottom-right"}return B?"left":W?"right":"bottom"}_updateClassList(){const M=this._container;if(!M)return;const m=[...this._classList];m.push("mapboxgl-popup"),this._anchor&&m.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&m.push("mapboxgl-popup-track-pointer"),M.className=m.join(" ")}_update(M){const m=this._map,v=this._content;if(!m||!this._lngLat&&!this._trackPointer||!v)return;let E=this._container;if(E||(E=this._container=N("div","mapboxgl-popup",m.getContainer()),this._tip=N("div","mapboxgl-popup-tip",E),E.appendChild(v)),this.options.maxWidth&&E.style.maxWidth!==this.options.maxWidth&&(E.style.maxWidth=this.options.maxWidth),m.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=YP(this._lngLat,this._pos,m.transform)),!this._trackPointer||M){const D=this._pos=this._trackPointer&&M instanceof i.P?M:m.project(this._lngLat,this._altitude),z=D3(this.options.offset),B=this._anchor=this._getAnchor(z.y),W=D3(this.options.offset,B),te=D.add(W).round();m._requestDomTask(()=>{this._container&&B&&(this._container.style.transform=`${w2[B]} translate(${te.x}px,${te.y}px)`)})}if(!this._marker&&m._showingGlobe()){const D=i.e$(m.transform,this._lngLat)?0:1;this._setOpacity(D)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const M=this._container.querySelector(Ope);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:Hm,Style:qm,LngLat:i.aU,LngLatBounds:i.aK,Point:i.P,MercatorCoordinate:i.ag,FreeCameraOptions:Bw,Evented:i.E,config:i.g,prewarm:function(){gt().acquire(Oe)},clearPrewarmedResources:function(){const M=Ke;M&&(M.isPreloaded()&&M.numActive()===1?(M.release(Oe),Ke=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()"))},get accessToken(){return i.g.ACCESS_TOKEN},set accessToken(M){i.g.ACCESS_TOKEN=M},get baseApiUrl(){return i.g.API_URL},set baseApiUrl(M){i.g.API_URL=M},get workerCount(){return Xe.workerCount},set workerCount(M){Xe.workerCount=M},get maxParallelImageRequests(){return i.g.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(M){i.g.MAX_PARALLEL_IMAGE_REQUESTS=M},clearStorage(M){i.f7(M)},get workerUrl(){return Ot.workerUrl},set workerUrl(M){Ot.workerUrl=M},get workerClass(){return Ot.workerClass},set workerClass(M){Ot.workerClass=M},get workerParams(){return Ot.workerParams},set workerParams(M){Ot.workerParams=M},get dracoUrl(){return i.f6()},set dracoUrl(M){i.g.DRACO_URL=i.o.resolveURL(M)},get meshoptUrl(){return i.f5()},set meshoptUrl(M){const m=i.o.resolveURL(M);i.g.MESHOPT_URL=m,i.g.MESHOPT_SIMD_URL=m},get buildingGenUrl(){return i.f4()},set buildingGenUrl(M){i.g.BUILDING_GEN_URL=i.o.resolveURL(M)},setNow:i.o.setNow,restoreNow:i.o.restoreNow}});var l=a;return l})})(qGe);var Ekt=qGe.exports;const yc=ro(Ekt);function Ss({className:t,...s}){return e.jsx("div",{className:Rt("animate-pulse rounded-md bg-muted",t),...s})}const nIe={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},aIe={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function Pkt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function Ikt({listings:t,isLoading:s}){const r=br(),n=k.useRef(null),a=k.useRef(null),o=k.useRef([]),[l,i]=k.useState(""),[d,u]=k.useState(!0);return k.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)})()},[]),k.useEffect(()=>{if(!n.current||!l||a.current)return;yc.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((w,S)=>w+S.longitude,0)/f.length,N=f.reduce((w,S)=>w+S.latitude,0)/f.length;y=[b,N],_=f.length===1?12:10}return a.current=new yc.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:_,center:y}),a.current.addControl(new yc.NavigationControl,"top-right"),()=>{var b;(b=a.current)==null||b.remove(),a.current=null}},[l]),k.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,O;const _=nIe[y.status]||"#10B981",b=((I=y.photos)==null?void 0:I.find(U=>U.is_primary))||((L=y.photos)==null?void 0:L[0]),w=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${y.slug||y.id}`:`/public/listing/${y.slug||y.id}`,S=document.createElement("div");S.className="cursor-pointer",S.innerHTML=`
`;const C=new yc.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${b!=null&&b.photo_url?``:""}
${Pkt(y.price)}
${y.property_address||""}
${y.city}, ${y.state}
${aIe[y.status]||y.status} ${y.bedrooms?`${y.bedrooms} bed`:""} ${y.bathrooms?`${y.bathrooms} bath`:""}
${(O=y.agent)!=null&&O.name?`
Listed by ${y.agent.name}
`:""}
Click to view details →
`),A=new yc.Marker(S).setLngLat([y.longitude,y.latitude]).setPopup(C).addTo(a.current);o.current.push(A)}),f.length>1){const y=new yc.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]),k.useEffect(()=>(window.__navigateToPublicListing__=f=>{r(f)},()=>{delete window.__navigateToPublicListing__}),[r]),d||s?e.jsx(Ss,{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(nIe).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:aIe[f]})]},f))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function nD(t,[s,r]){return Math.min(r,Math.max(s,t))}function Lkt(t){const s=Dkt(t),r=k.forwardRef((n,a)=>{const{children:o,...l}=n,i=k.Children.toArray(o),d=i.find(Okt);if(d){const u=d.props.children,p=i.map(f=>f===d?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:k.isValidElement(u)?k.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}function Dkt(t){const s=k.forwardRef((r,n)=>{const{children:a,...o}=r;if(k.isValidElement(a)){const l=zkt(a),i=Fkt(o,a.props);return a.type!==k.Fragment&&(i.ref=n?Mm(n,l):l),k.cloneElement(a,i)}return k.Children.count(a)>1?k.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var Rkt=Symbol("radix.slottable");function Okt(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Rkt}function Fkt(t,s){const r={...s};for(const n in s){const a=t[n],o=s[n];/^on[A-Z]/.test(n)?a&&o?r[n]=(...i)=>{const d=o(...i);return a(...i),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function zkt(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 BR(t){const s=k.useRef({value:t,previous:t});return k.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var Bkt=[" ","Enter","ArrowUp","ArrowDown"],$kt=[" ","Enter"],KS="Select",[Cue,Mue,qkt]=jR(KS),[HA]=bd(KS,[qkt,_0]),Tue=_0(),[Ukt,yw]=HA(KS),[Vkt,Hkt]=HA(KS),VGe=t=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:d,dir:u,name:p,autoComplete:f,disabled:y,required:_,form:b}=t,N=Tue(s),[w,S]=k.useState(null),[C,A]=k.useState(null),[I,L]=k.useState(!1),O=xw(u),[U,q]=Bu({prop:n,defaultProp:a??!1,onChange:o,caller:KS}),[$,V]=Bu({prop:l,defaultProp:i,onChange:d,caller:KS}),ee=k.useRef(null),Z=w?b||!!w.closest("form"):!0,[J,Y]=k.useState(new Set),ce=Array.from(J).map(ae=>ae.props.value).join(";");return e.jsx(CR,{...N,children:e.jsxs(Ukt,{required:_,scope:s,trigger:w,onTriggerChange:S,valueNode:C,onValueNodeChange:A,valueNodeHasChildren:I,onValueNodeHasChildrenChange:L,contentId:mu(),value:$,onValueChange:V,open:U,onOpenChange:q,dir:O,triggerPointerDownPosRef:ee,disabled:y,children:[e.jsx(Cue.Provider,{scope:s,children:e.jsx(Vkt,{scope:t.__scopeSelect,onNativeOptionAdd:k.useCallback(ae=>{Y(ie=>new Set(ie).add(ae))},[]),onNativeOptionRemove:k.useCallback(ae=>{Y(ie=>{const le=new Set(ie);return le.delete(ae),le})},[]),children:r})}),Z?e.jsxs(pWe,{"aria-hidden":!0,required:_,tabIndex:-1,name:p,autoComplete:f,value:$,onChange:ae=>V(ae.target.value),disabled:y,form:b,children:[$===void 0?e.jsx("option",{value:""}):null,Array.from(J)]},ce):null]})})};VGe.displayName=KS;var HGe="SelectTrigger",GGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=Tue(r),l=yw(HGe,r),i=l.disabled||n,d=Ma(s,l.onTriggerChange),u=Mue(r),p=k.useRef("touch"),[f,y,_]=xWe(N=>{const w=u().filter(A=>!A.disabled),S=w.find(A=>A.value===l.value),C=gWe(w,N,S);C!==void 0&&l.onValueChange(C.value)}),b=N=>{i||(l.onOpenChange(!0),_()),N&&(l.triggerPointerDownPosRef.current={x:Math.round(N.pageX),y:Math.round(N.pageY)})};return e.jsx(RA,{asChild:!0,...o,children:e.jsx(dn.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":fWe(l.value)?"":void 0,...a,ref:d,onClick:Tr(a.onClick,N=>{N.currentTarget.focus(),p.current!=="mouse"&&b(N)}),onPointerDown:Tr(a.onPointerDown,N=>{p.current=N.pointerType;const w=N.target;w.hasPointerCapture(N.pointerId)&&w.releasePointerCapture(N.pointerId),N.button===0&&N.ctrlKey===!1&&N.pointerType==="mouse"&&(b(N),N.preventDefault())}),onKeyDown:Tr(a.onKeyDown,N=>{const w=f.current!=="";!(N.ctrlKey||N.altKey||N.metaKey)&&N.key.length===1&&y(N.key),!(w&&N.key===" ")&&Bkt.includes(N.key)&&(b(),N.preventDefault())})})})});GGe.displayName=HGe;var WGe="SelectValue",KGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,d=yw(WGe,r),{onValueNodeHasChildrenChange:u}=d,p=o!==void 0,f=Ma(s,d.onValueNodeChange);return rd(()=>{u(p)},[u,p]),e.jsx(dn.span,{...i,ref:f,style:{pointerEvents:"none"},children:fWe(d.value)?e.jsx(e.Fragment,{children:l}):o})});KGe.displayName=WGe;var Gkt="SelectIcon",ZGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(dn.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});ZGe.displayName=Gkt;var Wkt="SelectPortal",YGe=t=>e.jsx(PA,{asChild:!0,...t});YGe.displayName=Wkt;var ZS="SelectContent",XGe=k.forwardRef((t,s)=>{const r=yw(ZS,t.__scopeSelect),[n,a]=k.useState();if(rd(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?ap.createPortal(e.jsx(QGe,{scope:t.__scopeSelect,children:e.jsx(Cue.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(JGe,{...t,ref:s})});XGe.displayName=ZS;var fg=10,[QGe,vw]=HA(ZS),Kkt="SelectContentImpl",Zkt=Lkt("SelectContent.RemoveScroll"),JGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:i,sideOffset:d,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:y,collisionPadding:_,sticky:b,hideWhenDetached:N,avoidCollisions:w,...S}=t,C=yw(ZS,r),[A,I]=k.useState(null),[L,O]=k.useState(null),U=Ma(s,ze=>I(ze)),[q,$]=k.useState(null),[V,ee]=k.useState(null),Z=Mue(r),[J,Y]=k.useState(!1),ce=k.useRef(!1);k.useEffect(()=>{if(A)return vue(A)},[A]),xue();const ae=k.useCallback(ze=>{const[Ee,...ve]=Z().map(ye=>ye.ref.current),[Re]=ve.slice(-1),Ue=document.activeElement;for(const ye of ze)if(ye===Ue||(ye==null||ye.scrollIntoView({block:"nearest"}),ye===Ee&&L&&(L.scrollTop=0),ye===Re&&L&&(L.scrollTop=L.scrollHeight),ye==null||ye.focus(),document.activeElement!==Ue))return},[Z,L]),ie=k.useCallback(()=>ae([q,A]),[ae,q,A]);k.useEffect(()=>{J&&ie()},[J,ie]);const{onOpenChange:le,triggerPointerDownPosRef:fe}=C;k.useEffect(()=>{if(A){let ze={x:0,y:0};const Ee=Re=>{var Ue,ye;ze={x:Math.abs(Math.round(Re.pageX)-(((Ue=fe.current)==null?void 0:Ue.x)??0)),y:Math.abs(Math.round(Re.pageY)-(((ye=fe.current)==null?void 0:ye.y)??0))}},ve=Re=>{ze.x<=10&&ze.y<=10?Re.preventDefault():A.contains(Re.target)||le(!1),document.removeEventListener("pointermove",Ee),fe.current=null};return fe.current!==null&&(document.addEventListener("pointermove",Ee),document.addEventListener("pointerup",ve,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Ee),document.removeEventListener("pointerup",ve,{capture:!0})}}},[A,le,fe]),k.useEffect(()=>{const ze=()=>le(!1);return window.addEventListener("blur",ze),window.addEventListener("resize",ze),()=>{window.removeEventListener("blur",ze),window.removeEventListener("resize",ze)}},[le]);const[xe,he]=xWe(ze=>{const Ee=Z().filter(Ue=>!Ue.disabled),ve=Ee.find(Ue=>Ue.ref.current===document.activeElement),Re=gWe(Ee,ze,ve);Re&&setTimeout(()=>Re.ref.current.focus())}),we=k.useCallback((ze,Ee,ve)=>{const Re=!ce.current&&!ve;(C.value!==void 0&&C.value===Ee||Re)&&($(ze),Re&&(ce.current=!0))},[C.value]),Ne=k.useCallback(()=>A==null?void 0:A.focus(),[A]),Ve=k.useCallback((ze,Ee,ve)=>{const Re=!ce.current&&!ve;(C.value!==void 0&&C.value===Ee||Re)&&ee(ze)},[C.value]),Te=n==="popper"?g1e:eWe,Ae=Te===g1e?{side:i,sideOffset:d,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:y,collisionPadding:_,sticky:b,hideWhenDetached:N,avoidCollisions:w}:{};return e.jsx(QGe,{scope:r,content:A,viewport:L,onViewportChange:O,itemRefCallback:we,selectedItem:q,onItemLeave:Ne,itemTextRefCallback:Ve,focusSelectedItem:ie,selectedItemText:V,position:n,isPositioned:J,searchRef:xe,children:e.jsx(LR,{as:Zkt,allowPinchZoom:!0,children:e.jsx(PR,{asChild:!0,trapped:C.open,onMountAutoFocus:ze=>{ze.preventDefault()},onUnmountAutoFocus:Tr(a,ze=>{var Ee;(Ee=C.trigger)==null||Ee.focus({preventScroll:!0}),ze.preventDefault()}),children:e.jsx(mw,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:ze=>ze.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:e.jsx(Te,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:ze=>ze.preventDefault(),...S,...Ae,onPlaced:()=>Y(!0),ref:U,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:Tr(S.onKeyDown,ze=>{const Ee=ze.ctrlKey||ze.altKey||ze.metaKey;if(ze.key==="Tab"&&ze.preventDefault(),!Ee&&ze.key.length===1&&he(ze.key),["ArrowUp","ArrowDown","Home","End"].includes(ze.key)){let Re=Z().filter(Ue=>!Ue.disabled).map(Ue=>Ue.ref.current);if(["ArrowUp","End"].includes(ze.key)&&(Re=Re.slice().reverse()),["ArrowUp","ArrowDown"].includes(ze.key)){const Ue=ze.target,ye=Re.indexOf(Ue);Re=Re.slice(ye+1)}setTimeout(()=>ae(Re)),ze.preventDefault()}})})})})})})});JGe.displayName=Kkt;var Ykt="SelectItemAlignedPosition",eWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=yw(ZS,r),l=vw(ZS,r),[i,d]=k.useState(null),[u,p]=k.useState(null),f=Ma(s,U=>p(U)),y=Mue(r),_=k.useRef(!1),b=k.useRef(!0),{viewport:N,selectedItem:w,selectedItemText:S,focusSelectedItem:C}=l,A=k.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&N&&w&&S){const U=o.trigger.getBoundingClientRect(),q=u.getBoundingClientRect(),$=o.valueNode.getBoundingClientRect(),V=S.getBoundingClientRect();if(o.dir!=="rtl"){const Ue=V.left-q.left,ye=$.left-Ue,ct=U.left-ye,pe=U.width+ct,Ge=Math.max(pe,q.width),tt=window.innerWidth-fg,st=nD(ye,[fg,Math.max(fg,tt-Ge)]);i.style.minWidth=pe+"px",i.style.left=st+"px"}else{const Ue=q.right-V.right,ye=window.innerWidth-$.right-Ue,ct=window.innerWidth-U.right-ye,pe=U.width+ct,Ge=Math.max(pe,q.width),tt=window.innerWidth-fg,st=nD(ye,[fg,Math.max(fg,tt-Ge)]);i.style.minWidth=pe+"px",i.style.right=st+"px"}const ee=y(),Z=window.innerHeight-fg*2,J=N.scrollHeight,Y=window.getComputedStyle(u),ce=parseInt(Y.borderTopWidth,10),ae=parseInt(Y.paddingTop,10),ie=parseInt(Y.borderBottomWidth,10),le=parseInt(Y.paddingBottom,10),fe=ce+ae+J+le+ie,xe=Math.min(w.offsetHeight*5,fe),he=window.getComputedStyle(N),we=parseInt(he.paddingTop,10),Ne=parseInt(he.paddingBottom,10),Ve=U.top+U.height/2-fg,Te=Z-Ve,Ae=w.offsetHeight/2,ze=w.offsetTop+Ae,Ee=ce+ae+ze,ve=fe-Ee;if(Ee<=Ve){const Ue=ee.length>0&&w===ee[ee.length-1].ref.current;i.style.bottom="0px";const ye=u.clientHeight-N.offsetTop-N.offsetHeight,ct=Math.max(Te,Ae+(Ue?Ne:0)+ye+ie),pe=Ee+ct;i.style.height=pe+"px"}else{const Ue=ee.length>0&&w===ee[0].ref.current;i.style.top="0px";const ct=Math.max(Ve,ce+N.offsetTop+(Ue?we:0)+Ae)+ve;i.style.height=ct+"px",N.scrollTop=Ee-Ve+N.offsetTop}i.style.margin=`${fg}px 0`,i.style.minHeight=xe+"px",i.style.maxHeight=Z+"px",n==null||n(),requestAnimationFrame(()=>_.current=!0)}},[y,o.trigger,o.valueNode,i,u,N,w,S,o.dir,n]);rd(()=>A(),[A]);const[I,L]=k.useState();rd(()=>{u&&L(window.getComputedStyle(u).zIndex)},[u]);const O=k.useCallback(U=>{U&&b.current===!0&&(A(),C==null||C(),b.current=!1)},[A,C]);return e.jsx(Qkt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:_,onScrollButtonChange:O,children:e.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:e.jsx(dn.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});eWe.displayName=Ykt;var Xkt="SelectPopperPosition",g1e=k.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=fg,...o}=t,l=Tue(r);return e.jsx(MR,{...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)"}})});g1e.displayName=Xkt;var[Qkt,Qje]=HA(ZS,{}),y1e="SelectViewport",tWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=vw(y1e,r),l=Qje(y1e,r),i=Ma(s,o.onViewportChange),d=k.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),e.jsx(Cue.Slot,{scope:r,children:e.jsx(dn.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Tr(a.onScroll,u=>{const p=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:y}=l;if(y!=null&&y.current&&f){const _=Math.abs(d.current-p.scrollTop);if(_>0){const b=window.innerHeight-fg*2,N=parseFloat(f.style.minHeight),w=parseFloat(f.style.height),S=Math.max(N,w);if(S0?I:0,f.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});tWe.displayName=y1e;var sWe="SelectGroup",[Jkt,e4t]=HA(sWe),t4t=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=mu();return e.jsx(Jkt,{scope:r,id:a,children:e.jsx(dn.div,{role:"group","aria-labelledby":a,...n,ref:s})})});t4t.displayName=sWe;var rWe="SelectLabel",nWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=e4t(rWe,r);return e.jsx(dn.div,{id:a.id,...n,ref:s})});nWe.displayName=rWe;var Yoe="SelectItem",[s4t,aWe]=HA(Yoe),iWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=yw(Yoe,r),d=vw(Yoe,r),u=i.value===n,[p,f]=k.useState(o??""),[y,_]=k.useState(!1),b=Ma(s,C=>{var A;return(A=d.itemRefCallback)==null?void 0:A.call(d,C,n,a)}),N=mu(),w=k.useRef("touch"),S=()=>{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(s4t,{scope:r,value:n,disabled:a,textId:N,isSelected:u,onItemTextChange:k.useCallback(C=>{f(A=>A||((C==null?void 0:C.textContent)??"").trim())},[]),children:e.jsx(Cue.ItemSlot,{scope:r,value:n,disabled:a,textValue:p,children:e.jsx(dn.div,{role:"option","aria-labelledby":N,"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:Tr(l.onFocus,()=>_(!0)),onBlur:Tr(l.onBlur,()=>_(!1)),onClick:Tr(l.onClick,()=>{w.current!=="mouse"&&S()}),onPointerUp:Tr(l.onPointerUp,()=>{w.current==="mouse"&&S()}),onPointerDown:Tr(l.onPointerDown,C=>{w.current=C.pointerType}),onPointerMove:Tr(l.onPointerMove,C=>{var A;w.current=C.pointerType,a?(A=d.onItemLeave)==null||A.call(d):w.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Tr(l.onPointerLeave,C=>{var A;C.currentTarget===document.activeElement&&((A=d.onItemLeave)==null||A.call(d))}),onKeyDown:Tr(l.onKeyDown,C=>{var I;((I=d.searchRef)==null?void 0:I.current)!==""&&C.key===" "||($kt.includes(C.key)&&S(),C.key===" "&&C.preventDefault())})})})})});iWe.displayName=Yoe;var P6="SelectItemText",oWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=yw(P6,r),i=vw(P6,r),d=aWe(P6,r),u=Hkt(P6,r),[p,f]=k.useState(null),y=Ma(s,S=>f(S),d.onItemTextChange,S=>{var C;return(C=i.itemTextRefCallback)==null?void 0:C.call(i,S,d.value,d.disabled)}),_=p==null?void 0:p.textContent,b=k.useMemo(()=>e.jsx("option",{value:d.value,disabled:d.disabled,children:_},d.value),[d.disabled,d.value,_]),{onNativeOptionAdd:N,onNativeOptionRemove:w}=u;return rd(()=>(N(b),()=>w(b)),[N,w,b]),e.jsxs(e.Fragment,{children:[e.jsx(dn.span,{id:d.textId,...o,ref:y}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?ap.createPortal(o.children,l.valueNode):null]})});oWe.displayName=P6;var lWe="SelectItemIndicator",cWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return aWe(lWe,r).isSelected?e.jsx(dn.span,{"aria-hidden":!0,...n,ref:s}):null});cWe.displayName=lWe;var v1e="SelectScrollUpButton",dWe=k.forwardRef((t,s)=>{const r=vw(v1e,t.__scopeSelect),n=Qje(v1e,t.__scopeSelect),[a,o]=k.useState(!1),l=Ma(s,n.onScrollButtonChange);return rd(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=d.scrollTop>0;o(u)};const d=r.viewport;return i(),d.addEventListener("scroll",i),()=>d.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(hWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop-d.offsetHeight)}}):null});dWe.displayName=v1e;var _1e="SelectScrollDownButton",uWe=k.forwardRef((t,s)=>{const r=vw(_1e,t.__scopeSelect),n=Qje(_1e,t.__scopeSelect),[a,o]=k.useState(!1),l=Ma(s,n.onScrollButtonChange);return rd(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=d.scrollHeight-d.clientHeight,p=Math.ceil(d.scrollTop)d.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(hWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop+d.offsetHeight)}}):null});uWe.displayName=_1e;var hWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=vw("SelectScrollButton",r),l=k.useRef(null),i=Mue(r),d=k.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return k.useEffect(()=>()=>d(),[d]),rd(()=>{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(dn.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Tr(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Tr(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Tr(a.onPointerLeave,()=>{d()})})}),r4t="SelectSeparator",mWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(dn.div,{"aria-hidden":!0,...n,ref:s})});mWe.displayName=r4t;var b1e="SelectArrow",n4t=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Tue(r),o=yw(b1e,r),l=vw(b1e,r);return o.open&&l.position==="popper"?e.jsx(TR,{...a,...n,ref:s}):null});n4t.displayName=b1e;var a4t="SelectBubbleInput",pWe=k.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=k.useRef(null),o=Ma(n,a),l=BR(s);return k.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&p){const f=new Event("change",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(dn.select,{...r,style:{...Gqe,...r.style},ref:o,defaultValue:s})});pWe.displayName=a4t;function fWe(t){return t===""||t===void 0}function xWe(t){const s=ed(t),r=k.useRef(""),n=k.useRef(0),a=k.useCallback(l=>{const i=r.current+l;s(i),function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))}(i)},[s]),o=k.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return k.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function gWe(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=i4t(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const d=l.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function i4t(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var o4t=VGe,yWe=GGe,l4t=KGe,c4t=ZGe,d4t=YGe,vWe=XGe,u4t=tWe,_We=nWe,bWe=iWe,h4t=oWe,m4t=cWe,wWe=dWe,jWe=uWe,NWe=mWe;const zs=o4t,qs=l4t,Os=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(yWe,{ref:n,className:Rt("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(c4t,{asChild:!0,children:e.jsx(Fi,{className:"h-4 w-4 opacity-50"})})]}));Os.displayName=yWe.displayName;const kWe=k.forwardRef(({className:t,...s},r)=>e.jsx(wWe,{ref:r,className:Rt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(lf,{className:"h-4 w-4"})}));kWe.displayName=wWe.displayName;const SWe=k.forwardRef(({className:t,...s},r)=>e.jsx(jWe,{ref:r,className:Rt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Fi,{className:"h-4 w-4"})}));SWe.displayName=jWe.displayName;const Fs=k.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(d4t,{children:e.jsxs(vWe,{ref:a,className:Rt("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(kWe,{}),e.jsx(u4t,{className:Rt("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(SWe,{})]})}));Fs.displayName=vWe.displayName;const p4t=k.forwardRef(({className:t,...s},r)=>e.jsx(_We,{ref:r,className:Rt("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));p4t.displayName=_We.displayName;const yt=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(bWe,{ref:n,className:Rt("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(m4t,{children:e.jsx(ea,{className:"h-4 w-4"})})}),e.jsx(h4t,{children:s})]}));yt.displayName=bWe.displayName;const f4t=k.forwardRef(({className:t,...s},r)=>e.jsx(NWe,{ref:r,className:Rt("-mx-1 my-1 h-px bg-muted",t),...s}));f4t.displayName=NWe.displayName;const x4t=t=>ft({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}}),CWe=t=>ft({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}),MWe=()=>Et({mutationFn:async({listingId:t,agentId:s,firstName:r,lastName:n,email:a,phone:o,shareToken:l,leadType:i="info_request",preferredDate:d,preferredTime:u,showingMode:p,message:f})=>{let y=null,_=null;if(l){const{data:S}=await G.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",t).maybeSingle();S&&(y=S.id,_=S.sharing_agent_id)}const{data:b,error:N}=await G.from("listing_leads").insert({listing_id:t,agent_id:_||s,first_name:r,last_name:n,email:a,phone:o,share_id:y,referred_by_agent_id:_,lead_type:i,preferred_date:d||null,preferred_time:u||null,showing_mode:p||null,message:f||null}).select().single();if(N)throw N;const{error:w}=await G.functions.invoke("process-listing-lead",{body:{leadId:b.id}});return w&&console.error("Error processing lead:",w),b}}),g4t=()=>Et({mutationFn:async t=>{const{error:s}=await G.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),y4t={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},iIe={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},v4t={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function TWe(){const[t,s]=k.useState(""),[r,n]=k.useState(!1),[a,o]=k.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=x4t({city:t||void 0,status:a.status||void 0,propertyType:a.propertyType||void 0,minPrice:a.minPrice?Number(a.minPrice):void 0,maxPrice:a.maxPrice?Number(a.maxPrice):void 0}),d=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(f),u=()=>{o({status:"",propertyType:"",minPrice:"",maxPrice:""}),s("")},p=t||a.status||a.propertyType||a.minPrice||a.maxPrice;return e.jsxs(e.Fragment,{children:[e.jsxs(Nc,{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(da,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:$Ge,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(${Akt})`},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(tn,{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(tn,{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(bS,{className:"h-4 w-4"}),r?"Hide Filters":"More Filters"]})}),r&&e.jsxs("div",{className:"mt-4 p-6 bg-white rounded-lg shadow-xl",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Status"}),e.jsxs(zs,{value:a.status||"all",onValueChange:f=>o({...a,status:f==="all"?"":f}),children:[e.jsx(Os,{className:"bg-white",children:e.jsx(qs,{placeholder:"Any status"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"Any status"}),Object.entries(iIe).map(([f,y])=>e.jsx(yt,{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(zs,{value:a.propertyType||"all",onValueChange:f=>o({...a,propertyType:f==="all"?"":f}),children:[e.jsx(Os,{className:"bg-white",children:e.jsx(qs,{placeholder:"Any type"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"Any type"}),Object.entries(v4t).map(([f,y])=>e.jsx(yt,{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(Sr,{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(Ikt,{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(Ss,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(Ss,{className:"h-7 w-28"}),e.jsx(Ss,{className:"h-4 w-full"}),e.jsx(Ss,{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 N,w,S;const y=((N=f.photos)==null?void 0:N.find(C=>C.is_primary))||((w=f.photos)==null?void 0:w[0]),b=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${f.slug||f.id}`:`/public/listing/${f.slug||f.id}`;return e.jsx(da,{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(Mn,{className:"h-12 w-12 text-gray-300"})}),e.jsx(Ye,{className:`absolute top-2 left-2 ${y4t[f.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:iIe[f.status]}),e.jsx("button",{className:"absolute top-2 right-2 p-2 rounded-full bg-white/80 hover:bg-white transition-colors",onClick:C=>C.preventDefault(),children:e.jsx(Za,{className:"h-5 w-5 text-gray-600"})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("p",{className:"text-xl font-bold text-gray-900 mb-1",children:d(f.price)}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-700 mb-2",children:[f.bedrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bedrooms}),e.jsx("span",{className:"text-gray-500",children:"bds"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.bathrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bathrooms}),e.jsx("span",{className:"text-gray-500",children:"ba"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.square_footage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.square_footage.toLocaleString()}),e.jsx("span",{className:"text-gray-500",children:"sqft"})]})]}),f.property_address&&e.jsx("p",{className:"text-sm text-gray-700 truncate",children:f.property_address}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[f.city,", ",f.state]}),f.agent&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[e.jsx("p",{className:"text-xs text-gray-500 truncate",children:f.agent.name}),((S=f.agent.brokerage)==null?void 0:S.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(Mn,{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:Xje,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 Ie=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Rt("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Ie.displayName="Card";const Lt=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Rt("flex flex-col space-y-1.5 p-6",t),...s}));Lt.displayName="CardHeader";const Ft=k.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:Rt("text-2xl font-semibold leading-none tracking-tight",t),...s}));Ft.displayName="CardTitle";const mr=k.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:Rt("text-sm text-muted-foreground",t),...s}));mr.displayName="CardDescription";const Be=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Rt("p-6 pt-0",t),...s}));Be.displayName="CardContent";const YL=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Rt("flex items-center p-6 pt-0",t),...s}));YL.displayName="CardFooter";var _4t=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],b4t=_4t.reduce((t,s)=>{const r=qA(`Primitive.${s}`),n=k.forwardRef((a,o)=>{const{asChild:l,...i}=a,d=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{}),w4t="Label",AWe=k.forwardRef((t,s)=>e.jsx(b4t.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())}}));AWe.displayName=w4t;var EWe=AWe;const j4t=wC("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ge=k.forwardRef(({className:t,...s},r)=>e.jsx(EWe,{ref:r,className:Rt(j4t(),t),...s}));ge.displayName=EWe.displayName;const Xoe="/assets/levelup-logo-color-D3mY9gCJ.png";function N4t(){const t=Fl(),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(TWe,{}):n.startsWith("public/")?null:e.jsx(k4t,{slug:n})}function k4t({slug:t}){return e.jsx(M4t,{slug:t})}const S4t={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},C4t={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},oIe={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function M4t({slug:t}){var $,V;const{data:s,isLoading:r}=CWe(t),n=MWe(),[a,o]=k.useState(""),[l,i]=k.useState(""),[d,u]=k.useState(""),[p,f]=k.useState(""),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState(null),C=ee=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ee),A=async ee=>{if(ee.preventDefault(),!(!a.trim()||!d.trim()||!s)){_(!0);try{await n.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:a.trim(),lastName:l.trim(),email:d.trim(),phone:p.trim()}),N(!0),me.success("Thanks! The agent will be in touch soon.")}catch(Z){console.error("Lead submission error:",Z),me.error(`Failed to submit: ${Z.message||"Please try again"}`)}finally{_(!1)}}},I=(s==null?void 0:s.photos)||[],L=I.find(ee=>ee.is_primary)||I[0],O=()=>{w!==null&&S(w===0?I.length-1:w-1)},U=()=>{w!==null&&S(w===I.length-1?0:w+1)};if(r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(Ss,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(Ss,{className:"h-10 w-48 mb-6"}),e.jsx(Ss,{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(Ss,{className:"h-12 w-48"}),e.jsx(Ss,{className:"h-6 w-full"}),e.jsx(Ss,{className:"h-6 w-3/4"})]}),e.jsx(Ss,{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:Xoe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Mn,{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(Nc,{children:[e.jsxs("title",{children:[q," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${C(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${oIe[s.property_type]} in ${s.city}, ${s.state}. ${(($=s.description)==null?void 0:$.slice(0,150))||""}`}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:`${C(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA in ${s.city}, ${s.state}`}),e.jsx("meta",{property:"og:type",content:"website"}),L&&e.jsx("meta",{property:"og:image",content:L.photo_url})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:Xoe,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(Ra,{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:()=>S(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((ee,Z)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>S(Z+1),children:[e.jsx("img",{src:ee.photo_url,alt:`Photo ${Z+2}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),Z===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"]})]},ee.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(Ye,{className:`${S4t[s.status]} text-white border-0`,children:C4t[s.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:C(s.price)}),s.property_address&&e.jsx("p",{className:"text-xl font-medium",children:s.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(La,{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(Ky,{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(of,{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(r0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),s.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(nn,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Ye,{variant:"secondary",children:[e.jsx(ma,{className:"h-3 w-3 mr-1"}),oIe[s.property_type]]}),s.lot_size&&e.jsxs(Ye,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(Ye,{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(Kr,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[s.agent&&e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ei,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Be,{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(Ie,{className:"border-primary",children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Be,{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(tr,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):e.jsxs("form",{onSubmit:A,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Fe,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:ee=>o(ee.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Fe,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:ee=>i(ee.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"email",children:"Email *"}),e.jsx(Fe,{id:"email",type:"email",placeholder:"you@example.com",value:d,onChange:ee=>u(ee.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"phone",children:"Phone"}),e.jsx(Fe,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:p,onChange:ee=>f(ee.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(fs,{open:w!==null,onOpenChange:()=>S(null),children:e.jsxs(ms,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(ks,{className:"sr-only",children:e.jsx(bs,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>S(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(Sr,{className:"h-5 w-5"})}),w!==null&&I[w]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:I[w].photo_url,alt:`Photo ${w+1}`,className:"w-full max-h-[80vh] object-contain"}),I.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:O,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(wl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:U,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(ja,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[w+1," / ",I.length]})]})]})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function Aue({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 PWe=t=>ft({queryKey:["agent-card-public",t],queryFn:async()=>{if(!t)throw new Error("No slug provided");const{data:s,error:r}=await G.from("agent_cards").select("*").eq("slug",t).eq("is_published",!0).single();if(r)throw r;const{data:n}=await G.from("profiles").select("name, email, phone, brokerage_id").eq("id",s.user_id).single();let a=null;if(n!=null&&n.brokerage_id){const{data:i}=await G.from("brokerages").select("name").eq("id",n.brokerage_id).single();a=(i==null?void 0:i.name)||null}let o=null;try{const{data:i}=await G.from("profiles").select("avatar_url").eq("id",s.user_id).single();if(i!=null&&i.avatar_url)o=i.avatar_url;else{const{data:d}=await G.storage.from("avatars").list(`${s.user_id}`);if(d&&d.length>0){const{data:u}=G.storage.from("avatars").getPublicUrl(`${s.user_id}/${d[0].name}`);o=`${u.publicUrl}?t=${Date.now()}`}}}catch{}const l={...n||{name:null,email:null,phone:null,brokerage_id:null},email:s.display_email||(n==null?void 0:n.email)||null};return{...s,social_links:s.social_links||[],profile:l,brokerage_name:s.brokerage_display_name||a,avatar_url:o}},enabled:!!t}),T4t=()=>ft({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}}),A4t=t=>ft({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}),IWe=()=>{const t=es();return Et({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)})},LWe=()=>{const t=es();return Et({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)})},Ui=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:{}})},E4t=async(t,s)=>{const{error:r}=await G.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},DWe=t=>ft({queryKey:["agent-card-analytics",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("agent_card_interactions").select("interaction_type, interaction_detail, created_at").eq("card_id",t).order("created_at",{ascending:!1}).limit(500);if(r)throw r;const{data:n,error:a}=await G.from("agent_card_leads").select("*").eq("card_id",t).order("created_at",{ascending:!1});if(a)throw a;const o=(s==null?void 0:s.filter(d=>d.interaction_type==="card_view").length)||0,l=(s==null?void 0:s.filter(d=>d.interaction_type==="button_click").length)||0,i=(s==null?void 0:s.filter(d=>d.interaction_type==="contact_saved").length)||0;return{views:o,clicks:l,saves:i,leads:n||[],interactions:s||[]}},enabled:!!t});function Eue({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=k.useState(""),[i,d]=k.useState(""),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(""),[N,w]=k.useState(!1),S=async C=>{if(C.preventDefault(),!o.trim()){me.error("Please enter your name");return}w(!0);try{await E4t(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}),Ui(r,"lead_submitted",n),G.functions.invoke("card-lead-notify",{body:{cardId:r,leadType:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:_.trim()||void 0,intent:f||void 0}}).catch(A=>console.error("Card lead notify failed:",A)),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(""),d(""),p(""),y(""),b("")}catch{me.error("Something went wrong. Please try again.")}finally{w(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:n==="booking"?"Book a Call":n==="connect"?"Connect with Me":"Refer a Friend"}),e.jsx(Rr,{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:S,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"lead-name",children:"Name *"}),e.jsx(Fe,{id:"lead-name",value:o,onChange:C=>l(C.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(Fe,{id:"lead-phone",type:"tel",value:u,onChange:C=>p(C.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"lead-email",children:"Email"}),e.jsx(Fe,{id:"lead-email",type:"email",value:i,onChange:C=>d(C.target.value),placeholder:"you@example.com"})]}),n==="booking"&&e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs(zs,{value:f,onValueChange:y,children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select one"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"buy",children:"Buy a home"}),e.jsx(yt,{value:"sell",children:"Sell my home"}),e.jsx(yt,{value:"both",children:"Buy & Sell"}),e.jsx(yt,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(Fe,{id:"lead-message",value:_,onChange:C=>b(C.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full rounded-2xl",disabled:N,children:N?"Sending...":"Submit"})]})]})})}const P4t=t=>ft({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}),I4t=t=>ft({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}),L4t=()=>{const t=es();return Et({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)})},D4t=()=>{const t=es();return Et({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)})},R4t=()=>{const t=es();return Et({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 O4t(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 F4t(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 z4t={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 B4t({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=F4t(r.video_url),o=n||!!a,l=n?O4t(r.video_url):a||r.video_url;return e.jsx("div",{className:z4t[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 $4t={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 q4t({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=k.useState(0);if(n.length===0)return null;const l=$4t[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(xS,{className:"h-4 w-4 mb-2 opacity-30"}),e.jsxs("p",{className:`${l.quote} mb-3`,children:['"',i.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:l.name,children:i.name}),i.role&&e.jsx("p",{className:l.role,children:i.role})]})]}),n.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[e.jsx("button",{onClick:()=>o(d=>(d-1+n.length)%n.length),className:l.nav,children:e.jsx(wl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex gap-1.5",children:n.map((d,u)=>e.jsx("div",{className:`h-1.5 w-1.5 rounded-full transition-colors cursor-pointer ${u===a?l.dot:l.dotInactive}`,onClick:()=>o(u)},u))}),e.jsx("button",{onClick:()=>o(d=>(d+1)%n.length),className:l.nav,children:e.jsx(ja,{className:"h-4 w-4"})})]})]})}const U4t={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 V4t({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=U4t[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const H4t={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 G4t({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=H4t[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:()=>Ui(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(Kr,{className:`h-4 w-4 ${o.icon}`})]},i))})}const w1e={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 W4t({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 K4t={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 Z4t({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=K4t[r];return a.length===0?null:e.jsxs("div",{className:o.container,children:[e.jsx("h3",{className:o.title,children:"Follow Me"}),e.jsx("div",{className:"flex flex-wrap gap-3 justify-center",children:a.map((l,i)=>{const d=w1e[l.platform.toLowerCase()];return!d||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Ui(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:d.label,children:e.jsx(W4t,{path:d.icon,color:d.color})},i)})})]})}function Pue({cardId:t,variant:s}){const{data:r}=P4t(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(B4t,{block:l,variant:s},l.id);case"testimonials":return e.jsx(q4t,{block:l,variant:s},l.id);case"specialties":return e.jsx(V4t,{block:l,variant:s},l.id);case"custom_links":return e.jsx(G4t,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(Z4t,{block:o,cardId:t,variant:s})]})}async function Y4t(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 X4t(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 Iue(t){const{first:s,last:r}=X4t(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 Y4t(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 Q4t({card:t}){var S;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((S=t.profile)==null?void 0:S.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{Ui(t.id,"button_click",C),A()},d=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.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),Ui(t.id,"button_click","book"))},y=()=>{var C,A;Ui(t.id,"contact_saved"),Iue({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(A=t.profile)==null?void 0:A.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{Ui(t.id,"share_event");const C=`https://cards.relevelup.com/${t.slug}`,A="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:A,url:C})}catch{}else await navigator.clipboard.writeText(C),me.success("Link copied!")},b=()=>{a("referral"),r(!0),Ui(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),Ui(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(vn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Ca,{src:t.avatar_url||void 0,alt:o}),e.jsx(_n,{className:"text-2xl font-semibold bg-primary text-primary-foreground",children:l})]}),e.jsx("h1",{className:"text-2xl font-bold text-slate-900 mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-primary mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-slate-500 mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-slate-600 italic leading-relaxed max-w-xs mx-auto",children:['"',t.positioning_statement,'"']})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs(K,{onClick:d,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(Tn,{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(Si,{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(tr,{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(nn,{className:"h-5 w-5 mr-2"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm text-slate-600",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Gn,{className:"h-4 w-4 text-amber-500 fill-amber-500"}),e.jsx("span",{className:"font-bold text-slate-900",children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"bg-slate-50 rounded-2xl p-4 mb-6 border border-slate-100",children:e.jsxs("p",{className:"text-sm text-slate-600 italic text-center",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-2",children:"About Me"}),e.jsx("p",{className:"text-sm text-slate-600 leading-relaxed",children:t.bio})]}),e.jsx(Aue,{card:t,variant:"standard"}),e.jsx(Pue,{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(Xa,{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:()=>{Ui(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Gn,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),t.show_refer_friend&&e.jsxs(K,{variant:"ghost",onClick:b,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(cr,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),e.jsxs(K,{variant:"ghost",onClick:N,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(il,{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(vd,{className:"h-4 w-4 mr-3 text-primary"}),"Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((C,A)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Ui(t.id,"button_click",`social_${C.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:w[C.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(Eue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function J4t({card:t}){var S;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((S=t.profile)==null?void 0:S.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{Ui(t.id,"button_click",C),A()},d=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.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),Ui(t.id,"button_click","book"))},y=()=>{var C,A;Ui(t.id,"contact_saved"),Iue({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(A=t.profile)==null?void 0:A.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{Ui(t.id,"share_event");const C=`https://cards.relevelup.com/${t.slug}`,A="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:A,url:C})}catch{}else await navigator.clipboard.writeText(C),me.success("Link copied!")},b=()=>{a("referral"),r(!0),Ui(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),Ui(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-[#0f1419] via-[#1a1f2e] to-[#0f1419]",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsx("div",{className:"w-16 h-0.5 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] mx-auto mb-8"}),e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(vn,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[e.jsx(Ca,{src:t.avatar_url||void 0,alt:o}),e.jsx(_n,{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:Tn,label:"Call",handler:d},{icon:Si,label:"Text",handler:u},{icon:tr,label:"Email",handler:p}].map(({icon:C,label:A,handler:I})=>e.jsxs("button",{onClick:I,className:"flex flex-col items-center gap-1.5 py-4 bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/20 rounded-xl transition-colors",children:[e.jsx(C,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:A})]},A))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-xl mb-6 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] text-[#0f1419] hover:opacity-90 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(nn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Gn,{className:"h-4 w-4 text-[#c9a84c] fill-[#c9a84c]"}),e.jsx("span",{className:"font-bold text-white",children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"bg-[#1e2636] rounded-xl p-4 mb-6 border border-[#c9a84c]/10",children:e.jsxs("p",{className:"text-sm text-[#a0aec0] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#c9a84c] mb-2 tracking-wide uppercase",children:"About"}),e.jsx("p",{className:"text-sm text-[#a0aec0] leading-relaxed",children:t.bio})]}),e.jsx(Aue,{card:t,variant:"luxury"}),e.jsx(Pue,{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(Xa,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{Ui(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(Gn,{className:"h-4 w-4 text-[#c9a84c]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(cr,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),e.jsxs("button",{onClick:N,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(il,{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(vd,{className:"h-4 w-4 text-[#c9a84c]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((C,A)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Ui(t.id,"button_click",`social_${C.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:w[C.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(Eue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function eSt({card:t}){var A,I,L,O;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((A=t.profile)==null?void 0:A.name)||"Agent",l=o.split(" ").map(U=>U[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:((O=t.bold_theme_colors)==null?void 0:O.button)||"#ff5722"},d=(U,q)=>{const $=parseInt(U.replace("#",""),16),V=Math.max(0,($>>16)-q),ee=Math.max(0,($>>8&255)-q),Z=Math.max(0,($&255)-q);return`#${(V<<16|ee<<8|Z).toString(16).padStart(6,"0")}`};d(i.accent,25),d(i.dark,-20),d(i.button,25);const u=(U,q)=>{Ui(t.id,"button_click",U),q()},p=()=>u("call",()=>{var U;(U=t.profile)!=null&&U.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),f=()=>u("text",()=>{var U;(U=t.profile)!=null&&U.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),y=()=>u("email",()=>{var U;(U=t.profile)!=null&&U.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),Ui(t.id,"button_click","book"))},b=()=>{var U,q;Ui(t.id,"contact_saved"),Iue({name:o,phone:(U=t.profile)==null?void 0:U.phone,email:(q=t.profile)==null?void 0:q.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},N=async()=>{Ui(t.id,"share_event");const U=`https://cards.relevelup.com/${t.slug}`,q="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:q,url:U})}catch{}else await navigator.clipboard.writeText(U),me.success("Link copied!")},w=()=>{a("referral"),r(!0),Ui(t.id,"button_click","refer")},S=()=>{a("connect"),r(!0),Ui(t.id,"button_click","connect")},C={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:i.accent},children:[e.jsxs("div",{className:"px-5 pt-10 pb-14 text-center relative",style:{backgroundColor:i.dark},children:[t.show_photo&&e.jsxs(vn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx(Ca,{src:t.avatar_url||void 0,alt:o}),e.jsx(_n,{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:Tn,label:"Call",handler:p},{icon:Si,label:"Text",handler:f},{icon:tr,label:"Email",handler:y}].map(({icon:U,label:q,handler:$})=>e.jsxs("button",{onClick:$,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(U,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:q})]},q))}),e.jsxs("button",{onClick:_,className:"w-full h-14 text-base font-black rounded-2xl mb-6 text-white transition-opacity hover:opacity-90 flex items-center justify-center gap-2 uppercase tracking-wide",style:{backgroundColor:i.button},children:[e.jsx(nn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-5 mb-6",children:t.review_snippet&&e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Gn,{className:"h-5 w-5",style:{color:i.accent,fill:i.accent}}),e.jsx("span",{className:"font-black text-2xl",style:{color:i.dark},children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"rounded-2xl p-4 mb-6",style:{backgroundColor:`${i.accent}15`},children:e.jsxs("p",{className:"text-sm font-medium text-center",style:{color:i.dark},children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xs font-black mb-2 uppercase tracking-wider",style:{color:i.accent},children:"About Me"}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:t.bio})]}),e.jsx(Aue,{card:t,variant:"bold"}),e.jsx(Pue,{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(Xa,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{Ui(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Gn,{className:"h-4 w-4",style:{color:i.accent}})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(cr,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),e.jsxs("button",{onClick:S,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(il,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),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(vd,{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((U,q)=>e.jsx("a",{href:U.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Ui(t.id,"button_click",`social_${U.platform}`),className:"h-10 w-10 rounded-full flex items-center justify-center text-lg transition-opacity hover:opacity-85",style:{backgroundColor:i.dark},children:C[U.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(Eue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function tSt({card:t}){var S;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((S=t.profile)==null?void 0:S.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{Ui(t.id,"button_click",C),A()},d=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.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),Ui(t.id,"button_click","book"))},y=()=>{var C,A;Ui(t.id,"contact_saved"),Iue({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(A=t.profile)==null?void 0:A.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{Ui(t.id,"share_event");const C=`https://cards.relevelup.com/${t.slug}`,A="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:A,url:C})}catch{}else await navigator.clipboard.writeText(C),me.success("Link copied!")},b=()=>{a("referral"),r(!0),Ui(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),Ui(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-[#f5f1eb]",children:[e.jsx("div",{className:"bg-[#1b3a4b] h-2"}),e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(vn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Ca,{src:t.avatar_url||void 0,alt:o}),e.jsx(_n,{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:Tn,label:"Call",handler:d},{icon:Si,label:"Text",handler:u},{icon:tr,label:"Email",handler:p}].map(({icon:C,label:A,handler:I})=>e.jsxs("button",{onClick:I,className:"flex flex-col items-center gap-1.5 py-4 bg-white hover:bg-[#e8e3db] border border-[#d4cfc5] rounded-lg transition-colors shadow-sm",children:[e.jsx(C,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:A})]},A))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-lg mb-6 bg-[#1b3a4b] hover:bg-[#264d61] text-white transition-colors flex items-center justify-center gap-2 shadow-sm",children:[e.jsx(nn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsx("div",{className:"flex items-center justify-center gap-6",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Gn,{className:"h-4 w-4 text-[#d4a843] fill-[#d4a843]"}),e.jsx("span",{className:"font-bold text-[#1b3a4b] font-serif",children:"5.0"})]})})}),t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsxs("p",{className:"text-sm text-[#4a5568] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#1b3a4b] mb-2 font-serif",children:"About"}),e.jsx("p",{className:"text-sm text-[#4a5568] leading-relaxed",children:t.bio})]}),e.jsx(Aue,{card:t,variant:"classic"}),e.jsx(Pue,{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(Xa,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{Ui(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(Gn,{className:"h-4 w-4 text-[#d4a843]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(cr,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),e.jsxs("button",{onClick:N,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(il,{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(vd,{className:"h-4 w-4 text-[#5a7a6f]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((C,A)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Ui(t.id,"button_click",`social_${C.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:w[C.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(Eue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Jje({card:t}){switch(t.theme){case"luxury":return e.jsx(J4t,{card:t});case"bold":return e.jsx(eSt,{card:t});case"classic":return e.jsx(tSt,{card:t});case"standard":default:return e.jsx(Q4t,{card:t})}}function sSt(){const t=Fl();k.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]);const s=t.pathname.slice(1);return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Agent Cards"}),e.jsx("p",{className:"text-slate-500",children:"Visit a specific agent's card URL to view their digital business card."})]})}):e.jsx(rSt,{slug:s})}function rSt({slug:t}){return e.jsx(nSt,{slug:t})}function nSt({slug:t}){var o;const{data:s,isLoading:r,error:n}=PWe(t);if(k.useEffect(()=>{s!=null&&s.id&&Ui(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(Ss,{className:"h-28 w-28 rounded-full"}),e.jsx(Ss,{className:"h-6 w-48"}),e.jsx(Ss,{className:"h-4 w-36"})]}),e.jsx(Ss,{className:"h-12 w-full"}),e.jsx(Ss,{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(Nc,{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(Jje,{card:s})]})}function RWe({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=k.useState(n||""),[d,u]=k.useState(a||""),[p,f]=k.useState(o||""),[y,_]=k.useState(""),[b,N]=k.useState(""),[w,S]=k.useState(!1),[C,A]=k.useState(!1),I=async L=>{if(L.preventDefault(),!l.trim()){me.error("Please enter your name");return}S(!0);try{const{error:O}=await G.from("smart_presentation_leads").insert({presentation_id:t,name:l.trim(),email:d.trim()||null,phone:p.trim()||null,intent:y||null,message:b.trim()||null});if(O)throw O;try{await G.rpc("log_presentation_view",{p_presentation_id:t,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}G.functions.invoke("presentation-lead-notify",{body:{presentationId:t,name:l.trim(),email:d.trim()||void 0,phone:p.trim()||void 0,intent:y||void 0,message:b.trim()||void 0}}).catch(U=>console.error("Presentation lead notify failed:",U)),A(!0)}catch{me.error("Something went wrong. Please try again.")}finally{S(!1)}};return C?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(ea,{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(ge,{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(ge,{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(ge,{htmlFor:"pres-lead-email",children:"Email"}),e.jsx(Fe,{id:"pres-lead-email",type:"email",value:d,onChange:L=>u(L.target.value),placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs(zs,{value:y,onValueChange:_,children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select one"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"buy",children:"Buy a home"}),e.jsx(yt,{value:"sell",children:"Sell my home"}),e.jsx(yt,{value:"both",children:"Buy & Sell"}),e.jsx(yt,{value:"other",children:"Something else"})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(Fe,{id:"pres-lead-message",value:b,onChange:L=>N(L.target.value),placeholder:"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:w,children:w?"Sending...":s})]})}function aSt(){const t=Fl();k.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]);const s=t.pathname.slice(1);return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Smart Presentations"}),e.jsx("p",{className:"text-slate-500",children:"Visit a specific presentation URL to view it."})]})}):e.jsx(iSt,{shareToken:s})}function iSt({shareToken:t}){var b;const[s,r]=k.useState(null),[n,a]=k.useState(!0),[o,l]=k.useState(0),[i,d]=k.useState(!1);k.useEffect(()=>{u()},[t]);const u=async()=>{const{data:N,error:w}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(w||!N){d(!0),a(!1);return}const{data:S}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",N.owner_user_id).single();let C;if(S!=null&&S.brokerage_id){const{data:I}=await G.from("brokerages").select("name").eq("id",S.brokerage_id).single();C=(I==null?void 0:I.name)||void 0}let A=null;if(N.contact_id){const{data:I}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",N.contact_id).single();A=I}r({...N,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:C,contact_name:A?[A.first_name,A.last_name].filter(Boolean).join(" "):void 0,contact_email:(A==null?void 0:A.email)||void 0,contact_phone:(A==null?void 0:A.phone)||void 0}),a(!1);try{await G.rpc("log_presentation_view",{p_presentation_id:N.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=N=>{const w=N.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(w)return`https://www.youtube.com/embed/${w[1]}?rel=0`;if(N.includes("iframe.mediadelivery.net/play/")){const A=N.replace("/play/","/embed/"),I=A.includes("?")?"&":"?";return`${A}${I}responsive=true`}if(N.includes("iframe.mediadelivery.net")){const A=N.includes("?")?"&":"?";return`${N}${A}responsive=true`}const S=N.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(S)return`https://www.loom.com/embed/${S[1]}`;const C=N.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return C?`https://iframe.mediadelivery.net/embed/${C[1]}/${C[2]}?responsive=true`:N};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(Ss,{className:"h-12 w-3/4 mx-auto"}),e.jsx(Ss,{className:"h-64 w-full"}),e.jsx(Ss,{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(N=>N.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((N,w)=>e.jsx("button",{onClick:()=>l(w),className:Rt("w-full text-left p-4 rounded-xl border transition-all",o===w?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(w+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:N.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:N.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:N.description})]})]})},w))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(b=s.cta_url)!=null&&b.trim()?e.jsxs(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(Kr,{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(RWe,{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 Rx=()=>{const t=_a();return ft({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 oSt(){const{user:t}=$s(),s=_a(),{data:r}=Rx();return ft({queryKey:["open-houses",s,r==null?void 0:r.teamId,r==null?void 0:r.role],queryFn:async()=>{const{data:n,error:a}=await G.from("open_houses").select("*").eq("agent_id",s).order("event_date",{ascending:!1});if(a)throw a;let o=n||[];if((r==null?void 0:r.role)==="team_leader"&&r.teamId){const{data:l,error:i}=await G.rpc("get_team_open_houses",{_user_id:s});if(!i&&l){const d=[...new Set(l.map(f=>f.agent_id))],u={};if(d.length>0){const{data:f}=await G.from("profiles").select("id, name").in("id",d);f==null||f.forEach(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 mEs(t){const{user:s}=$s();return ft({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 OWe(t){const{user:s}=$s(),r=es();return k.useEffect(()=>{if(!t)return;const n=`visitors-${t}-${Math.random().toString(36).slice(2,10)}`,a=G.channel(n).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(a)}},[t,r]),ft({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 lSt(){const t=es(),s=_a();return Et({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"]}),cn({title:"Open house created!"})},onError:r=>{cn({title:"Error",description:r.message,variant:"destructive"})}})}function FWe(){const t=es();return Et({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 cSt(){const t=es();return Et({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"]}),cn({title:"Open house deleted"})}})}function dSt(t){return ft({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 uSt(t){const{user:s}=$s();return ft({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 hSt(t){return ft({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 mSt(){return Et({mutationFn:async t=>{const{error:s}=await G.from("open_house_survey_responses").insert(t);if(s)throw s}})}function pSt(t){const{user:s}=$s();return ft({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 fSt(){const t=es();return Et({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 xSt(){const t=es();return Et({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 gSt(){const t=es();return Et({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 ySt(){const t=es();return Et({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 vSt(){return Et({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}})}function _St(){return Et({mutationFn:async({visitor_id:t,...s})=>{const{error:r}=await G.from("open_house_visitors").update(s).eq("id",t);if(r)throw r}})}function bSt(){return Et({mutationFn:async t=>{await G.rpc("increment_open_house_scan",{_slug:t})}})}var Lue="Switch",[wSt]=bd(Lue),[jSt,NSt]=wSt(Lue),zWe=k.forwardRef((t,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d="on",onCheckedChange:u,form:p,...f}=t,[y,_]=k.useState(null),b=Ma(s,A=>_(A)),N=k.useRef(!1),w=y?p||!!y.closest("form"):!0,[S,C]=Bu({prop:a,defaultProp:o??!1,onChange:u,caller:Lue});return e.jsxs(jSt,{scope:r,checked:S,disabled:i,children:[e.jsx(dn.button,{type:"button",role:"switch","aria-checked":S,"aria-required":l,"data-state":UWe(S),"data-disabled":i?"":void 0,disabled:i,value:d,...f,ref:b,onClick:Tr(t.onClick,A=>{C(I=>!I),w&&(N.current=A.isPropagationStopped(),N.current||A.stopPropagation())})}),w&&e.jsx(qWe,{control:y,bubbles:!N.current,name:n,value:d,checked:S,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});zWe.displayName=Lue;var BWe="SwitchThumb",$We=k.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=NSt(BWe,r);return e.jsx(dn.span,{"data-state":UWe(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});$We.displayName=BWe;var kSt="SwitchBubbleInput",qWe=k.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=k.useRef(null),i=Ma(l,o),d=BR(r),u=SR(s);return k.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&_){const b=new Event("click",{bubbles:n});_.call(p,r),p.dispatchEvent(b)}},[d,r,n]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});qWe.displayName=kSt;function UWe(t){return t?"checked":"unchecked"}var VWe=zWe,SSt=$We;const Lr=k.forwardRef(({className:t,...s},r)=>e.jsx(VWe,{className:Rt("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(SSt,{className:Rt("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")})}));Lr.displayName=VWe.displayName;function Kn(t){const s=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&s==="[object Date]"?new t.constructor(+t):typeof t=="number"||s==="[object Number]"||typeof t=="string"||s==="[object String]"?new Date(t):new Date(NaN)}function Wo(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function dl(t,s){const r=Kn(t);return isNaN(s)?Wo(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function Tm(t,s){const r=Kn(t);if(isNaN(s))return Wo(t,NaN);if(!s)return r;const n=r.getDate(),a=Wo(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 HWe(t,s){const r=+Kn(t);return Wo(t,r+s)}const eNe=6048e5,CSt=864e5,Due=6e4,$R=36e5,MSt=1e3,Tz=43200,lIe=1440;function cIe(t,s){return HWe(t,s*$R)}let TSt={};function _w(){return TSt}function Bh(t,s){var i,d,u,p;const r=_w(),n=(s==null?void 0:s.weekStartsOn)??((d=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:d.weekStartsOn)??r.weekStartsOn??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=Kn(t),o=a.getDay(),l=(o=a.getTime()?r+1:s.getTime()>=l.getTime()?r:r-1}function Am(t){const s=Kn(t);return s.setHours(0,0,0,0),s}function ew(t){const s=Kn(t),r=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return r.setUTCFullYear(s.getFullYear()),+t-+r}function nf(t,s){const r=Am(t),n=Am(s),a=+r-ew(r),o=+n-ew(n);return Math.round((a-o)/CSt)}function ASt(t){const s=GWe(t),r=Wo(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),f1(r)}function tM(t,s){return HWe(t,s*Due)}function y4(t,s){const r=s*7;return dl(t,r)}function ESt(t,s){return Tm(t,s*12)}function PSt(t){let s;return t.forEach(function(r){const n=Kn(r);(s===void 0||s{const n=Kn(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function qie(t,s){const r=Kn(t),n=Kn(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function tNe(t){return Wo(t,Date.now())}function rl(t,s){const r=Am(t),n=Am(s);return+r==+n}function sNe(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function j1e(t){if(!sNe(t)&&typeof t!="number")return!1;const s=Kn(t);return!isNaN(Number(s))}function ET(t,s){const r=Kn(t),n=Kn(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function LSt(t,s,r){const n=Bh(t,r),a=Bh(s,r),o=+n-ew(n),l=+a-ew(a);return Math.round((o-l)/eNe)}function Vg(t,s){const r=Kn(t),n=Kn(s),a=dIe(r,n),o=Math.abs(nf(r,n));r.setDate(r.getDate()-a*o);const l=+(dIe(r,n)===-a),i=a*(o-l);return i===0?0:i}function dIe(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 WWe(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function KWe(t,s){return+Kn(t)-+Kn(s)}function DSt(t,s,r){const n=KWe(t,s)/$R;return WWe(r==null?void 0:r.roundingMethod)(n)}function RSt(t){const s=Kn(t);return s.setHours(23,59,59,999),s}function nx(t){const s=Kn(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function OSt(t){const s=Kn(t);return+RSt(s)==+nx(s)}function FSt(t,s){const r=Kn(t),n=Kn(s),a=qie(r,n),o=Math.abs(ET(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=qie(r,n)===-a;OSt(Kn(t))&&o===1&&qie(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function zSt(t,s,r){const n=KWe(t,s)/1e3;return WWe(r==null?void 0:r.roundingMethod)(n)}function BSt(t,s){const r=Kn(t.start),n=Kn(t.end);let a=+r>+n;const o=a?+r:+n,l=a?n:r;l.setHours(0,0,0,0);let i=1;const d=[];for(;+l<=o;)d.push(Kn(l)),l.setDate(l.getDate()+i),l.setHours(0,0,0,0);return a?d.reverse():d}function xc(t){const s=Kn(t);return s.setDate(1),s.setHours(0,0,0,0),s}function ZWe(t){const s=Kn(t),r=Wo(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Rue(t,s){var i,d,u,p;const r=_w(),n=(s==null?void 0:s.weekStartsOn)??((d=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:d.weekStartsOn)??r.weekStartsOn??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=Kn(t),o=a.getDay(),l=(o{let n;const a=$St[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 yge(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const USt={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},VSt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},HSt={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},GSt={date:yge({formats:USt,defaultWidth:"full"}),time:yge({formats:VSt,defaultWidth:"full"}),dateTime:yge({formats:HSt,defaultWidth:"full"})},WSt={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},KSt=(t,s,r,n)=>WSt[t];function QI(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 ZSt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},YSt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},XSt={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"]},QSt={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"]},JSt={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"}},eCt={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"}},tCt=(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"},sCt={ordinalNumber:tCt,era:QI({values:ZSt,defaultWidth:"wide"}),quarter:QI({values:YSt,defaultWidth:"wide",argumentCallback:t=>t-1}),month:QI({values:XSt,defaultWidth:"wide"}),day:QI({values:QSt,defaultWidth:"wide"}),dayPeriod:QI({values:JSt,defaultWidth:"wide",formattingValues:eCt,defaultFormattingWidth:"wide"})};function JI(t){return(s,r={})=>{const n=r.width,a=n&&t.matchPatterns[n]||t.matchPatterns[t.defaultMatchWidth],o=s.match(a);if(!o)return null;const l=o[0],i=n&&t.parsePatterns[n]||t.parsePatterns[t.defaultParseWidth],d=Array.isArray(i)?nCt(i,f=>f.test(l)):rCt(i,f=>f.test(l));let u;u=t.valueCallback?t.valueCallback(d):d,u=r.valueCallback?r.valueCallback(u):u;const p=s.slice(l.length);return{value:u,rest:p}}}function rCt(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function nCt(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 iCt=/^(\d+)(th|st|nd|rd)?/i,oCt=/\d+/i,lCt={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},cCt={any:[/^b/i,/^(a|c)/i]},dCt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},uCt={any:[/1/i,/2/i,/3/i,/4/i]},hCt={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},mCt={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]},pCt={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},fCt={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]},xCt={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},gCt={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}},yCt={ordinalNumber:aCt({matchPattern:iCt,parsePattern:oCt,valueCallback:t=>parseInt(t,10)}),era:JI({matchPatterns:lCt,defaultMatchWidth:"wide",parsePatterns:cCt,defaultParseWidth:"any"}),quarter:JI({matchPatterns:dCt,defaultMatchWidth:"wide",parsePatterns:uCt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:JI({matchPatterns:hCt,defaultMatchWidth:"wide",parsePatterns:mCt,defaultParseWidth:"any"}),day:JI({matchPatterns:pCt,defaultMatchWidth:"wide",parsePatterns:fCt,defaultParseWidth:"any"}),dayPeriod:JI({matchPatterns:xCt,defaultMatchWidth:"any",parsePatterns:gCt,defaultParseWidth:"any"})},Oue={code:"en-US",formatDistance:qSt,formatLong:GSt,formatRelative:KSt,localize:sCt,match:yCt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function vCt(t){const s=Kn(t);return nf(s,ZWe(s))+1}function rNe(t){const s=Kn(t),r=+f1(s)-+ASt(s);return Math.round(r/eNe)+1}function nNe(t,s){var p,f,y,_;const r=Kn(t),n=r.getFullYear(),a=_w(),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=Wo(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=Bh(l,s),d=Wo(t,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);const u=Bh(d,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function _Ct(t,s){var i,d,u,p;const r=_w(),n=(s==null?void 0:s.firstWeekContainsDate)??((d=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:d.firstWeekContainsDate)??r.firstWeekContainsDate??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.firstWeekContainsDate)??1,a=nNe(t,s),o=Wo(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),Bh(o,s)}function aNe(t,s){const r=Kn(t),n=+Bh(r,s)-+_Ct(r,s);return Math.round(n/eNe)+1}function Go(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const b_={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return Go(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):Go(r+1,2)},d(t,s){return Go(t.getDate(),s.length)},a(t,s){const r=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(t,s){return Go(t.getHours()%12||12,s.length)},H(t,s){return Go(t.getHours(),s.length)},m(t,s){return Go(t.getMinutes(),s.length)},s(t,s){return Go(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return Go(a,s.length)}},g5={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},uIe={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 b_.y(t,s)},Y:function(t,s,r,n){const a=nNe(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return Go(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):Go(o,s.length)},R:function(t,s){const r=GWe(t);return Go(r,s.length)},u:function(t,s){const r=t.getFullYear();return Go(r,s.length)},Q:function(t,s,r){const n=Math.ceil((t.getMonth()+1)/3);switch(s){case"Q":return String(n);case"QQ":return Go(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(t,s,r){const n=Math.ceil((t.getMonth()+1)/3);switch(s){case"q":return String(n);case"qq":return Go(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(t,s,r){const n=t.getMonth();switch(s){case"M":case"MM":return b_.M(t,s);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(t,s,r){const n=t.getMonth();switch(s){case"L":return String(n+1);case"LL":return Go(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(t,s,r,n){const a=aNe(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):Go(a,s.length)},I:function(t,s,r){const n=rNe(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):Go(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):b_.d(t,s)},D:function(t,s,r){const n=vCt(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):Go(n,s.length)},E:function(t,s,r){const n=t.getDay();switch(s){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(t,s,r,n){const a=t.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(s){case"e":return String(o);case"ee":return Go(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(t,s,r,n){const a=t.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(s){case"c":return String(o);case"cc":return Go(o,s.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(t,s,r){const n=t.getDay(),a=n===0?7:n;switch(s){case"i":return String(a);case"ii":return Go(a,s.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(t,s,r){const a=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,s,r){const n=t.getHours();let a;switch(n===12?a=g5.noon:n===0?a=g5.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=g5.evening:n>=12?a=g5.afternoon:n>=4?a=g5.morning:a=g5.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 b_.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):b_.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):Go(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):Go(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):b_.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):b_.s(t,s)},S:function(t,s){return b_.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return mIe(n);case"XXXX":case"XX":return a4(n);case"XXXXX":case"XXX":default:return a4(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return mIe(n);case"xxxx":case"xx":return a4(n);case"xxxxx":case"xxx":default:return a4(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+hIe(n,":");case"OOOO":default:return"GMT"+a4(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+hIe(n,":");case"zzzz":default:return"GMT"+a4(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return Go(n,s.length)},T:function(t,s,r){const n=t.getTime();return Go(n,s.length)}};function hIe(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=Math.trunc(n/60),o=n%60;return o===0?r+String(a):r+String(a)+s+Go(o,2)}function mIe(t,s){return t%60===0?(t>0?"-":"+")+Go(Math.abs(t)/60,2):a4(t,s)}function a4(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=Go(Math.trunc(n/60),2),o=Go(n%60,2);return r+a+s+o}const pIe=(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"})}},XWe=(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"})}},bCt=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return pIe(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}}",pIe(n,s)).replace("{{time}}",XWe(a,s))},N1e={p:XWe,P:bCt},wCt=/^D+$/,jCt=/^Y+$/,NCt=["D","DD","YY","YYYY"];function QWe(t){return wCt.test(t)}function JWe(t){return jCt.test(t)}function k1e(t,s,r){const n=kCt(t,s,r);if(console.warn(n),NCt.includes(t))throw new RangeError(n)}function kCt(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 SCt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,CCt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,MCt=/^'([^]*?)'?$/,TCt=/''/g,ACt=/[a-zA-Z]/;function gs(t,s,r){var p,f,y,_,b,N,w,S;const n=_w(),a=(r==null?void 0:r.locale)??n.locale??Oue,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)??((N=(b=r==null?void 0:r.locale)==null?void 0:b.options)==null?void 0:N.weekStartsOn)??n.weekStartsOn??((S=(w=n.locale)==null?void 0:w.options)==null?void 0:S.weekStartsOn)??0,i=Kn(t);if(!j1e(i))throw new RangeError("Invalid time value");let d=s.match(CCt).map(C=>{const A=C[0];if(A==="p"||A==="P"){const I=N1e[A];return I(C,a.formatLong)}return C}).join("").match(SCt).map(C=>{if(C==="''")return{isToken:!1,value:"'"};const A=C[0];if(A==="'")return{isToken:!1,value:ECt(C)};if(uIe[A])return{isToken:!0,value:C};if(A.match(ACt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+A+"`");return{isToken:!1,value:C}});a.localize.preprocessor&&(d=a.localize.preprocessor(i,d));const u={firstWeekContainsDate:o,weekStartsOn:l,locale:a};return d.map(C=>{if(!C.isToken)return C.value;const A=C.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&JWe(A)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&QWe(A))&&k1e(A,s,String(t));const I=uIe[A[0]];return I(i,A,a.localize,u)}).join("")}function ECt(t){const s=t.match(MCt);return s?s[1].replace(TCt,"'"):t}function PCt(t,s,r){const n=_w(),a=(r==null?void 0:r.locale)??n.locale??Oue,o=2520,l=qie(t,s);if(isNaN(l))throw new RangeError("Invalid time value");const i=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:l});let d,u;l>0?(d=Kn(s),u=Kn(t)):(d=Kn(t),u=Kn(s));const p=zSt(u,d),f=(ew(u)-ew(d))/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 XS(t,s){const r=Kn(t),n=Kn(s);return+r<+n}function zCt(t){return+Kn(t)>Date.now()}function BCt(t,s){const r=s instanceof Date?Wo(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 $Ct=10;class eKe{constructor(){Cn(this,"subPriority",0)}validate(s,r){return!0}}class qCt extends eKe{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 UCt extends eKe{constructor(){super(...arguments);Cn(this,"priority",$Ct);Cn(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:Wo(r,BCt(r,Date))}}class Ro{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new qCt(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class VCt extends Ro{constructor(){super(...arguments);Cn(this,"priority",140);Cn(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 md={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}/},By={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 pd(t,s){return t&&{value:s(t.value),rest:t.rest}}function Rc(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function $y(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*$R+o*Due+l*MSt),rest:s.slice(r[0].length)}}function tKe(t){return Rc(md.anyDigitsSigned,t)}function nd(t,s){switch(t){case 1:return Rc(md.singleDigit,s);case 2:return Rc(md.twoDigits,s);case 3:return Rc(md.threeDigits,s);case 4:return Rc(md.fourDigits,s);default:return Rc(new RegExp("^\\d{1,"+t+"}"),s)}}function Qoe(t,s){switch(t){case 1:return Rc(md.singleDigitSigned,s);case 2:return Rc(md.twoDigitsSigned,s);case 3:return Rc(md.threeDigitsSigned,s);case 4:return Rc(md.fourDigitsSigned,s);default:return Rc(new RegExp("^-?\\d{1,"+t+"}"),s)}}function iNe(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 sKe(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 rKe(t){return t%400===0||t%4===0&&t%100!==0}class HCt extends Ro{constructor(){super(...arguments);Cn(this,"priority",130);Cn(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 pd(nd(4,r),o);case"yo":return pd(a.ordinalNumber(r,{unit:"year"}),o);default:return pd(nd(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=sKe(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 GCt extends Ro{constructor(){super(...arguments);Cn(this,"priority",130);Cn(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 pd(nd(4,r),o);case"Yo":return pd(a.ordinalNumber(r,{unit:"year"}),o);default:return pd(nd(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=nNe(r,o);if(a.isTwoDigitYear){const d=sKe(a.year,l);return r.setFullYear(d,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Bh(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),Bh(r,o)}}class WCt extends Ro{constructor(){super(...arguments);Cn(this,"priority",130);Cn(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return Qoe(n==="R"?4:n.length,r)}set(r,n,a){const o=Wo(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),f1(o)}}class KCt extends Ro{constructor(){super(...arguments);Cn(this,"priority",130);Cn(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return Qoe(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class ZCt extends Ro{constructor(){super(...arguments);Cn(this,"priority",120);Cn(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 nd(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 YCt extends Ro{constructor(){super(...arguments);Cn(this,"priority",120);Cn(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 nd(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 XCt extends Ro{constructor(){super(...arguments);Cn(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);Cn(this,"priority",110)}parse(r,n,a){const o=l=>l-1;switch(n){case"M":return pd(Rc(md.month,r),o);case"MM":return pd(nd(2,r),o);case"Mo":return pd(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 QCt extends Ro{constructor(){super(...arguments);Cn(this,"priority",110);Cn(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 pd(Rc(md.month,r),o);case"LL":return pd(nd(2,r),o);case"Lo":return pd(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 JCt(t,s,r){const n=Kn(t),a=aNe(n,r)-s;return n.setDate(n.getDate()-a*7),n}class e3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",100);Cn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return Rc(md.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return nd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return Bh(JCt(r,a,o),o)}}function t3t(t,s){const r=Kn(t),n=rNe(r)-s;return r.setDate(r.getDate()-n*7),r}class s3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",100);Cn(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 Rc(md.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return nd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return f1(t3t(r,a))}}const r3t=[31,28,31,30,31,30,31,31,30,31,30,31],n3t=[31,29,31,30,31,30,31,31,30,31,30,31];class a3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",90);Cn(this,"subPriority",1);Cn(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return Rc(md.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return nd(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=rKe(a),l=r.getMonth();return o?n>=1&&n<=n3t[l]:n>=1&&n<=r3t[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class i3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",90);Cn(this,"subpriority",1);Cn(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 Rc(md.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return nd(n.length,r)}}validate(r,n){const a=r.getFullYear();return rKe(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 oNe(t,s,r){var f,y,_,b;const n=_w(),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=Kn(t),l=o.getDay(),d=(s%7+7)%7,u=7-a,p=s<0||s>6?s-(l+u)%7:(d+u)%7-(l+u)%7;return dl(o,p)}class o3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",90);Cn(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=oNe(r,a,o),r.setHours(0,0,0,0),r}}class l3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",90);Cn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(r,n,a,o){const l=i=>{const d=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+d};switch(n){case"e":case"ee":return pd(nd(n.length,r),l);case"eo":return pd(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=oNe(r,a,o),r.setHours(0,0,0,0),r}}class c3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",90);Cn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(r,n,a,o){const l=i=>{const d=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+d};switch(n){case"c":case"cc":return pd(nd(n.length,r),l);case"co":return pd(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=oNe(r,a,o),r.setHours(0,0,0,0),r}}function d3t(t,s){const r=Kn(t),n=DCt(r),a=s-n;return dl(r,a)}class u3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",90);Cn(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 nd(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return pd(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 pd(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return pd(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return pd(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=d3t(r,a),r.setHours(0,0,0,0),r}}class h3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",80);Cn(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(iNe(a),0,0,0),r}}class m3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",80);Cn(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(iNe(a),0,0,0),r}}class p3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",80);Cn(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(iNe(a),0,0,0),r}}class f3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",70);Cn(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return Rc(md.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return nd(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 x3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",70);Cn(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return Rc(md.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return nd(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class g3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",70);Cn(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return Rc(md.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return nd(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 y3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",70);Cn(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return Rc(md.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return nd(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 v3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",60);Cn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return Rc(md.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return nd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class _3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",50);Cn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return Rc(md.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return nd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class b3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",30);Cn(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return pd(nd(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class w3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",10);Cn(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return $y(By.basicOptionalMinutes,r);case"XX":return $y(By.basic,r);case"XXXX":return $y(By.basicOptionalSeconds,r);case"XXXXX":return $y(By.extendedOptionalSeconds,r);case"XXX":default:return $y(By.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Wo(r,r.getTime()-ew(r)-a)}}class j3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",10);Cn(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return $y(By.basicOptionalMinutes,r);case"xx":return $y(By.basic,r);case"xxxx":return $y(By.basicOptionalSeconds,r);case"xxxxx":return $y(By.extendedOptionalSeconds,r);case"xxx":default:return $y(By.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Wo(r,r.getTime()-ew(r)-a)}}class N3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",40);Cn(this,"incompatibleTokens","*")}parse(r){return tKe(r)}set(r,n,a){return[Wo(r,a*1e3),{timestampIsSet:!0}]}}class k3t extends Ro{constructor(){super(...arguments);Cn(this,"priority",20);Cn(this,"incompatibleTokens","*")}parse(r){return tKe(r)}set(r,n,a){return[Wo(r,a),{timestampIsSet:!0}]}}const S3t={G:new VCt,y:new HCt,Y:new GCt,R:new WCt,u:new KCt,Q:new ZCt,q:new YCt,M:new XCt,L:new QCt,w:new e3t,I:new s3t,d:new a3t,D:new i3t,E:new o3t,e:new l3t,c:new c3t,i:new u3t,a:new h3t,b:new m3t,B:new p3t,h:new f3t,H:new x3t,K:new g3t,k:new y3t,m:new v3t,s:new _3t,S:new b3t,X:new w3t,x:new j3t,t:new N3t,T:new k3t},C3t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,M3t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,T3t=/^'([^]*?)'?$/,A3t=/''/g,E3t=/\S/,P3t=/[a-zA-Z]/;function lNe(t,s,r,n){var N,w,S,C;const a=LCt(),o=a.locale??Oue,l=a.firstWeekContainsDate??((w=(N=a.locale)==null?void 0:N.options)==null?void 0:w.firstWeekContainsDate)??1,i=a.weekStartsOn??((C=(S=a.locale)==null?void 0:S.options)==null?void 0:C.weekStartsOn)??0;if(s==="")return t===""?Kn(r):Wo(r,NaN);const d={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new UCt],p=s.match(M3t).map(A=>{const I=A[0];if(I in N1e){const L=N1e[I];return L(A,o.formatLong)}return A}).join("").match(C3t),f=[];for(let A of p){JWe(A)&&k1e(A,s,t),QWe(A)&&k1e(A,s,t);const I=A[0],L=S3t[I];if(L){const{incompatibleTokens:O}=L;if(Array.isArray(O)){const q=f.find($=>O.includes($.token)||$.token===I);if(q)throw new RangeError(`The format string mustn't contain \`${q.fullToken}\` and \`${A}\` at the same time`)}else if(L.incompatibleTokens==="*"&&f.length>0)throw new RangeError(`The format string mustn't contain \`${A}\` and any other token at the same time`);f.push({token:I,fullToken:A});const U=L.run(t,A,o.match,d);if(!U)return Wo(r,NaN);u.push(U.setter),t=U.rest}else{if(I.match(P3t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+I+"`");if(A==="''"?A="'":I==="'"&&(A=I3t(A)),t.indexOf(A)===0)t=t.slice(A.length);else return Wo(r,NaN)}}if(t.length>0&&E3t.test(t))return Wo(r,NaN);const y=u.map(A=>A.priority).sort((A,I)=>I-A).filter((A,I,L)=>L.indexOf(A)===I).map(A=>u.filter(I=>I.priority===A).sort((I,L)=>L.subPriority-I.subPriority)).map(A=>A[0]);let _=Kn(r);if(isNaN(_.getTime()))return Wo(r,NaN);const b={};for(const A of y){if(!A.validate(_,d))return Wo(r,NaN);const I=A.set(_,b,d);Array.isArray(I)?(_=I[0],Object.assign(b,I[1])):_=I}return Wo(r,_)}function I3t(t){return t.match(T3t)[1].replace(A3t,"'")}function a0(t){return+Kn(t)o-l);return r>=n&&r<=a}function Uie(t,s){return dl(t,-s)}function mm(t,s){const n=B3t(t);let a;if(n.date){const d=$3t(n.date,2);a=q3t(d.restDateString,d.year)}if(!a||isNaN(a.getTime()))return new Date(NaN);const o=a.getTime();let l=0,i;if(n.time&&(l=U3t(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=V3t(n.timezone),isNaN(i))return new Date(NaN)}else{const d=new Date(o+l),u=new Date(0);return u.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),u.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),u}return new Date(o+l+i)}const Az={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},O3t=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,F3t=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,z3t=/^([+-])(\d{2})(?::?(\d{2}))?$/;function B3t(t){const s={},r=t.split(Az.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],Az.timeZoneDelimiter.test(s.date)&&(s.date=t.split(Az.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=Az.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function $3t(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 q3t(t,s){if(s===null)return new Date(NaN);const r=t.match(O3t);if(!r)return new Date(NaN);const n=!!r[4],a=e6(r[1]),o=e6(r[2])-1,l=e6(r[3]),i=e6(r[4]),d=e6(r[5])-1;if(n)return Z3t(s,i,d)?H3t(s,i,d):new Date(NaN);{const u=new Date(0);return!W3t(s,o,l)||!K3t(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function e6(t){return t?parseInt(t):1}function U3t(t){const s=t.match(F3t);if(!s)return NaN;const r=vge(s[1]),n=vge(s[2]),a=vge(s[3]);return Y3t(r,n,a)?r*$R+n*Due+a*1e3:NaN}function vge(t){return t&&parseFloat(t.replace(",","."))||0}function V3t(t){if(t==="Z")return 0;const s=t.match(z3t);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return X3t(n,a)?r*(n*$R+a*Due):NaN}function H3t(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 G3t=[31,null,31,30,31,30,31,31,30,31,30,31];function nKe(t){return t%400===0||t%4===0&&t%100!==0}function W3t(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(G3t[s]||(nKe(t)?29:28))}function K3t(t,s){return s>=1&&s<=(nKe(t)?366:365)}function Z3t(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function Y3t(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function X3t(t,s){return s>=0&&s<=59}function _ge(t,s){const r=Kn(t),n=r.getFullYear(),a=r.getDate(),o=Wo(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=ICt(o);return r.setMonth(s,Math.min(a,l)),r}function XL(t,s){const r=Kn(t);return r.setHours(s),r}function QL(t,s){const r=Kn(t);return r.setMinutes(s),r}function xIe(t,s){const r=Kn(t);return isNaN(+r)?Wo(t,NaN):(r.setFullYear(s),r)}function v4(t,s){return Tm(t,-s)}var wo;(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})(wo||(wo={}));var gIe;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(gIe||(gIe={}));const ca=wo.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),O_=t=>{switch(typeof t){case"undefined":return ca.undefined;case"string":return ca.string;case"number":return Number.isNaN(t)?ca.nan:ca.number;case"boolean":return ca.boolean;case"function":return ca.function;case"bigint":return ca.bigint;case"symbol":return ca.symbol;case"object":return Array.isArray(t)?ca.array:t===null?ca.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?ca.promise:typeof Map<"u"&&t instanceof Map?ca.map:typeof Set<"u"&&t instanceof Set?ca.set:typeof Date<"u"&&t instanceof Date?ca.date:ca.object;default:return ca.unknown}},Xr=wo.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 u0 extends Error{get errors(){return this.issues}constructor(s){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=s}format(s){const r=s||function(o){return o.message},n={_errors:[]},a=o=>{for(const l of o.issues)if(l.code==="invalid_union")l.unionErrors.map(a);else if(l.code==="invalid_return_type")a(l.returnTypeError);else if(l.code==="invalid_arguments")a(l.argumentsError);else if(l.path.length===0)n._errors.push(r(l));else{let i=n,d=0;for(;dr.message){const r={},n=[];for(const a of this.issues)if(a.path.length>0){const o=a.path[0];r[o]=r[o]||[],r[o].push(s(a))}else n.push(s(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}u0.create=t=>new u0(t);const S1e=(t,s)=>{let r;switch(t.code){case Xr.invalid_type:t.received===ca.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case Xr.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,wo.jsonStringifyReplacer)}`;break;case Xr.unrecognized_keys:r=`Unrecognized key(s) in object: ${wo.joinValues(t.keys,", ")}`;break;case Xr.invalid_union:r="Invalid input";break;case Xr.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${wo.joinValues(t.options)}`;break;case Xr.invalid_enum_value:r=`Invalid enum value. Expected ${wo.joinValues(t.options)}, received '${t.received}'`;break;case Xr.invalid_arguments:r="Invalid function arguments";break;case Xr.invalid_return_type:r="Invalid function return type";break;case Xr.invalid_date:r="Invalid date";break;case Xr.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}"`:wo.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case Xr.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 Xr.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 Xr.custom:r="Invalid input";break;case Xr.invalid_intersection_types:r="Intersection results could not be merged";break;case Xr.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case Xr.not_finite:r="Number must be finite";break;default:r=s.defaultError,wo.assertNever(t)}return{message:r}};let Q3t=S1e;function J3t(){return Q3t}const e5t=t=>{const{data:s,path:r,errorMaps:n,issueData:a}=t,o=[...r,...a.path||[]],l={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let i="";const d=n.filter(u=>!!u).slice().reverse();for(const u of d)i=u(l,{data:s,defaultError:i}).message;return{...a,path:o,message:i}};function zn(t,s){const r=J3t(),n=e5t({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===S1e?void 0:S1e].filter(a=>!!a)});t.common.issues.push(n)}class bf{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 xi;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 bf.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 xi;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 xi=Object.freeze({status:"aborted"}),I6=t=>({status:"dirty",value:t}),Ox=t=>({status:"valid",value:t}),yIe=t=>t.status==="aborted",vIe=t=>t.status==="dirty",PT=t=>t.status==="valid",Joe=t=>typeof Promise<"u"&&t instanceof Promise;var ha;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(ha||(ha={}));class tw{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 _Ie=(t,s)=>{if(PT(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 u0(t.common.issues);return this._error=r,this._error}}};function Oi(t){if(!t)return{};const{errorMap:s,invalid_type_error:r,required_error:n,description:a}=t;if(s&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return s?{errorMap:s,description:a}:{errorMap:(l,i)=>{const{message:d}=t;return l.code==="invalid_enum_value"?{message:d??i.defaultError}:typeof i.data>"u"?{message:d??n??i.defaultError}:l.code!=="invalid_type"?{message:i.defaultError}:{message:d??r??i.defaultError}},description:a}}class bo{get description(){return this._def.description}_getType(s){return O_(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:O_(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new bf,ctx:{common:s.parent.common,data:s.data,parsedType:O_(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(Joe(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:O_(s)},a=this._parseSync({data:s,path:n.path,parent:n});return _Ie(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:O_(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return PT(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=>PT(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:O_(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(Joe(a)?a:Promise.resolve(a));return _Ie(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:Xr.custom,...n(a)});return typeof Promise<"u"&&l instanceof Promise?l.then(d=>d?!0:(i(),!1)):l?!0:(i(),!1)})}refinement(s,r){return this._refinement((n,a)=>s(n)?!0:(a.addIssue(typeof r=="function"?r(n,a):r),!1))}_refinement(s){return new DT({schema:this,typeName:gi.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 Bb.create(this,this._def)}nullable(){return RT.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return i0.create(this)}promise(){return rle.create(this,this._def)}or(s){return tle.create([this,s],this._def)}and(s){return sle.create(this,s,this._def)}transform(s){return new DT({...Oi(this._def),schema:this,typeName:gi.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new A1e({...Oi(this._def),innerType:this,defaultValue:r,typeName:gi.ZodDefault})}brand(){return new j5t({typeName:gi.ZodBranded,type:this,...Oi(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new E1e({...Oi(this._def),innerType:this,catchValue:r,typeName:gi.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return cNe.create(this,s)}readonly(){return P1e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const t5t=/^c[^\s-]{8,}$/i,s5t=/^[0-9a-z]+$/,r5t=/^[0-9A-HJKMNP-TV-Z]{26}$/i,n5t=/^[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,a5t=/^[a-z0-9_-]{21}$/i,i5t=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,o5t=/^[-+]?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)?)??$/,l5t=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,c5t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let bge;const d5t=/^(?:(?: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])$/,u5t=/^(?:(?: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])$/,h5t=/^(([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]))$/,m5t=/^(([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])$/,p5t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,f5t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,aKe="((\\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])))",x5t=new RegExp(`^${aKe}$`);function iKe(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 g5t(t){return new RegExp(`^${iKe(t)}$`)}function y5t(t){let s=`${aKe}T${iKe(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 v5t(t,s){return!!((s==="v4"||!s)&&d5t.test(t)||(s==="v6"||!s)&&h5t.test(t))}function _5t(t,s){if(!i5t.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 b5t(t,s){return!!((s==="v4"||!s)&&u5t.test(t)||(s==="v6"||!s)&&m5t.test(t))}class mb extends bo{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==ca.string){const o=this._getOrReturnCtx(s);return zn(o,{code:Xr.invalid_type,expected:ca.string,received:o.parsedType}),xi}const n=new bf;let a;for(const o of this._def.checks)if(o.kind==="min")s.data.lengtho.value&&(a=this._getOrReturnCtx(s,a),zn(a,{code:Xr.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:Xr.invalid_string,...ha.errToObj(n)})}_addCheck(s){return new mb({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...ha.errToObj(s)})}url(s){return this._addCheck({kind:"url",...ha.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...ha.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...ha.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...ha.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...ha.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...ha.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...ha.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...ha.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...ha.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...ha.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...ha.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...ha.errToObj(s)})}datetime(s){return typeof s=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:s}):this._addCheck({kind:"datetime",precision:typeof(s==null?void 0:s.precision)>"u"?null:s==null?void 0:s.precision,offset:(s==null?void 0:s.offset)??!1,local:(s==null?void 0:s.local)??!1,...ha.errToObj(s==null?void 0:s.message)})}date(s){return this._addCheck({kind:"date",message:s})}time(s){return typeof s=="string"?this._addCheck({kind:"time",precision:null,message:s}):this._addCheck({kind:"time",precision:typeof(s==null?void 0:s.precision)>"u"?null:s==null?void 0:s.precision,...ha.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...ha.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...ha.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...ha.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...ha.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...ha.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...ha.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...ha.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...ha.errToObj(r)})}nonempty(s){return this.min(1,ha.errToObj(s))}trim(){return new mb({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new mb({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new mb({...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 mb({checks:[],typeName:gi.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Oi(t)});function w5t(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 IT extends bo{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)!==ca.number){const o=this._getOrReturnCtx(s);return zn(o,{code:Xr.invalid_type,expected:ca.number,received:o.parsedType}),xi}let n;const a=new bf;for(const o of this._def.checks)o.kind==="int"?wo.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),zn(n,{code:Xr.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),zn(n,{code:Xr.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?w5t(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),zn(n,{code:Xr.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),zn(n,{code:Xr.not_finite,message:o.message}),a.dirty()):wo.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,ha.toString(r))}gt(s,r){return this.setLimit("min",s,!1,ha.toString(r))}lte(s,r){return this.setLimit("max",s,!0,ha.toString(r))}lt(s,r){return this.setLimit("max",s,!1,ha.toString(r))}setLimit(s,r,n,a){return new IT({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ha.toString(a)}]})}_addCheck(s){return new IT({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:ha.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ha.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ha.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ha.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ha.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:ha.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:ha.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ha.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ha.toString(s)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.values.kind==="int"||s.kind==="multipleOf"&&wo.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 IT({checks:[],typeName:gi.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Oi(t)});class aD extends bo{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)!==ca.bigint)return this._getInvalidInput(s);let n;const a=new bf;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),zn(n,{code:Xr.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?s.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(s,n),zn(n,{code:Xr.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):wo.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return zn(r,{code:Xr.invalid_type,expected:ca.bigint,received:r.parsedType}),xi}gte(s,r){return this.setLimit("min",s,!0,ha.toString(r))}gt(s,r){return this.setLimit("min",s,!1,ha.toString(r))}lte(s,r){return this.setLimit("max",s,!0,ha.toString(r))}lt(s,r){return this.setLimit("max",s,!1,ha.toString(r))}setLimit(s,r,n,a){return new aD({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ha.toString(a)}]})}_addCheck(s){return new aD({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ha.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ha.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ha.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ha.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:ha.toString(r)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.valuenew aD({checks:[],typeName:gi.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Oi(t)});class C1e extends bo{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==ca.boolean){const n=this._getOrReturnCtx(s);return zn(n,{code:Xr.invalid_type,expected:ca.boolean,received:n.parsedType}),xi}return Ox(s.data)}}C1e.create=t=>new C1e({typeName:gi.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Oi(t)});class ele extends bo{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==ca.date){const o=this._getOrReturnCtx(s);return zn(o,{code:Xr.invalid_type,expected:ca.date,received:o.parsedType}),xi}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return zn(o,{code:Xr.invalid_date}),xi}const n=new bf;let a;for(const o of this._def.checks)o.kind==="min"?s.data.getTime()o.value&&(a=this._getOrReturnCtx(s,a),zn(a,{code:Xr.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):wo.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new ele({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:ha.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:ha.toString(r)})}get minDate(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s!=null?new Date(s):null}get maxDate(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.valuenew ele({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:gi.ZodDate,...Oi(t)});class bIe extends bo{_parse(s){if(this._getType(s)!==ca.symbol){const n=this._getOrReturnCtx(s);return zn(n,{code:Xr.invalid_type,expected:ca.symbol,received:n.parsedType}),xi}return Ox(s.data)}}bIe.create=t=>new bIe({typeName:gi.ZodSymbol,...Oi(t)});class wIe extends bo{_parse(s){if(this._getType(s)!==ca.undefined){const n=this._getOrReturnCtx(s);return zn(n,{code:Xr.invalid_type,expected:ca.undefined,received:n.parsedType}),xi}return Ox(s.data)}}wIe.create=t=>new wIe({typeName:gi.ZodUndefined,...Oi(t)});class jIe extends bo{_parse(s){if(this._getType(s)!==ca.null){const n=this._getOrReturnCtx(s);return zn(n,{code:Xr.invalid_type,expected:ca.null,received:n.parsedType}),xi}return Ox(s.data)}}jIe.create=t=>new jIe({typeName:gi.ZodNull,...Oi(t)});class NIe extends bo{constructor(){super(...arguments),this._any=!0}_parse(s){return Ox(s.data)}}NIe.create=t=>new NIe({typeName:gi.ZodAny,...Oi(t)});class kIe extends bo{constructor(){super(...arguments),this._unknown=!0}_parse(s){return Ox(s.data)}}kIe.create=t=>new kIe({typeName:gi.ZodUnknown,...Oi(t)});class sw extends bo{_parse(s){const r=this._getOrReturnCtx(s);return zn(r,{code:Xr.invalid_type,expected:ca.never,received:r.parsedType}),xi}}sw.create=t=>new sw({typeName:gi.ZodNever,...Oi(t)});class SIe extends bo{_parse(s){if(this._getType(s)!==ca.undefined){const n=this._getOrReturnCtx(s);return zn(n,{code:Xr.invalid_type,expected:ca.void,received:n.parsedType}),xi}return Ox(s.data)}}SIe.create=t=>new SIe({typeName:gi.ZodVoid,...Oi(t)});class i0 extends bo{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==ca.array)return zn(r,{code:Xr.invalid_type,expected:ca.array,received:r.parsedType}),xi;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&(zn(r,{code:Xr.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 tw(r,l,r.path,i)))).then(l=>bf.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new tw(r,l,r.path,i)));return bf.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new i0({...this._def,minLength:{value:s,message:ha.toString(r)}})}max(s,r){return new i0({...this._def,maxLength:{value:s,message:ha.toString(r)}})}length(s,r){return new i0({...this._def,exactLength:{value:s,message:ha.toString(r)}})}nonempty(s){return this.min(1,s)}}i0.create=(t,s)=>new i0({type:t,minLength:null,maxLength:null,exactLength:null,typeName:gi.ZodArray,...Oi(s)});function L5(t){if(t instanceof Pd){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=Bb.create(L5(n))}return new Pd({...t._def,shape:()=>s})}else return t instanceof i0?new i0({...t._def,type:L5(t.element)}):t instanceof Bb?Bb.create(L5(t.unwrap())):t instanceof RT?RT.create(L5(t.unwrap())):t instanceof QS?QS.create(t.items.map(s=>L5(s))):t}class Pd extends bo{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=wo.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==ca.object){const u=this._getOrReturnCtx(s);return zn(u,{code:Xr.invalid_type,expected:ca.object,received:u.parsedType}),xi}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof sw&&this._def.unknownKeys==="strip"))for(const u in a.data)l.includes(u)||i.push(u);const d=[];for(const u of l){const p=o[u],f=a.data[u];d.push({key:{status:"valid",value:u},value:p._parse(new tw(a,f,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof sw){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of i)d.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(u==="strict")i.length>0&&(zn(a,{code:Xr.unrecognized_keys,keys:i}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of i){const f=a.data[p];d.push({key:{status:"valid",value:p},value:u._parse(new tw(a,f,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of d){const f=await p.key,y=await p.value;u.push({key:f,value:y,alwaysSet:p.alwaysSet})}return u}).then(u=>bf.mergeObjectSync(n,u)):bf.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(s){return ha.errToObj,new Pd({...this._def,unknownKeys:"strict",...s!==void 0?{errorMap:(r,n)=>{var o,l;const a=((l=(o=this._def).errorMap)==null?void 0:l.call(o,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:ha.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new Pd({...this._def,unknownKeys:"strip"})}passthrough(){return new Pd({...this._def,unknownKeys:"passthrough"})}extend(s){return new Pd({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new Pd({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:gi.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new Pd({...this._def,catchall:s})}pick(s){const r={};for(const n of wo.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Pd({...this._def,shape:()=>r})}omit(s){const r={};for(const n of wo.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new Pd({...this._def,shape:()=>r})}deepPartial(){return L5(this)}partial(s){const r={};for(const n of wo.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new Pd({...this._def,shape:()=>r})}required(s){const r={};for(const n of wo.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Bb;)o=o._def.innerType;r[n]=o}return new Pd({...this._def,shape:()=>r})}keyof(){return oKe(wo.objectKeys(this.shape))}}Pd.create=(t,s)=>new Pd({shape:()=>t,unknownKeys:"strip",catchall:sw.create(),typeName:gi.ZodObject,...Oi(s)});Pd.strictCreate=(t,s)=>new Pd({shape:()=>t,unknownKeys:"strict",catchall:sw.create(),typeName:gi.ZodObject,...Oi(s)});Pd.lazycreate=(t,s)=>new Pd({shape:t,unknownKeys:"strip",catchall:sw.create(),typeName:gi.ZodObject,...Oi(s)});class tle extends bo{_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 u0(i.ctx.common.issues));return zn(r,{code:Xr.invalid_union,unionErrors:l}),xi}if(r.common.async)return Promise.all(n.map(async o=>{const l={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:l}),ctx:l}})).then(a);{let o;const l=[];for(const d of n){const u={...r,common:{...r.common,issues:[]},parent:null},p=d._parseSync({data:r.data,path:r.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!o&&(o={result:p,ctx:u}),u.common.issues.length&&l.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;const i=l.map(d=>new u0(d));return zn(r,{code:Xr.invalid_union,unionErrors:i}),xi}}get options(){return this._def.options}}tle.create=(t,s)=>new tle({options:t,typeName:gi.ZodUnion,...Oi(s)});function M1e(t,s){const r=O_(t),n=O_(s);if(t===s)return{valid:!0,data:t};if(r===ca.object&&n===ca.object){const a=wo.objectKeys(s),o=wo.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const d=M1e(t[i],s[i]);if(!d.valid)return{valid:!1};l[i]=d.data}return{valid:!0,data:l}}else if(r===ca.array&&n===ca.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(yIe(o)||yIe(l))return xi;const i=M1e(o.value,l.value);return i.valid?((vIe(o)||vIe(l))&&r.dirty(),{status:r.value,value:i.data}):(zn(n,{code:Xr.invalid_intersection_types}),xi)};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}))}}sle.create=(t,s,r)=>new sle({left:t,right:s,typeName:gi.ZodIntersection,...Oi(r)});class QS extends bo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ca.array)return zn(n,{code:Xr.invalid_type,expected:ca.array,received:n.parsedType}),xi;if(n.data.lengththis._def.items.length&&(zn(n,{code:Xr.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const o=[...n.data].map((l,i)=>{const d=this._def.items[i]||this._def.rest;return d?d._parse(new tw(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>bf.mergeArray(r,l)):bf.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new QS({...this._def,rest:s})}}QS.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new QS({items:t,typeName:gi.ZodTuple,rest:null,...Oi(s)})};class CIe extends bo{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!==ca.map)return zn(n,{code:Xr.invalid_type,expected:ca.map,received:n.parsedType}),xi;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,d],u)=>({key:a._parse(new tw(n,i,n.path,[u,"key"])),value:o._parse(new tw(n,d,n.path,[u,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const d of l){const u=await d.key,p=await d.value;if(u.status==="aborted"||p.status==="aborted")return xi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}})}else{const i=new Map;for(const d of l){const u=d.key,p=d.value;if(u.status==="aborted"||p.status==="aborted")return xi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}}}}CIe.create=(t,s,r)=>new CIe({valueType:s,keyType:t,typeName:gi.ZodMap,...Oi(r)});class iD extends bo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ca.set)return zn(n,{code:Xr.invalid_type,expected:ca.set,received:n.parsedType}),xi;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(zn(n,{code:Xr.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const o=this._def.valueType;function l(d){const u=new Set;for(const p of d){if(p.status==="aborted")return xi;p.status==="dirty"&&r.dirty(),u.add(p.value)}return{status:r.value,value:u}}const i=[...n.data.values()].map((d,u)=>o._parse(new tw(n,d,n.path,u)));return n.common.async?Promise.all(i).then(d=>l(d)):l(i)}min(s,r){return new iD({...this._def,minSize:{value:s,message:ha.toString(r)}})}max(s,r){return new iD({...this._def,maxSize:{value:s,message:ha.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}iD.create=(t,s)=>new iD({valueType:t,minSize:null,maxSize:null,typeName:gi.ZodSet,...Oi(s)});class MIe extends bo{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})}}MIe.create=(t,s)=>new MIe({getter:t,typeName:gi.ZodLazy,...Oi(s)});class T1e extends bo{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return zn(r,{received:r.data,code:Xr.invalid_literal,expected:this._def.value}),xi}return{status:"valid",value:s.data}}get value(){return this._def.value}}T1e.create=(t,s)=>new T1e({value:t,typeName:gi.ZodLiteral,...Oi(s)});function oKe(t,s){return new LT({values:t,typeName:gi.ZodEnum,...Oi(s)})}class LT extends bo{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return zn(r,{expected:wo.joinValues(n),received:r.parsedType,code:Xr.invalid_type}),xi}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(s.data)){const r=this._getOrReturnCtx(s),n=this._def.values;return zn(r,{received:r.data,code:Xr.invalid_enum_value,options:n}),xi}return Ox(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 LT.create(s,{...this._def,...r})}exclude(s,r=this._def){return LT.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}LT.create=oKe;class TIe extends bo{_parse(s){const r=wo.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==ca.string&&n.parsedType!==ca.number){const a=wo.objectValues(r);return zn(n,{expected:wo.joinValues(a),received:n.parsedType,code:Xr.invalid_type}),xi}if(this._cache||(this._cache=new Set(wo.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=wo.objectValues(r);return zn(n,{received:n.data,code:Xr.invalid_enum_value,options:a}),xi}return Ox(s.data)}get enum(){return this._def.values}}TIe.create=(t,s)=>new TIe({values:t,typeName:gi.ZodNativeEnum,...Oi(s)});class rle extends bo{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==ca.promise&&r.common.async===!1)return zn(r,{code:Xr.invalid_type,expected:ca.promise,received:r.parsedType}),xi;const n=r.parsedType===ca.promise?r.data:Promise.resolve(r.data);return Ox(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}rle.create=(t,s)=>new rle({type:t,typeName:gi.ZodPromise,...Oi(s)});class DT extends bo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===gi.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(s){const{status:r,ctx:n}=this._processInputParams(s),a=this._def.effect||null,o={addIssue:l=>{zn(n,l),l.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),a.type==="preprocess"){const l=a.transform(n.data,o);if(n.common.async)return Promise.resolve(l).then(async i=>{if(r.value==="aborted")return xi;const d=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return d.status==="aborted"?xi:d.status==="dirty"||r.value==="dirty"?I6(d.value):d});{if(r.value==="aborted")return xi;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?xi:i.status==="dirty"||r.value==="dirty"?I6(i.value):i}}if(a.type==="refinement"){const l=i=>{const d=a.refinement(i,o);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?xi:(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"?xi:(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(!PT(l))return xi;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=>PT(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):xi);wo.assertNever(a)}}DT.create=(t,s,r)=>new DT({schema:t,typeName:gi.ZodEffects,effect:s,...Oi(r)});DT.createWithPreprocess=(t,s,r)=>new DT({schema:s,effect:{type:"preprocess",transform:t},typeName:gi.ZodEffects,...Oi(r)});class Bb extends bo{_parse(s){return this._getType(s)===ca.undefined?Ox(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}Bb.create=(t,s)=>new Bb({innerType:t,typeName:gi.ZodOptional,...Oi(s)});class RT extends bo{_parse(s){return this._getType(s)===ca.null?Ox(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}RT.create=(t,s)=>new RT({innerType:t,typeName:gi.ZodNullable,...Oi(s)});class A1e extends bo{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===ca.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}A1e.create=(t,s)=>new A1e({innerType:t,typeName:gi.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...Oi(s)});class E1e extends bo{_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 Joe(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new u0(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new u0(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}E1e.create=(t,s)=>new E1e({innerType:t,typeName:gi.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...Oi(s)});class AIe extends bo{_parse(s){if(this._getType(s)!==ca.nan){const n=this._getOrReturnCtx(s);return zn(n,{code:Xr.invalid_type,expected:ca.nan,received:n.parsedType}),xi}return{status:"valid",value:s.data}}}AIe.create=t=>new AIe({typeName:gi.ZodNaN,...Oi(t)});class j5t extends bo{_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 cNe extends bo{_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"?xi:o.status==="dirty"?(r.dirty(),I6(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"?xi: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 cNe({in:s,out:r,typeName:gi.ZodPipeline})}}class P1e extends bo{_parse(s){const r=this._def.innerType._parse(s),n=a=>(PT(a)&&(a.value=Object.freeze(a.value)),a);return Joe(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}P1e.create=(t,s)=>new P1e({innerType:t,typeName:gi.ZodReadonly,...Oi(s)});var gi;(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"})(gi||(gi={}));const Yl=mb.create,JL=IT.create,N5t=C1e.create;sw.create;i0.create;const SC=Pd.create;tle.create;sle.create;QS.create;const nle=T1e.create,lKe=LT.create;rle.create;Bb.create;RT.create;const _r=k.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:Rt("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}));_r.displayName="Textarea";const k5t=["Excellent","Good","Neutral","Bad","Very Bad"],S5t=[5,4,3,2,1];function C5t({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=mSt(),[o,l]=k.useState({}),i=t.filter(y=>y.question_type==="rating"),d=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 N;return{visitor_id:s,question_id:_,rating_value:b.rating_value??null,text_value:((N=b.text_value)==null?void 0:N.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"}),k5t.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}),S5t.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))]}),d.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(_r,{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(ps,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const M5t=SC({first_name:Yl().trim().min(1,"First name is required").max(50),last_name:Yl().trim().max(50).optional(),email:Yl().trim().email("Please enter a valid email").max(255).optional().or(nle("")),phone:Yl().trim().max(20).optional().or(nle(""))}),T5t=[{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 cKe({slug:t}={}){var xe;const s=ho(),r=t||s.slug,{data:n,isLoading:a,error:o}=dSt(r),l=vSt(),i=_St(),d=bSt(),u=k.useRef(!1),[p,f]=k.useState("welcome"),[y,_]=k.useState(null),[b,N]=k.useState({first_name:"",last_name:"",email:"",phone:""}),[w,S]=k.useState(""),[C,A]=k.useState(!1),[I,L]=k.useState(!1),[O,U]=k.useState(""),[q,$]=k.useState(""),{data:V,isLoading:ee}=hSt(n==null?void 0:n.id),Z=!!(n!=null&&n.enable_survey),J=(n==null?void 0:n.ask_visitor_intent)!==!1;k.useEffect(()=>{if(!r||!(n!=null&&n.id)||u.current)return;const he=`oh_scan_${n.id}`;if(sessionStorage.getItem(he)){u.current=!0;return}u.current=!0,sessionStorage.setItem(he,"1"),d.mutate(r)},[r,n==null?void 0:n.id]),k.useEffect(()=>{p==="pending_survey"&&(ee||f(Z&&((V==null?void 0:V.length)??0)>0?"survey":"done"))},[p,ee,Z,V]);const Y=he=>{if(!he)return"";const[we,Ne]=he.split(":"),Ve=parseInt(we),Te=Ve>=12?"PM":"AM";return`${Ve>12?Ve-12:Ve||12}:${Ne} ${Te}`},ce=async()=>{$("");const he=M5t.safeParse(b);if(!he.success){$(he.error.issues[0].message);return}if(!b.email&&!b.phone){$("Please provide either an email or phone number");return}if(!y&&(n!=null&&n.id))try{const we=await l.mutateAsync({open_house_id:n.id,first_name:b.first_name.trim(),last_name:b.last_name.trim()||void 0,email:b.email.trim()||void 0,phone:b.phone.trim()||void 0,wants_market_updates:C,has_agent:I,working_with_agent_name:I&&O.trim()?O.trim():void 0,partial_signin:J});_(we.id)}catch{}if(!J){Z?!ee&&V&&V.length>0?f("survey"):f("pending_survey"):f("done");return}f("intent")},ae=async he=>{S(he);try{let we=y;we?await i.mutateAsync({visitor_id:we,visitor_intent:he,wants_market_updates:C,has_agent:I,working_with_agent_name:I&&O.trim()?O.trim():null,partial_signin:!1}):(we=(await l.mutateAsync({open_house_id:n.id,first_name:b.first_name.trim(),last_name:b.last_name.trim()||void 0,email:b.email.trim()||void 0,phone:b.phone.trim()||void 0,visitor_intent:he,wants_market_updates:C,has_agent:I,working_with_agent_name:I&&O.trim()?O.trim():void 0,partial_signin:!1})).id,_(we)),Z?!ee&&V&&V.length>0?f("survey"):f("pending_survey"):f("done")}catch{$("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(Mn,{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 ie=n.profiles,le=((xe=ie==null?void 0:ie.name)==null?void 0:xe.split(" ").map(he=>he[0]).join("").slice(0,2))||"?",fe=n.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(Nc,{children:[e.jsxs("title",{children:[fe?"Community Event":"Open House"," | ",n.property_address]}),e.jsx("meta",{name:"description",content:`Sign in to the ${fe?"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(vn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx(Ca,{src:(ie==null?void 0:ie.avatar_url)||"",alt:(ie==null?void 0:ie.name)||""}),e.jsx(_n,{className:"bg-white/10 text-white text-lg",children:le})]}),e.jsx("p",{className:"text-white/60 text-sm",children:ie==null?void 0:ie.name}),(ie==null?void 0:ie.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:ie.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(La,{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(nn,{className:"h-3 w-3"}),gs(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(rn,{className:"h-3 w-3"}),Y(n.start_time),n.end_time?` – ${Y(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:fe?e.jsx(ma,{className:"h-5 w-5 text-white"}):e.jsx(Mn,{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(La,{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(nn,{className:"h-3 w-3"}),gs(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(rn,{className:"h-3 w-3"}),Y(n.start_time),n.end_time?` – ${Y(n.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[p==="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:()=>f("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",e.jsx(ti,{className:"h-5 w-5 ml-2"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),p==="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:()=>f("welcome"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ra,{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(ge,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(Fe,{value:b.first_name,onChange:he=>N(we=>({...we,first_name:he.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(Fe,{value:b.last_name,onChange:he=>N(we=>({...we,last_name:he.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(Fe,{type:"email",value:b.email,onChange:he=>N(we=>({...we,email:he.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(Fe,{type:"tel",value:b.phone,onChange:he=>N(we=>({...we,phone:he.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:C,onChange:he=>A(he.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:I?"Yes":"No"}),e.jsx(Lr,{checked:I,onCheckedChange:L})]})]}),I&&e.jsx(Fe,{value:O,onChange:he=>U(he.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),q&&e.jsx("p",{className:"text-destructive text-sm",children:q}),e.jsxs(K,{onClick:ce,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(ti,{className:"h-5 w-5 ml-2"})]})]}),p==="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:()=>f("info"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ra,{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:T5t.map(he=>e.jsxs("button",{onClick:()=>ae(he.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:he.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:he.label})]},he.value))}),q&&e.jsx("p",{className:"text-destructive text-sm text-center",children:q})]}),p==="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..."})]}),p==="survey"&&y&&V&&e.jsx(C5t,{questions:V,visitorId:y,onComplete:()=>f("done"),onSkip:()=>f("done")}),p==="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(Hn,{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, ",b.first_name,". ",fe?"Enjoy the event!":"Enjoy the open house!"]})]}),(n==null?void 0:n.disclosure_pdf_url)&&e.jsxs("a",{href:`https://docs.google.com/gview?url=${encodeURIComponent(n.disclosure_pdf_url)}&embedded=true`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-5 py-3 rounded-xl bg-slate-100 hover:bg-slate-200 text-slate-800 font-medium text-sm transition-colors",children:[e.jsx(mn,{className:"h-4 w-4"}),"View Seller's Disclosures"]}),(ie==null?void 0:ie.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:ie.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function pEs(t){const{user:s}=$s();return ft({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 fEs(){const t=es(),{user:s}=$s();return Et({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 xEs(){const t=es();return Et({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 A5t(t){return ft({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 dNe="ScrollArea",[dKe]=bd(dNe),[P5t,Fx]=dKe(dNe),uKe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,d]=k.useState(null),[u,p]=k.useState(null),[f,y]=k.useState(null),[_,b]=k.useState(null),[N,w]=k.useState(null),[S,C]=k.useState(0),[A,I]=k.useState(0),[L,O]=k.useState(!1),[U,q]=k.useState(!1),$=Ma(s,ee=>d(ee)),V=xw(a);return e.jsx(P5t,{scope:r,type:n,dir:V,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:p,content:f,onContentChange:y,scrollbarX:_,onScrollbarXChange:b,scrollbarXEnabled:L,onScrollbarXEnabledChange:O,scrollbarY:N,onScrollbarYChange:w,scrollbarYEnabled:U,onScrollbarYEnabledChange:q,onCornerWidthChange:C,onCornerHeightChange:I,children:e.jsx(dn.div,{dir:V,...l,ref:$,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":A+"px",...t.style}})})});uKe.displayName=dNe;var hKe="ScrollAreaViewport",mKe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=Fx(hKe,r),i=k.useRef(null),d=Ma(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(dn.div,{"data-radix-scroll-area-viewport":"",...o,ref:d,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...t.style},children:e.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});mKe.displayName=hKe;var w0="ScrollAreaScrollbar",uNe=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Fx(w0,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return k.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(I5t,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(L5t,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(pKe,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(hNe,{...n,ref:s}):null});uNe.displayName=w0;var I5t=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Fx(w0,t.__scopeScrollArea),[o,l]=k.useState(!1);return k.useEffect(()=>{const i=a.scrollArea;let d=0;if(i){const u=()=>{window.clearTimeout(d),l(!0)},p=()=>{d=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",u),i.addEventListener("pointerleave",p),()=>{window.clearTimeout(d),i.removeEventListener("pointerenter",u),i.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(wd,{present:r||o,children:e.jsx(pKe,{"data-state":o?"visible":"hidden",...n,ref:s})})}),L5t=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Fx(w0,t.__scopeScrollArea),o=t.orientation==="horizontal",l=Bue(()=>d("SCROLL_END"),100),[i,d]=E5t("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return k.useEffect(()=>{if(i==="idle"){const u=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,d]),k.useEffect(()=>{const u=a.viewport,p=o?"scrollLeft":"scrollTop";if(u){let f=u[p];const y=()=>{const _=u[p];f!==_&&(d("SCROLL"),l()),f=_};return u.addEventListener("scroll",y),()=>u.removeEventListener("scroll",y)}},[a.viewport,o,d,l]),e.jsx(wd,{present:r||i!=="hidden",children:e.jsx(hNe,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Tr(t.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Tr(t.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),pKe=k.forwardRef((t,s)=>{const r=Fx(w0,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=k.useState(!1),i=t.orientation==="horizontal",d=Bue(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=Fx(w0,t.__scopeScrollArea),o=k.useRef(null),l=k.useRef(0),[i,d]=k.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=vKe(i.viewport,i.content),p={...n,sizes:i,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:y=>o.current=y,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:y=>l.current=y};function f(y,_){return B5t(y,l.current,i,_)}return r==="horizontal"?e.jsx(D5t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const y=a.viewport.scrollLeft,_=EIe(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(R5t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const y=a.viewport.scrollTop,_=EIe(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}),D5t=k.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Fx(w0,t.__scopeScrollArea),[l,i]=k.useState(),d=k.useRef(null),u=Ma(s,d,o.onScrollbarXChange);return k.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(xKe,{"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":zue(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),bKe(y,f)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:ile(l.paddingLeft),paddingEnd:ile(l.paddingRight)}})}})}),R5t=k.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Fx(w0,t.__scopeScrollArea),[l,i]=k.useState(),d=k.useRef(null),u=Ma(s,d,o.onScrollbarYChange);return k.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(xKe,{"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":zue(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),bKe(y,f)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:ile(l.paddingTop),paddingEnd:ile(l.paddingBottom)}})}})}),[O5t,fKe]=dKe(w0),xKe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:p,onResize:f,...y}=t,_=Fx(w0,r),[b,N]=k.useState(null),w=Ma(s,$=>N($)),S=k.useRef(null),C=k.useRef(""),A=_.viewport,I=n.content-n.viewport,L=ed(p),O=ed(d),U=Bue(f,10);function q($){if(S.current){const V=$.clientX-S.current.left,ee=$.clientY-S.current.top;u({x:V,y:ee})}}return k.useEffect(()=>{const $=V=>{const ee=V.target;(b==null?void 0:b.contains(ee))&&L(V,I)};return document.addEventListener("wheel",$,{passive:!1}),()=>document.removeEventListener("wheel",$,{passive:!1})},[A,b,I,L]),k.useEffect(O,[n,O]),OT(b,U),OT(_.content,U),e.jsx(O5t,{scope:r,scrollbar:b,hasThumb:a,onThumbChange:ed(o),onThumbPointerUp:ed(l),onThumbPositionChange:O,onThumbPointerDown:ed(i),children:e.jsx(dn.div,{...y,ref:w,style:{position:"absolute",...y.style},onPointerDown:Tr(t.onPointerDown,$=>{$.button===0&&($.target.setPointerCapture($.pointerId),S.current=b.getBoundingClientRect(),C.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",_.viewport&&(_.viewport.style.scrollBehavior="auto"),q($))}),onPointerMove:Tr(t.onPointerMove,q),onPointerUp:Tr(t.onPointerUp,$=>{const V=$.target;V.hasPointerCapture($.pointerId)&&V.releasePointerCapture($.pointerId),document.body.style.webkitUserSelect=C.current,_.viewport&&(_.viewport.style.scrollBehavior=""),S.current=null})})})}),ale="ScrollAreaThumb",gKe=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=fKe(ale,t.__scopeScrollArea);return e.jsx(wd,{present:r||a.hasThumb,children:e.jsx(F5t,{ref:s,...n})})}),F5t=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=Fx(ale,r),l=fKe(ale,r),{onThumbPositionChange:i}=l,d=Ma(s,f=>l.onThumbChange(f)),u=k.useRef(void 0),p=Bue(()=>{u.current&&(u.current(),u.current=void 0)},100);return k.useEffect(()=>{const f=o.viewport;if(f){const y=()=>{if(p(),!u.current){const _=$5t(f,i);u.current=_,i()}};return i(),f.addEventListener("scroll",y),()=>f.removeEventListener("scroll",y)}},[o.viewport,p,i]),e.jsx(dn.div,{"data-state":l.hasThumb?"visible":"hidden",...a,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Tr(t.onPointerDownCapture,f=>{const _=f.target.getBoundingClientRect(),b=f.clientX-_.left,N=f.clientY-_.top;l.onThumbPointerDown({x:b,y:N})}),onPointerUp:Tr(t.onPointerUp,l.onThumbPointerUp)})});gKe.displayName=ale;var mNe="ScrollAreaCorner",yKe=k.forwardRef((t,s)=>{const r=Fx(mNe,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(z5t,{...t,ref:s}):null});yKe.displayName=mNe;var z5t=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=Fx(mNe,r),[o,l]=k.useState(0),[i,d]=k.useState(0),u=!!(o&&i);return OT(a.scrollbarX,()=>{var f;const p=((f=a.scrollbarX)==null?void 0:f.offsetHeight)||0;a.onCornerHeightChange(p),d(p)}),OT(a.scrollbarY,()=>{var f;const p=((f=a.scrollbarY)==null?void 0:f.offsetWidth)||0;a.onCornerWidthChange(p),l(p)}),u?e.jsx(dn.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 ile(t){return t?parseInt(t,10):0}function vKe(t,s){const r=t/s;return isNaN(r)?0:r}function zue(t){const s=vKe(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function B5t(t,s,r,n="ltr"){const a=zue(r),o=a/2,l=s||o,i=a-l,d=r.scrollbar.paddingStart+l,u=r.scrollbar.size-r.scrollbar.paddingEnd-i,p=r.content-r.viewport,f=n==="ltr"?[0,p]:[p*-1,0];return _Ke([d,u],f)(t)}function EIe(t,s,r="ltr"){const n=zue(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,o=s.scrollbar.size-a,l=s.content-s.viewport,i=o-n,d=r==="ltr"?[0,l]:[l*-1,0],u=nD(t,d);return _Ke([0,l],[0,i])(u)}function _Ke(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 bKe(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 Bue(t,s){const r=ed(t),n=k.useRef(0);return k.useEffect(()=>()=>window.clearTimeout(n.current),[]),k.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function OT(t,s){const r=ed(s);rd(()=>{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 wKe=uKe,q5t=mKe,U5t=yKe;const di=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(wKe,{ref:n,className:Rt("relative overflow-hidden",t),...r,children:[e.jsx(q5t,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx($ue,{}),e.jsx(U5t,{})]}));di.displayName=wKe.displayName;const $ue=k.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(uNe,{ref:n,orientation:s,className:Rt("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(gKe,{className:"relative flex-1 rounded-full bg-border"})}));$ue.displayName=uNe.displayName;const pNe=k.createContext({});function fNe(t){const s=k.useRef(null);return s.current===null&&(s.current=t()),s.current}const V5t=typeof window<"u",jKe=V5t?k.useLayoutEffect:k.useEffect,que=k.createContext(null);function xNe(t,s){t.indexOf(s)===-1&&t.push(s)}function ole(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const h0=(t,s,r)=>r>s?s:r{};const rw={},NKe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function kKe(t){return typeof t=="object"&&t!==null}const SKe=t=>/^0[^.\s]+$/u.test(t);function CKe(t){let s;return()=>(s===void 0&&(s=t()),s)}const kx=t=>t,H5t=(t,s)=>r=>s(t(r)),qR=(...t)=>t.reduce(H5t),oD=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class yNe{constructor(){this.subscriptions=[]}add(s){return xNe(this.subscriptions,s),()=>ole(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,xx=t=>t/1e3;function MKe(t,s){return s?t*(1e3/s):0}const TKe=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,G5t=1e-7,W5t=12;function K5t(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=TKe(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>G5t&&++iK5t(o,0,1,t,r);return o=>o===0||o===1?o:TKe(a(o),s,n)}const AKe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,EKe=t=>s=>1-t(1-s),PKe=UR(.33,1.53,.69,.99),vNe=EKe(PKe),IKe=AKe(vNe),LKe=t=>t>=1?1:(t*=2)<1?.5*vNe(t):.5*(2-Math.pow(2,-10*(t-1))),_Ne=t=>1-Math.sin(Math.acos(t)),DKe=EKe(_Ne),RKe=AKe(_Ne),Z5t=UR(.42,0,1,1),Y5t=UR(0,0,.58,1),OKe=UR(.42,0,.58,1),X5t=t=>Array.isArray(t)&&typeof t[0]!="number",FKe=t=>Array.isArray(t)&&typeof t[0]=="number",Q5t={linear:kx,easeIn:Z5t,easeInOut:OKe,easeOut:Y5t,circIn:_Ne,circInOut:RKe,circOut:DKe,backIn:vNe,backInOut:IKe,backOut:PKe,anticipate:LKe},J5t=t=>typeof t=="string",PIe=t=>{if(FKe(t)){gNe(t.length===4);const[s,r,n,a]=t;return UR(s,r,n,a)}else if(J5t(t))return Q5t[t];return t},Ez=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function eMt(t,s){let r=new Set,n=new Set,a=!1,o=!1;const l=new WeakSet;let i={delta:0,timestamp:0,isProcessing:!1};function d(p){l.has(p)&&(u.schedule(p),t()),p(i)}const u={schedule:(p,f=!1,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(d),r.clear(),a=!1,o&&(o=!1,u.process(p))}};return u}const tMt=40;function zKe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=Ez.reduce((A,I)=>(A[I]=eMt(o),A),{}),{setup:i,read:d,resolveKeyframes:u,preUpdate:p,update:f,preRender:y,render:_,postRender:b}=l,N=()=>{const A=rw.useManualTiming,I=A?a.timestamp:performance.now();r=!1,A||(a.delta=n?1e3/60:Math.max(Math.min(I-a.timestamp,tMt),1)),a.timestamp=I,a.isProcessing=!0,i.process(a),d.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(N))},w=()=>{r=!0,n=!0,a.isProcessing||t(N)};return{schedule:Ez.reduce((A,I)=>{const L=l[I];return A[I]=(O,U=!1,q=!1)=>(r||w(),L.schedule(O,U,q)),A},{}),cancel:A=>{for(let I=0;I(Vie===void 0&&fm.set(Ju.isProcessing||rw.useManualTiming?Ju.timestamp:performance.now()),Vie),set:t=>{Vie=t,queueMicrotask(sMt)}},BKe=t=>s=>typeof s=="string"&&s.startsWith(t),$Ke=BKe("--"),rMt=BKe("var(--"),bNe=t=>rMt(t)?nMt.test(t.split("/*")[0].trim()):!1,nMt=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function IIe(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const GA={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},lD={...GA,transform:t=>h0(0,1,t)},Pz={...GA,default:1},e8=t=>Math.round(t*1e5)/1e5,wNe=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function aMt(t){return t==null}const iMt=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,jNe=(t,s)=>r=>!!(typeof r=="string"&&iMt.test(r)&&r.startsWith(t)||s&&!aMt(r)&&Object.prototype.hasOwnProperty.call(r,s)),qKe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(wNe);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},oMt=t=>h0(0,255,t),jge={...GA,transform:t=>Math.round(oMt(t))},_4={test:jNe("rgb","red"),parse:qKe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+jge.transform(t)+", "+jge.transform(s)+", "+jge.transform(r)+", "+e8(lD.transform(n))+")"};function lMt(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 I1e={test:jNe("#"),parse:lMt,transform:_4.transform},VR=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),A_=VR("deg"),o0=VR("%"),ra=VR("px"),cMt=VR("vh"),dMt=VR("vw"),LIe={...o0,parse:t=>o0.parse(t)/100,transform:t=>o0.transform(t*100)},sM={test:jNe("hsl","hue"),parse:qKe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+o0.transform(e8(s))+", "+o0.transform(e8(r))+", "+e8(lD.transform(n))+")"},Id={test:t=>_4.test(t)||I1e.test(t)||sM.test(t),parse:t=>_4.test(t)?_4.parse(t):sM.test(t)?sM.parse(t):I1e.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?_4.transform(t):sM.transform(t),getAnimatableNone:t=>{const s=Id.parse(t);return s.alpha=0,Id.transform(s)}},uMt=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function hMt(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(wNe))==null?void 0:s.length)||0)+(((r=t.match(uMt))==null?void 0:r.length)||0)>0}const UKe="number",VKe="color",mMt="var",pMt="var(",DIe="${}",fMt=/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 FT(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace(fMt,d=>(Id.test(d)?(n.color.push(o),a.push(VKe),r.push(Id.parse(d))):d.startsWith(pMt)?(n.var.push(o),a.push(mMt),r.push(d)):(n.number.push(o),a.push(UKe),r.push(parseFloat(d))),++o,DIe)).split(DIe);return{values:r,split:i,indexes:n,types:a}}function xMt(t){return FT(t).values}function HKe({split:t,types:s}){const r=t.length;return n=>{let a="";for(let o=0;otypeof t=="number"?0:Id.test(t)?Id.getAnimatableNone(t):t,vMt=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:yMt(t);function _Mt(t){const s=FT(t);return HKe(s)(s.values.map((n,a)=>vMt(n,s.split[a])))}const Fg={test:hMt,parse:xMt,createTransformer:gMt,getAnimatableNone:_Mt};function Nge(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 bMt({hue:t,saturation:s,lightness:r,alpha:n}){t/=360,s/=100,r/=100;let a=0,o=0,l=0;if(!s)a=o=l=r;else{const i=r<.5?r*(1+s):r+s-r*s,d=2*r-i;a=Nge(d,i,t+1/3),o=Nge(d,i,t),l=Nge(d,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function lle(t,s){return r=>r>0?s:t}const tc=(t,s,r)=>t+(s-t)*r,kge=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},wMt=[I1e,_4,sM],jMt=t=>wMt.find(s=>s.test(t));function RIe(t){const s=jMt(t);if(!s)return!1;let r=s.parse(t);return s===sM&&(r=bMt(r)),r}const OIe=(t,s)=>{const r=RIe(t),n=RIe(s);if(!r||!n)return lle(t,s);const a={...r};return o=>(a.red=kge(r.red,n.red,o),a.green=kge(r.green,n.green,o),a.blue=kge(r.blue,n.blue,o),a.alpha=tc(r.alpha,n.alpha,o),_4.transform(a))},L1e=new Set(["none","hidden"]);function NMt(t,s){return L1e.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function kMt(t,s){return r=>tc(t,s,r)}function NNe(t){return typeof t=="number"?kMt:typeof t=="string"?bNe(t)?lle:Id.test(t)?OIe:MMt:Array.isArray(t)?GKe:typeof t=="object"?Id.test(t)?OIe:SMt:lle}function GKe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>NNe(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function CMt(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=Fg.createTransformer(s),n=FT(t),a=FT(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?L1e.has(t)&&!a.values.length||L1e.has(s)&&!n.values.length?NMt(t,s):qR(GKe(CMt(n,a),a.values),r):lle(t,s)};function WKe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?tc(t,s,r):NNe(t)(t,s)}const TMt=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>ml.update(s,r),stop:()=>nw(s),now:()=>Ju.isProcessing?Ju.timestamp:fm.now()}},KKe=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=cle?1/0:s}function AMt(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(kNe(n),cle);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:xx(a)}}const Wc={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 D1e(t,s){return t*Math.sqrt(1-s*s)}const EMt=12;function PMt(t,s,r){let n=r;for(let a=1;a{const p=u*l,f=p*t,y=p-r,_=D1e(u,l),b=Math.exp(-f);return Sge-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),N=D1e(Math.pow(u,2),l);return(-a(u)+Sge>0?-1:1)*((y-_)*b)/N}):(a=u=>{const p=Math.exp(-u*t),f=(u-r)*t+1;return-Sge+p*f},o=u=>{const p=Math.exp(-u*t),f=(r-u)*(t*t);return p*f});const i=5/t,d=PMt(a,o,i);if(t=df(t),isNaN(d))return{stiffness:Wc.stiffness,damping:Wc.damping,duration:t};{const u=Math.pow(d,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const LMt=["duration","bounce"],DMt=["stiffness","damping","mass"];function FIe(t,s){return s.some(r=>t[r]!==void 0)}function RMt(t){let s={velocity:Wc.velocity,stiffness:Wc.stiffness,damping:Wc.damping,mass:Wc.mass,isResolvedFromDuration:!1,...t};if(!FIe(t,DMt)&&FIe(t,LMt))if(s.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),a=n*n,o=2*h0(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:Wc.mass,stiffness:a,damping:o}}else{const r=IMt({...t,velocity:0});s={...s,...r,mass:Wc.mass},s.isResolvedFromDuration=!0}return s}function dle(t=Wc.visualDuration,s=Wc.bounce){const r=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:s}:t;let{restSpeed:n,restDelta:a}=r;const o=r.keyframes[0],l=r.keyframes[r.keyframes.length-1],i={done:!1,value:o},{stiffness:d,damping:u,mass:p,duration:f,velocity:y,isResolvedFromDuration:_}=RMt({...r,velocity:-xx(r.velocity||0)}),b=y||0,N=u/(2*Math.sqrt(d*p)),w=l-o,S=xx(Math.sqrt(d/p)),C=Math.abs(w)<5;n||(n=C?Wc.restSpeed.granular:Wc.restSpeed.default),a||(a=C?Wc.restDelta.granular:Wc.restDelta.default);let A,I,L,O,U,q;if(N<1)L=D1e(S,N),O=(b+N*S*w)/L,A=V=>{const ee=Math.exp(-N*S*V);return l-ee*(O*Math.sin(L*V)+w*Math.cos(L*V))},U=N*S*O+w*L,q=N*S*w-O*L,I=V=>Math.exp(-N*S*V)*(U*Math.sin(L*V)+q*Math.cos(L*V));else if(N===1){A=ee=>l-Math.exp(-S*ee)*(w+(b+S*w)*ee);const V=b+S*w;I=ee=>Math.exp(-S*ee)*(S*V*ee-b)}else{const V=S*Math.sqrt(N*N-1);A=Y=>{const ce=Math.exp(-N*S*Y),ae=Math.min(V*Y,300);return l-ce*((b+N*S*w)*Math.sinh(ae)+V*w*Math.cosh(ae))/V};const ee=(b+N*S*w)/V,Z=N*S*ee-w*V,J=N*S*w-ee*V;I=Y=>{const ce=Math.exp(-N*S*Y),ae=Math.min(V*Y,300);return ce*(Z*Math.sinh(ae)+J*Math.cosh(ae))}}const $={calculatedDuration:_&&f||null,velocity:V=>df(I(V)),next:V=>{if(!_&&N<1){const Z=Math.exp(-N*S*V),J=Math.sin(L*V),Y=Math.cos(L*V),ce=l-Z*(O*J+w*Y),ae=df(Z*(U*J+q*Y));return i.done=Math.abs(ae)<=n&&Math.abs(l-ce)<=a,i.value=i.done?l:ce,i}const ee=A(V);if(_)i.done=V>=f;else{const Z=df(I(V));i.done=Math.abs(Z)<=n&&Math.abs(l-ee)<=a}return i.value=i.done?l:ee,i},toString:()=>{const V=Math.min(kNe($),cle),ee=KKe(Z=>$.next(V*Z).value,V,30);return V+"ms "+ee},toTransition:()=>{}};return $}dle.applyToOptions=t=>{const s=AMt(t,100,dle);return t.ease=s.ease,t.duration=df(s.duration),t.type="keyframes",t};const OMt=5;function ZKe(t,s,r){const n=Math.max(s-OMt,0);return MKe(r-t(n),s-n)}function R1e({keyframes:t,velocity:s=0,power:r=.8,timeConstant:n=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:l,min:i,max:d,restDelta:u=.5,restSpeed:p}){const f=t[0],y={done:!1,value:f},_=q=>i!==void 0&&qd,b=q=>i===void 0?d:d===void 0||Math.abs(i-q)-N*Math.exp(-q/n),A=q=>S+C(q),I=q=>{const $=C(q),V=A(q);y.done=Math.abs($)<=u,y.value=y.done?S:V};let L,O;const U=q=>{_(y.value)&&(L=q,O=dle({keyframes:[y.value,b(y.value)],velocity:ZKe(A,q,y.value),damping:a,stiffness:o,restDelta:u,restSpeed:p}))};return U(0),{calculatedDuration:null,next:q=>{let $=!1;return!O&&L===void 0&&($=!0,I(q),U(q)),L!==void 0&&q>=L?O.next(q-L):(!$&&I(q),y)}}}function FMt(t,s,r){const n=[],a=r||rw.mix||WKe,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=FMt(s,n,a),d=i.length,u=p=>{if(l&&p1)for(;fu(h0(t[0],t[o-1],p)):u}function BMt(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=oD(0,s,n);t.push(tc(r,1,a))}}function $Mt(t){const s=[0];return BMt(s,t.length-1),s}function qMt(t,s){return t.map(r=>r*s)}function UMt(t,s){return t.map(()=>s||OKe).splice(0,t.length-1)}function t8({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=X5t(n)?n.map(PIe):PIe(n),o={done:!1,value:s[0]},l=qMt(r&&r.length===s.length?r:$Mt(s),t),i=zMt(l,s,{ease:Array.isArray(a)?a:UMt(s,a)});return{calculatedDuration:t,next:d=>(o.value=i(d),o.done=d>=t,o)}}const VMt=t=>t!==null;function Uue(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(VMt),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const HMt={decay:R1e,inertia:R1e,tween:t8,keyframes:t8,spring:dle};function YKe(t){typeof t.type=="string"&&(t.type=HMt[t.type])}class SNe{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 GMt=t=>t/100;class ule extends SNe{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!==fm.now()&&this.tick(fm.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(a=(n=this.options).onStop)==null||a.call(n))},this.options=s,this.initAnimation(),this.play(),s.autoplay===!1&&this.pause()}initAnimation(){const{options:s}=this;YKe(s);const{type:r=t8,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const d=r||t8;d!==t8&&typeof i[0]!="number"&&(this.mixKeyframes=qR(GMt,WKe(i[0],i[1])),i=[0,100]);const u=d({...s,keyframes:i});o==="mirror"&&(this.mirroredGenerator=d({...s,keyframes:[...i].reverse(),velocity:-l})),u.calculatedDuration===null&&(u.calculatedDuration=kNe(u));const{calculatedDuration:p}=u;this.calculatedDuration=p,this.resolvedDuration=p+a,this.totalDuration=this.resolvedDuration*(n+1)-a,this.generator=u}updateTime(s){const r=Math.round(s-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=r}tick(s,r=!1){const{generator:n,totalDuration:a,mixKeyframes:o,mirroredGenerator:l,resolvedDuration:i,calculatedDuration:d}=this;if(this.startTime===null)return n.next(0);const{delay:u=0,keyframes:p,repeat:f,repeatType:y,repeatDelay:_,type:b,onUpdate:N,finalKeyframe:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-a/this.speed,this.startTime)),r?this.currentTime=s:this.updateTime(s);const S=this.currentTime-u*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?S<0:S>a;this.currentTime=Math.max(S,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let A=this.currentTime,I=n;if(f){const q=Math.min(this.currentTime,a)/i;let $=Math.floor(q),V=q%1;!V&&q>=1&&(V=1),V===1&&$--,$=Math.min($,f+1),!!($%2)&&(y==="reverse"?(V=1-V,_&&(V-=_/i)):y==="mirror"&&(I=l)),A=h0(0,1,V)*i}let L;C?(this.delayState.value=p[0],L=this.delayState):L=I.next(A),o&&!C&&(L.value=o(L.value));let{done:O}=L;!C&&d!==null&&(O=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const U=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return U&&b!==R1e&&(L.value=Uue(p,this.options,w,this.speed)),N&&N(L.value),U&&this.finish(),L}then(s,r){return this.finished.then(s,r)}get duration(){return xx(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+xx(s)}get time(){return xx(this.currentTime)}set time(s){s=df(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 ZKe(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(fm.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=xx(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=TMt,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(fm.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 WMt(t){for(let s=1;st*180/Math.PI,O1e=t=>{const s=b4(Math.atan2(t[1],t[0]));return F1e(s)},KMt={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:O1e,rotateZ:O1e,skewX:t=>b4(Math.atan(t[1])),skewY:t=>b4(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},F1e=t=>(t=t%360,t<0&&(t+=360),t),zIe=O1e,BIe=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),$Ie=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),ZMt={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:BIe,scaleY:$Ie,scale:t=>(BIe(t)+$Ie(t))/2,rotateX:t=>F1e(b4(Math.atan2(t[6],t[5]))),rotateY:t=>F1e(b4(Math.atan2(-t[2],t[0]))),rotateZ:zIe,rotate:zIe,skewX:t=>b4(Math.atan(t[4])),skewY:t=>b4(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function z1e(t){return t.includes("scale")?1:0}function B1e(t,s){if(!t||t==="none")return z1e(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=ZMt,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=KMt,a=i}if(!a)return z1e(s);const o=n[s],l=a[1].split(",").map(XMt);return typeof o=="function"?o(l):l[o]}const YMt=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return B1e(r,s)};function XMt(t){return parseFloat(t.trim())}const WA=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],KA=new Set(WA),qIe=t=>t===GA||t===ra,QMt=new Set(["x","y","z"]),JMt=WA.filter(t=>!QMt.has(t));function eTt(t){const s=[];return JMt.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const pb={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})=>B1e(s,"x"),y:(t,{transform:s})=>B1e(s,"y")};pb.translateX=pb.x;pb.translateY=pb.y;const SS=new Set;let $1e=!1,q1e=!1,U1e=!1;function XKe(){if(q1e){const t=Array.from(SS).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=eTt(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)})}q1e=!1,$1e=!1,SS.forEach(t=>t.complete(U1e)),SS.clear()}function QKe(){SS.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(q1e=!0)})}function tTt(){U1e=!0,QKe(),XKe(),U1e=!1}class CNe{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?(SS.add(this),$1e||($1e=!0,ml.read(QKe),ml.resolveKeyframes(XKe))):(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])}WMt(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),SS.delete(this)}cancel(){this.state==="scheduled"&&(SS.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const sTt=t=>t.startsWith("--");function JKe(t,s,r){sTt(s)?t.style.setProperty(s,r):t.style[s]=r}const rTt={};function eZe(t,s){const r=CKe(t);return()=>rTt[s]??r()}const nTt=eZe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),tZe=eZe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),L6=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,UIe={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:L6([0,.65,.55,1]),circOut:L6([.55,0,1,.45]),backIn:L6([.31,.01,.66,-.59]),backOut:L6([.33,1.53,.69,.99])};function sZe(t,s){if(t)return typeof t=="function"?tZe()?KKe(t,s):"ease-out":FKe(t)?L6(t):Array.isArray(t)?t.map(r=>sZe(r,s)||UIe.easeOut):UIe[t]}function aTt(t,s,r,{delay:n=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:i="easeOut",times:d}={},u=void 0){const p={[s]:r};d&&(p.offset=d);const f=sZe(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 rZe(t){return typeof t=="function"&&"applyToOptions"in t}function iTt({type:t,...s}){return rZe(t)&&tZe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class nZe extends SNe{constructor(s){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!s)return;const{element:r,name:n,keyframes:a,pseudoElement:o,allowFlatten:l=!1,finalKeyframe:i,onComplete:d}=s;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=s,gNe(typeof s.type!="string");const u=iTt(s);this.animation=aTt(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=Uue(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(p),JKe(r,n,p),this.animation.cancel()}d==null||d(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var s,r;(r=(s=this.animation).finish)==null||r.call(s)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:s}=this;s==="idle"||s==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var r,n,a;const s=(r=this.options)==null?void 0:r.element;!this.isPseudoElement&&(s!=null&&s.isConnected)&&((a=(n=this.animation).commitStyles)==null||a.call(n))}get duration(){var r,n;const s=((n=(r=this.animation.effect)==null?void 0:r.getComputedTiming)==null?void 0:n.call(r).duration)||0;return xx(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+xx(s)}get time(){return xx(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=df(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&&nTt()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),kx):a(this)}}const aZe={anticipate:LKe,backInOut:IKe,circInOut:RKe};function oTt(t){return t in aZe}function lTt(t){typeof t.ease=="string"&&oTt(t.ease)&&(t.ease=aZe[t.ease])}const Cge=10;class cTt extends nZe{constructor(s){lTt(s),YKe(s),super(s),s.startTime!==void 0&&s.autoplay!==!1&&(this.startTime=s.startTime),this.options=s}updateMotionValue(s){const{motionValue:r,onUpdate:n,onComplete:a,element:o,...l}=this.options;if(!r)return;if(s!==void 0){r.set(s);return}const i=new ule({...l,autoplay:!1}),d=Math.max(Cge,fm.now()-this.startTime),u=h0(0,Cge,d-Cge),p=i.sample(d).value,{name:f}=this.options;o&&f&&JKe(o,f,p),r.setWithVelocity(i.sample(Math.max(0,d-u)).value,p,u),i.stop()}}const VIe=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Fg.test(t)||t==="0")&&!t.startsWith("url("));function dTt(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function xTt(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 fTt()&&r&&(iZe.has(r)||pTt.has(r)&&mTt(i))&&(r!=="transform"||!p)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const gTt=40;class yTt extends SNe{constructor({autoplay:s=!0,delay:r=0,type:n="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:l="loop",keyframes:i,name:d,motionValue:u,element:p,...f}){var b;super(),this.stop=()=>{var N,w;this._animation&&(this._animation.stop(),(N=this.stopTimeline)==null||N.call(this)),(w=this.keyframeResolver)==null||w.cancel()},this.createdAt=fm.now();const y={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:d,motionValue:u,element:p,...f},_=(p==null?void 0:p.KeyframeResolver)||CNe;this.keyframeResolver=new _(i,(N,w,S)=>this.onKeyframesResolved(N,w,y,!S),d,u,p),(b=this.keyframeResolver)==null||b.scheduleResolve()}onKeyframesResolved(s,r,n,a){var S,C;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:d,isHandoff:u,onUpdate:p}=n;this.resolvedAt=fm.now();let f=!0;uTt(s,o,l,i)||(f=!1,(rw.instantAnimations||!d)&&(p==null||p(Uue(s,n,r))),s[0]=s[s.length-1],V1e(n),n.repeat=0);const _={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>gTt?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},b=f&&!u&&xTt(_),N=(C=(S=_.motionValue)==null?void 0:S.owner)==null?void 0:C.current;let w;if(b)try{w=new cTt({..._,element:N})}catch{w=new ule(_)}else w=new ule(_);w.finished.then(()=>{this.notifyFinished()}).catch(kx),this.pendingTimeline&&(this.stopTimeline=w.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=w}get finished(){return this._animation?this.animation.finished:this._finished}then(s,r){return this.finished.finally(s).then(()=>{})}get animation(){var s;return this._animation||((s=this.keyframeResolver)==null||s.resume(),tTt()),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 oZe(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 vTt=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function _Tt(t){const s=vTt.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}function lZe(t,s,r=1){const[n,a]=_Tt(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return NKe(l)?parseFloat(l):l}return bNe(a)?lZe(a,s,r+1):a}const bTt={type:"spring",stiffness:500,damping:25,restSpeed:10},wTt=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),jTt={type:"keyframes",duration:.8},NTt={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},kTt=(t,{keyframes:s})=>s.length>2?jTt:KA.has(t)?t.startsWith("scale")?wTt(s[1]):bTt:NTt;function cZe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function MNe(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?cZe(r,t):r}const STt=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function CTt(t){for(const s in t)if(!STt.has(s))return!0;return!1}const TNe=(t,s,r,n={},a,o)=>l=>{const i=MNe(n,t)||{},d=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-df(d);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};CTt(i)||Object.assign(p,kTt(t,p)),p.duration&&(p.duration=df(p.duration)),p.repeatDelay&&(p.repeatDelay=df(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let f=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(V1e(p),p.delay===0&&(f=!0)),(rw.instantAnimations||rw.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(f=!0,V1e(p),p.delay=0),p.allowFlatten=!i.type&&!i.ease,f&&!o&&s.get()!==void 0){const y=Uue(p.keyframes,i);if(y!==void 0){ml.update(()=>{p.onUpdate(y),p.onComplete()});return}}return i.isSync?new ule(p):new yTt(p)};function HIe(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function ANe(t,s,r,n){if(typeof s=="function"){const[a,o]=HIe(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]=HIe(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function CS(t,s,r){const n=t.getProps();return ANe(n,s,r!==void 0?r:n.custom,t)}const dZe=new Set(["width","height","top","left","right","bottom",...WA]),GIe=30,MTt=t=>!isNaN(parseFloat(t));class TTt{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=fm.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=fm.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=MTt(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 yNe);const n=this.events[s].add(r);return s==="change"?()=>{n(),ml.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=fm.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>GIe)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,GIe);return MKe(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 zT(t,s){return new TTt(t,s)}const H1e=t=>Array.isArray(t);function ATt(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,zT(r))}function ETt(t){return H1e(t)?t[t.length-1]||0:t}function PTt(t,s){const r=CS(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=ETt(o[l]);ATt(t,l,i)}}const rh=t=>!!(t&&t.getVelocity);function ITt(t){return!!(rh(t)&&t.add)}function G1e(t,s){const r=t.getValue("willChange");if(ITt(r))return r.add(s);if(!r&&rw.WillChange){const n=new rw.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function ENe(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const LTt="framerAppearId",uZe="data-"+ENe(LTt);function hZe(t){return t.props[uZe]}function DTt({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function mZe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const d=t.getDefaultTransition();o=o?cZe(o,d):d;const u=o==null?void 0:o.reduceMotion;n&&(o=n);const p=[],f=a&&t.animationState&&t.animationState.getState()[a];for(const y in i){const _=t.getValue(y,t.latestValues[y]??null),b=i[y];if(b===void 0||f&&DTt(f,y))continue;const N={delay:r,...MNe(o||{},y)},w=_.get();if(w!==void 0&&!_.isAnimating()&&!Array.isArray(b)&&b===w&&!N.velocity){ml.update(()=>_.set(b));continue}let S=!1;if(window.MotionHandoffAnimation){const I=hZe(t);if(I){const L=window.MotionHandoffAnimation(I,y,ml);L!==null&&(N.startTime=L,S=!0)}}G1e(t,y);const C=u??t.shouldReduceMotion;_.start(TNe(y,_,b,C&&dZe.has(y)?{type:!1}:N,t,S));const A=_.animation;A&&p.push(A)}if(l){const y=()=>ml.update(()=>{l&&PTt(t,l)});p.length?Promise.all(p).then(y):y()}return p}function W1e(t,s,r={}){var d;const n=CS(t,s,r.type==="exit"?(d=t.presenceContext)==null?void 0:d.custom:void 0);let{transition:a=t.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(a=r.transitionOverride);const o=n?()=>Promise.all(mZe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:p=0,staggerChildren:f,staggerDirection:y}=a;return RTt(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 RTt(t,s,r=0,n=0,a=0,o=1,l){const i=[];for(const d of t.variantChildren)d.notify("AnimationStart",s),i.push(W1e(d,s,{...l,delay:r+(typeof n=="function"?0:n)+oZe(t.variantChildren,d,n,a,o)}).then(()=>d.notify("AnimationComplete",s)));return Promise.all(i)}function OTt(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>W1e(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=W1e(t,s,r);else{const a=typeof s=="function"?CS(t,s,r.custom):s;n=Promise.all(mZe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const FTt={test:t=>t==="auto",parse:t=>t},pZe=t=>s=>s.test(t),fZe=[GA,ra,o0,A_,dMt,cMt,FTt],WIe=t=>fZe.find(pZe(t));function zTt(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||SKe(t):!0}const BTt=new Set(["brightness","contrast","saturate","opacity"]);function $Tt(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(wNe)||[];if(!n)return t;const a=r.replace(n,"");let o=BTt.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const qTt=/\b([a-z-]*)\(.*?\)/gu,K1e={...Fg,getAnimatableNone:t=>{const s=t.match(qTt);return s?s.map($Tt).join(" "):t}},Z1e={...Fg,getAnimatableNone:t=>{const s=Fg.parse(t);return Fg.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},KIe={...GA,transform:Math.round},UTt={rotate:A_,rotateX:A_,rotateY:A_,rotateZ:A_,scale:Pz,scaleX:Pz,scaleY:Pz,scaleZ:Pz,skew:A_,skewX:A_,skewY:A_,distance:ra,translateX:ra,translateY:ra,translateZ:ra,x:ra,y:ra,z:ra,perspective:ra,transformPerspective:ra,opacity:lD,originX:LIe,originY:LIe,originZ:ra},PNe={borderWidth:ra,borderTopWidth:ra,borderRightWidth:ra,borderBottomWidth:ra,borderLeftWidth:ra,borderRadius:ra,borderTopLeftRadius:ra,borderTopRightRadius:ra,borderBottomRightRadius:ra,borderBottomLeftRadius:ra,width:ra,maxWidth:ra,height:ra,maxHeight:ra,top:ra,right:ra,bottom:ra,left:ra,inset:ra,insetBlock:ra,insetBlockStart:ra,insetBlockEnd:ra,insetInline:ra,insetInlineStart:ra,insetInlineEnd:ra,padding:ra,paddingTop:ra,paddingRight:ra,paddingBottom:ra,paddingLeft:ra,paddingBlock:ra,paddingBlockStart:ra,paddingBlockEnd:ra,paddingInline:ra,paddingInlineStart:ra,paddingInlineEnd:ra,margin:ra,marginTop:ra,marginRight:ra,marginBottom:ra,marginLeft:ra,marginBlock:ra,marginBlockStart:ra,marginBlockEnd:ra,marginInline:ra,marginInlineStart:ra,marginInlineEnd:ra,fontSize:ra,backgroundPositionX:ra,backgroundPositionY:ra,...UTt,zIndex:KIe,fillOpacity:lD,strokeOpacity:lD,numOctaves:KIe},VTt={...PNe,color:Id,backgroundColor:Id,outlineColor:Id,fill:Id,stroke:Id,borderColor:Id,borderTopColor:Id,borderRightColor:Id,borderBottomColor:Id,borderLeftColor:Id,filter:K1e,WebkitFilter:K1e,mask:Z1e,WebkitMask:Z1e},xZe=t=>VTt[t],HTt=new Set([K1e,Z1e]);function gZe(t,s){let r=xZe(t);return HTt.has(r)||(r=Fg),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const GTt=new Set(["auto","none","0"]);function WTt(t,s,r){let n=0,a;for(;n{s.getValue(d).set(u)}),this.resolveNoneKeyframes()}}function INe(t,s,r){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){const a=document.querySelectorAll(t);return a?Array.from(a):[]}return Array.from(t).filter(n=>n!=null)}const yZe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function Hie(t){return kKe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:LNe}=zKe(queueMicrotask,!1),xg={x:!1,y:!1};function vZe(){return xg.x||xg.y}function ZTt(t){return t==="x"||t==="y"?xg[t]?null:(xg[t]=!0,()=>{xg[t]=!1}):xg.x||xg.y?null:(xg.x=xg.y=!0,()=>{xg.x=xg.y=!1})}function _Ze(t,s){const r=INe(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function YTt(t){return!(t.pointerType==="touch"||vZe())}function XTt(t,s,r={}){const[n,a,o]=_Ze(t,r);return n.forEach(l=>{let i=!1,d=!1,u;const p=()=>{l.removeEventListener("pointerleave",b)},f=w=>{u&&(u(w),u=void 0),p()},y=w=>{i=!1,window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),d&&(d=!1,f(w))},_=()=>{i=!0,window.addEventListener("pointerup",y,a),window.addEventListener("pointercancel",y,a)},b=w=>{if(w.pointerType!=="touch"){if(i){d=!0;return}f(w)}},N=w=>{if(!YTt(w))return;d=!1;const S=s(l,w);typeof S=="function"&&(u=S,l.addEventListener("pointerleave",b,a))};l.addEventListener("pointerenter",N,a),l.addEventListener("pointerdown",_,a)}),o}const bZe=(t,s)=>s?t===s?!0:bZe(t,s.parentElement):!1,DNe=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,QTt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function JTt(t){return QTt.has(t.tagName)||t.isContentEditable===!0}const eAt=new Set(["INPUT","SELECT","TEXTAREA"]);function tAt(t){return eAt.has(t.tagName)||t.isContentEditable===!0}const Gie=new WeakSet;function ZIe(t){return s=>{s.key==="Enter"&&t(s)}}function Mge(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const sAt=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=ZIe(()=>{if(Gie.has(r))return;Mge(r,"down");const a=ZIe(()=>{Mge(r,"up")}),o=()=>Mge(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 YIe(t){return DNe(t)&&!vZe()}const XIe=new WeakSet;function rAt(t,s,r={}){const[n,a,o]=_Ze(t,r),l=i=>{const d=i.currentTarget;if(!YIe(i)||XIe.has(i))return;Gie.add(d),r.stopPropagation&&XIe.add(i);const u=s(d,i),p=(_,b)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",y),Gie.has(d)&&Gie.delete(d),YIe(_)&&typeof u=="function"&&u(_,{success:b})},f=_=>{p(_,d===window||d===document||r.useGlobalTarget||bZe(d,_.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),Hie(i)&&(i.addEventListener("focus",u=>sAt(u,a)),!JTt(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function RNe(t){return kKe(t)&&"ownerSVGElement"in t}const Wie=new WeakMap;let E_;const wZe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:RNe(n)&&"getBBox"in n?n.getBBox()[s]:n[r],nAt=wZe("inline","width","offsetWidth"),aAt=wZe("block","height","offsetHeight");function iAt({target:t,borderBoxSize:s}){var r;(r=Wie.get(t))==null||r.forEach(n=>{n(t,{get width(){return nAt(t,s)},get height(){return aAt(t,s)}})})}function oAt(t){t.forEach(iAt)}function lAt(){typeof ResizeObserver>"u"||(E_=new ResizeObserver(oAt))}function cAt(t,s){E_||lAt();const r=INe(t);return r.forEach(n=>{let a=Wie.get(n);a||(a=new Set,Wie.set(n,a)),a.add(s),E_==null||E_.observe(n)}),()=>{r.forEach(n=>{const a=Wie.get(n);a==null||a.delete(s),a!=null&&a.size||E_==null||E_.unobserve(n)})}}const Kie=new Set;let rM;function dAt(){rM=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Kie.forEach(s=>s(t))},window.addEventListener("resize",rM)}function uAt(t){return Kie.add(t),rM||dAt(),()=>{Kie.delete(t),!Kie.size&&typeof rM=="function"&&(window.removeEventListener("resize",rM),rM=void 0)}}function QIe(t,s){return typeof t=="function"?uAt(t):cAt(t,s)}function hAt(t){return RNe(t)&&t.tagName==="svg"}const mAt=[...fZe,Id,Fg],pAt=t=>mAt.find(pZe(t)),JIe=()=>({translate:0,scale:1,origin:0,originPoint:0}),nM=()=>({x:JIe(),y:JIe()}),e6e=()=>({min:0,max:0}),eu=()=>({x:e6e(),y:e6e()}),fAt=new WeakMap;function Vue(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function cD(t){return typeof t=="string"||Array.isArray(t)}const ONe=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],FNe=["initial",...ONe];function Hue(t){return Vue(t.animate)||FNe.some(s=>cD(t[s]))}function jZe(t){return!!(Hue(t)||t.variants)}function xAt(t,s,r){for(const n in s){const a=s[n],o=r[n];if(rh(a))t.addValue(n,a);else if(rh(o))t.addValue(n,zT(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,zT(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const Y1e={current:null},NZe={current:!1},gAt=typeof window<"u";function yAt(){if(NZe.current=!0,!!gAt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>Y1e.current=t.matches;t.addEventListener("change",s),s()}else Y1e.current=!1}const t6e=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let hle={};function kZe(t){hle=t}function vAt(){return hle}class _At{scrapeMotionValuesFromProps(s,r,n){return{}}constructor({parent:s,props:r,presenceContext:n,reducedMotionConfig:a,skipAnimations:o,blockInitialAnimation:l,visualState:i},d={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=CNe,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 _=fm.now();this.renderScheduledAt<_&&(this.renderScheduledAt=_,ml.render(this.render,!1,!0))};const{latestValues:u,renderState:p}=i;this.latestValues=u,this.baseTarget={...u},this.initialValues=r.initial?{...u}:{},this.renderState=p,this.parent=s,this.props=r,this.presenceContext=n,this.depth=s?s.depth+1:0,this.reducedMotionConfig=a,this.skipAnimationsConfig=o,this.options=d,this.blockInitialAnimation=!!l,this.isControllingVariants=Hue(r),this.isVariantNode=jZe(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&&rh(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,fAt.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:(NZe.current||yAt(),this.shouldReduceMotion=Y1e.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(),nw(this.notifyUpdate),nw(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&&iZe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:d,ease:u,duration:p}=r.accelerate,f=new nZe({element:this.current,name:s,keyframes:i,times:d,ease:u,duration:df(p)}),y=l(f);this.valueSubscriptions.set(s,()=>{y(),f.cancel()});return}const n=KA.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&ml.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 hle){const r=hle[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):eu()}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=zT(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"&&(NKe(n)||SKe(n))?n=parseFloat(n):!pAt(n)&&Fg.test(r)&&(n=gZe(s,r)),this.setBaseTarget(s,rh(n)?n.get():n)),rh(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=ANe(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&&!rh(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 yNe),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){LNe.render(this.render)}}class SZe extends _At{constructor(){super(...arguments),this.KeyframeResolver=KTt}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;rh(s)&&(this.childSubscription=s.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class bw{constructor(s){this.isMounted=!1,this.node=s}update(){}}function CZe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function bAt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function wAt(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 Tge(t){return t===void 0||t===1}function X1e({scale:t,scaleX:s,scaleY:r}){return!Tge(t)||!Tge(s)||!Tge(r)}function i4(t){return X1e(t)||MZe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function MZe(t){return s6e(t.x)||s6e(t.y)}function s6e(t){return t&&t!=="0%"}function mle(t,s,r){const n=t-r,a=s*n;return r+a}function r6e(t,s,r,n,a){return a!==void 0&&(t=mle(t,a,n)),mle(t,r,n)+s}function Q1e(t,s=0,r=1,n,a){t.min=r6e(t.min,s,r,n,a),t.max=r6e(t.max,s,r,n,a)}function TZe(t,{x:s,y:r}){Q1e(t.x,s.translate,s.scale,s.originPoint),Q1e(t.y,r.translate,r.scale,r.originPoint)}const n6e=.999999999999,a6e=1.0000000000001;function jAt(t,s,r,n=!1){var i;const a=r.length;if(!a)return;s.x=s.y=1;let o,l;for(let d=0;dn6e&&(s.x=1),s.yn6e&&(s.y=1)}function Oy(t,s){t.min+=s,t.max+=s}function i6e(t,s,r,n,a=.5){const o=tc(t.min,t.max,a);Q1e(t,s,r,o,n)}function o6e(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function Zie(t,s,r){const n=r??t;i6e(t.x,o6e(s.x,n.x),s.scaleX,s.scale,s.originX),i6e(t.y,o6e(s.y,n.y),s.scaleY,s.scale,s.originY)}function AZe(t,s){return CZe(wAt(t.getBoundingClientRect(),s))}function NAt(t,s,r){const n=AZe(t,r),{scroll:a}=s;return a&&(Oy(n.x,a.offset.x),Oy(n.y,a.offset.y)),n}const kAt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},SAt=WA.length;function CAt(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(ra.test(t))t=parseFloat(t);else return t;const r=l6e(t,s.target.x),n=l6e(t,s.target.y);return`${r}% ${n}%`}},MAt={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=Fg.parse(t);if(a.length>5)return n;const o=Fg.createTransformer(t),l=typeof a[0]!="number"?1:0,i=r.x.scale*s.x,d=r.y.scale*s.y;a[0+l]/=i,a[1+l]/=d;const u=tc(i,d,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},J1e={borderRadius:{...t6,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:t6,borderTopRightRadius:t6,borderBottomLeftRadius:t6,borderBottomRightRadius:t6,boxShadow:MAt};function PZe(t,{layout:s,layoutId:r}){return KA.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!J1e[t]||t==="opacity")}function BNe(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)(rh(n[i])||a&&rh(a[i])||PZe(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function TAt(t){return window.getComputedStyle(t)}class AAt extends SZe{constructor(){super(...arguments),this.type="html",this.renderInstance=EZe}readValueFromInstance(s,r){var n;if(KA.has(r))return(n=this.projection)!=null&&n.isProjecting?z1e(r):YMt(s,r);{const a=TAt(s),o=($Ke(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return AZe(s,r)}build(s,r,n){zNe(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return BNe(s,r,n)}}const EAt={offset:"stroke-dashoffset",array:"stroke-dasharray"},PAt={offset:"strokeDashoffset",array:"strokeDasharray"};function IAt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?EAt:PAt;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const LAt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function IZe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},d,u,p){if(zNe(t,i,u),d){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 LAt)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&&IAt(f,a,o,l,!1)}const LZe=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"]),DZe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function DAt(t,s,r,n){EZe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(LZe.has(a)?a:ENe(a),s.attrs[a])}function RZe(t,s,r){const n=BNe(t,s,r);for(const a in t)if(rh(t[a])||rh(s[a])){const o=WA.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class RAt extends SZe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=eu}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(KA.has(r)){const n=xZe(r);return n&&n.default||0}return r=LZe.has(r)?r:ENe(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return RZe(s,r,n)}build(s,r,n){IZe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){DAt(s,r,n,a)}mount(s){this.isSVGTag=DZe(s.tagName),super.mount(s)}}const OAt=FNe.length;function OZe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?OZe(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})=>OTt(t,r,n)))}function $At(t){let s=BAt(t),r=c6e(),n=!0,a=!1;const o=u=>(p,f)=>{var _;const y=CS(t,f,u==="exit"?(_=t.presenceContext)==null?void 0:_.custom:void 0);if(y){const{transition:b,transitionEnd:N,...w}=y;p={...p,...w,...N}}return p};function l(u){s=u(t)}function i(u){const{props:p}=t,f=OZe(t.parent)||{},y=[],_=new Set;let b={},N=1/0;for(let S=0;SN&&L,V=!1;const ee=Array.isArray(I)?I:[I];let Z=ee.reduce(o(C),{});O===!1&&(Z={});const{prevResolvedValues:J={}}=A,Y={...J,...Z},ce=le=>{$=!0,_.has(le)&&(V=!0,_.delete(le)),A.needsAnimating[le]=!0;const fe=t.getValue(le);fe&&(fe.liveStyle=!1)};for(const le in Y){const fe=Z[le],xe=J[le];if(b.hasOwnProperty(le))continue;let he=!1;H1e(fe)&&H1e(xe)?he=!FZe(fe,xe):he=fe!==xe,he?fe!=null?ce(le):_.add(le):fe!==void 0&&_.has(le)?ce(le):A.protectedKeys[le]=!0}A.prevProp=I,A.prevResolvedValues=Z,A.isActive&&(b={...b,...Z}),(n||a)&&t.blockInitialAnimation&&($=!1);const ae=U&&q;$&&(!ae||V)&&y.push(...ee.map(le=>{const fe={type:C};if(typeof le=="string"&&(n||a)&&!ae&&t.manuallyAnimateOnMount&&t.parent){const{parent:xe}=t,he=CS(xe,le);if(xe.enteringChildren&&he){const{delayChildren:we}=he.transition||{};fe.delay=oZe(xe.enteringChildren,t,we)}}return{animation:le,options:fe}}))}if(_.size){const S={};if(typeof p.initial!="boolean"){const C=CS(t,Array.isArray(p.initial)?p.initial[0]:p.initial);C&&C.transition&&(S.transition=C.transition)}_.forEach(C=>{const A=t.getBaseTarget(C),I=t.getValue(C);I&&(I.liveStyle=!0),S[C]=A??null}),y.push({animation:S})}let w=!!y.length;return n&&(p.initial===!1||p.initial===p.animate)&&!t.manuallyAnimateOnMount&&(w=!1),n=!1,a=!1,w?s(y):Promise.resolve()}function d(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:d,setAnimateFunction:l,getState:()=>r,reset:()=>{r=c6e(),a=!0}}}function qAt(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!FZe(s,t):!1}function B2(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function c6e(){return{animate:B2(!0),whileInView:B2(),whileHover:B2(),whileTap:B2(),whileDrag:B2(),whileFocus:B2(),exit:B2()}}function e_e(t,s){t.min=s.min,t.max=s.max}function hg(t,s){e_e(t.x,s.x),e_e(t.y,s.y)}function d6e(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const zZe=1e-4,UAt=1-zZe,VAt=1+zZe,BZe=.01,HAt=0-BZe,GAt=0+BZe;function xm(t){return t.max-t.min}function WAt(t,s,r){return Math.abs(t-s)<=r}function u6e(t,s,r,n=.5){t.origin=n,t.originPoint=tc(s.min,s.max,t.origin),t.scale=xm(r)/xm(s),t.translate=tc(r.min,r.max,t.origin)-t.originPoint,(t.scale>=UAt&&t.scale<=VAt||isNaN(t.scale))&&(t.scale=1),(t.translate>=HAt&&t.translate<=GAt||isNaN(t.translate))&&(t.translate=0)}function s8(t,s,r,n){u6e(t.x,s.x,r.x,n?n.originX:void 0),u6e(t.y,s.y,r.y,n?n.originY:void 0)}function h6e(t,s,r,n=0){const a=n?tc(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+xm(s)}function KAt(t,s,r,n){h6e(t.x,s.x,r.x,n==null?void 0:n.x),h6e(t.y,s.y,r.y,n==null?void 0:n.y)}function m6e(t,s,r,n=0){const a=n?tc(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+xm(s)}function ple(t,s,r,n){m6e(t.x,s.x,r.x,n==null?void 0:n.x),m6e(t.y,s.y,r.y,n==null?void 0:n.y)}function p6e(t,s,r,n,a){return t-=s,t=mle(t,1/r,n),a!==void 0&&(t=mle(t,1/a,n)),t}function ZAt(t,s=0,r=1,n=.5,a,o=t,l=t){if(o0.test(s)&&(s=parseFloat(s),s=tc(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=tc(o.min,o.max,n);t===o&&(i-=s),t.min=p6e(t.min,s,r,i,a),t.max=p6e(t.max,s,r,i,a)}function f6e(t,s,[r,n,a],o,l){ZAt(t,s[r],s[n],s[a],s.scale,o,l)}const YAt=["x","scaleX","originX"],XAt=["y","scaleY","originY"];function x6e(t,s,r,n){f6e(t.x,s,YAt,r?r.x:void 0,n?n.x:void 0),f6e(t.y,s,XAt,r?r.y:void 0,n?n.y:void 0)}function g6e(t){return t.translate===0&&t.scale===1}function $Ze(t){return g6e(t.x)&&g6e(t.y)}function y6e(t,s){return t.min===s.min&&t.max===s.max}function QAt(t,s){return y6e(t.x,s.x)&&y6e(t.y,s.y)}function v6e(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function qZe(t,s){return v6e(t.x,s.x)&&v6e(t.y,s.y)}function _6e(t){return xm(t.x)/xm(t.y)}function b6e(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function My(t){return[t("x"),t("y")]}function JAt(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,d=t.y.scale*s.y;return(i!==1||d!==1)&&(n+=`scale(${i}, ${d})`),n||"none"}const UZe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],eEt=UZe.length,w6e=t=>typeof t=="string"?parseFloat(t):t,j6e=t=>typeof t=="number"||ra.test(t);function tEt(t,s,r,n,a,o){a?(t.opacity=tc(0,r.opacity??1,sEt(n)),t.opacityExit=tc(s.opacity??1,0,rEt(n))):o&&(t.opacity=tc(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(oD(t,s,n))}function nEt(t,s,r){const n=rh(t)?t:zT(t);return n.start(TNe("",n,s,r)),n.animation}function dD(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const aEt=(t,s)=>t.depth-s.depth;class iEt{constructor(){this.children=[],this.isDirty=!1}add(s){xNe(this.children,s),this.isDirty=!0}remove(s){ole(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(aEt),this.isDirty=!1,this.children.forEach(s)}}function oEt(t,s){const r=fm.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(nw(n),t(o-s))};return ml.setup(n,!0),()=>nw(n)}function Yie(t){return rh(t)?t.get():t}class lEt{constructor(){this.members=[]}add(s){xNe(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&&(ole(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(ole(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 Xie={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Age=["","X","Y","Z"],cEt=1e3;let dEt=0;function Ege(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function HZe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=hZe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",ml,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&HZe(n)}function GZe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=dEt++,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(mEt),this.nodes.forEach(vEt),this.nodes.forEach(_Et),this.nodes.forEach(pEt)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=l,this.root=i?i.root||i:this,this.path=i?[...i.path,i]:[],this.parent=i,this.depth=i?i.depth+1:0;for(let d=0;dthis.root.updateBlockedByResize=!1;ml.read(()=>{f=window.innerWidth}),t(l,()=>{const _=window.innerWidth;_!==f&&(f=_,this.root.updateBlockedByResize=!0,p&&p(),p=oEt(y,250),Xie.hasAnimatedSinceResize&&(Xie.hasAnimatedSinceResize=!1,this.nodes.forEach(C6e)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||d)&&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()||kEt,{onLayoutAnimationStart:N,onLayoutAnimationComplete:w}=u.getProps(),S=!this.targetLayout||!qZe(this.targetLayout,_),C=!f&&y;if(this.options.layoutRoot||this.resumeFrom||C||f&&(S||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const A={...MNe(b,"layout"),onPlay:N,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(A.delay=0,A.type=!1),this.startAnimation(A),this.setAnimationOrigin(p,C)}else f||C6e(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(),nw(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(bEt),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&&HZe(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&&!xm(this.snapshot.measuredBox.x)&&!xm(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let d=0;d{const L=I/1e3;M6e(f.x,l.x,L),M6e(f.y,l.y,L),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(ple(y,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),jEt(this.relativeTarget,this.relativeTargetOrigin,y,L),A&&QAt(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=eu()),hg(A,this.relativeTarget)),N&&(this.animationValues=p,tEt(p,u,this.latestValues,L,C,S)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=L},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var i,d,u;this.notifyListeners("animationStart"),(i=this.currentAnimation)==null||i.stop(),(u=(d=this.resumingFrom)==null?void 0:d.currentAnimation)==null||u.stop(),this.pendingAnimation&&(nw(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ml.update(()=>{Xie.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=zT(0)),this.motionValue.jump(0,!1),this.currentAnimation=nEt(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(cEt),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:i,target:d,layout:u,latestValues:p}=l;if(!(!i||!d||!u)){if(this!==l&&this.layout&&u&&WZe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){d=this.target||eu();const f=xm(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+f;const y=xm(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+y}hg(i,d),Zie(i,p),s8(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new lEt),this.sharedNodes.get(l).add(i);const u=i.options.initialPromotionConfig;i.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(i):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){var i;const{layoutId:l}=this.options;return l?((i=this.getStack())==null?void 0:i.lead)||this:this}getPrevLead(){var i;const{layoutId:l}=this.options;return l?(i=this.getStack())==null?void 0:i.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:i,preserveFollowOpacity:d}={}){const u=this.getStack();u&&u.promote(this,d),l&&(this.projectionDelta=void 0,this.needsReset=!0),i&&this.setOptions({transition:i})}relegate(){const l=this.getStack();return l?l.relegate(this):!1}resetSkewAndRotation(){const{visualElement:l}=this.options;if(!l)return;let i=!1;const{latestValues:d}=l;if((d.z||d.rotate||d.rotateX||d.rotateY||d.rotateZ||d.skewX||d.skewY)&&(i=!0),!i)return;const u={};d.z&&Ege("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(k6e),this.root.sharedNodes.clear()}}}function uEt(t){t.updateLayout()}function hEt(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")My(f=>{const y=l?s.measuredBox[f]:s.layoutBox[f],_=xm(y);y.min=n[f].min,y.max=y.min+_});else if(o==="x"||o==="y"){const f=o==="x"?"y":"x";e_e(l?s.measuredBox[f]:s.layoutBox[f],n[f])}else WZe(o,s.layoutBox,n)&&My(f=>{const y=l?s.measuredBox[f]:s.layoutBox[f],_=xm(n[f]);y.max=y.min+_,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[f].max=t.relativeTarget[f].min+_)});const i=nM();s8(i,n,s.layoutBox);const d=nM();l?s8(d,t.applyTransform(a,!0),s.measuredBox):s8(d,n,s.layoutBox);const u=!$Ze(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,N=eu();ple(N,s.layoutBox,y.layoutBox,b);const w=eu();ple(w,n,_.layoutBox,b),qZe(N,w)||(p=!0),f.options.layoutRoot&&(t.relativeTarget=w,t.relativeTargetOrigin=N,t.relativeParent=f)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:s,delta:d,layoutDelta:i,hasLayoutChanged:u,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function mEt(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 pEt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function fEt(t){t.clearSnapshot()}function k6e(t){t.clearMeasurements()}function xEt(t){t.isLayoutDirty=!0,t.updateLayout()}function S6e(t){t.isLayoutDirty=!1}function gEt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function yEt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function C6e(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function vEt(t){t.resolveTargetDelta()}function _Et(t){t.calcProjection()}function bEt(t){t.resetSkewAndRotation()}function wEt(t){t.removeLeadSnapshot()}function M6e(t,s,r){t.translate=tc(s.translate,0,r),t.scale=tc(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function T6e(t,s,r,n){t.min=tc(s.min,r.min,n),t.max=tc(s.max,r.max,n)}function jEt(t,s,r,n){T6e(t.x,s.x,r.x,n),T6e(t.y,s.y,r.y,n)}function NEt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const kEt={duration:.45,ease:[.4,0,.1,1]},A6e=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),E6e=A6e("applewebkit/")&&!A6e("chrome/")?Math.round:kx;function P6e(t){t.min=E6e(t.min),t.max=E6e(t.max)}function SEt(t){P6e(t.x),P6e(t.y)}function WZe(t,s,r){return t==="position"||t==="preserve-aspect"&&!WAt(_6e(s),_6e(r),.2)}function CEt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const MEt=GZe({attachResizeListener:(t,s)=>dD(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}),Pge={current:void 0},KZe=GZe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Pge.current){const t=new MEt({});t.mount(window),t.setOptions({layoutScroll:!0}),Pge.current=t}return Pge.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),$Ne=k.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function I6e(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function TEt(...t){return s=>{let r=!1;const n=t.map(a=>{const o=I6e(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{width:_,height:b,top:N,left:w,right:S,bottom:C}=d.current;if(s||o===!1||!i.current||!_||!b)return;const A=r==="left"?`left: ${w}`:`right: ${S}`,I=n==="bottom"?`bottom: ${C}`:`top: ${N}`;i.current.dataset.motionPopId=l;const L=document.createElement("style");u&&(L.nonce=u);const O=a??document.head;return O.appendChild(L),L.sheet&&L.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${_}px !important; height: ${b}px !important; ${A}px !important; ${I}px !important; } `),()=>{var U;(U=i.current)==null||U.removeAttribute("data-motion-pop-id"),O.contains(L)&&O.removeChild(L)}},[s]),e.jsx(EEt,{isPresent:s,childRef:i,sizeRef:d,pop:o,children:o===!1?t:k.cloneElement(t,{ref:f})})}const IEt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:d,root:u})=>{const p=fNe(LEt),f=k.useId();let y=!0,_=k.useMemo(()=>(y=!1,{id:f,initial:s,isPresent:r,custom:a,onExitComplete:b=>{p.set(b,!0);for(const N of p.values())if(!N)return;n&&n()},register:b=>(p.set(b,!1),()=>p.delete(b))}),[r,p,n]);return o&&y&&(_={..._}),k.useMemo(()=>{p.forEach((b,N)=>p.set(N,!1))},[r]),k.useEffect(()=>{!r&&!p.size&&n&&n()},[r]),t=e.jsx(PEt,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:d,root:u,children:t}),e.jsx(que.Provider,{value:_,children:t})};function LEt(){return new Map}function ZZe(t=!0){const s=k.useContext(que);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=k.useId();k.useEffect(()=>{if(t)return a(o)},[t]);const l=k.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const Iz=t=>t.key||"";function L6e(t){const s=[];return k.Children.forEach(t,r=>{k.isValidElement(r)&&s.push(r)}),s}const qNe=({children:t,custom:s,initial:r=!0,onExitComplete:n,presenceAffectsLayout:a=!0,mode:o="sync",propagate:l=!1,anchorX:i="left",anchorY:d="top",root:u})=>{const[p,f]=ZZe(l),y=k.useMemo(()=>L6e(t),[t]),_=l&&!p?[]:y.map(Iz),b=k.useRef(!0),N=k.useRef(y),w=fNe(()=>new Map),S=k.useRef(new Set),[C,A]=k.useState(y),[I,L]=k.useState(y);jKe(()=>{b.current=!1,N.current=y;for(let q=0;q{const $=Iz(q),V=l&&!p?!1:y===I||_.includes($),ee=()=>{if(S.current.has($))return;if(w.has($))S.current.add($),w.set($,!0);else return;let Z=!0;w.forEach(J=>{J||(Z=!1)}),Z&&(U==null||U(),L(N.current),l&&(f==null||f()),n&&n())};return e.jsx(IEt,{isPresent:V,initial:!b.current||r?void 0:!1,custom:s,presenceAffectsLayout:a,mode:o,root:u,onExitComplete:V?void 0:ee,anchorX:i,anchorY:d,children:q},$)})})},YZe=k.createContext({strict:!1}),D6e={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 R6e=!1;function DEt(){if(R6e)return;const t={};for(const s in D6e)t[s]={isEnabled:r=>D6e[s].some(n=>!!r[n])};kZe(t),R6e=!0}function XZe(){return DEt(),vAt()}function REt(t){const s=XZe();for(const r in t)s[r]={...s[r],...t[r]};kZe(s)}const OEt=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 fle(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||OEt.has(t)}let QZe=t=>!fle(t);function FEt(t){typeof t=="function"&&(QZe=s=>s.startsWith("on")?!fle(s):t(s))}try{FEt(require("@emotion/is-prop-valid").default)}catch{}function zEt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||rh(t[a])||(QZe(a)||r===!0&&fle(a)||!s&&!fle(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const Gue=k.createContext({});function BEt(t,s){if(Hue(t)){const{initial:r,animate:n}=t;return{initial:r===!1||cD(r)?r:void 0,animate:cD(n)?n:void 0}}return t.inherit!==!1?s:{}}function $Et(t){const{initial:s,animate:r}=BEt(t,k.useContext(Gue));return k.useMemo(()=>({initial:s,animate:r}),[O6e(s),O6e(r)])}function O6e(t){return Array.isArray(t)?t.join(" "):t}const UNe=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function JZe(t,s,r){for(const n in s)!rh(s[n])&&!PZe(n,r)&&(t[n]=s[n])}function qEt({transformTemplate:t},s){return k.useMemo(()=>{const r=UNe();return zNe(r,s,t),Object.assign({},r.vars,r.style)},[s])}function UEt(t,s){const r=t.style||{},n={};return JZe(n,r,t),Object.assign(n,qEt(t,s)),n}function VEt(t,s){const r={},n=UEt(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 eYe=()=>({...UNe(),attrs:{}});function HEt(t,s,r,n){const a=k.useMemo(()=>{const o=eYe();return IZe(o,s,DZe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};JZe(o,t.style,t),a.style={...o,...a.style}}return a}const GEt=["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 VNe(t){return typeof t!="string"||t.includes("-")?!1:!!(GEt.indexOf(t)>-1||/[A-Z]/u.test(t))}function WEt(t,s,r,{latestValues:n},a,o=!1,l){const d=(l??VNe(t)?HEt:VEt)(s,n,a,t),u=zEt(s,typeof t=="string",o),p=t!==k.Fragment?{...u,...d,ref:r}:{},{children:f}=s,y=k.useMemo(()=>rh(f)?f.get():f,[f]);return k.createElement(t,{...p,children:y})}function KEt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:ZEt(r,n,a,t),renderState:s()}}function ZEt(t,s,r,n){const a={},o=n(t,{});for(const y in o)a[y]=Yie(o[y]);let{initial:l,animate:i}=t;const d=Hue(t),u=jZe(t);s&&u&&!d&&t.inherit!==!1&&(l===void 0&&(l=s.initial),i===void 0&&(i=s.animate));let p=r?r.initial===!1:!1;p=p||l===!1;const f=p?i:l;if(f&&typeof f!="boolean"&&!Vue(f)){const y=Array.isArray(f)?f:[f];for(let _=0;_(s,r)=>{const n=k.useContext(Gue),a=k.useContext(que),o=()=>KEt(t,s,n,a);return r?o():fNe(o)},YEt=tYe({scrapeMotionValuesFromProps:BNe,createRenderState:UNe}),XEt=tYe({scrapeMotionValuesFromProps:RZe,createRenderState:eYe}),QEt=Symbol.for("motionComponentSymbol");function JEt(t,s,r){const n=k.useRef(r);k.useInsertionEffect(()=>{n.current=r});const a=k.useRef(null);return k.useCallback(o=>{var i;o&&((i=t.onMount)==null||i.call(t,o));const l=n.current;if(typeof l=="function")if(o){const d=l(o);typeof d=="function"&&(a.current=d)}else a.current?(a.current(),a.current=null):l(o);else l&&(l.current=o);s&&(o?s.mount(o):s.unmount())},[s])}const sYe=k.createContext({});function D5(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function ePt(t,s,r,n,a,o){var A,I;const{visualElement:l}=k.useContext(Gue),i=k.useContext(YZe),d=k.useContext(que),u=k.useContext($Ne),p=u.reducedMotion,f=u.skipAnimations,y=k.useRef(null),_=k.useRef(!1);n=n||i.renderer,!y.current&&n&&(y.current=n(t,{visualState:s,parent:l,props:r,presenceContext:d,blockInitialAnimation:d?d.initial===!1:!1,reducedMotionConfig:p,skipAnimations:f,isSVG:o}),_.current&&y.current&&(y.current.manuallyAnimateOnMount=!0));const b=y.current,N=k.useContext(sYe);b&&!b.projection&&a&&(b.type==="html"||b.type==="svg")&&tPt(y.current,r,a,N);const w=k.useRef(!1);k.useInsertionEffect(()=>{b&&w.current&&b.update(r,d)});const S=r[uZe],C=k.useRef(!!S&&typeof window<"u"&&!((A=window.MotionHandoffIsComplete)!=null&&A.call(window,S))&&((I=window.MotionHasOptimisedAnimation)==null?void 0:I.call(window,S)));return jKe(()=>{_.current=!0,b&&(w.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),C.current&&b.animationState&&b.animationState.animateChanges())}),k.useEffect(()=>{b&&(!C.current&&b.animationState&&b.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,S)}),C.current=!1),b.enteringChildren=void 0)}),b}function tPt(t,s,r,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:d,layoutRoot:u,layoutAnchor:p,layoutCrossfade:f}=s;t.projection=new r(t.latestValues,s["data-framer-portal-id"]?void 0:rYe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&D5(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:d,layoutRoot:u,layoutAnchor:p})}function rYe(t){if(t)return t.options.allowProjection!==!1?t.projection:rYe(t.parent)}function Ige(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&REt(n);const o=r?r==="svg":VNe(t),l=o?XEt:YEt;function i(u,p){let f;const y={...k.useContext($Ne),...u,layoutId:sPt(u)},{isStatic:_}=y,b=$Et(u),N=l(u,_);if(!_&&typeof window<"u"){rPt();const w=nPt(y);f=w.MeasureLayout,b.visualElement=ePt(t,N,y,a,w.ProjectionNode,o)}return e.jsxs(Gue.Provider,{value:b,children:[f&&b.visualElement?e.jsx(f,{visualElement:b.visualElement,...y}):null,WEt(t,u,JEt(N,b.visualElement,p),N,_,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const d=k.forwardRef(i);return d[QEt]=t,d}function sPt({layoutId:t}){const s=k.useContext(pNe).id;return s&&t!==void 0?s+"-"+t:t}function rPt(t,s){k.useContext(YZe).strict}function nPt(t){const s=XZe(),{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 aPt(t,s){if(typeof Proxy>"u")return Ige;const r=new Map,n=(o,l)=>Ige(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,Ige(l,void 0,t,s)),r.get(l))})}const iPt=(t,s)=>s.isSVG??VNe(t)?new RAt(s):new AAt(s,{allowProjection:t!==k.Fragment});class oPt extends bw{constructor(s){super(s),s.animationState||(s.animationState=$At(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();Vue(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 lPt=0;class cPt extends bw{constructor(){super(...arguments),this.id=lPt++,this.isExitComplete=!1}update(){var o;if(!this.node.presenceContext)return;const{isPresent:s,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||s===n)return;if(s&&n===!1){if(this.isExitComplete){const{initial:l,custom:i}=this.node.getProps();if(typeof l=="string"){const d=CS(this.node,l,i);if(d){const{transition:u,transitionEnd:p,...f}=d;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 dPt={animation:{Feature:oPt},exit:{Feature:cPt}};function HR(t){return{point:{x:t.pageX,y:t.pageY}}}const uPt=t=>s=>DNe(s)&&t(s,HR(s));function r8(t,s,r,n){return dD(t,s,uPt(r),n)}const nYe=({current:t})=>t?t.ownerDocument.defaultView:null,F6e=(t,s)=>Math.abs(t-s);function hPt(t,s){const r=F6e(t.x,s.x),n=F6e(t.y,s.y);return Math.sqrt(r**2+n**2)}const z6e=new Set(["auto","scroll"]);class aYe{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=Lz(this.lastRawMoveEventInfo,this.transformPagePoint));const _=Lge(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,N=hPt(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!b&&!N)return;const{point:w}=_,{timestamp:S}=Ju;this.history.push({...w,timestamp:S});const{onStart:C,onMove:A}=this.handlers;b||(C&&C(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),A&&A(this.lastMoveEvent,_)},this.handlePointerMove=(_,b)=>{this.lastMoveEvent=_,this.lastRawMoveEventInfo=b,this.lastMoveEventInfo=Lz(b,this.transformPagePoint),ml.update(this.updatePoint,!0)},this.handlePointerUp=(_,b)=>{this.end();const{onEnd:N,onSessionEnd:w,resumeAnimation:S}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&S&&S(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=Lge(_.type==="pointercancel"?this.lastMoveEventInfo:Lz(b,this.transformPagePoint),this.history);this.startEvent&&N&&N(_,C),w&&w(_,C)},!DNe(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const d=HR(s),u=Lz(d,this.transformPagePoint),{point:p}=u,{timestamp:f}=Ju;this.history=[{...p,timestamp:f}];const{onSessionStart:y}=r;y&&y(s,Lge(u,this.history)),this.removeListeners=qR(r8(this.contextWindow,"pointermove",this.handlePointerMove),r8(this.contextWindow,"pointerup",this.handlePointerUp),r8(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(z6e.has(n.overflowX)||z6e.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),ml.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),nw(this.updatePoint)}}function Lz(t,s){return s?{point:s(t.point)}:t}function B6e(t,s){return{x:t.x-s.x,y:t.y-s.y}}function Lge({point:t},s){return{point:t,delta:B6e(t,iYe(s)),offset:B6e(t,mPt(s)),velocity:pPt(s,.1)}}function mPt(t){return t[0]}function iYe(t){return t[t.length-1]}function pPt(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=iYe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>df(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>df(s)*2&&(n=t[1]);const o=xx(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 fPt(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?tc(r,t,n.max):Math.min(t,r)),t}function $6e(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 xPt(t,{top:s,left:r,bottom:n,right:a}){return{x:$6e(t.x,r,a),y:$6e(t.y,s,n)}}function q6e(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=oD(s.min,s.max-n,t.min):n>a&&(r=oD(t.min,t.max-a,s.min)),h0(0,1,r)}function vPt(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 t_e=.35;function _Pt(t=t_e){return t===!1?t=0:t===!0&&(t=t_e),{x:U6e(t,"left","right"),y:U6e(t,"top","bottom")}}function U6e(t,s,r){return{min:V6e(t,s),max:V6e(t,r)}}function V6e(t,s){return typeof t=="number"?t:t[s]||0}const bPt=new WeakMap;class wPt{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=eu(),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(HR(f).point),this.stopAnimation()},l=(f,y)=>{const{drag:_,dragPropagation:b,onDragStart:N}=this.getProps();if(_&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=ZTt(_),!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),My(S=>{let C=this.getAxisMotionValue(S).get()||0;if(o0.test(C)){const{projection:A}=this.visualElement;if(A&&A.layout){const I=A.layout.layoutBox[S];I&&(C=xm(I)*(parseFloat(C)/100))}}this.originPoint[S]=C}),N&&ml.update(()=>N(f,y),!1,!0),G1e(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},i=(f,y)=>{this.latestPointerEvent=f,this.latestPanInfo=y;const{dragPropagation:_,dragDirectionLock:b,onDirectionLock:N,onDrag:w}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:S}=y;if(b&&this.currentDirection===null){this.currentDirection=NPt(S),this.currentDirection!==null&&N&&N(this.currentDirection);return}this.updateAxis("x",y.point,S),this.updateAxis("y",y.point,S),this.visualElement.render(),w&&ml.update(()=>w(f,y),!1,!0)},d=(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 aYe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:d,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:n,contextWindow:nYe(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&&ml.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||!Dz(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=fPt(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&&D5(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=xPt(n.layoutBox,s):this.constraints=!1,this.elastic=_Pt(r),a!==this.constraints&&!D5(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&My(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=vPt(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!D5(s))return!1;const n=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=NAt(n,a.root,this.visualElement.getTransformPagePoint());let l=gPt(a.layout.layoutBox,o);if(r){const i=r(bAt(l));this.hasMutatedConstraints=!!i,i&&(l=CZe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),d=this.constraints||{},u=My(p=>{if(!Dz(p,r,this.currentDirection))return;let f=d&&d[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 G1e(this.visualElement,s),n.start(TNe(s,n,0,r,this.visualElement,!1))}stopAnimation(){My(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){My(r=>{const{drag:n}=this.getProps();if(!Dz(r,n,this.currentDirection))return;const{projection:a}=this.visualElement,o=this.getAxisMotionValue(r);if(a&&a.layout){const{min:l,max:i}=a.layout.layoutBox[r],d=o.get()||0;o.set(s[r]-tc(l,i,.5)+d)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!D5(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};My(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const d=i.get();a[l]=yPt({min:d,max:d},this.constraints[l])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),My(l=>{if(!Dz(l,s,null))return;const i=this.getAxisMotionValue(l),{min:d,max:u}=this.constraints[l];i.set(tc(d,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;bPt.set(this.visualElement,this);const s=this.visualElement.current,r=r8(s,"pointerdown",u=>{const{drag:p,dragListener:f=!0}=this.getProps(),y=u.target,_=y!==s&&tAt(y);p&&f&&!_&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();D5(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=jPt(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),ml.read(a);const i=dD(window,"resize",()=>this.scalePositionWithinConstraints()),d=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p})=>{this.isDragging&&p&&(My(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(),d&&d(),n&&n()}}getProps(){const s=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:a=!1,dragConstraints:o=!1,dragElastic:l=t_e,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function H6e(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function jPt(t,s,r){const n=QIe(t,H6e(r)),a=QIe(s,H6e(r));return()=>{n(),a()}}function Dz(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function NPt(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class kPt extends bw{constructor(s){super(s),this.removeGroupControls=kx,this.removeListeners=kx,this.controls=new wPt(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||kx}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 Dge=t=>(s,r)=>{t&&ml.update(()=>t(s,r),!1,!0)};class SPt extends bw{constructor(){super(...arguments),this.removePointerDownListener=kx}onPointerDown(s){this.session=new aYe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:nYe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:Dge(s),onStart:Dge(r),onMove:Dge(n),onEnd:(o,l)=>{delete this.session,a&&ml.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=r8(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 Rge=!1;class CPt extends k.Component{componentDidMount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n,layoutId:a}=this.props,{projection:o}=s;o&&(r.group&&r.group.add(o),n&&n.register&&a&&n.register(o),Rge&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Xie.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}),Rge=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||ml.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(),LNe.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;Rge=!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 oYe(t){const[s,r]=ZZe(),n=k.useContext(pNe);return e.jsx(CPt,{...t,layoutGroup:n,switchLayoutGroup:k.useContext(sYe),isPresent:s,safeToRemove:r})}const MPt={pan:{Feature:SPt},drag:{Feature:kPt,ProjectionNode:KZe,MeasureLayout:oYe}};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&&ml.postRender(()=>o(s,HR(s)))}class TPt extends bw{mount(){const{current:s}=this.node;s&&(this.unmount=XTt(s,(r,n)=>(G6e(this.node,n,"Start"),a=>G6e(this.node,a,"End"))))}unmount(){}}class APt extends bw{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=qR(dD(this.node.current,"focus",()=>this.onFocus()),dD(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function W6e(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&&ml.postRender(()=>o(s,HR(s)))}class EPt extends bw{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=rAt(s,(a,o)=>(W6e(this.node,o,"Start"),(l,{success:i})=>W6e(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const s_e=new WeakMap,Oge=new WeakMap,PPt=t=>{const s=s_e.get(t.target);s&&s(t)},IPt=t=>{t.forEach(PPt)};function LPt({root:t,...s}){const r=t||document;Oge.has(r)||Oge.set(r,{});const n=Oge.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(IPt,{root:t,...s})),n[a]}function DPt(t,s,r){const n=LPt(s);return s_e.set(t,r),n.observe(t),()=>{s_e.delete(t),n.unobserve(t)}}const RPt={some:0,all:1};class OPt extends bw{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var d;(d=this.stopObserver)==null||d.call(this);const{viewport:s={}}=this.node.getProps(),{root:r,margin:n,amount:a="some",once:o}=s,l={root:r?r.current:void 0,rootMargin:n,threshold:typeof a=="number"?a:RPt[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=DPt(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(FPt(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function FPt({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const zPt={inView:{Feature:OPt},tap:{Feature:EPt},focus:{Feature:APt},hover:{Feature:TPt}},BPt={layout:{ProjectionNode:KZe,MeasureLayout:oYe}},$Pt={...dPt,...zPt,...MPt,...BPt},ur=aPt($Pt,iPt),qPt={some:0,all:1};function UPt(t,s,{root:r,margin:n,amount:a="some"}={}){const o=INe(t),l=new WeakMap,i=u=>{u.forEach(p=>{const f=l.get(p.target);if(p.isIntersecting!==!!f)if(p.isIntersecting){const y=s(p.target,p);typeof y=="function"?l.set(p.target,y):d.unobserve(p.target)}else typeof f=="function"&&(f(p),l.delete(p.target))})},d=new IntersectionObserver(i,{root:r,rootMargin:n,threshold:typeof a=="number"?a:qPt[a]});return o.forEach(u=>d.observe(u)),()=>d.disconnect()}function VPt(t,{root:s,margin:r,amount:n,once:a=!1,initial:o=!1}={}){const[l,i]=k.useState(o);return k.useEffect(()=>{if(!t.current||a&&l)return;const d=()=>(i(!0),a?void 0:()=>i(!1)),u={root:s&&s.current||void 0,margin:r,amount:n};return UPt(t.current,d,u)},[s,t,r,a,n]),l}function HPt(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 K6e(t){return t.visitor_intent==="buying"&&!t.has_agent}function GPt({token:t}={}){var b;const s=ho(),r=t||s.token,{data:n,isLoading:a,isError:o}=A5t(r),l=es(),i=(b=n==null?void 0:n.open_houses)==null?void 0:b.id,{data:d}=ft({queryKey:["cohost-visitors",i],queryFn:async()=>{const{data:N,error:w}=await G.from("open_house_visitors").select("*").eq("open_house_id",i).order("created_at",{ascending:!1});if(w)throw w;return N},enabled:!!i});if(k.useEffect(()=>{if(!i)return;const N=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(N)}},[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=(d==null?void 0:d.length)||0,f=(d==null?void 0:d.filter(N=>N.visitor_intent==="buying").length)||0,y=(d==null?void 0:d.filter(K6e).length)||0,_=N=>{if(!N)return"";const[w,S]=N.split(":"),C=parseInt(w);return`${C>12?C-12:C||12}:${S} ${C>=12?"PM":"AM"}`};return e.jsxs("div",{className:"fixed inset-0 bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex flex-col",children:[e.jsxs("div",{className:"border-b border-white/10 px-4 sm:px-6 py-3 flex items-center justify-between bg-black/30 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-xs font-medium text-emerald-400 uppercase tracking-wider",children:"Live · Co-Host View"})]}),e.jsx("h1",{className:"text-white font-bold text-sm sm:text-base truncate",children:u.property_address})]}),e.jsxs("div",{className:"flex items-center gap-4 sm:gap-6 text-white/70",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(cr,{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(ch,{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(Mn,{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:gs(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(di,{className:"flex-1 p-4 sm:p-6",children:d!=null&&d.length?e.jsx("div",{className:"space-y-2 max-w-3xl mx-auto",children:e.jsx(qNe,{children:d.map((N,w)=>{var A;const S=HPt(N.visitor_intent),C=K6e(N);return e.jsxs(ur.div,{initial:{opacity:0,x:-40,scale:.95},animate:{opacity:1,x:0,scale:1},transition:{duration:.4,delay:w*.05},className:`flex items-center gap-4 p-4 rounded-xl border ${C?"bg-orange-500/10 border-orange-500/30":"bg-white/5 border-white/10"}`,children:[e.jsx("div",{className:`w-11 h-11 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${C?"bg-gradient-to-br from-orange-500 to-amber-500 text-white":"bg-white/10 text-white/80"}`,children:(A=N.first_name[0])==null?void 0:A.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:[N.first_name," ",N.last_name||""]}),C&&e.jsx(Ye,{className:"bg-orange-500/20 text-orange-300 border-orange-500/40 text-[10px] px-1.5 py-0",children:"🔥 HOT"}),N.has_agent&&e.jsx(Ye,{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(Ye,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${S.color}`,children:[S.emoji," ",S.label]}),e.jsx("span",{className:"text-white/30 text-xs",children:gs(new Date(N.created_at),"h:mm a")})]})]})]},N.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(e1,{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 WPt(){const s=Fl().pathname.slice(1);if(k.useEffect(()=>(document.body.classList.add("guestbook-page"),()=>{document.body.classList.remove("guestbook-page")}),[]),s.startsWith("live/")){const r=s.slice(5);if(r)return e.jsx(GPt,{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(cKe,{slug:s})}function KPt({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(Mn,{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(La,{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(Tn,{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(tr,{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(bc,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function ZPt({journeyStages:t,currentIndex:s}){return t.length===0?null:e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800 mb-1",children:"Your Home Journey"}),e.jsx("p",{className:"text-xs text-slate-400 mb-5",children:"Follow along as your transaction progresses"}),e.jsx("div",{className:"relative",children:t.map((r,n)=>{const a=ns;return e.jsxs("div",{className:"flex items-start gap-3.5 relative",children:[n{var l,i;if(o.includes("youtube.com/watch")){const d=new URL(o).searchParams.get("v");return d?`https://www.youtube.com/embed/${d}`:null}if(o.includes("youtu.be/")){const d=(l=o.split("youtu.be/")[1])==null?void 0:l.split("?")[0];return d?`https://www.youtube.com/embed/${d}`:null}if(o.includes("loom.com/share/")){const d=(i=o.split("loom.com/share/")[1])==null?void 0:i.split("?")[0];return d?`https://www.loom.com/embed/${d}`:null}return o};return e.jsxs("div",{className:"bg-gradient-to-br from-[#406E71]/5 via-white to-[#406E71]/5 rounded-2xl border border-[#406E71]/15 overflow-hidden",children:[e.jsx("div",{className:"bg-[#406E71] px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ti,{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 pl(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 QPt(t,s){const r=gs(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 JPt(t,s){const r=gs(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 eIt({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:NM,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:tn,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:Mn,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:nn,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,d,u)=>{const p=pl(d);if(u==="google")window.open(QPt(i,p),"_blank");else{const f=JPt(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:d,icon:u,color:p})=>{const f=pl(d),y=a0(f)&&!nu(f),_=nu(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:[gs(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,d,"google"),className:"text-xs text-slate-400 hover:text-blue-500 transition-colors px-1.5 py-1 rounded hover:bg-blue-50",title:"Add to Google Calendar",children:e.jsx(Cb,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>l(i,d,"apple"),className:"text-[10px] text-slate-400 hover:text-slate-600 transition-colors px-1.5 py-1 rounded hover:bg-slate-100",title:"Download .ics file",children:".ics"})]})]},i)})})]})}function tIt({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(mn,{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(Xa,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function sIt({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(td,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(Nm,{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:gs(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 rIt({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var b,N;const[l,i]=k.useState({first_name:((b=t.client_name)==null?void 0:b.split(" ")[0])||"",last_name:((N=t.client_name)==null?void 0:N.split(" ").slice(1).join(" "))||"",email:t.client_email||"",phone:t.client_phone||"",preferred_contact_method:"email",client_role:"buyer",notes:"",spouse_first_name:"",spouse_last_name:"",spouse_email:"",spouse_phone:""}),[d,u]=k.useState({}),[p,f]=k.useState(!1),y=Et({mutationFn:async()=>{const{error:w}=await G.from("portal_onboarding_submissions").insert({portal_id:t.id,first_name:l.first_name,last_name:l.last_name||null,email:l.email||null,phone:l.phone||null,preferred_contact_method:l.preferred_contact_method,client_role:l.client_role,notes:l.notes||null,device_fingerprint:a,custom_answers:Object.keys(d).length>0?d:null,spouse_first_name:p&&l.spouse_first_name||null,spouse_last_name:p&&l.spouse_last_name||null,spouse_email:p&&l.spouse_email||null,spouse_phone:p&&l.spouse_phone||null});if(w)throw w},onSuccess:o,onError:w=>{console.error("[PortalOnboarding] Submit failed:",w),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(La,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:_.replace(/,\s*,/g,",").replace(/,\s*$/,"")})]}),e.jsx("p",{className:"text-sm text-slate-500 mt-2",children:"Please fill in your details to access your transaction portal."})]}),e.jsxs("form",{onSubmit:w=>{w.preventDefault(),y.mutate()},className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(Fe,{required:!0,value:l.first_name,onChange:w=>i(S=>({...S,first_name:w.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Fe,{value:l.last_name,onChange:w=>i(S=>({...S,last_name:w.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Fe,{type:"email",value:l.email,onChange:w=>i(S=>({...S,email:w.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Fe,{type:"tel",value:l.phone,onChange:w=>i(S=>({...S,phone:w.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs text-slate-600",children:"Preferred Contact Method"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:[{value:"email",label:"Email"},{value:"call",label:"Phone"},{value:"text",label:"Text"}].map(w=>e.jsx("button",{type:"button",onClick:()=>i(S=>({...S,preferred_contact_method:w.value})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===w.value?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.label},w.value))})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs text-slate-600",children:"Your Role"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(w=>e.jsx("button",{type:"button",onClick:()=>i(S=>({...S,client_role:w})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===w?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.charAt(0).toUpperCase()+w.slice(1)},w))})]}),n.map(w=>e.jsxs("div",{children:[e.jsxs(ge,{className:"text-xs text-slate-600",children:[w.question_text," ",w.is_required&&"*"]}),w.field_type==="text"&&e.jsx(Fe,{required:w.is_required,value:d[w.id]||"",onChange:S=>u(C=>({...C,[w.id]:S.target.value})),className:"mt-1 rounded-xl"}),w.field_type==="textarea"&&e.jsx("textarea",{required:w.is_required,value:d[w.id]||"",onChange:S=>u(C=>({...C,[w.id]:S.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),w.field_type==="dropdown"&&e.jsxs("select",{required:w.is_required,value:d[w.id]||"",onChange:S=>u(C=>({...C,[w.id]:S.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm h-10",children:[e.jsx("option",{value:"",children:"Select..."}),(w.options||[]).map(S=>e.jsx("option",{value:S,children:S},S))]}),w.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(S=>e.jsx("button",{type:"button",onClick:()=>u(C=>({...C,[w.id]:S})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${d[w.id]===S?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:S},S))})]},w.id)),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs text-slate-600",children:"Notes for your agent"}),e.jsx("textarea",{value:l.notes,onChange:w=>i(S=>({...S,notes:w.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Anything you'd like your agent to know..."})]}),t.allow_spouse&&e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>f(!p),className:"text-sm text-blue-600 hover:text-blue-700 font-medium",children:p?"− Remove spouse/partner":"+ Add spouse/partner"}),p&&e.jsxs("div",{className:"mt-3 p-4 bg-slate-50 rounded-xl space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs text-slate-600",children:"First Name"}),e.jsx(Fe,{value:l.spouse_first_name,onChange:w=>i(S=>({...S,spouse_first_name:w.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Fe,{value:l.spouse_last_name,onChange:w=>i(S=>({...S,spouse_last_name:w.target.value})),className:"mt-1 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Fe,{type:"email",value:l.spouse_email,onChange:w=>i(S=>({...S,spouse_email:w.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Fe,{type:"tel",value:l.spouse_phone,onChange:w=>i(S=>({...S,spouse_phone:w.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 nIt(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function aIt(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 iIt={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. 🎉"}},lYe=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function HNe(t){return lYe.map(s=>{if(s==="Active")return{key:"Active",label:nIt(t),description:aIt(t)};const r=iIt[s];return{key:s,label:r.label,description:r.description}})}function Z6e(t){if(!t)return 0;const s=lYe.indexOf(t);return s>=0?s:0}function oIt(t,s){return ft({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 lIt(t){return ft({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 cYe({slug:t}){var J,Y,ce,ae,ie,le;const[s,r]=k.useState(!1),[n,a]=k.useState("primary"),[o]=k.useState(()=>{const fe=`portal_fp_${t}`;let xe=localStorage.getItem(fe);return xe||(xe=localStorage.getItem("portal_fp"),xe?localStorage.setItem(fe,xe):(xe=crypto.randomUUID(),localStorage.setItem(fe,xe),localStorage.setItem("portal_fp",xe))),xe});k.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:d}=oIt(t,!0),u=l==null?void 0:l.linked_portal_id,{data:p}=lIt(u),f=(J=l==null?void 0:l.deal_pipeline)==null?void 0:J.owner_user_id,{data:y}=ft({queryKey:["portal-stages",f],queryFn:async()=>{const{data:fe,error:xe}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",f).order("sort_order",{ascending:!0});if(xe)throw xe;return fe},enabled:!!f}),{data:_}=ft({queryKey:["portal-agent",f],queryFn:async()=>{const{data:fe,error:xe}=await G.from("profiles").select("id, name, avatar_url, phone, email").eq("id",f).single();if(xe)throw xe;return fe},enabled:!!f}),b=n==="linked"&&p?p:l,N=b==null?void 0:b.id,{data:w}=ft({queryKey:["portal-updates-public",N],queryFn:async()=>{const{data:fe,error:xe}=await G.from("portal_updates").select("*").eq("portal_id",N).order("created_at",{ascending:!1});if(xe)throw xe;return fe},enabled:!!N}),S=(Y=b==null?void 0:b.deal_pipeline)==null?void 0:Y.id,{data:C}=ft({queryKey:["portal-documents",S],queryFn:async()=>{const{data:fe,error:xe}=await G.from("deal_files").select("*").eq("deal_id",S).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(xe)throw xe;return fe},enabled:!!S}),A=l==null?void 0:l.id,{data:I,isLoading:L}=ft({queryKey:["portal-onboarding-check",A,o],queryFn:async()=>{const{data:fe,error:xe}=await G.from("portal_onboarding_submissions").select("id").eq("portal_id",A).eq("device_fingerprint",o).maybeSingle();if(xe)throw xe;return fe},enabled:!!A&&!!(l!=null&&l.require_onboarding)}),{data:O}=ft({queryKey:["portal-custom-questions-public",f],queryFn:async()=>{const{data:fe,error:xe}=await G.from("portal_custom_questions").select("*").eq("owner_user_id",f).eq("is_active",!0).order("sort_order",{ascending:!0});if(xe)throw xe;return fe},enabled:!!f&&!!(l!=null&&l.require_onboarding)}),U=!!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(Ss,{className:"h-48 w-full rounded-2xl"}),e.jsx(Ss,{className:"h-10 w-48 mx-auto"}),e.jsx(Ss,{className:"h-32 w-full rounded-2xl"}),e.jsx(Ss,{className:"h-24 w-full rounded-2xl"})]})});if(d||!l)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("span",{className:"text-2xl",children:"🔒"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Available"}),e.jsx("p",{className:"text-slate-500",children:"This portal is no longer active or doesn't exist."})]})});if(!U){const fe=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(rIt,{portal:l,dealData:fe,agentProfile:_,customQuestions:O||[],deviceFingerprint:o,onComplete:()=>r(!0)})})}const q=(ce=l==null?void 0:l.deal_pipeline)==null?void 0:ce.deal_type,$=(ae=p==null?void 0:p.deal_pipeline)==null?void 0:ae.deal_type,V=!!p,ee=fe=>fe==="listing"?"Your Sale":fe==="buy-side"?"Your Purchase":"Transaction",Z=fe=>fe==="listing"?e.jsx(Mn,{className:"w-3.5 h-3.5"}):e.jsx(mp,{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(KPt,{dealData:b==null?void 0:b.deal_pipeline,agentProfile:_,welcomeMessage:b==null?void 0:b.welcome_message,isWon:(le=(ie=b==null?void 0:b.deal_pipeline)==null?void 0:ie.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:[Z(q),ee(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:[Z($),ee($)]})]}),e.jsx(cIt,{portal:b,updates:w,documents:C}),e.jsxs("div",{className:"text-center pt-6 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-slate-400",children:[e.jsx(Ru,{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 cIt({portal:t,updates:s,documents:r}){const n=t,a=n==null?void 0:n.deal_pipeline,o=a==null?void 0:a.deal_pipeline_stages,l=o==null?void 0:o.is_won_stage,i=a==null?void 0:a.deal_type,d=t.stage_mapping;let u=HNe(i);d&&d.length>0&&(u=d.map((_,b)=>{var N,w;return{key:`custom-${b}`,label:_.label||((N=u[b])==null?void 0:N.label)||`Stage ${b+1}`,description:_.description||((w=u[b])==null?void 0:w.description)||"",video_url:_.video_url||void 0}}));const p=d&&d.length>0?Math.min(Z6e(o==null?void 0:o.name),u.length-1):Z6e(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(YPt,{targetCloseDate:a==null?void 0:a.target_close_date,actualCloseDate:a==null?void 0:a.actual_close_date,clientName:t.client_name}),e.jsx(ZPt,{journeyStages:u,currentIndex:p}),f&&e.jsx(XPt,{currentStage:f,nextStepText:t.next_step_text,nextStepVideoUrl:y||t.next_step_video_url}),e.jsx(eIt,{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(tIt,{documents:r}),s&&s.length>0&&e.jsx(sIt,{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 dIt(){const s=Fl().pathname.slice(1);return k.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>{document.body.classList.remove("client-portal-page")}),[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Client Portal"}),e.jsx("p",{className:"text-slate-500",children:"Visit your personalized portal link to view your transaction details."})]})}):e.jsx(cYe,{slug:s})}const r_e="levelup_affiliate_ref",uIt=30,hIt=()=>{const[t]=Sc();k.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(r_e,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},mIt=()=>{try{const t=localStorage.getItem(r_e);if(!t)return null;const s=JSON.parse(t),r=uIt*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(r_e),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},xle="/assets/levelup-logo-header-_ZX7DvlA.png",pIt="/assets/scale-your-team-ku4MPatU.png";function fIt({open:t,onOpenChange:s}){return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(ks,{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(ma,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(bs,{children:"Schedule a Brokerage Interest Meeting"}),e.jsx(Rr,{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 Su={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"]}},xIt=[{icon:tp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Rl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:nn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:bc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:mn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:Vi,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],gIt=[{icon:cr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:qr,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Tn,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:lh,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:La,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:so,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Za,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Fh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],yIt=[{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."}],vIt=()=>{const{user:t,loading:s}=$s(),r=br(),[n]=Sc();k.useEffect(()=>{const U=window.location.host==="listings.relevelup.com",q=window.location.pathname==="/";if(U&&q){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=k.useState(null),[l,i]=k.useState(null),[d,u]=k.useState(!1),[p,f]=k.useState(""),[y,_]=k.useState(""),[b,N]=k.useState(""),[w,S]=k.useState(!1),[C,A]=k.useState(!1),I=(U,q=!1)=>{i({tier:U,skipTrial:q}),u(!0)};hIt(),k.useEffect(()=>{const U=window.location.host==="listings.relevelup.com",q=location.pathname.startsWith("/public/");!s&&t&&!U&&!q&&r("/dashboard")},[t,s,r,location.pathname]),k.useEffect(()=>{n.get("canceled")==="true"&&me.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const L=async(U,q=!1)=>{if(!p){me.error("Please enter your email address");return}if(!y.trim()){me.error("Please enter your full name");return}S(!0),o(U+(q?"_direct":""));const $=mIt();try{const{data:V,error:ee}=await G.functions.invoke("create-checkout",{body:{tier:U,email:p,name:y.trim(),couponCode:b.trim()||void 0,skipTrial:q,referralCode:$}});if(ee)throw ee;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{S(!1),o(null),u(!1),i(null)}},O=()=>{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:xle,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 U;return(U=document.getElementById("features"))==null?void 0:U.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 U;return(U=document.getElementById("pricing"))==null?void 0:U.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 U;return(U=document.getElementById("free-trial"))==null?void 0:U.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(ti,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(K,{size:"lg",variant:"outline",onClick:()=>{var U;return(U=document.getElementById("features"))==null?void 0:U.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 U;return(U=document.getElementById("brokerage"))==null?void 0:U.scrollIntoView({behavior:"smooth"})},className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/5",children:[e.jsx(ma,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(K,{size:"lg",onClick:()=>{var U;return(U=document.getElementById("pricing"))==null?void 0:U.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[e.jsx(Ei,{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:xIt.map((U,q)=>e.jsxs(Ie,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Lt,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx(U.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Ft,{className:"text-xl font-sans",children:U.title})]}),e.jsx(Be,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:U.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(qr,{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:gIt.map((U,q)=>e.jsxs(Ie,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx(U.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Ft,{className:"text-lg font-semibold text-white",children:U.title})]}),e.jsx(Be,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:U.description})})]},q))}),e.jsx("div",{className:"text-center mt-12",children:e.jsxs(K,{size:"lg",onClick:()=>{var U;return(U=document.getElementById("pricing"))==null?void 0:U.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(ti,{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(ma,{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((U,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(ea,{className:"w-4 h-4 text-[#4a6b6d]"})}),e.jsx("span",{className:"text-foreground",children:U})]},q))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var U;return(U=document.getElementById("pricing"))==null?void 0:U.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["See Brokerage Plans",e.jsx(ja,{className:"ml-2 w-5 h-5"})]}),e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>A(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(nn,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:pIt,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:yIt.map((U,q)=>e.jsx(Ie,{className:"bg-muted/30 border-0",children:e.jsxs(Be,{className:"pt-8",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map($=>e.jsx(Gn,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},$))}),e.jsxs("p",{className:"text-lg mb-6 italic text-muted-foreground",children:['"',U.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:U.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:U.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(ti,{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(Ie,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Lt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(Ei,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(Ft,{className:"text-xl font-sans",children:Su.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:Su.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Su.individual_agent.period})]}),e.jsx(mr,{className:"text-base mt-2",children:Su.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(rn,{className:"w-4 h-4"}),Su.individual_agent.trial]})]}),e.jsx(Be,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Su.individual_agent.features.map((U,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ea,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:U})]},q))})}),e.jsxs(YL,{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(Ie,{className:"relative flex flex-col border-2 border-[#4a6b6d] shadow-2xl scale-105 bg-background",children:[e.jsx("div",{className:"absolute -top-4 left-1/2 -translate-x-1/2 px-6 py-2 bg-[#4a6b6d] text-white text-sm font-semibold rounded-full shadow-lg",children:"Most Popular"}),e.jsxs(Lt,{className:"pb-4 pt-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/20 flex items-center justify-center",children:e.jsx(ma,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-xl font-sans",children:Su.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Su.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:Su.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Su.brokerage_under_25.period})]}),e.jsx(mr,{className:"text-base mt-2",children:Su.brokerage_under_25.description})]}),e.jsx(Be,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Su.brokerage_under_25.features.map((U,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ea,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:U})]},q))})}),e.jsx(YL,{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(Ie,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Lt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(ma,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-xl font-sans",children:Su.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Su.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:Su.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Su.brokerage_over_25.period})]}),e.jsx(mr,{className:"text-base mt-2",children:Su.brokerage_over_25.description})]}),e.jsx(Be,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Su.brokerage_over_25.features.map((U,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ea,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:U})]},q))})}),e.jsx(YL,{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 U;return(U=document.getElementById("pricing"))==null?void 0:U.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(ti,{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:xle,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(fIt,{open:C,onOpenChange:A}),e.jsx(fs,{open:d,onOpenChange:u,children:e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsx(bs,{className:"text-xl font-sans font-semibold",children:"Enter your details to get started"}),e.jsx(Rr,{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(ge,{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:U=>_(U.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(ge,{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:U=>f(U.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(ge,{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:U=>N(U.target.value),className:"mt-1"})]})]}),e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:O,disabled:w,children:w?"Loading...":"Continue to Checkout"})]})})]})},Y6e=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Nc,{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. Mobile Information Sharing Policy"}),e.jsx("p",{children:"We respect your privacy. Mobile information (including phone numbers) collected through our website or platform will not be shared, sold, or disclosed to third parties for marketing or promotional purposes."}),e.jsx("p",{className:"mt-3",children:e.jsx("strong",{className:"text-foreground",children:"No mobile information will be shared with third parties/affiliates for marketing/promotional purposes."})}),e.jsx("p",{className:"mt-3",children:"This information is used solely for the purpose of providing services, including sending transactional messages such as account notifications and lead alerts."}),e.jsx("p",{className:"mt-3",children:"By providing your phone number, you consent to receive SMS communications related to your use of our services. Message and data rates may apply. You may opt out at any time."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"8. 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:"9. 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"})]})]})]})]})})]}),X6e=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Nc,{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"})]})]})]})]})})]}),_It=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Nc,{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"})]})]})]})]})})]}),bIt=SC({email:Yl().email("Invalid email address"),password:Yl().min(6,"Password must be at least 6 characters")}),wIt=()=>{const{signIn:t,user:s}=$s(),r=br(),[n,a]=k.useState(!1),[o,l]=k.useState({}),[i,d]=k.useState(""),[u,p]=k.useState(!1),[f,y]=k.useState(!1);k.useEffect(()=>{if(s){const N=sessionStorage.getItem("redirectAfterLogin")||"/dashboard";sessionStorage.removeItem("redirectAfterLogin"),r(N)}},[s,r]);const _=async N=>{N.preventDefault(),l({}),a(!0);const w=new FormData(N.currentTarget),S=w.get("email"),C=w.get("password");try{bIt.parse({email:S,password:C}),await t(S,C)}catch(A){if(A instanceof u0){const I={};A.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:N}=await G.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(N)throw N;me.success("Password reset email sent! Check your inbox."),y(!1),d("")}catch(N){me.error(N.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(da,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(Ra,{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:$Ge,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Ie,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs(Lt,{className:"space-y-1 text-center pb-4",children:[e.jsx(Ft,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(mr,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx(Be,{children:e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(ge,{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(fs,{open:f,onOpenChange:y,children:[e.jsx(ui,{asChild:!0,children:e.jsx(K,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(ms,{className:"bg-white",children:[e.jsxs(ks,{children:[e.jsx(bs,{className:"text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Reset Password"}),e.jsx(Rr,{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(ge,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),e.jsx(Fe,{id:"reset-email",type:"email",placeholder:"your@email.com",value:i,onChange:N=>d(N.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(da,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},jIt=()=>{const[t]=Sc(),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(Ie,{className:"max-w-lg w-full",children:[e.jsxs(Lt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center mb-4",children:e.jsx(si,{className:"w-10 h-10 text-green-500"})}),e.jsx(Ft,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(mr,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs(Be,{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(tr,{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."})})]})]})})},dYe=t=>{const[s,r]=k.useState(null),[n,a]=k.useState(!0);return k.useEffect(()=>{if(!t){a(!1);return}(async()=>{try{const{data:i}=await G.storage.from("avatars").list(`${t}`);if(i&&i.length>0){const{data:d}=G.storage.from("avatars").getPublicUrl(`${t}/${i[0].name}`);r(`${d.publicUrl}?t=${Date.now()}`)}else r(null)}catch(i){console.error("Error fetching avatar:",i),r(null)}finally{a(!1)}})()},[t]),{avatarUrl:s,loading:n,refreshAvatar:async()=>{if(t)try{const{data:l}=await G.storage.from("avatars").list(`${t}`);if(l&&l.length>0){const{data:i}=G.storage.from("avatars").getPublicUrl(`${t}/${l[0].name}`);r(`${i.publicUrl}?t=${Date.now()}`)}}catch(l){console.error("Error refreshing avatar:",l)}}}},uYe=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},NIt=t=>{const[s,r]=k.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return k.useEffect(()=>{if(!t){r(a=>({...a,loading:!1}));return}(async()=>{try{const{data:a,error:o}=await G.from("profiles").select("is_trial, trial_expires_at, subscription_status, subscription_end_date").eq("id",t).single();if(o){console.error("Error fetching trial status:",o),r(d=>({...d,loading:!1}));return}const l=(a==null?void 0:a.subscription_status)==="trialing"&&(a==null?void 0:a.subscription_end_date),i=(a==null?void 0:a.is_trial)&&(a==null?void 0:a.trial_expires_at);if(l){const d=new Date().getTime(),u=new Date(a.subscription_end_date).getTime(),p=Math.ceil((u-d)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.subscription_end_date,daysLeft:f?0:p,loading:!1})}else if(i){const d=new Date().getTime(),u=new Date(a.trial_expires_at).getTime(),p=Math.ceil((u-d)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.trial_expires_at,daysLeft:f?0:p,loading:!1})}else r({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!1})}catch(a){console.error("Error in useTrialStatus:",a),r(o=>({...o,loading:!1}))}})()},[t]),s},hYe=()=>{const{data:t,isLoading:s}=ft({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")}},Q6e="community_last_seen_post_at";function kIt(){const{user:t}=$s(),s=Fl(),[r,n]=k.useState(0),[a,o]=k.useState(null);k.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${Q6e}_${t.id}`);o(i)},[t]),k.useEffect(()=>{if(!t)return;(async()=>{let d=G.from("community_posts").select("id",{count:"exact",head:!0});a&&(d=d.gt("created_at",a));const{data:u}=await G.from("profiles").select("brokerage_id").eq("id",t.id).single(),{count:p,error:f}=await d;!f&&p!==null&&n(p)})()},[t,a]),k.useEffect(()=>{if(!t)return;const i=G.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async d=>{const u=d.new;if(u.user_id===t.id)return;const p=s.pathname==="/community";p||n(N=>N+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=k.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${Q6e}_${t.id}`,i),o(i),n(0)},[t]);return k.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function SIt(){const{isAdmin:t}=$s(),{data:s=0}=ft({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 ZA=kue,GNe=Yje,CIt=Sue,mYe=k.forwardRef(({className:t,...s},r)=>e.jsx(UA,{className:Rt("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}));mYe.displayName=UA.displayName;const MIt=wC("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"}}),CC=k.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(CIt,{children:[e.jsx(mYe,{}),e.jsxs(VA,{ref:a,className:Rt(MIt({side:t}),s),...n,children:[r,e.jsxs(zR,{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(Sr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));CC.displayName=VA.displayName;const YA=({className:t,...s})=>e.jsx("div",{className:Rt("flex flex-col space-y-2 text-center sm:text-left",t),...s});YA.displayName="SheetHeader";const XA=k.forwardRef(({className:t,...s},r)=>e.jsx(OR,{ref:r,className:Rt("text-lg font-semibold text-foreground",t),...s}));XA.displayName=OR.displayName;const pYe=k.forwardRef(({className:t,...s},r)=>e.jsx(FR,{ref:r,className:Rt("text-sm text-muted-foreground",t),...s}));pYe.displayName=FR.displayName;var Wue="Collapsible",[TIt]=bd(Wue),[AIt,WNe]=TIt(Wue),fYe=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[d,u]=Bu({prop:n,defaultProp:a??!1,onChange:l,caller:Wue});return e.jsx(AIt,{scope:r,disabled:o,contentId:mu(),open:d,onOpenToggle:k.useCallback(()=>u(p=>!p),[u]),children:e.jsx(dn.div,{"data-state":ZNe(d),"data-disabled":o?"":void 0,...i,ref:s})})});fYe.displayName=Wue;var xYe="CollapsibleTrigger",gYe=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=WNe(xYe,r);return e.jsx(dn.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":ZNe(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Tr(t.onClick,a.onOpenToggle)})});gYe.displayName=xYe;var KNe="CollapsibleContent",yYe=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=WNe(KNe,t.__scopeCollapsible);return e.jsx(wd,{present:r||a.open,children:({present:o})=>e.jsx(EIt,{...n,ref:s,present:o})})});yYe.displayName=KNe;var EIt=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=WNe(KNe,r),[i,d]=k.useState(n),u=k.useRef(null),p=Ma(s,u),f=k.useRef(0),y=f.current,_=k.useRef(0),b=_.current,N=l.open||i,w=k.useRef(N),S=k.useRef(void 0);return k.useEffect(()=>{const C=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(C)},[]),rd(()=>{const C=u.current;if(C){S.current=S.current||{transitionDuration:C.style.transitionDuration,animationName:C.style.animationName},C.style.transitionDuration="0s",C.style.animationName="none";const A=C.getBoundingClientRect();f.current=A.height,_.current=A.width,w.current||(C.style.transitionDuration=S.current.transitionDuration,C.style.animationName=S.current.animationName),d(n)}},[l.open,n]),e.jsx(dn.div,{"data-state":ZNe(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!N,...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:N&&a})});function ZNe(t){return t?"open":"closed"}var PIt=fYe;const uf=PIt,hf=gYe,mf=yYe,IIt="/assets/levelup-logo-Eif24dqY.png",LIt="/assets/levelup-logo-icon-C-7iromj.png",DIt="/assets/levelup-logo-mobile-B9skSjUG.png";var GR=t=>t.type==="checkbox",w4=t=>t instanceof Date,Qm=t=>t==null;const vYe=t=>typeof t=="object";var fd=t=>!Qm(t)&&!Array.isArray(t)&&vYe(t)&&!w4(t),_Ye=t=>fd(t)&&t.target?GR(t.target)?t.target.checked:t.target.value:t,bYe=(t,s)=>s.split(".").some((r,n,a)=>!isNaN(Number(r))&&t.has(a.slice(0,n).join("."))),RIt=t=>{const s=t.constructor&&t.constructor.prototype;return fd(s)&&s.hasOwnProperty("isPrototypeOf")},YNe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Td(t){if(t instanceof Date)return new Date(t);const s=typeof FileList<"u"&&t instanceof FileList;if(YNe&&(t instanceof Blob||s))return t;const r=Array.isArray(t);if(!r&&!(fd(t)&&RIt(t)))return t;const n=r?[]:Object.create(Object.getPrototypeOf(t));for(const a in t)Object.prototype.hasOwnProperty.call(t,a)&&(n[a]=Td(t[a]));return n}var Kue=t=>/^\w*$/.test(t),fc=t=>t===void 0,XNe=t=>Array.isArray(t)?t.filter(Boolean):[],QNe=t=>XNe(t.replace(/["|']|\]/g,"").split(/\.|\[/)),xn=(t,s,r)=>{if(!s||!fd(t))return r;const a=(Kue(s)?[s]:QNe(s)).reduce((o,l)=>Qm(o)?void 0:o[l],t);return fc(a)||a===t?fc(t[s])?r:t[s]:a},Xp=t=>typeof t=="boolean",pm=t=>typeof t=="function",qo=(t,s,r)=>{let n=-1;const a=Kue(s)?[s]:QNe(s),o=a.length,l=o-1;for(;++nht.useContext(JNe);var jYe=(t,s,r,n=!0)=>{const a={defaultValues:s._defaultValues};for(const o in t)Object.defineProperty(a,o,{get:()=>{const l=o;return s._proxyFormState[l]!==Sg.all&&(s._proxyFormState[l]=!n||Sg.all),r&&(r[l]=!0),t[l]}});return a};const tke=typeof window<"u"?ht.useLayoutEffect:ht.useEffect;function OIt(t){const s=eke(),{control:r=s,disabled:n,name:a,exact:o}=t||{},[l,i]=ht.useState(r._formState),d=ht.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return tke(()=>r._subscribe({name:a,formState:d.current,exact:o,callback:u=>{!n&&i({...r._formState,...u})}}),[a,n,o]),ht.useEffect(()=>{d.current.isValid&&r._setValid(!0)},[r]),ht.useMemo(()=>jYe(l,r,d.current,!1),[l,r])}var Eh=t=>typeof t=="string",n_e=(t,s,r,n,a)=>Eh(t)?(n&&s.watch.add(t),xn(r,t,a)):Array.isArray(t)?t.map(o=>(n&&s.watch.add(o),xn(r,o))):(n&&(s.watchAll=!0),r),a_e=t=>Qm(t)||!vYe(t);function ux(t,s,r=new WeakSet){if(t===s)return!0;if(a_e(t)||a_e(s))return Object.is(t,s);if(w4(t)&&w4(s))return Object.is(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(!(o in s))return!1;if(o!=="ref"){const i=s[o];if(w4(l)&&w4(i)||(fd(l)||Array.isArray(l))&&(fd(i)||Array.isArray(i))?!ux(l,i,r):!Object.is(l,i))return!1}}return!0}function FIt(t){const s=eke(),{control:r=s,name:n,defaultValue:a,disabled:o,exact:l,compute:i}=t||{},d=ht.useRef(a),u=ht.useRef(i),p=ht.useRef(void 0),f=ht.useRef(r),y=ht.useRef(n);u.current=i;const[_,b]=ht.useState(()=>{const I=r._getWatch(n,d.current);return u.current?u.current(I):I}),N=ht.useCallback(I=>{const L=n_e(n,r._names,I||r._formValues,!1,d.current);return u.current?u.current(L):L},[r._formValues,r._names,n]),w=ht.useCallback(I=>{if(!o){const L=n_e(n,r._names,I||r._formValues,!1,d.current);if(u.current){const O=u.current(L);ux(O,p.current)||(b(O),p.current=O)}else b(L)}},[r._formValues,r._names,o,n]);tke(()=>((f.current!==r||!ux(y.current,n))&&(f.current=r,y.current=n,w()),r._subscribe({name:n,formState:{values:!0},exact:l,callback:I=>{w(I.values)}})),[r,l,n,w]),ht.useEffect(()=>r._removeUnmounted());const S=f.current!==r,C=y.current,A=ht.useMemo(()=>{if(o)return null;const I=!S&&!ux(C,n);return S||I?N():null},[o,S,n,C,N]);return A!==null?A:_}function zIt(t){const s=eke(),{name:r,disabled:n,control:a=s,shouldUnregister:o,defaultValue:l,exact:i=!0}=t,d=bYe(a._names.array,r),u=ht.useMemo(()=>xn(a._formValues,r,xn(a._defaultValues,r,l)),[a,r,l]),p=FIt({control:a,name:r,defaultValue:u,exact:i}),f=OIt({control:a,name:r,exact:i}),y=ht.useRef(t),_=ht.useRef(void 0),b=ht.useRef(a.register(r,{...t.rules,value:p,...Xp(t.disabled)?{disabled:t.disabled}:{}}));y.current=t;const N=ht.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!xn(f.errors,r)},isDirty:{enumerable:!0,get:()=>!!xn(f.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!xn(f.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!xn(f.validatingFields,r)},error:{enumerable:!0,get:()=>xn(f.errors,r)}}),[f,r]),w=ht.useCallback(I=>b.current.onChange({target:{value:_Ye(I),name:r},type:F_.CHANGE}),[r]),S=ht.useCallback(()=>b.current.onBlur({target:{value:xn(a._formValues,r),name:r},type:F_.BLUR}),[r,a._formValues]),C=ht.useCallback(I=>{const L=xn(a._fields,r);L&&L._f&&I&&(L._f.ref={focus:()=>pm(I.focus)&&I.focus(),select:()=>pm(I.select)&&I.select(),setCustomValidity:O=>pm(I.setCustomValidity)&&I.setCustomValidity(O),reportValidity:()=>pm(I.reportValidity)&&I.reportValidity()})},[a._fields,r]),A=ht.useMemo(()=>({name:r,value:p,...Xp(n)||f.disabled?{disabled:f.disabled||n}:{},onChange:w,onBlur:S,ref:C}),[r,n,f.disabled,w,S,C,p]);return ht.useEffect(()=>{const I=a._options.shouldUnregister||o,L=_.current;L&&L!==r&&!d&&a.unregister(L),a.register(r,{...y.current.rules,...Xp(y.current.disabled)?{disabled:y.current.disabled}:{}});const O=(U,q)=>{const $=xn(a._fields,U);$&&$._f&&($._f.mount=q)};if(O(r,!0),I){const U=Td(xn(a._options.defaultValues,r,y.current.defaultValue));qo(a._defaultValues,r,U),fc(xn(a._formValues,r))&&qo(a._formValues,r,U)}return!d&&a.register(r),_.current=r,()=>{(d?I&&!a._state.action:I)?a.unregister(r):O(r,!1)}},[r,a,d,o]),ht.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),ht.useMemo(()=>({field:A,formState:f,fieldState:N}),[A,f,N])}const BIt=t=>t.render(zIt(t)),ske=ht.createContext(null);ske.displayName="HookFormContext";const $It=()=>ht.useContext(ske),qIt=t=>{const{children:s,watch:r,getValues:n,getFieldState:a,setError:o,clearErrors:l,setValue:i,trigger:d,formState:u,resetField:p,reset:f,handleSubmit:y,unregister:_,control:b,register:N,setFocus:w,subscribe:S}=t,C=ht.useMemo(()=>({watch:r,getValues:n,getFieldState:a,setError:o,clearErrors:l,setValue:i,trigger:d,formState:u,resetField:p,reset:f,handleSubmit:y,unregister:_,control:b,register:N,setFocus:w,subscribe:S}),[l,b,u,a,n,y,N,f,p,o,w,i,S,d,_,r]);return ht.createElement(ske.Provider,{value:C},ht.createElement(JNe.Provider,{value:C.control},s))};var NYe=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},n8=t=>Array.isArray(t)?t:[t],J6e=()=>{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=[]}}};function kYe(t,s){const r={};for(const n in t)if(t.hasOwnProperty(n)){const a=t[n],o=s[n];if(a&&fd(a)&&o){const l=kYe(a,o);fd(l)&&(r[n]=l)}else t[n]&&(r[n]=o)}return r}var kh=t=>fd(t)&&!Object.keys(t).length,rke=t=>t.type==="file",gle=t=>{if(!YNe)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},SYe=t=>t.type==="select-multiple",nke=t=>t.type==="radio",UIt=t=>nke(t)||GR(t),zge=t=>gle(t)&&t.isConnected;function VIt(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(pm(t[s]))return!0;return!1};function CYe(t){return Array.isArray(t)||fd(t)&&!GIt(t)}function i_e(t,s={}){for(const r in t){const n=t[r];CYe(n)?(s[r]=Array.isArray(n)?[]:{},i_e(n,s[r])):fc(n)||(s[r]=!0)}return s}function D6(t,s,r){r||(r=i_e(s));for(const n in t){const a=t[n];if(CYe(a))fc(s)||a_e(r[n])?r[n]=i_e(a,Array.isArray(a)?[]:{}):D6(a,Qm(s)?{}:s[n],r[n]);else{const o=s[n];r[n]=!ux(a,o)}}return r}const eLe={value:!1,isValid:!1},tLe={value:!0,isValid:!0};var MYe=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&&!fc(t[0].attributes.value)?fc(t[0].value)||t[0].value===""?tLe:{value:t[0].value,isValid:!0}:tLe:eLe}return eLe},TYe=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>fc(t)?t:s?t===""?NaN:t&&+t:r&&Eh(t)?new Date(t):n?n(t):t;const sLe={isValid:!1,value:null};var AYe=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,sLe):sLe;function rLe(t){const s=t.ref;return rke(s)?s.files:nke(s)?AYe(t.refs).value:SYe(s)?[...s.selectedOptions].map(({value:r})=>r):GR(s)?MYe(t.refs).value:TYe(fc(s.value)?t.ref.value:s.value,t)}var WIt=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,KIt=(t,s,r,n)=>{const a={};for(const o of t){const l=xn(s,o);l&&qo(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},yle=t=>t instanceof RegExp,s6=t=>fc(t)?t:yle(t)?t.source:fd(t)?yle(t.value)?t.value.source:t.value:t,nLe=t=>({isOnSubmit:!t||t===Sg.onSubmit,isOnBlur:t===Sg.onBlur,isOnChange:t===Sg.onChange,isOnAll:t===Sg.all,isOnTouch:t===Sg.onTouched});const aLe="AsyncFunction";var ZIt=t=>!!t&&!!t.validate&&!!(pm(t.validate)&&t.validate.constructor.name===aLe||fd(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===aLe)),YIt=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),iLe=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const a8=(t,s,r,n)=>{for(const a of r||Object.keys(t)){const o=xn(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(a8(i,s))break}else if(fd(i)&&a8(i,s))break}}};function oLe(t,s,r){const n=xn(t,r);if(n||Kue(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),l=xn(s,o),i=xn(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 XIt=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return kh(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||Sg.all))},QIt=(t,s,r)=>!t||!s||t===s||n8(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),JIt=(t,s,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(s||t):(r?n.isOnBlur:a.isOnBlur)?!t:(r?n.isOnChange:a.isOnChange)?t:!0,e6t=(t,s)=>!XNe(xn(t,s)).length&&Ad(t,s),t6t=(t,s,r)=>{const n=n8(xn(t,r));return qo(n,wYe,s[r]),qo(t,r,n),t};function lLe(t,s,r="validate"){if(Eh(t)||Array.isArray(t)&&t.every(Eh)||Xp(t)&&!t)return{type:r,message:Eh(t)?t:"",ref:s}}var y5=t=>fd(t)&&!yle(t)?t:{value:t,message:""},cLe=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:d,maxLength:u,minLength:p,min:f,max:y,pattern:_,validate:b,name:N,valueAsNumber:w,mount:S}=t._f,C=xn(r,N);if(!S||s.has(N))return{};const A=i?i[0]:l,I=Z=>{a&&A.reportValidity&&(A.setCustomValidity(Xp(Z)?"":Z||""),A.reportValidity())},L={},O=nke(l),U=GR(l),q=O||U,$=(w||rke(l))&&fc(l.value)&&fc(C)||gle(l)&&l.value===""||C===""||Array.isArray(C)&&!C.length,V=NYe.bind(null,N,n,L),ee=(Z,J,Y,ce=gg.maxLength,ae=gg.minLength)=>{const ie=Z?J:Y;L[N]={type:Z?ce:ae,message:ie,ref:l,...V(Z?ce:ae,ie)}};if(o?!Array.isArray(C)||!C.length:d&&(!q&&($||Qm(C))||Xp(C)&&!C||U&&!MYe(i).isValid||O&&!AYe(i).isValid)){const{value:Z,message:J}=Eh(d)?{value:!!d,message:d}:y5(d);if(Z&&(L[N]={type:gg.required,message:J,ref:A,...V(gg.required,J)},!n))return I(J),L}if(!$&&(!Qm(f)||!Qm(y))){let Z,J;const Y=y5(y),ce=y5(f);if(!Qm(C)&&!isNaN(C)){const ae=l.valueAsNumber||C&&+C;Qm(Y.value)||(Z=ae>Y.value),Qm(ce.value)||(J=aenew Date(new Date().toDateString()+" "+xe),le=l.type=="time",fe=l.type=="week";Eh(Y.value)&&C&&(Z=le?ie(C)>ie(Y.value):fe?C>Y.value:ae>new Date(Y.value)),Eh(ce.value)&&C&&(J=le?ie(C)+Z.value,ce=!Qm(J.value)&&C.length<+J.value;if((Y||ce)&&(ee(Y,Z.message,J.message),!n))return I(L[N].message),L}if(_&&!$&&Eh(C)){const{value:Z,message:J}=y5(_);if(yle(Z)&&!C.match(Z)&&(L[N]={type:gg.pattern,message:J,ref:l,...V(gg.pattern,J)},!n))return I(J),L}if(b){if(pm(b)){const Z=await b(C,r),J=lLe(Z,A);if(J&&(L[N]={...J,...V(gg.validate,J.message)},!n))return I(J.message),L}else if(fd(b)){let Z={};for(const J in b){if(!kh(Z)&&!n)break;const Y=lLe(await b[J](C,r),A,J);Y&&(Z={...Y,...V(J,Y.message)},I(Y.message),n&&(L[N]=Z))}if(!kh(Z)&&(L[N]={ref:A,...Z},!n))return L}}return I(!0),L};const s6t={mode:Sg.onSubmit,reValidateMode:Sg.onChange,shouldFocusError:!0};function r6t(t={}){let s={...s6t,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:pm(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=fd(s.defaultValues)||fd(s.values)?Td(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:Td(a),l={action:!1,mount:!1,watch:!1,keepIsValid:!1},i={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},d,u=0;const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...p};let y={...f};const _={array:J6e(),state:J6e()},b=s.criteriaMode===Sg.all,N=Oe=>Xe=>{clearTimeout(u),u=setTimeout(Oe,Xe)},w=async Oe=>{if(!l.keepIsValid&&!s.disabled&&(f.isValid||y.isValid||Oe)){let Xe;s.resolver?(Xe=kh((await $()).errors),S()):Xe=await Z({fields:n,onlyCheckValid:!0,eventType:F_.VALID}),Xe!==r.isValid&&_.state.next({isValid:Xe})}},S=(Oe,Xe)=>{!s.disabled&&(f.isValidating||f.validatingFields||y.isValidating||y.validatingFields)&&((Oe||Array.from(i.mount)).forEach(at=>{at&&(Xe?qo(r.validatingFields,at,Xe):Ad(r.validatingFields,at))}),_.state.next({validatingFields:r.validatingFields,isValidating:!kh(r.validatingFields)}))},C=Oe=>{const Xe=D6(a,o),at=WIt(Oe);qo(r.dirtyFields,at,xn(Xe,at))},A=(Oe,Xe=[],at,Ke,He=!0,gt=!0)=>{if(Ke&&at&&!s.disabled){if(l.action=!0,gt&&Array.isArray(xn(n,Oe))){const Mt=at(xn(n,Oe),Ke.argA,Ke.argB);He&&qo(n,Oe,Mt)}if(gt&&Array.isArray(xn(r.errors,Oe))){const Mt=at(xn(r.errors,Oe),Ke.argA,Ke.argB);He&&qo(r.errors,Oe,Mt),e6t(r.errors,Oe)}if((f.touchedFields||y.touchedFields)&>&&Array.isArray(xn(r.touchedFields,Oe))){const Mt=at(xn(r.touchedFields,Oe),Ke.argA,Ke.argB);He&&qo(r.touchedFields,Oe,Mt)}(f.dirtyFields||y.dirtyFields)&&C(Oe),_.state.next({name:Oe,isDirty:Y(Oe,Xe),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else qo(o,Oe,Xe)},I=(Oe,Xe)=>{qo(r.errors,Oe,Xe),_.state.next({errors:r.errors})},L=Oe=>{r.errors=Oe,_.state.next({errors:r.errors,isValid:!1})},O=(Oe,Xe,at,Ke)=>{const He=xn(n,Oe);if(He){const gt=xn(o,Oe,fc(at)?xn(a,Oe):at);fc(gt)||Ke&&Ke.defaultChecked||Xe?qo(o,Oe,Xe?gt:rLe(He._f)):ie(Oe,gt),l.mount&&!l.action&&w()}},U=(Oe,Xe,at,Ke,He)=>{let gt=!1,Mt=!1;const Wt={name:Oe};if(!s.disabled){if(!at||Ke){(f.isDirty||y.isDirty)&&(Mt=r.isDirty,r.isDirty=Wt.isDirty=Y(),gt=Mt!==Wt.isDirty);const xs=ux(xn(a,Oe),Xe);Mt=!!xn(r.dirtyFields,Oe),xs?Ad(r.dirtyFields,Oe):qo(r.dirtyFields,Oe,!0),Wt.dirtyFields=r.dirtyFields,gt=gt||(f.dirtyFields||y.dirtyFields)&&Mt!==!xs}if(at){const xs=xn(r.touchedFields,Oe);xs||(qo(r.touchedFields,Oe,at),Wt.touchedFields=r.touchedFields,gt=gt||(f.touchedFields||y.touchedFields)&&xs!==at)}gt&&He&&_.state.next(Wt)}return gt?Wt:{}},q=(Oe,Xe,at,Ke)=>{const He=xn(r.errors,Oe),gt=(f.isValid||y.isValid)&&Xp(Xe)&&r.isValid!==Xe;if(s.delayError&&at?(d=N(()=>I(Oe,at)),d(s.delayError)):(clearTimeout(u),d=null,at?qo(r.errors,Oe,at):Ad(r.errors,Oe)),(at?!ux(He,at):He)||!kh(Ke)||gt){const Mt={...Ke,...gt&&Xp(Xe)?{isValid:Xe}:{},errors:r.errors,name:Oe};r={...r,...Mt},_.state.next(Mt)}},$=async Oe=>(S(Oe,!0),await s.resolver(o,s.context,KIt(Oe||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation))),V=async Oe=>{const{errors:Xe}=await $(Oe);if(S(Oe),Oe)for(const at of Oe){const Ke=xn(Xe,at);Ke?qo(r.errors,at,Ke):Ad(r.errors,at)}else r.errors=Xe;return Xe},ee=async({name:Oe,eventType:Xe})=>{if(t.validate){const at=await t.validate({formValues:o,formState:r,name:Oe,eventType:Xe});if(fd(at))for(const Ke in at)at[Ke]&&Ae(`${Fge}.${Ke}`,{message:Eh(at.message)?at.message:"",type:gg.validate});else Eh(at)||!at?Ae(Fge,{message:at||"",type:gg.validate}):Te(Fge);return at}return!0},Z=async({fields:Oe,onlyCheckValid:Xe,name:at,eventType:Ke,context:He={valid:!0,runRootValidation:!1}})=>{if(t.validate&&(He.runRootValidation=!0,!await ee({name:at,eventType:Ke})&&(He.valid=!1,Xe)))return He.valid;for(const gt in Oe){const Mt=Oe[gt];if(Mt){const{_f:Wt,...xs}=Mt;if(Wt){const Cs=i.array.has(Wt.name),Us=Mt._f&&ZIt(Mt._f);Us&&f.validatingFields&&S([Wt.name],!0);const Ar=await cLe(Mt,i.disabled,o,b,s.shouldUseNativeValidation&&!Xe,Cs);if(Us&&f.validatingFields&&S([Wt.name]),Ar[Wt.name]&&(He.valid=!1,Xe)||(!Xe&&(xn(Ar,Wt.name)?Cs?t6t(r.errors,Ar,Wt.name):qo(r.errors,Wt.name,Ar[Wt.name]):Ad(r.errors,Wt.name)),t.shouldUseNativeValidation&&Ar[Wt.name]))break}!kh(xs)&&await Z({context:He,onlyCheckValid:Xe,fields:xs,name:gt,eventType:Ke})}}return He.valid},J=()=>{for(const Oe of i.unMount){const Xe=xn(n,Oe);Xe&&(Xe._f.refs?Xe._f.refs.every(at=>!zge(at)):!zge(Xe._f.ref))&&Re(Oe)}i.unMount=new Set},Y=(Oe,Xe)=>!s.disabled&&(Oe&&Xe&&qo(o,Oe,Xe),!ux(Ne(),a)),ce=(Oe,Xe,at)=>n_e(Oe,i,{...l.mount?o:fc(Xe)?a:Eh(Oe)?{[Oe]:Xe}:Xe},at,Xe),ae=Oe=>XNe(xn(l.mount?o:a,Oe,s.shouldUnregister?xn(a,Oe,[]):[])),ie=(Oe,Xe,at={})=>{const Ke=xn(n,Oe);let He=Xe;if(Ke){const gt=Ke._f;gt&&(!gt.disabled&&qo(o,Oe,TYe(Xe,gt)),He=gle(gt.ref)&&Qm(Xe)?"":Xe,SYe(gt.ref)?[...gt.ref.options].forEach(Mt=>Mt.selected=He.includes(Mt.value)):gt.refs?GR(gt.ref)?gt.refs.forEach(Mt=>{(!Mt.defaultChecked||!Mt.disabled)&&(Array.isArray(He)?Mt.checked=!!He.find(Wt=>Wt===Mt.value):Mt.checked=He===Mt.value||!!He)}):gt.refs.forEach(Mt=>Mt.checked=Mt.value===He):rke(gt.ref)?gt.ref.value="":(gt.ref.value=He,gt.ref.type||_.state.next({name:Oe,values:Td(o)})))}(at.shouldDirty||at.shouldTouch)&&U(Oe,He,at.shouldTouch,at.shouldDirty,!0),at.shouldValidate&&we(Oe)},le=(Oe,Xe,at)=>{for(const Ke in Xe){if(!Xe.hasOwnProperty(Ke))return;const He=Xe[Ke],gt=Oe+"."+Ke,Mt=xn(n,gt);(i.array.has(Oe)||fd(He)||Mt&&!Mt._f)&&!w4(He)?le(gt,He,at):ie(gt,He,at)}},fe=(Oe,Xe,at={})=>{const Ke=xn(n,Oe),He=i.array.has(Oe),gt=Td(Xe),Mt=xn(o,Oe),Wt=ux(Mt,gt);if(qo(o,Oe,gt),He)_.array.next({name:Oe,values:Td(o)}),at.shouldDirty&&(C(Oe),_.state.next({name:Oe,dirtyFields:r.dirtyFields,isDirty:Y(Oe,gt)}));else{const xs=Array.isArray(gt)&&!gt.length||kh(gt);!Ke||Ke._f||Qm(gt)||xs?ie(Oe,gt,at):le(Oe,gt,at)}Wt||(iLe(Oe,i)?_.state.next({...r,name:Oe,values:Td(o)}):_.state.next({name:l.mount?Oe:void 0,values:Td(o)}))},xe=async Oe=>{l.mount=!0;const Xe=Oe.target;let at=Xe.name,Ke=!0;const He=xn(n,at),gt=xs=>{Ke=Number.isNaN(xs)||w4(xs)&&isNaN(xs.getTime())||ux(xs,xn(o,at,xs))},Mt=nLe(s.mode),Wt=nLe(s.reValidateMode);if(He){let xs,Cs;const Us=Xe.type?rLe(He._f):_Ye(Oe),Ar=Oe.type===F_.BLUR||Oe.type===F_.FOCUS_OUT,Bt=!YIt(He._f)&&!t.validate&&!s.resolver&&!xn(r.errors,at)&&!He._f.deps||JIt(Ar,xn(r.touchedFields,at),r.isSubmitted,Wt,Mt),Xs=iLe(at,i,Ar);qo(o,at,Us),Ar?(!Xe||!Xe.readOnly)&&(He._f.onBlur&&He._f.onBlur(Oe),d&&d(0)):He._f.onChange&&He._f.onChange(Oe);const Nr=U(at,Us,Ar),Vs=!kh(Nr)||Xs;if(!Ar&&_.state.next({name:at,type:Oe.type,values:Td(o)}),Bt)return(f.isValid||y.isValid)&&(s.mode==="onBlur"?Ar&&w():Ar||w()),Vs&&_.state.next({name:at,...Xs?{}:Nr});if(!s.resolver&&t.validate&&await ee({name:at,eventType:Oe.type}),!Ar&&Xs&&_.state.next({...r}),s.resolver){const{errors:ar}=await $([at]);if(S([at]),gt(Us),Ke){const Or=oLe(r.errors,n,at),Rn=oLe(ar,n,Or.name||at);xs=Rn.error,at=Rn.name,Cs=kh(ar)}}else S([at],!0),xs=(await cLe(He,i.disabled,o,b,s.shouldUseNativeValidation))[at],S([at]),gt(Us),Ke&&(xs?Cs=!1:(f.isValid||y.isValid)&&(Cs=await Z({fields:n,onlyCheckValid:!0,name:at,eventType:Oe.type})));Ke&&(He._f.deps&&(!Array.isArray(He._f.deps)||He._f.deps.length>0)&&we(He._f.deps),q(at,Cs,xs,Nr))}},he=(Oe,Xe)=>{if(xn(r.errors,Xe)&&Oe.focus)return Oe.focus(),1},we=async(Oe,Xe={})=>{let at,Ke;const He=n8(Oe);if(s.resolver){const gt=await V(fc(Oe)?Oe:He);at=kh(gt),Ke=Oe?!He.some(Mt=>xn(gt,Mt)):at}else Oe?(Ke=(await Promise.all(He.map(async gt=>{const Mt=xn(n,gt);return await Z({fields:Mt&&Mt._f?{[gt]:Mt}:Mt,eventType:F_.TRIGGER})}))).every(Boolean),!(!Ke&&!r.isValid)&&w()):Ke=at=await Z({fields:n,name:Oe,eventType:F_.TRIGGER});return _.state.next({...!Eh(Oe)||(f.isValid||y.isValid)&&at!==r.isValid?{}:{name:Oe},...s.resolver||!Oe?{isValid:at}:{},errors:r.errors}),Xe.shouldFocus&&!Ke&&a8(n,he,Oe?He:i.mount),Ke},Ne=(Oe,Xe)=>{let at={...l.mount?o:a};return Xe&&(at=kYe(Xe.dirtyFields?r.dirtyFields:r.touchedFields,at)),fc(Oe)?at:Eh(Oe)?xn(at,Oe):Oe.map(Ke=>xn(at,Ke))},Ve=(Oe,Xe)=>({invalid:!!xn((Xe||r).errors,Oe),isDirty:!!xn((Xe||r).dirtyFields,Oe),error:xn((Xe||r).errors,Oe),isValidating:!!xn(r.validatingFields,Oe),isTouched:!!xn((Xe||r).touchedFields,Oe)}),Te=Oe=>{const Xe=Oe?n8(Oe):void 0;Xe==null||Xe.forEach(at=>Ad(r.errors,at)),Xe?Xe.forEach(at=>{_.state.next({name:at,errors:r.errors})}):_.state.next({errors:{}})},Ae=(Oe,Xe,at)=>{const Ke=(xn(n,Oe,{_f:{}})._f||{}).ref,He=xn(r.errors,Oe)||{},{ref:gt,message:Mt,type:Wt,...xs}=He;qo(r.errors,Oe,{...xs,...Xe,ref:Ke}),_.state.next({name:Oe,errors:r.errors,isValid:!1}),at&&at.shouldFocus&&Ke&&Ke.focus&&Ke.focus()},ze=(Oe,Xe)=>pm(Oe)?_.state.subscribe({next:at=>"values"in at&&Oe(at.values||ce(void 0,Xe),at)}):ce(Oe,Xe,!0),Ee=Oe=>_.state.subscribe({next:Xe=>{if(QIt(Oe.name,Xe.name,Oe.exact)&&XIt(Xe,Oe.formState||f,Ct,Oe.reRenderRoot)){const at={...o};Oe.callback({values:at,...r,...Xe,defaultValues:a})}}}).unsubscribe,ve=Oe=>(l.mount=!0,y={...y,...Oe.formState},Ee({...Oe,formState:{...p,...Oe.formState}})),Re=(Oe,Xe={})=>{for(const at of Oe?n8(Oe):i.mount)i.mount.delete(at),i.array.delete(at),Xe.keepValue||(Ad(n,at),Ad(o,at)),!Xe.keepError&&Ad(r.errors,at),!Xe.keepDirty&&Ad(r.dirtyFields,at),!Xe.keepTouched&&Ad(r.touchedFields,at),!Xe.keepIsValidating&&Ad(r.validatingFields,at),!s.shouldUnregister&&!Xe.keepDefaultValue&&Ad(a,at);_.state.next({values:Td(o)}),_.state.next({...r,...Xe.keepDirty?{isDirty:Y()}:{}}),!Xe.keepIsValid&&w()},Ue=({disabled:Oe,name:Xe})=>{if(Xp(Oe)&&l.mount||Oe||i.disabled.has(Xe)){const He=i.disabled.has(Xe)!==!!Oe;Oe?i.disabled.add(Xe):i.disabled.delete(Xe),He&&l.mount&&!l.action&&w()}},ye=(Oe,Xe={})=>{let at=xn(n,Oe);const Ke=Xp(Xe.disabled)||Xp(s.disabled),He=!i.registerName.has(Oe)&&at&&at._f&&!at._f.mount;return qo(n,Oe,{...at||{},_f:{...at&&at._f?at._f:{ref:{name:Oe}},name:Oe,mount:!0,...Xe}}),i.mount.add(Oe),at&&!He?Ue({disabled:Xp(Xe.disabled)?Xe.disabled:s.disabled,name:Oe}):O(Oe,!0,Xe.value),{...Ke?{disabled:Xe.disabled||s.disabled}:{},...s.progressive?{required:!!Xe.required,min:s6(Xe.min),max:s6(Xe.max),minLength:s6(Xe.minLength),maxLength:s6(Xe.maxLength),pattern:s6(Xe.pattern)}:{},name:Oe,onChange:xe,onBlur:xe,ref:gt=>{if(gt){i.registerName.add(Oe),ye(Oe,Xe),i.registerName.delete(Oe),at=xn(n,Oe);const Mt=fc(gt.value)&>.querySelectorAll&>.querySelectorAll("input,select,textarea")[0]||gt,Wt=UIt(Mt),xs=at._f.refs||[];if(Wt?xs.find(Cs=>Cs===Mt):Mt===at._f.ref)return;qo(n,Oe,{_f:{...at._f,...Wt?{refs:[...xs.filter(zge),Mt,...Array.isArray(xn(a,Oe))?[{}]:[]],ref:{type:Mt.type,name:Oe}}:{ref:Mt}}}),O(Oe,!1,void 0,Mt)}else at=xn(n,Oe,{}),at._f&&(at._f.mount=!1),(s.shouldUnregister||Xe.shouldUnregister)&&!(bYe(i.array,Oe)&&l.action)&&i.unMount.add(Oe)}}},ct=()=>s.shouldFocusError&&a8(n,he,i.mount),pe=Oe=>{Xp(Oe)&&(_.state.next({disabled:Oe}),a8(n,(Xe,at)=>{const Ke=xn(n,at);Ke&&(Xe.disabled=Ke._f.disabled||Oe,Array.isArray(Ke._f.refs)&&Ke._f.refs.forEach(He=>{He.disabled=Ke._f.disabled||Oe}))},0,!1))},Ge=(Oe,Xe)=>async at=>{let Ke;at&&(at.preventDefault&&at.preventDefault(),at.persist&&at.persist());let He=Td(o);if(_.state.next({isSubmitting:!0}),s.resolver){const{errors:gt,values:Mt}=await $();S(),r.errors=gt,He=Td(Mt)}else await Z({fields:n,eventType:F_.SUBMIT});if(i.disabled.size)for(const gt of i.disabled)Ad(He,gt);if(Ad(r.errors,wYe),kh(r.errors)){_.state.next({errors:{}});try{await Oe(He,at)}catch(gt){Ke=gt}}else Xe&&await Xe({...r.errors},at),ct(),setTimeout(ct);if(_.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:kh(r.errors)&&!Ke,submitCount:r.submitCount+1,errors:r.errors}),Ke)throw Ke},tt=(Oe,Xe={})=>{xn(n,Oe)&&(fc(Xe.defaultValue)?fe(Oe,Td(xn(a,Oe))):(fe(Oe,Xe.defaultValue),qo(a,Oe,Td(Xe.defaultValue))),Xe.keepTouched||Ad(r.touchedFields,Oe),Xe.keepDirty||(Ad(r.dirtyFields,Oe),r.isDirty=Xe.defaultValue?Y(Oe,Td(xn(a,Oe))):Y()),Xe.keepError||(Ad(r.errors,Oe),f.isValid&&w()),_.state.next({...r}))},st=(Oe,Xe={})=>{const at=Oe?Td(Oe):a,Ke=Td(at),He=kh(Oe),gt=He?a:Ke;if(Xe.keepDefaultValues||(a=at),!Xe.keepValues){if(Xe.keepDirtyValues){const Mt=new Set([...i.mount,...Object.keys(D6(a,o))]);for(const Wt of Array.from(Mt)){const xs=xn(r.dirtyFields,Wt),Cs=xn(o,Wt),Us=xn(gt,Wt);xs&&!fc(Cs)?qo(gt,Wt,Cs):!xs&&!fc(Us)&&fe(Wt,Us)}}else{if(YNe&&fc(Oe))for(const Mt of i.mount){const Wt=xn(n,Mt);if(Wt&&Wt._f){const xs=Array.isArray(Wt._f.refs)?Wt._f.refs[0]:Wt._f.ref;if(gle(xs)){const Cs=xs.closest("form");if(Cs){Cs.reset();break}}}}if(Xe.keepFieldsRef)for(const Mt of i.mount)fe(Mt,xn(gt,Mt));else n={}}o=s.shouldUnregister?Xe.keepDefaultValues?Td(a):{}:Td(gt),_.array.next({values:{...gt}}),_.state.next({values:{...gt}})}i={mount:Xe.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!f.isValid||!!Xe.keepIsValid||!!Xe.keepDirtyValues||!s.shouldUnregister&&!kh(gt),l.watch=!!s.shouldUnregister,l.keepIsValid=!!Xe.keepIsValid,l.action=!1,Xe.keepErrors||(r.errors={}),_.state.next({submitCount:Xe.keepSubmitCount?r.submitCount:0,isDirty:He?!1:Xe.keepDirty?r.isDirty:!!(Xe.keepDefaultValues&&!ux(Oe,a)),isSubmitted:Xe.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:He?{}:Xe.keepDirtyValues?Xe.keepDefaultValues&&o?D6(a,o):r.dirtyFields:Xe.keepDefaultValues&&Oe?D6(a,Oe):Xe.keepDirty?r.dirtyFields:{},touchedFields:Xe.keepTouched?r.touchedFields:{},errors:Xe.keepErrors?r.errors:{},isSubmitSuccessful:Xe.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Ce=(Oe,Xe)=>st(pm(Oe)?Oe(o):Oe,{...s.resetOptions,...Xe}),et=(Oe,Xe={})=>{const at=xn(n,Oe),Ke=at&&at._f;if(Ke){const He=Ke.refs?Ke.refs[0]:Ke.ref;He.focus&&setTimeout(()=>{He.focus(),Xe.shouldSelect&&pm(He.select)&&He.select()})}},Ct=Oe=>{r={...r,...Oe}},ut={control:{register:ye,unregister:Re,getFieldState:Ve,handleSubmit:Ge,setError:Ae,_subscribe:Ee,_runSchema:$,_updateIsValidating:S,_focusError:ct,_getWatch:ce,_getDirty:Y,_setValid:w,_setFieldArray:A,_setDisabledField:Ue,_setErrors:L,_getFieldArray:ae,_reset:st,_resetDefaultValues:()=>pm(s.defaultValues)&&s.defaultValues().then(Oe=>{Ce(Oe,s.resetOptions),_.state.next({isLoading:!1})}),_removeUnmounted:J,_disableForm:pe,_subjects:_,_proxyFormState:f,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(Oe){l=Oe},get _defaultValues(){return a},get _names(){return i},set _names(Oe){i=Oe},get _formState(){return r},get _options(){return s},set _options(Oe){s={...s,...Oe}}},subscribe:ve,trigger:we,register:ye,handleSubmit:Ge,watch:ze,setValue:fe,getValues:Ne,reset:Ce,resetField:tt,clearErrors:Te,unregister:Re,setError:Ae,setFocus:et,getFieldState:Ve};return{...ut,formControl:ut}}function Zue(t={}){const s=ht.useRef(void 0),r=ht.useRef(void 0),[n,a]=ht.useState({isDirty:!1,isValidating:!1,isLoading:pm(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:pm(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!pm(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=r6t(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,tke(()=>{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(()=>{var l;t.values&&!ux(t.values,r.current)?(o._reset(t.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),r.current=t.values,a(i=>({...i}))):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=ht.useMemo(()=>jYe(n,o),[o,n]),s.current}const dLe=(t,s,r)=>{if(t&&"reportValidity"in t){const n=xn(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},EYe=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?dLe(n.ref,r,t):n.refs&&n.refs.forEach(a=>dLe(a,r,t))}},n6t=(t,s)=>{s.shouldUseNativeValidation&&EYe(t,s);const r={};for(const n in t){const a=xn(s.fields,n),o=Object.assign(t[n]||{},{ref:a&&a.ref});if(a6t(s.names||Object.keys(t),n)){const l=Object.assign({},xn(r,n));qo(l,"root",o),qo(r,n,l)}else qo(r,n,o)}return r},a6t=(t,s)=>t.some(r=>r.startsWith(s+"."));var i6t=function(t,s){for(var r={};t.length;){var n=t[0],a=n.code,o=n.message,l=n.path.join(".");if(!r[l])if("unionErrors"in n){var i=n.unionErrors[0].errors[0];r[l]={message:i.message,type:i.code}}else r[l]={message:o,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(p){return p.errors.forEach(function(f){return t.push(f)})}),s){var d=r[l].types,u=d&&d[n.code];r[l]=NYe(l,s,r,a,u?[].concat(u,n.message):n.message)}t.shift()}return r},Yue=function(t,s,r){return r===void 0&&(r={}),function(n,a,o){try{return Promise.resolve(function(l,i){try{var d=Promise.resolve(t[r.mode==="sync"?"parse":"parseAsync"](n,s)).then(function(u){return o.shouldUseNativeValidation&&EYe({},o),{errors:{},values:r.raw?n:u}})}catch(u){return i(u)}return d&&d.then?d.then(void 0,i):d}(0,function(l){if(function(i){return Array.isArray(i==null?void 0:i.errors)}(l))return{values:{},errors:n6t(i6t(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const Xue=qIt,PYe=k.createContext({}),Ic=({...t})=>e.jsx(PYe.Provider,{value:{name:t.name},children:e.jsx(BIt,{...t})}),Que=()=>{const t=k.useContext(PYe),s=k.useContext(IYe),{getFieldState:r,formState:n}=$It(),a=r(t.name,n);if(!t)throw new Error("useFormField should be used within ");const{id:o}=s;return{id:o,name:t.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...a}},IYe=k.createContext({}),uc=k.forwardRef(({className:t,...s},r)=>{const n=k.useId();return e.jsx(IYe.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:Rt("space-y-2",t),...s})})});uc.displayName="FormItem";const hc=k.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=Que();return e.jsx(ge,{ref:r,className:Rt(n&&"text-destructive",t),htmlFor:a,...s})});hc.displayName="FormLabel";const mc=k.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=Que();return e.jsx(Dje,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});mc.displayName="FormControl";const Qie=k.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=Que();return e.jsx("p",{ref:r,id:n,className:Rt("text-sm text-muted-foreground",t),...s})});Qie.displayName="FormDescription";const gm=k.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=Que(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:Rt("text-sm font-medium text-destructive",t),...r,children:l}):null});gm.displayName="FormMessage";const o6t=SC({category:lKe(["general","technology","crm","marketing"]),subject:Yl().min(5,"Subject must be at least 5 characters").max(200),description:Yl().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),l6t={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function o_e({trigger:t}){const[s,r]=k.useState(!1),[n,a]=k.useState(!1),{user:o}=$s(),l=Zue({resolver:Yue(o6t),defaultValues:{category:"general",subject:"",description:""}}),i=async d=>{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:d.category,subject:d.subject,description:d.description});if(u)throw u;try{await G.functions.invoke("support-ticket-notify",{body:{category:l6t[d.category],subject:d.subject}})}catch(p){console.log("Notification send attempted:",p)}me.success("Support ticket submitted successfully!"),l.reset(),r(!1)}catch(u){console.error("Error submitting ticket:",u),me.error("Failed to submit ticket. Please try again.")}finally{a(!1)}};return e.jsxs(fs,{open:s,onOpenChange:r,children:[e.jsx(ui,{asChild:!0,children:t||e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(jL,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(ms,{className:"sm:max-w-[500px]",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Need Help?"}),e.jsx(Rr,{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(Tn,{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(Xue,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(Ic,{control:l.control,name:"category",render:({field:d})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Category"}),e.jsxs(zs,{onValueChange:d.onChange,defaultValue:d.value,children:[e.jsx(mc,{children:e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select a category"})})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"general",children:"General Support"}),e.jsx(yt,{value:"technology",children:"Technology Support"}),e.jsx(yt,{value:"crm",children:"CRM Support"}),e.jsx(yt,{value:"marketing",children:"Marketing Support"})]})]}),e.jsx(gm,{})]})}),e.jsx(Ic,{control:l.control,name:"subject",render:({field:d})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Subject"}),e.jsx(mc,{children:e.jsx(Fe,{placeholder:"Brief description of your issue",...d})}),e.jsx(gm,{})]})}),e.jsx(Ic,{control:l.control,name:"description",render:({field:d})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Description"}),e.jsx(mc,{children:e.jsx(_r,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...d})}),e.jsx(gm,{})]})}),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 c6t=()=>{const{user:t}=$s(),s=br(),[r,n]=k.useState([]),[a,o]=k.useState(0),[l,i]=k.useState(!1),[d,u]=k.useState(null);k.useEffect(()=>{if(!t)return;const b=`notification_last_read_${t.id}`;let N=d;if(!N){const C=localStorage.getItem(b);C&&(N=C,u(C))}(async()=>{const{data:C,error:A}=await G.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!A&&C){n(C);const I=N?new Date(N):null,L=C.filter(O=>I?new Date(O.created_at)>I:!0);o(L.length)}})();const S=G.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},C=>{const A=C.new;n(L=>[A,...L].slice(0,20));const I=N?new Date(N):null;(!I||new Date(A.created_at)>I)&&o(L=>L+1),Notification.permission==="granted"&&new Notification(A.title,{body:A.body,icon:"/favicon.ico"})}).subscribe();return()=>{G.removeChannel(S)}},[t,d]);const p=b=>{const N=b.toLowerCase();return N.includes("community")||N.includes("post")?Si:N.includes("academy")||N.includes("video")?hn:N.includes("template")?Rl:N.includes("event")?nn:N.includes("newsletter")?Jv:N.includes("brokerage")?Lh:N.includes("swag")||N.includes("social")?Vi:N.includes("toolbox")||N.includes("tool")?Og:N.includes("brief")?qr:Si},f=b=>{i(!1),b.url&&b.url!=="/"&&s(b.url)},y=()=>{if(!t)return;const b=new Date().toISOString(),N=`notification_last_read_${t.id}`;localStorage.setItem(N,b),u(b),o(0)},_=b=>{i(b),b&&a>0&&y()};return e.jsxs(Ud,{open:l,onOpenChange:_,children:[e.jsx(Vd,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(Nm,{className:"h-5 w-5"}),a>0&&e.jsx(Ye,{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(di,{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 N=p(b.title);return e.jsxs(xa,{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(N,{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:jl(new Date(b.created_at),{addSuffix:!0})})]})]},b.id)})})]})]})};var uLe=1,d6t=.9,u6t=.8,h6t=.17,Bge=.1,$ge=.999,m6t=.9999,p6t=.99,f6t=/[\\\/_+.#"@\[\(\{&]/,x6t=/[\\\/_+.#"@\[\(\{&]/g,g6t=/[\s-]/,LYe=/[\s-]/g;function l_e(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?uLe:p6t;var i=`${a},${o}`;if(l[i]!==void 0)return l[i];for(var d=n.charAt(o),u=r.indexOf(d,a),p=0,f,y,_,b;u>=0;)f=l_e(t,s,r,n,u+1,o+1,l),f>p&&(u===a?f*=uLe:f6t.test(t.charAt(u-1))?(f*=u6t,_=t.slice(a,u-1).match(x6t),_&&a>0&&(f*=Math.pow($ge,_.length))):g6t.test(t.charAt(u-1))?(f*=d6t,b=t.slice(a,u-1).match(LYe),b&&a>0&&(f*=Math.pow($ge,b.length))):(f*=h6t,a>0&&(f*=Math.pow($ge,u-a))),t.charAt(u)!==s.charAt(o)&&(f*=m6t)),(ff&&(f=y*Bge)),f>p&&(p=f),u=r.indexOf(d,u+1);return l[i]=p,p}function hLe(t){return t.toLowerCase().replace(LYe," ")}function y6t(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,l_e(t,s,hLe(t),hLe(s),0,0,{})}var r6='[cmdk-group=""]',qge='[cmdk-group-items=""]',v6t='[cmdk-group-heading=""]',DYe='[cmdk-item=""]',mLe=`${DYe}:not([aria-disabled="true"])`,c_e="cmdk-item-select",R5="data-value",_6t=(t,s,r)=>y6t(t,s,r),RYe=k.createContext(void 0),WR=()=>k.useContext(RYe),OYe=k.createContext(void 0),ake=()=>k.useContext(OYe),FYe=k.createContext(void 0),zYe=k.forwardRef((t,s)=>{let r=O5(()=>{var we,Ne;return{search:"",value:(Ne=(we=t.value)!=null?we:t.defaultValue)!=null?Ne:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=O5(()=>new Set),a=O5(()=>new Map),o=O5(()=>new Map),l=O5(()=>new Set),i=BYe(t),{label:d,children:u,value:p,onValueChange:f,filter:y,shouldFilter:_,loop:b,disablePointerSelection:N=!1,vimBindings:w=!0,...S}=t,C=mu(),A=mu(),I=mu(),L=k.useRef(null),O=E6t();JS(()=>{if(p!==void 0){let we=p.trim();r.current.value=we,U.emit()}},[p]),JS(()=>{O(6,J)},[]);let U=k.useMemo(()=>({subscribe:we=>(l.current.add(we),()=>l.current.delete(we)),snapshot:()=>r.current,setState:(we,Ne,Ve)=>{var Te,Ae,ze,Ee;if(!Object.is(r.current[we],Ne)){if(r.current[we]=Ne,we==="search")Z(),V(),O(1,ee);else if(we==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ve=document.getElementById(I);ve?ve.focus():(Te=document.getElementById(C))==null||Te.focus()}if(O(7,()=>{var ve;r.current.selectedItemId=(ve=Y())==null?void 0:ve.id,U.emit()}),Ve||O(5,J),((Ae=i.current)==null?void 0:Ae.value)!==void 0){let ve=Ne??"";(Ee=(ze=i.current).onValueChange)==null||Ee.call(ze,ve);return}}U.emit()}},emit:()=>{l.current.forEach(we=>we())}}),[]),q=k.useMemo(()=>({value:(we,Ne,Ve)=>{var Te;Ne!==((Te=o.current.get(we))==null?void 0:Te.value)&&(o.current.set(we,{value:Ne,keywords:Ve}),r.current.filtered.items.set(we,$(Ne,Ve)),O(2,()=>{V(),U.emit()}))},item:(we,Ne)=>(n.current.add(we),Ne&&(a.current.has(Ne)?a.current.get(Ne).add(we):a.current.set(Ne,new Set([we]))),O(3,()=>{Z(),V(),r.current.value||ee(),U.emit()}),()=>{o.current.delete(we),n.current.delete(we),r.current.filtered.items.delete(we);let Ve=Y();O(4,()=>{Z(),(Ve==null?void 0:Ve.getAttribute("id"))===we&&ee(),U.emit()})}),group:we=>(a.current.has(we)||a.current.set(we,new Set),()=>{o.current.delete(we),a.current.delete(we)}),filter:()=>i.current.shouldFilter,label:d||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:C,inputId:I,labelId:A,listInnerRef:L}),[]);function $(we,Ne){var Ve,Te;let Ae=(Te=(Ve=i.current)==null?void 0:Ve.filter)!=null?Te:_6t;return we?Ae(we,r.current.search,Ne):0}function V(){if(!r.current.search||i.current.shouldFilter===!1)return;let we=r.current.filtered.items,Ne=[];r.current.filtered.groups.forEach(Te=>{let Ae=a.current.get(Te),ze=0;Ae.forEach(Ee=>{let ve=we.get(Ee);ze=Math.max(ve,ze)}),Ne.push([Te,ze])});let Ve=L.current;ce().sort((Te,Ae)=>{var ze,Ee;let ve=Te.getAttribute("id"),Re=Ae.getAttribute("id");return((ze=we.get(Re))!=null?ze:0)-((Ee=we.get(ve))!=null?Ee:0)}).forEach(Te=>{let Ae=Te.closest(qge);Ae?Ae.appendChild(Te.parentElement===Ae?Te:Te.closest(`${qge} > *`)):Ve.appendChild(Te.parentElement===Ve?Te:Te.closest(`${qge} > *`))}),Ne.sort((Te,Ae)=>Ae[1]-Te[1]).forEach(Te=>{var Ae;let ze=(Ae=L.current)==null?void 0:Ae.querySelector(`${r6}[${R5}="${encodeURIComponent(Te[0])}"]`);ze==null||ze.parentElement.appendChild(ze)})}function ee(){let we=ce().find(Ve=>Ve.getAttribute("aria-disabled")!=="true"),Ne=we==null?void 0:we.getAttribute(R5);U.setState("value",Ne||void 0)}function Z(){var we,Ne,Ve,Te;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Ae=0;for(let ze of n.current){let Ee=(Ne=(we=o.current.get(ze))==null?void 0:we.value)!=null?Ne:"",ve=(Te=(Ve=o.current.get(ze))==null?void 0:Ve.keywords)!=null?Te:[],Re=$(Ee,ve);r.current.filtered.items.set(ze,Re),Re>0&&Ae++}for(let[ze,Ee]of a.current)for(let ve of Ee)if(r.current.filtered.items.get(ve)>0){r.current.filtered.groups.add(ze);break}r.current.filtered.count=Ae}function J(){var we,Ne,Ve;let Te=Y();Te&&(((we=Te.parentElement)==null?void 0:we.firstChild)===Te&&((Ve=(Ne=Te.closest(r6))==null?void 0:Ne.querySelector(v6t))==null||Ve.scrollIntoView({block:"nearest"})),Te.scrollIntoView({block:"nearest"}))}function Y(){var we;return(we=L.current)==null?void 0:we.querySelector(`${DYe}[aria-selected="true"]`)}function ce(){var we;return Array.from(((we=L.current)==null?void 0:we.querySelectorAll(mLe))||[])}function ae(we){let Ne=ce()[we];Ne&&U.setState("value",Ne.getAttribute(R5))}function ie(we){var Ne;let Ve=Y(),Te=ce(),Ae=Te.findIndex(Ee=>Ee===Ve),ze=Te[Ae+we];(Ne=i.current)!=null&&Ne.loop&&(ze=Ae+we<0?Te[Te.length-1]:Ae+we===Te.length?Te[0]:Te[Ae+we]),ze&&U.setState("value",ze.getAttribute(R5))}function le(we){let Ne=Y(),Ve=Ne==null?void 0:Ne.closest(r6),Te;for(;Ve&&!Te;)Ve=we>0?T6t(Ve,r6):A6t(Ve,r6),Te=Ve==null?void 0:Ve.querySelector(mLe);Te?U.setState("value",Te.getAttribute(R5)):ie(we)}let fe=()=>ae(ce().length-1),xe=we=>{we.preventDefault(),we.metaKey?fe():we.altKey?le(1):ie(1)},he=we=>{we.preventDefault(),we.metaKey?ae(0):we.altKey?le(-1):ie(-1)};return k.createElement(dn.div,{ref:s,tabIndex:-1,...S,"cmdk-root":"",onKeyDown:we=>{var Ne;(Ne=S.onKeyDown)==null||Ne.call(S,we);let Ve=we.nativeEvent.isComposing||we.keyCode===229;if(!(we.defaultPrevented||Ve))switch(we.key){case"n":case"j":{w&&we.ctrlKey&&xe(we);break}case"ArrowDown":{xe(we);break}case"p":case"k":{w&&we.ctrlKey&&he(we);break}case"ArrowUp":{he(we);break}case"Home":{we.preventDefault(),ae(0);break}case"End":{we.preventDefault(),fe();break}case"Enter":{we.preventDefault();let Te=Y();if(Te){let Ae=new Event(c_e);Te.dispatchEvent(Ae)}}}}},k.createElement("label",{"cmdk-label":"",htmlFor:q.inputId,id:q.labelId,style:I6t},d),Jue(t,we=>k.createElement(OYe.Provider,{value:U},k.createElement(RYe.Provider,{value:q},we))))}),b6t=k.forwardRef((t,s)=>{var r,n;let a=mu(),o=k.useRef(null),l=k.useContext(FYe),i=WR(),d=BYe(t),u=(n=(r=d.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;JS(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let p=$Ye(a,o,[t.value,t.children,o],t.keywords),f=ake(),y=aw(O=>O.value&&O.value===p.current),_=aw(O=>u||i.filter()===!1?!0:O.search?O.filtered.items.get(a)>0:!0);k.useEffect(()=>{let O=o.current;if(!(!O||t.disabled))return O.addEventListener(c_e,b),()=>O.removeEventListener(c_e,b)},[_,t.onSelect,t.disabled]);function b(){var O,U;N(),(U=(O=d.current).onSelect)==null||U.call(O,p.current)}function N(){f.setState("value",p.current,!0)}if(!_)return null;let{disabled:w,value:S,onSelect:C,forceMount:A,keywords:I,...L}=t;return k.createElement(dn.div,{ref:Mm(o,s),...L,id:a,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!y,"data-disabled":!!w,"data-selected":!!y,onPointerMove:w||i.getDisablePointerSelection()?void 0:N,onClick:w?void 0:b},t.children)}),w6t=k.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=mu(),i=k.useRef(null),d=k.useRef(null),u=mu(),p=WR(),f=aw(_=>a||p.filter()===!1?!0:_.search?_.filtered.groups.has(l):!0);JS(()=>p.group(l),[]),$Ye(l,i,[t.value,t.heading,d]);let y=k.useMemo(()=>({id:l,forceMount:a}),[a]);return k.createElement(dn.div,{ref:Mm(i,s),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},r&&k.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),Jue(t,_=>k.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},k.createElement(FYe.Provider,{value:y},_))))}),j6t=k.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=k.useRef(null),o=aw(l=>!l.search);return!r&&!o?null:k.createElement(dn.div,{ref:Mm(a,s),...n,"cmdk-separator":"",role:"separator"})}),N6t=k.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=ake(),l=aw(u=>u.search),i=aw(u=>u.selectedItemId),d=WR();return k.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),k.createElement(dn.input,{ref:s,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":i,id:d.inputId,type:"text",value:a?t.value:l,onChange:u=>{a||o.setState("search",u.target.value),r==null||r(u.target.value)}})}),k6t=k.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=k.useRef(null),l=k.useRef(null),i=aw(u=>u.selectedItemId),d=WR();return k.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)}}},[]),k.createElement(dn.div,{ref:Mm(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:d.listId},Jue(t,u=>k.createElement("div",{ref:Mm(l,d.listInnerRef),"cmdk-list-sizer":""},u)))}),S6t=k.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return k.createElement(kue,{open:r,onOpenChange:n},k.createElement(Sue,{container:l},k.createElement(UA,{"cmdk-overlay":"",className:a}),k.createElement(VA,{"aria-label":t.label,"cmdk-dialog":"",className:o},k.createElement(zYe,{ref:s,...i}))))}),C6t=k.forwardRef((t,s)=>aw(r=>r.filtered.count===0)?k.createElement(dn.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),M6t=k.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return k.createElement(dn.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Jue(t,l=>k.createElement("div",{"aria-hidden":!0},l)))}),yp=Object.assign(zYe,{List:k6t,Item:b6t,Input:N6t,Group:w6t,Separator:j6t,Dialog:S6t,Empty:C6t,Loading:M6t});function T6t(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function A6t(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function BYe(t){let s=k.useRef(t);return JS(()=>{s.current=t}),s}var JS=typeof window>"u"?k.useEffect:k.useLayoutEffect;function O5(t){let s=k.useRef();return s.current===void 0&&(s.current=t()),s}function aw(t){let s=ake(),r=()=>t(s.snapshot());return k.useSyncExternalStore(s.subscribe,r,r)}function $Ye(t,s,r,n=[]){let a=k.useRef(),o=WR();return JS(()=>{var l;let i=(()=>{var u;for(let p of r){if(typeof p=="string")return p.trim();if(typeof p=="object"&&"current"in p)return p.current?(u=p.current.textContent)==null?void 0:u.trim():a.current}})(),d=n.map(u=>u.trim());o.value(t,i,d),(l=s.current)==null||l.setAttribute(R5,i),a.current=i}),a}var E6t=()=>{let[t,s]=k.useState(),r=O5(()=>new Map);return JS(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function P6t(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function Jue({asChild:t,children:s},r){return t&&k.isValidElement(s)?k.cloneElement(P6t(s),{ref:s.ref},r(s.props.children)):r(s)}var I6t={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Ax=k.forwardRef(({className:t,...s},r)=>e.jsx(yp,{ref:r,className:Rt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));Ax.displayName=yp.displayName;const L6t=({children:t,...s})=>e.jsx(fs,{...s,children:e.jsx(ms,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(Ax,{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})})}),Ex=k.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(tn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(yp.Input,{ref:r,className:Rt("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})]}));Ex.displayName=yp.Input.displayName;const Px=k.forwardRef(({className:t,...s},r)=>e.jsx(yp.List,{ref:r,className:Rt("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));Px.displayName=yp.List.displayName;const Ix=k.forwardRef((t,s)=>e.jsx(yp.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Ix.displayName=yp.Empty.displayName;const Lx=k.forwardRef(({className:t,...s},r)=>e.jsx(yp.Group,{ref:r,className:Rt("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}));Lx.displayName=yp.Group.displayName;const D6t=k.forwardRef(({className:t,...s},r)=>e.jsx(yp.Separator,{ref:r,className:Rt("-mx-1 h-px bg-border",t),...s}));D6t.displayName=yp.Separator.displayName;const op=k.forwardRef(({className:t,...s},r)=>e.jsx(yp.Item,{ref:r,className:Rt("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}));op.displayName=yp.Item.displayName;const R6t={event:{label:"Events",icon:xd,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:Rl,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:Dh,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:Og,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:qr,color:"bg-fuchsia-500/10 text-fuchsia-600"}},pLe=()=>{const[t,s]=k.useState(!1),[r,n]=k.useState(""),[a,o]=k.useState([]),[l,i]=k.useState(!1),d=br();k.useEffect(()=>{const y=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),s(b=>!b))};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[]);const u=k.useCallback(async y=>{if(!y.trim()){o([]);return}i(!0);const _=`%${y}%`;try{const[b,N,w,S,C]=await Promise.all([G.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),G.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${_},description.ilike.${_}`).limit(5),G.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),G.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${_},description.ilike.${_}`).limit(5),G.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5)]),A=[];b.data&&b.data.forEach(I=>{A.push({id:I.id,title:I.title,description:I.description,type:"event",date:I.event_date,path:`/event/${I.id}`})}),N.data&&N.data.forEach(I=>{A.push({id:I.id,title:I.name,description:I.description,type:"template",date:I.publish_date,path:`/templates/${I.id}`})}),w.data&&w.data.forEach(I=>{A.push({id:I.id,title:I.title,description:I.description,type:"academy",date:I.publish_date,path:`/academy/${I.id}`})}),S.data&&S.data.forEach(I=>{A.push({id:I.id,title:I.name,description:I.description,type:"toolbox",date:I.publish_date,path:`/toolbox/${I.id}`})}),C.data&&C.data.forEach(I=>{A.push({id:I.id,title:I.title,description:I.description,type:"social-swag",date:I.publish_date,path:`/social-swag/${I.id}`})}),o(A)}catch(b){console.error("Search error:",b)}finally{i(!1)}},[]);k.useEffect(()=>{const y=setTimeout(()=>{u(r)},300);return()=>clearTimeout(y)},[r,u]);const p=y=>{s(!1),n(""),d(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(tn,{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(L6t,{open:t,onOpenChange:s,children:[e.jsx(Ex,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(Px,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Ix,{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=R6t[y],N=b.icon;return e.jsx(Lx,{heading:b.label,children:_.map(w=>e.jsxs(op,{value:`${w.type}-${w.id}-${w.title}`,onSelect:()=>p(w.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[e.jsx("div",{className:`p-2 rounded-md ${b.color}`,children:e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:w.title}),w.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:w.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(Ye,{variant:"secondary",className:"text-xs",children:b.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:jl(new Date(w.date),{addSuffix:!0})})]})]},`${w.type}-${w.id}`))},y)})]})]})]})},O6t=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=k.useState(null),o=br();if(k.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)),N=Math.floor(_%(1e3*60*60*24)/(1e3*60*60)),w=Math.floor(_%(1e3*60*60)/(1e3*60));a({days:b,hours:N,minutes:w})};u();const p=setInterval(u,6e4);return()=>clearInterval(p)},[t]),!n)return null;const l=n.days===0&&n.hours===0&&n.minutes===0,i=n.days<=1,d=n.days<=3&&!i;return l?e.jsxs("div",{className:Rt("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(Qc,{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(qr,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:Rt("flex items-center justify-between gap-3 px-4 py-2 rounded-lg border transition-colors",i?"bg-destructive/10 border-destructive/20":d?"bg-amber-500/10 border-amber-500/20":"bg-primary/10 border-primary/20",s),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(rn,{className:Rt("h-4 w-4",i?"text-destructive":d?"text-amber-500":"text-primary")}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:Rt("text-sm font-medium",i?"text-destructive":d?"text-amber-600":"text-primary"),children:"Free Trial:"}),e.jsxs("div",{className:"flex items-center gap-1",children:[n.days>0&&e.jsxs("span",{className:Rt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:Rt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:Rt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:Rt("text-xs",i?"text-destructive/70":d?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&e.jsxs(K,{size:"sm",onClick:()=>o("/subscription"),variant:i?"destructive":d?"default":"outline",className:Rt("text-xs h-7 px-3",d&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(qr,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},F6t=()=>{const t=br();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(Ie,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[e.jsxs(Lt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-4 h-16 w-16 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(Qc,{className:"h-8 w-8 text-destructive"})}),e.jsx(Ft,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(mr,{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(Be,{className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(Ie,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Be,{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(cr,{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(qr,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),e.jsx(Ie,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Be,{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(ma,{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(ma,{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(Tn,{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(tr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},z6t=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",onClick:s,className:Rt("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[e.jsx(dh,{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(Il,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var ehe="Checkbox",[B6t]=bd(ehe),[$6t,ike]=B6t(ehe);function q6t(t){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:a,disabled:o,form:l,name:i,onCheckedChange:d,required:u,value:p="on",internal_do_not_use_render:f}=t,[y,_]=Bu({prop:r,defaultProp:a??!1,onChange:d,caller:ehe}),[b,N]=k.useState(null),[w,S]=k.useState(null),C=k.useRef(!1),A=b?!!l||!!b.closest("form"):!0,I={checked:y,disabled:o,setChecked:_,control:b,setControl:N,name:i,form:l,value:p,hasConsumerStoppedPropagationRef:C,required:u,defaultChecked:$b(a)?!1:a,isFormControl:A,bubbleInput:w,setBubbleInput:S};return e.jsx($6t,{scope:s,...I,children:U6t(f)?f(I):n})}var qYe="CheckboxTrigger",UYe=k.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:o,value:l,disabled:i,checked:d,required:u,setControl:p,setChecked:f,hasConsumerStoppedPropagationRef:y,isFormControl:_,bubbleInput:b}=ike(qYe,t),N=Ma(a,p),w=k.useRef(d);return k.useEffect(()=>{const S=o==null?void 0:o.form;if(S){const C=()=>f(w.current);return S.addEventListener("reset",C),()=>S.removeEventListener("reset",C)}},[o,f]),e.jsx(dn.button,{type:"button",role:"checkbox","aria-checked":$b(d)?"mixed":d,"aria-required":u,"data-state":KYe(d),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:N,onKeyDown:Tr(s,S=>{S.key==="Enter"&&S.preventDefault()}),onClick:Tr(r,S=>{f(C=>$b(C)?!0:!C),b&&_&&(y.current=S.isPropagationStopped(),y.current||S.stopPropagation())})})});UYe.displayName=qYe;var oke=k.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d,onCheckedChange:u,form:p,...f}=t;return e.jsx(q6t,{__scopeCheckbox:r,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:u,name:n,form:p,value:d,internal_do_not_use_render:({isFormControl:y})=>e.jsxs(e.Fragment,{children:[e.jsx(UYe,{...f,ref:s,__scopeCheckbox:r}),y&&e.jsx(WYe,{__scopeCheckbox:r})]})})});oke.displayName=ehe;var VYe="CheckboxIndicator",HYe=k.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=ike(VYe,r);return e.jsx(wd,{present:n||$b(o.checked)||o.checked===!0,children:e.jsx(dn.span,{"data-state":KYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});HYe.displayName=VYe;var GYe="CheckboxBubbleInput",WYe=k.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:d,name:u,value:p,form:f,bubbleInput:y,setBubbleInput:_}=ike(GYe,t),b=Ma(r,_),N=BR(o),w=SR(n);k.useEffect(()=>{const C=y;if(!C)return;const A=window.HTMLInputElement.prototype,L=Object.getOwnPropertyDescriptor(A,"checked").set,O=!a.current;if(N!==o&&L){const U=new Event("click",{bubbles:O});C.indeterminate=$b(o),L.call(C,$b(o)?!1:o),C.dispatchEvent(U)}},[y,N,o,a]);const S=k.useRef($b(o)?!1:o);return e.jsx(dn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??S.current,required:i,disabled:d,name:u,value:p,form:f,...s,tabIndex:-1,ref:b,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});WYe.displayName=GYe;function U6t(t){return typeof t=="function"}function $b(t){return t==="indeterminate"}function KYe(t){return $b(t)?"indeterminate":t?"checked":"unchecked"}const Gi=k.forwardRef(({className:t,...s},r)=>e.jsx(oke,{ref:r,className:Rt("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(HYe,{className:Rt("flex items-center justify-center text-current"),children:e.jsx(ea,{className:"h-4 w-4"})})}));Gi.displayName=oke.displayName;var lke="Radio",[V6t,ZYe]=bd(lke),[H6t,G6t]=V6t(lke),YYe=k.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:d,form:u,...p}=t,[f,y]=k.useState(null),_=Ma(s,w=>y(w)),b=k.useRef(!1),N=f?u||!!f.closest("form"):!0;return e.jsxs(H6t,{scope:r,checked:a,disabled:l,children:[e.jsx(dn.button,{type:"button",role:"radio","aria-checked":a,"data-state":eXe(a),"data-disabled":l?"":void 0,disabled:l,value:i,...p,ref:_,onClick:Tr(t.onClick,w=>{a||d==null||d(),N&&(b.current=w.isPropagationStopped(),b.current||w.stopPropagation())})}),N&&e.jsx(JYe,{control:f,bubbles:!b.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});YYe.displayName=lke;var XYe="RadioIndicator",QYe=k.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=G6t(XYe,r);return e.jsx(wd,{present:n||o.checked,children:e.jsx(dn.span,{"data-state":eXe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});QYe.displayName=XYe;var W6t="RadioBubbleInput",JYe=k.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=k.useRef(null),i=Ma(l,o),d=BR(r),u=SR(s);return k.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&_){const b=new Event("click",{bubbles:n});_.call(p,r),p.dispatchEvent(b)}},[d,r,n]),e.jsx(dn.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}})});JYe.displayName=W6t;function eXe(t){return t?"checked":"unchecked"}var K6t=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],the="RadioGroup",[Z6t]=bd(the,[gw,ZYe]),tXe=gw(),sXe=ZYe(),[Y6t,X6t]=Z6t(the),rXe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:o,required:l=!1,disabled:i=!1,orientation:d,dir:u,loop:p=!0,onValueChange:f,...y}=t,_=tXe(r),b=xw(u),[N,w]=Bu({prop:o,defaultProp:a??null,onChange:f,caller:the});return e.jsx(Y6t,{scope:r,name:n,required:l,disabled:i,value:N,onValueChange:w,children:e.jsx(gue,{asChild:!0,..._,orientation:d,dir:b,loop:p,children:e.jsx(dn.div,{role:"radiogroup","aria-required":l,"aria-orientation":d,"data-disabled":i?"":void 0,dir:b,...y,ref:s})})})});rXe.displayName=the;var nXe="RadioGroupItem",aXe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=X6t(nXe,r),l=o.disabled||n,i=tXe(r),d=sXe(r),u=k.useRef(null),p=Ma(s,u),f=o.value===a.value,y=k.useRef(!1);return k.useEffect(()=>{const _=N=>{K6t.includes(N.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(yue,{asChild:!0,...i,focusable:!l,active:f,children:e.jsx(YYe,{disabled:l,required:o.required,checked:f,...d,...a,name:o.name,ref:p,onCheck:()=>o.onValueChange(a.value),onKeyDown:Tr(_=>{_.key==="Enter"&&_.preventDefault()}),onFocus:Tr(a.onFocus,()=>{var _;y.current&&((_=u.current)==null||_.click())})})})});aXe.displayName=nXe;var Q6t="RadioGroupIndicator",iXe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=sXe(r);return e.jsx(QYe,{...a,...n,ref:s})});iXe.displayName=Q6t;var oXe=rXe,lXe=aXe,J6t=iXe;const cke=k.forwardRef(({className:t,...s},r)=>e.jsx(oXe,{className:Rt("grid gap-2",t),...s,ref:r}));cke.displayName=oXe.displayName;const vle=k.forwardRef(({className:t,...s},r)=>e.jsx(lXe,{ref:r,className:Rt("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(J6t,{className:"flex items-center justify-center",children:e.jsx(sd,{className:"h-2.5 w-2.5 fill-current text-current"})})}));vle.displayName=lXe.displayName;const eLt=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=$s(),[o,l]=k.useState({}),[i,d]=k.useState({}),[u,p]=k.useState([]);k.useEffect(()=>{s&&a&&t.polls.length>0&&f()},[s,a,t.polls]);const f=async()=>{if(!a)return;const w=t.polls.map(C=>C.id),{data:S}=await G.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",w);if(S){const C={};S.forEach(A=>{C[A.poll_id]||(C[A.poll_id]=[]),C[A.poll_id].push(A.option_id)}),d(C)}},y=(w,S)=>{l(C=>({...C,[w]:S}))},_=(w,S,C)=>{l(A=>{const I=A[w]||[];return C?{...A,[w]:[...I,S]}:{...A,[w]:I.filter(L=>L!==S)}})},b=async w=>{if(!a)return;const S=o[w];if(!S||Array.isArray(S)&&S.length===0){me.error("Please select an option");return}p(C=>[...C,w]);try{await G.from("levelup_brief_poll_responses").delete().eq("poll_id",w).eq("user_id",a.id);const C=Array.isArray(S)?S:[S],A=C.map(L=>({poll_id:w,option_id:L,user_id:a.id})),{error:I}=await G.from("levelup_brief_poll_responses").insert(A);if(I)throw I;d(L=>({...L,[w]:C})),me.success("Response submitted!")}catch(C){console.error("Error submitting poll response:",C),me.error("Failed to submit response")}finally{p(C=>C.filter(A=>A!==w))}},N=w=>(w.includes("mediadelivery.net")||w.includes("bunny"),w);return e.jsx(fs,{open:s,onOpenChange:w=>!w&&r(),children:e.jsxs(ms,{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(Sr,{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(dh,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx(Ye,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),e.jsx(bs,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),e.jsx(di,{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:N(t.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),t.brief.graphic_url&&!t.brief.video_url&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:t.brief.graphic_link_url?e.jsx("a",{href:t.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),t.links.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.links.map(w=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.open(w.url,"_blank"),className:"gap-2",children:[e.jsx(Kr,{className:"h-4 w-4"}),w.title]},w.id))})]}),t.polls.map(w=>{var A,I;const S=((A=i[w.id])==null?void 0:A.length)>0,C=u.includes(w.id);return e.jsxs("div",{className:"space-y-3 p-4 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:w.question}),S&&e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(Hn,{className:"h-3 w-3"}),"Responded"]})]}),w.poll_type==="single"?e.jsx(cke,{value:o[w.id]||((I=i[w.id])==null?void 0:I[0])||"",onValueChange:L=>y(w.id,L),className:"space-y-2",children:w.options.map(L=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(vle,{value:L.id,id:L.id}),e.jsx(ge,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id))}):e.jsx("div",{className:"space-y-2",children:w.options.map(L=>{const U=(o[w.id]||i[w.id]||[]).includes(L.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Gi,{id:L.id,checked:U,onCheckedChange:q=>_(w.id,L.id,q)}),e.jsx(ge,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id)})}),e.jsx(K,{size:"sm",onClick:()=>b(w.id),disabled:C,children:C?"Submitting...":S?"Update Response":"Submit"})]},w.id)})]})}),e.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t bg-muted/30 flex flex-col items-center gap-2 sticky bottom-0 z-10",children:[e.jsx(K,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},tLt=()=>{const{user:t}=$s(),[s,r]=k.useState(null),[n,a]=k.useState(!1),[o,l]=k.useState(!0),[i,d]=k.useState(!1),u=k.useCallback(async()=>{if(!t){l(!1);return}try{const{data:b,error:N}=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(N||!b){l(!1);return}const{data:w}=await G.from("levelup_brief_views").select("*").eq("brief_id",b.id).eq("user_id",t.id).maybeSingle(),[S,C]=await Promise.all([G.from("levelup_brief_links").select("*").eq("brief_id",b.id).order("sort_order"),G.from("levelup_brief_polls").select("*").eq("brief_id",b.id).order("sort_order")]),A=[];if(C.data)for(const q of C.data){const{data:$}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",q.id).order("sort_order");A.push({...q,options:$||[]})}const I={brief:b,links:S.data||[],polls:A};r(I);const L=!!w,O=(w==null?void 0:w.dismissed_at)!=null,U=localStorage.getItem(`brief-dismissed-${b.id}`)==="true";if(O||U)d(!1),a(!1);else if(!L)a(!0),d(!0);else if(b.show_frequency==="every_login")a(!0),d(!0);else if(b.show_frequency==="daily"){const q=new Date(w.viewed_at);(new Date().getTime()-q.getTime())/(1e3*60*60)>=24&&(a(!0),d(!0))}else d(!1)}catch(b){console.error("Error fetching brief:",b)}finally{l(!1)}},[t]);k.useEffect(()=>{u()},[u]);const p=async()=>{if(!(!t||!s))try{const{data:b}=await G.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();b?await G.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",b.id):await G.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id})}catch(b){console.error("Error marking brief as viewed:",b)}};return{currentBrief:s,shouldShowPopup:n,hasUnseenBrief:i,loading:o,openBrief:()=>{a(!0)},closeBrief:()=>{a(!1),p()},dismissBrief:async()=>{if(!(!t||!s)){a(!1),d(!1);try{const{data:b,error:N}=await G.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(N&&console.error("Error checking existing brief view:",N),b){const{error:w}=await G.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",b.id).eq("user_id",t.id);w&&console.error("Error updating brief dismiss:",w)}else{const{error:w}=await G.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});w&&console.error("Error inserting brief dismiss:",w)}localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}catch(b){console.error("Error dismissing brief:",b),s&&localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}}},refetch:u}};function sLt(){const[t,s]=k.useState(!1),[r,n]=k.useState(!1),[a,o]=k.useState(null);k.useEffect(()=>{if(localStorage.getItem("install-banner-dismissed")||window.matchMedia("(display-mode: standalone)").matches||!/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))return;const f=/iPhone|iPad|iPod/i.test(navigator.userAgent);n(f),s(!0);const 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:d}=await a.userChoice;d==="accepted"&&l(),o(null)}};return t?e.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 p-4 bg-primary text-primary-foreground shadow-lg animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"flex-shrink-0 p-2 bg-primary-foreground/10 rounded-full",children:e.jsx(Xa,{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(FL,{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(Sr,{className:"h-4 w-4"})})]})]})}):null}const rLt=({children:t,onRefresh:s})=>{const[r,n]=k.useState(!1),[a,o]=k.useState(0),[l,i]=k.useState(!1),d=k.useRef(null),u=k.useRef(0),p=es(),f=80,y=120,_=k.useCallback(C=>{const A=d.current;A&&A.scrollTop<=0&&(u.current=C.touches[0].clientY,n(!0))},[]),b=k.useCallback(C=>{if(!r||l)return;const A=d.current;if(!A||A.scrollTop>0){n(!1),o(0);return}const L=C.touches[0].clientY-u.current;if(L>0){const U=Math.min(L*.5,y);o(U),U>10&&C.preventDefault()}},[r,l]),N=k.useCallback(async()=>{if(r)if(n(!1),a>=f&&!l){i(!0),o(f);try{s?await s():await p.invalidateQueries()}catch(C){console.error("Refresh failed:",C)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,p]),w=Math.min(a/f,1),S=w*180;return e.jsxs("div",{ref:d,className:"h-full overflow-auto",onTouchStart:_,onTouchMove:b,onTouchEnd:N,children:[e.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:a>0?a:0,opacity:w},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${S}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(to,{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})]})},cXe=()=>{const{user:t}=$s(),[s,r]=k.useState(!1),[n,a]=k.useState(!1),[o,l]=k.useState(0),[i,d]=k.useState(!0);k.useEffect(()=>{(async()=>{if(!t){d(!1);return}try{const{data:_}=await G.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(_){a(!0),r(!1),d(!1);return}const{data:b}=await G.from("profiles").select("login_count").eq("id",t.id).single(),N=(b==null?void 0:b.login_count)||0;l(N);const w=sessionStorage.getItem("review-prompt-dismissed");r(N>=4&&!w)}catch(_){console.error("Error checking review eligibility:",_)}finally{d(!1)}})()},[t]);const u=k.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),p=k.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=k.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}},nLt="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",aLt=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=cXe(),[o,l]=k.useState(!1),[i,d]=k.useState("review"),[u,p]=k.useState(0),[f,y]=k.useState(0),[_,b]=k.useState(""),[N,w]=k.useState(!1),[S,C]=k.useState(!1);if(s||!t&&!S)return null;const A=async()=>{if(u===0){cn({title:"Please select a rating",variant:"destructive"});return}w(!0);const O=await n(u,_);w(!1),O.success?(C(!0),cn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),d("google")):cn({title:"Error submitting review",description:O.error,variant:"destructive"})},I=async O=>{O&&(await navigator.clipboard.writeText(_||`${u} star rating for LevelUp!`),cn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(nLt,"_blank")),l(!1),r()},L=()=>{l(!1),r()};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>l(!0),className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-40 flex items-center gap-2 rounded-full bg-primary/90 px-3 py-2 text-xs text-primary-foreground shadow-lg backdrop-blur-sm transition-all hover:bg-primary hover:scale-105 md:bottom-6",children:[e.jsx(Gn,{className:"h-3.5 w-3.5 fill-current"}),e.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),e.jsx(fs,{open:o,onOpenChange:L,children:e.jsx(ms,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(ks,{children:[e.jsx(bs,{className:"text-center",children:"How are you enjoying LevelUp?"}),e.jsx(Rr,{className:"text-center",children:"Your feedback helps us improve the experience for all members."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsx("div",{className:"flex justify-center gap-1",children:[1,2,3,4,5].map(O=>e.jsx("button",{type:"button",onClick:()=>p(O),onMouseEnter:()=>y(O),onMouseLeave:()=>y(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(Gn,{className:Rt("h-8 w-8 transition-colors",(f||u)>=O?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},O))}),e.jsx(_r,{placeholder:"Tell us about your experience (optional)",value:_,onChange:O=>b(O.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:L,className:"flex-1",children:"Maybe Later"}),e.jsx(K,{onClick:A,disabled:N||u===0,className:"flex-1",children:N?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ks,{children:[e.jsx(bs,{className:"text-center",children:"🎉 Thank you!"}),e.jsx(Rr,{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 iLt(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 N="vapid_public_key";let w=localStorage.getItem(N);if(!w){const{data:A,error:I}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(I)throw I;if(w=(A==null?void 0:A.vapidPublicKey)??null,!w)throw new Error("Missing VAPID public key");localStorage.setItem(N,w)}p(w);const S=await navigator.serviceWorker.register("/push-sw.js",{scope:"/push-notifications/"});d(S),r(Notification.permission);const C=await S.pushManager.getSubscription();a(!!C)}catch(N){console.error("Error initializing push notifications:",N)}finally{l(!1)}})()},[f]);const y=k.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:A}=await G.from("push_subscriptions").delete().eq("user_id",t.id);A&&console.warn("Failed to cleanup push_subscriptions rows:",A)}if(Notification.permission!=="granted"){const A=await Notification.requestPermission();if(r(A),A!=="granted")return A==="denied"?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 N=iLt(u);let w;try{w=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:N})}catch(A){console.error("PushManager.subscribe() failed:",A);const I=(A==null?void 0:A.message)||String(A);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 S=w.toJSON(),{error:C}=await G.from("push_subscriptions").upsert({user_id:t.id,endpoint:S.endpoint,p256dh_key:S.keys.p256dh,auth_key:S.keys.auth},{onConflict:"user_id,endpoint"});if(C)throw console.error("Error saving subscription:",C),me.error("Failed to save notification preferences. Please try again."),C;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 N=b instanceof Error?b.message:"Unknown error";me.error("Failed to enable push notifications: "+N)}return!1}finally{l(!1)}},[f,i,t,u]),_=k.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 N=b instanceof Error?b.message:"Unknown error";return me.error("Failed to disable push notifications: "+N),!1}finally{l(!1)}},[i,t]);return{isSupported:f,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:y,unsubscribe:_}}const Uge="push_notification_prompt_dismissed",oLt=["/dashboard","/admin"],lLt=()=>{const{user:t}=$s(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=dXe(),o=Fl(),[l,i]=k.useState(!1),[d,u]=k.useState(!1),p=oLt.some(_=>o.pathname===_||o.pathname.startsWith(`${_}/`));k.useEffect(()=>{if(p){i(!1);return}if(!t||!s||r||n||localStorage.getItem(`${Uge}_${t.id}`))return;const b=setTimeout(()=>{i(!0)},2e3);return()=>clearTimeout(b)},[t,s,r,n,p]);const f=async()=>{u(!0);const _=await a();u(!1),_&&(t&&localStorage.setItem(`${Uge}_${t.id}`,"true"),i(!1))},y=()=>{t&&localStorage.setItem(`${Uge}_${t.id}`,"true"),i(!1)};return!s||r||p?null:e.jsx(fs,{open:l,onOpenChange:_=>!_&&y(),children:e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(ks,{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(Nm,{className:"h-6 w-6 text-primary"})}),e.jsx(bs,{className:"text-center",children:"Stay in the Loop!"}),e.jsx(Rr,{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:f,disabled:d,className:"w-full",children:d?"Enabling...":"Enable Notifications"}),e.jsx(K,{variant:"ghost",onClick:y,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."})]})})},fLe=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:()=>d,subscribe:u=>(r.add(u),()=>r.delete(u))},d=s=t(n,a,i);return i},cLt=t=>t?fLe(t):fLe,dLt=t=>t;function uLt(t,s=dLt){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 xLe=t=>{const s=cLt(t),r=n=>uLt(s,n);return Object.assign(r,s),r},hLt=t=>t?xLe(t):xLe;function mLt(t,s){let r;try{r=t()}catch{return}return{getItem:a=>{var o;const l=d=>d===null?null:JSON.parse(d,void 0),i=(o=r.getItem(a))!=null?o:null;return i instanceof Promise?i.then(l):l(i)},setItem:(a,o)=>r.setItem(a,JSON.stringify(o,void 0)),removeItem:a=>r.removeItem(a)}}const d_e=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return d_e(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return d_e(n)(r)}}}},pLt=(t,s)=>(r,n,a)=>{let o={storage:mLt(()=>window.localStorage),partialize:w=>w,version:0,merge:(w,S)=>({...S,...w}),...s},l=!1,i=0;const d=new Set,u=new Set;let p=o.storage;if(!p)return t((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...w)},n,a);const f=()=>{const w=o.partialize({...n()});return p.setItem(o.name,{state:w,version:o.version})},y=a.setState;a.setState=(w,S)=>(y(w,S),f());const _=t((...w)=>(r(...w),f()),n,a);a.getInitialState=()=>_;let b;const N=()=>{var w,S;if(!p)return;const C=++i;l=!1,d.forEach(I=>{var L;return I((L=n())!=null?L:_)});const A=((S=o.onRehydrateStorage)==null?void 0:S.call(o,(w=n())!=null?w:_))||void 0;return d_e(p.getItem.bind(p))(o.name).then(I=>{if(I)if(typeof I.version=="number"&&I.version!==o.version){if(o.migrate){const L=o.migrate(I.state,I.version);return L instanceof Promise?L.then(O=>[!0,O]):[!0,L]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,I.state];return[!1,void 0]}).then(I=>{var L;if(C!==i)return;const[O,U]=I;if(b=o.merge(U,(L=n())!=null?L:_),r(b,!0),O)return f()}).then(()=>{C===i&&(A==null||A(n(),void 0),b=n(),l=!0,u.forEach(I=>I(b)))}).catch(I=>{C===i&&(A==null||A(void 0,I))})};return a.persist={setOptions:w=>{o={...o,...w},w.storage&&(p=w.storage)},clearStorage:()=>{p==null||p.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>N(),hasHydrated:()=>l,onHydrate:w=>(d.add(w),()=>{d.delete(w)}),onFinishHydration:w=>(u.add(w),()=>{u.delete(w)})},o.skipHydration||N(),b||_},fLt=pLt,she=hLt()(fLt((t,s)=>({cartItems:[],addToCart:(r,n,a=1,o)=>{t(l=>{const i=l.cartItems.findIndex(d=>{var u;return d.product.id===r.id&&((u=d.variant)==null?void 0:u.id)===(n==null?void 0:n.id)});if(i>=0){const d=[...l.cartItems];return d[i].quantity+=a,o&&(d[i].artworkUrl=o),{cartItems:d}}return{cartItems:[...l.cartItems,{product:r,variant:n,quantity:a,artworkUrl:o}]}})},removeFromCart:(r,n)=>{t(a=>({cartItems:a.cartItems.filter(o=>{var l;return!(o.product.id===r&&((l=o.variant)==null?void 0:l.id)===n)})}))},updateQuantity:(r,n,a)=>{t(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===r&&((i=l.variant)==null?void 0:i.id)===n?{...l,quantity:Math.max(1,a)}:l})}))},updateArtwork:(r,n,a)=>{t(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===r&&((i=l.variant)==null?void 0:i.id)===n?{...l,artworkUrl:a}:l})}))},clearCart:()=>t({cartItems:[]}),getItemPrice:r=>{const n=Number(r.product.base_price),a=r.variant?Number(r.variant.price_adjustment):0;return n+a},getSubtotal:()=>{const{cartItems:r,getItemPrice:n}=s();return r.reduce((a,o)=>a+n(o)*o.quantity,0)},getShippingTotal:()=>{const{cartItems:r}=s();return r.reduce((n,a)=>n+Number(a.product.shipping_fee)*a.quantity,0)},getTotal:()=>{const{getSubtotal:r,getShippingTotal:n}=s();return r()+n()}}),{name:"marketplace-cart",partialize:t=>({cartItems:t.cartItems})}));function QA(){const{user:t}=$s(),{data:s,isLoading:r}=ft({queryKey:["agent-lead-site",t==null?void 0:t.id],queryFn:async()=>{const{data:n,error:a}=await G.from("lead_sites").select("id, subdomain_slug, site_title, is_active").eq("agent_id",t.id).eq("is_active",!0).order("created_at",{ascending:!0}).limit(1).maybeSingle();if(a)throw a;return n},enabled:!!t,staleTime:5*60*1e3});return{leadSite:s??null,hasLeadSite:!!s,isLoading:r,siteUrl:s?`https://${s.subdomain_slug}.thelocalmove.com`:null}}const uXe=k.createContext({onlineUsers:[],totalOnline:0}),xLt=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{}},gLt=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=$s(),[a,o]=k.useState([]),[l,i]=k.useState(null);k.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 xLt(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 d=a.filter(u=>u.id===(s==null?void 0:s.id)?!1:!!(n||r&&u.brokerageId===r||!r&&!u.brokerageId));return e.jsx(uXe.Provider,{value:{onlineUsers:d,totalOnline:a.length},children:t})},hXe=()=>k.useContext(uXe),gLe="dashboard-sidebar-collapsed",Ls=({children:t,title:s})=>{var ct;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=$s(),{isAssistant:i,actingAsAgent:d,hasPermission:u}=Rje(),{isImpersonating:p}=fue(),y=(i&&!!d?40:0)+(p?40:0),{avatarUrl:_}=dYe(r==null?void 0:r.id),{isTrial:b,isExpired:N,expiresAt:w}=NIt(r==null?void 0:r.id),{isMarketplaceEnabled:S}=hYe(),{currentBrief:C,shouldShowPopup:A,hasUnseenBrief:I,openBrief:L,closeBrief:O,dismissBrief:U}=tLt(),{unreadCount:q}=kIt(),{openCount:$}=SIt(),{data:V}=Rx(),ee=!!V,J=she(pe=>pe.cartItems).reduce((pe,Ge)=>pe+Ge.quantity,0),{leadSite:Y,hasLeadSite:ce,siteUrl:ae}=QA(),ie=br(),le=Fl(),[fe,xe]=k.useState(null);k.useEffect(()=>{r!=null&&r.id&&G.from("profiles").select("name").eq("id",r.id).single().then(({data:pe})=>{pe!=null&&pe.name&&xe(pe.name)})},[r==null?void 0:r.id]);const he=fe||((ct=r==null?void 0:r.user_metadata)==null?void 0:ct.name)||(r==null?void 0:r.email)||"User",[we,Ne]=k.useState(()=>typeof window<"u"?localStorage.getItem(gLe)==="true":!1);k.useEffect(()=>{localStorage.setItem(gLe,String(we))},[we]);const[Ve,Te]=k.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,website:!0,help:!1}),Ae=pe=>{Te(Ge=>({...Ge,[pe]:!Ge[pe]}))},ze=pe=>pe.split(" ").map(Ge=>Ge[0]).join("").toUpperCase().slice(0,2),Ee=pe=>le.pathname===pe,ve=pe=>pe.some(Ge=>le.pathname===Ge),Re=({path:pe,icon:Ge,label:tt,badgeCount:st})=>{const Ce=e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Ee(pe)&&"bg-sidebar-accent text-sidebar-accent-foreground",we?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>ie(pe),children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ge,{className:"h-4 w-4 shrink-0"}),we&&st!=null&&st>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!we&&tt,!we&&st!=null&&st>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:st>9?"9+":st})]});return we?e.jsxs(Jl,{delayDuration:0,children:[e.jsx(ec,{asChild:!0,children:Ce}),e.jsxs(Il,{side:"right",className:"flex items-center gap-2",children:[tt,st!=null&&st>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:st>9?"9+":st})]})]}):Ce},Ue=({id:pe,label:Ge,icon:tt,children:st,activePaths:Ce,showBetaBadge:et,defaultPath:Ct,badgeCount:Ot})=>{if(we){const ut=Ct||Ce[0];return e.jsxs(Jl,{delayDuration:0,children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:Rt("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",ve(Ce)&&"text-primary"),onClick:()=>ie(ut),children:e.jsxs("div",{className:"relative",children:[e.jsx(tt,{className:"h-4 w-4"}),Ot!=null&&Ot>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(Il,{side:"right",className:"flex items-center gap-2",children:[Ge,et&&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"}),Ot!=null&&Ot>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:Ot>9?"9+":Ot})]})]})}return e.jsxs(uf,{open:Ve[pe],onOpenChange:()=>Ae(pe),children:[e.jsx(hf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ve(Ce)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(tt,{className:"h-4 w-4"}),Ge,et&&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:[Ot!=null&&Ot>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:Ot>9?"9+":Ot}),e.jsx(Fi,{className:Rt("h-4 w-4 transition-transform duration-200",Ve[pe]&&"rotate-180")})]})]})}),e.jsx(mf,{className:"pl-4 space-y-1 mt-1",children:st})]})},ye=({isMobile:pe=!1})=>{const Ge=pe?!1:we;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:Rt("p-3 border-b border-sidebar-border",Ge?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[Ge?e.jsx("img",{src:LIt,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:IIt,alt:"LevelUp",className:"h-8 w-auto"}),!pe&&e.jsxs(Jl,{delayDuration:0,children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>Ne(!Ge),children:e.jsx(wl,{className:Rt("h-4 w-4 transition-transform duration-300",Ge&&"rotate-180")})})}),e.jsx(Il,{side:"right",children:Ge?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(di,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:Rt("p-3 space-y-1",Ge&&"flex flex-col items-center"),children:[e.jsx(Re,{path:"/dashboard",icon:oS,label:"Dashboard"}),e.jsx(Re,{path:"/apps",icon:tx,label:"Apps & Tools"}),we?e.jsxs(Jl,{delayDuration:0,children:[e.jsx(ec,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ee("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/levelup-u"),children:[e.jsx(Dh,{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(Il,{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:Rt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ee("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/levelup-u"),children:[e.jsx(Dh,{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(Re,{path:"/events",icon:xd,label:"Events"}),e.jsxs(Ue,{id:"agentos",label:"Agent OS",icon:bM,activePaths:["/mission-control","/mission-control/contacts","/mission-control/plans","/mission-control/popbys","/mission-control/video-library","/mission-control/scorecard","/mission-control/listings","/mission-control/pipeline","/mission-control/tasks","/mission-control/smart-drips","/mission-control/relationship-scorecard","/mission-control/sphere-gaps","/mission-control/connect-page"],showBetaBadge:!0,defaultPath:"/mission-control",children:[u("contacts")&&e.jsx(Re,{path:"/mission-control",icon:Za,label:"Mission Control"}),u("contacts")&&!Ge&&e.jsxs(uf,{open:Ve.contacts,onOpenChange:()=>Ae("contacts"),children:[e.jsx(hf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ve(["/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(cr,{className:"h-4 w-4"}),"Contacts"]}),e.jsx(Fi,{className:Rt("h-3.5 w-3.5 transition-transform duration-200",Ve.contacts&&"rotate-180")})]})}),e.jsxs(mf,{className:"pl-4 pr-1 space-y-0.5 mt-0.5",children:[e.jsx(Re,{path:"/mission-control/contacts",icon:cr,label:"All Contacts"}),e.jsx(Re,{path:"/mission-control/relationship-scorecard",icon:ih,label:"Relationship Report"}),e.jsx(Re,{path:"/mission-control/sphere-gaps",icon:RL,label:"Sphere Gaps"}),e.jsx(Re,{path:"/mission-control/connect-page",icon:Do,label:"Connect Page"})]})]}),u("contacts")&&Ge&&e.jsx(Re,{path:"/mission-control/contacts",icon:cr,label:"Contacts"}),u("contacts")&&e.jsx(Re,{path:"/mission-control/plans",icon:xd,label:"TouchPlans"}),u("pipeline")&&e.jsx(Re,{path:"/mission-control/pipeline",icon:Zy,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(Re,{path:"/mission-control/tasks",icon:Av,label:"Tasks"}),u("popbys")&&e.jsx(Re,{path:"/mission-control/popbys",icon:Vi,label:"Popbys"}),u("videos")&&e.jsx(Re,{path:"/mission-control/video-library",icon:hn,label:"Video Library"}),u("scorecard")&&e.jsx(Re,{path:"/mission-control/scorecard",icon:so,label:"Scorecard"}),u("listings")&&e.jsx(Re,{path:"/mission-control/listings",icon:ma,label:"Listing Exchange"}),!Ge&&e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ee("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/mission-control/smart-drips"),children:[e.jsx(Fh,{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"})]}),Ge&&e.jsx(Re,{path:"/mission-control/smart-drips",icon:Fh,label:"Smart Drips"})]}),ce&&Y&&e.jsxs(Ue,{id:"website",label:"My Website",icon:gd,activePaths:[`/admin/lead-sites/${Y.id}/edit`],defaultPath:`/admin/lead-sites/${Y.id}/edit`,children:[Ge?e.jsxs(Jl,{delayDuration:0,children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open(ae||"#","_blank"),children:e.jsx(jn,{className:"h-4 w-4"})})}),e.jsx(Il,{side:"right",children:"View Site"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open(ae||"#","_blank"),children:[e.jsx(jn,{className:"h-4 w-4"}),"View Site",e.jsx(Kr,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsx(Re,{path:`/my-website/${Y.id}/edit`,icon:pa,label:"Edit Website"}),e.jsx(Re,{path:"/my-website/mls-listings",icon:Mn,label:"MLS Listings"}),e.jsx(Re,{path:"/my-website/market-report",icon:so,label:"Market Reports"}),e.jsx(Re,{path:"/mission-control/website-activity",icon:ih,label:"Website Activity"}),e.jsx(Re,{path:"/m",icon:s0,label:"Mobile Command"})]}),e.jsxs(Ue,{id:"marketing",label:"Marketing",icon:dh,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Re,{path:"/templates",icon:Rl,label:"Templates"}),e.jsx(Re,{path:"/social-swag-2",icon:s0,label:"Social Swag"}),e.jsx(Re,{path:"/newsletters",icon:Jv,label:"Newsletters"})]}),e.jsxs(Ue,{id:"learning",label:"Learning",icon:oh,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Re,{path:"/academy",icon:Dh,label:"Academy"}),e.jsx(Re,{path:"/toolbox",icon:Og,label:"Toolbox"})]}),e.jsxs(Ue,{id:"community",label:"Community",icon:Si,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:q,children:[e.jsx(Re,{path:"/community",icon:cr,label:"Community",badgeCount:q}),e.jsx(Re,{path:"/wishlist",icon:Eb,label:"Wishlist",badgeCount:$}),!Ge&&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(Kr,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(Ue,{id:"goods",label:"The Goods",icon:ip,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[S&&!Ge&&e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",le.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/marketplace"),children:[e.jsx(ip,{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"})]}),S&&Ge&&e.jsx(Re,{path:"/marketplace",icon:ip,label:"Marketplace"}),e.jsx(Re,{path:"/reward-store",icon:Hi,label:"Reward Store"})]}),e.jsxs(Ue,{id:"help",label:"Help & Services",icon:Sv,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Re,{path:"/support",icon:EM,label:"Support"}),e.jsx(Re,{path:"/additional-services",icon:qr,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!Ge&&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"})}),Ge?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(Re,{path:"/admin",icon:yd,label:"Admin Dashboard"})}):e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",le.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/admin"),children:[e.jsx(yd,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!Ge&&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"})}),Ge?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(Re,{path:"/my-brokerage",icon:ma,label:"My Brokerage"}),e.jsx(Re,{path:"/brokerage-content",icon:oh,label:"Brokerage Content"})]}),ee&&!o&&e.jsx(Re,{path:"/my-team",icon:cr,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{path:"/brokerage/dashboard",icon:So,label:"Manage Brokerages"}),e.jsx(Re,{path:"/brokerage/teams",icon:cr,label:"Teams"}),e.jsx(Re,{path:"/brokerage/recruiting",icon:dh,label:"Recruiting"}),e.jsx(Re,{path:"/brokerage-resources",icon:Lh,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ee("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/my-brokerage"),children:[e.jsx(ma,{className:"h-4 w-4"}),"My Brokerage"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ee("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/brokerage-content"),children:[e.jsx(oh,{className:"h-4 w-4"}),"Brokerage Content"]})]}),ee&&!o&&e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ee("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/my-team"),children:[e.jsx(cr,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ee("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/brokerage/dashboard"),children:[e.jsx(So,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ee("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/brokerage/teams"),children:[e.jsx(cr,{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:Rt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ee("/brokerage/recruiting")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/brokerage/recruiting"),children:[e.jsx(dh,{className:"h-4 w-4"}),"Recruiting"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ee("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/brokerage-resources"),children:[e.jsx(Lh,{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:Rt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ee("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ie("/profile"),children:[e.jsx(Ei,{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(IM,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(gLt,{children:e.jsx(S1,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[b&&N&&e.jsx(F6t,{}),typeof document<"u"&&ap.createPortal(e.jsx("aside",{className:Rt("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-30 !pointer-events-auto transition-[width] duration-300",we?"w-16":"w-56"),style:{top:`${y}px`,height:`calc(100vh - ${y}px)`},children:e.jsx(ye,{})}),document.body),e.jsxs("div",{className:Rt("flex-1 flex flex-col overflow-hidden transition-all duration-300",we?"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(ZA,{children:[e.jsx(GNe,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(hS,{className:"h-5 w-5"})})}),e.jsx(CC,{side:"left",className:"w-56 p-0 bg-card",children:e.jsx(ye,{isMobile:!0})})]}),e.jsx("div",{className:"flex-1 md:hidden",children:e.jsx("img",{src:DIt,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(pLe,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[b&&!N&&w&&e.jsx(O6t,{expiresAt:w,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(pLe,{})}),C&&e.jsx(z6t,{hasUnseenBrief:I,onClick:L}),S&&e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",onClick:()=>ie("/marketplace/cart"),children:[e.jsx(ip,{className:"h-5 w-5"}),J>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:J>99?"99+":J})]}),e.jsx(c6t,{}),e.jsx(o_e,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",he.split(" ")[0],"!"]}),e.jsxs(Ud,{children:[e.jsx(Vd,{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(vn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx(Ca,{src:_||void 0}),e.jsx(_n,{className:"bg-primary text-primary-foreground font-medium text-sm",children:ze(he)})]})})}),e.jsxs(jd,{align:"end",className:"w-48",children:[e.jsxs(xa,{onClick:()=>ie("/profile"),className:"cursor-pointer",children:[e.jsx(Ei,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(xa,{onClick:()=>ie("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(TL,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(Jb,{}),e.jsxs(xa,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(IM,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(rLt,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),C&&e.jsx(eLt,{brief:C,open:A,onClose:O,onDismiss:U}),e.jsx(sLt,{}),e.jsx(aLt,{}),e.jsx(lLt,{})]})]})})})},yLt=()=>{const{user:t}=$s(),[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.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)}},d=["Unlimited access to all marketing templates","Complete Academy training library","AI-powered tools and resources","Community forums and support","Exclusive member events and workshops","Deal pipeline & scorecard tracking","Listing exchange access","Social media content library"],u=["Everything in Individual plan","Up to 25 agent seats","Brokerage admin dashboard","Team performance analytics","Custom branding options","Priority support","Agent onboarding tools","Brokerage-wide announcements"],p=["Everything in Brokerage plan","Unlimited agent seats","Dedicated account manager","Advanced analytics & reporting","White-label options","API access","Custom integrations","Enterprise-level support"];return e.jsx(Ls,{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(ge,{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(Ie,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 bg-primary text-primary-foreground text-xs px-3 py-1 rounded-bl-lg font-medium",children:"Popular"}),e.jsxs(Lt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(cr,{className:"h-7 w-7 text-primary"})}),e.jsx(Ft,{className:"text-xl",children:"Individual Agent"}),e.jsx(mr,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs(Be,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-primary",children:"$39"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:d.map((f,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ea,{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(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(qr,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ie,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors",children:[e.jsxs(Lt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(ma,{className:"h-7 w-7 text-amber-600"})}),e.jsx(Ft,{className:"text-xl",children:"Brokerage"}),e.jsx(mr,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(Be,{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(ea,{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(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ma,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ie,{className:"border-2 border-purple-500/20 hover:border-purple-500/50 transition-colors",children:[e.jsxs(Lt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-purple-500/10 flex items-center justify-center",children:e.jsx(ma,{className:"h-7 w-7 text-purple-600"})}),e.jsx(Ft,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(mr,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(Be,{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(ea,{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(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ma,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(Ie,{className:"bg-muted/50",children:e.jsxs(Be,{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(Tn,{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(tr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},vLt=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=$s(),a=br(),[o,l]=k.useState(""),[i,d]=k.useState(!1),[u,p]=k.useState(!1);k.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),k.useEffect(()=>{!s&&t&&n&&a("/profile?setup=true")},[t,s,n,a]);const f=async()=>{if(!o.trim()){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}d(!0);try{console.log("[SetupBrokerage] Creating brokerage…",{hasUser:!!t,hasSession:!!_,userId:t==null?void 0:t.id});const{data:b,error:N}=await G.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:b,error:N}),N)throw N;if(!(b!=null&&b.ok))throw new Error((b==null?void 0:b.error)||"Failed to create brokerage");d(!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"),d(!1)}};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):u?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ie,{className:"max-w-lg w-full",children:[e.jsxs(Lt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(ps,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(Ft,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(mr,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(si,{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(ps,{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(Ie,{className:"max-w-lg w-full",children:[e.jsxs(Lt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(ma,{className:"w-10 h-10 text-primary"})}),e.jsx(Ft,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(mr,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs(Be,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(cr,{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(si,{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(si,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(si,{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(si,{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(ti,{className:"w-4 h-4 ml-2"})]})]})]})})},yLe=()=>{const t=br(),[s,r]=k.useState("verifying"),[n,a]=k.useState("");k.useEffect(()=>{(async()=>{try{const{data:{session:i},error:d}=await G.auth.getSession();if(d)throw d;if(i!=null&&i.user){const{data:u}=await G.from("profiles").select("login_count").eq("id",i.user.id).single();if(((u==null?void 0:u.login_count)||0)>1){console.log("Account already claimed, redirecting to dashboard"),r("already_claimed");return}console.log("User logged in successfully:",i.user.email),r("success");try{await G.functions.invoke("trial-claim-hook",{body:{userId:i.user.id}})}catch(p){console.log("Trial claim hook (non-critical):",p)}setTimeout(()=>{t("/profile?setup=true")},1500)}else setTimeout(()=>{r("already_claimed")},2e3)}catch(i){console.error("Claim error:",i),r("already_claimed")}})()},[t]);const o=()=>{window.location.href="https://dashboard.relevelup.com/auth"};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Ie,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"space-y-1 text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:[s==="verifying"&&e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),s==="success"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),s==="already_claimed"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),s==="error"&&e.jsx("svg",{className:"h-8 w-8 text-destructive",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]}),e.jsxs(Ft,{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(mr,{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(Be,{children:e.jsx(K,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},_Lt=()=>{const t=br(),[s]=Sc(),[r,n]=k.useState(s.get("code")||""),[a,o]=k.useState(""),[l,i]=k.useState(""),[d,u]=k.useState(""),[p,f]=k.useState(!1),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState(!1),[C,A]=k.useState(null),[I,L]=k.useState(null),[O,U]=k.useState(null),[q,$]=k.useState(null);k.useEffect(()=>{const J=s.get("code");J&&(n(J),V(J))},[s]);const V=async J=>{N(!0);const{data:Y,error:ce}=await G.from("invite_codes").select("id, code, max_uses, uses_count, expires_at, is_active, brokerage_id, trial_days").eq("code",J.toUpperCase().trim()).single();if(ce||!Y){me.error("Invalid invite code"),N(!1);return}if(!Y.is_active){me.error("This invite code is no longer active"),N(!1);return}if(Y.max_uses&&Y.uses_count>=Y.max_uses){me.error("This invite code has reached its maximum uses"),N(!1);return}if(Y.expires_at&&new Date(Y.expires_at){J.preventDefault(),V(r)},Z=async J=>{var Y;if(J.preventDefault(),!d.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 ce=`${window.location.origin}/`,{data:ae,error:ie}=await G.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:ce,data:{name:d.trim()}}});if(ie){ie.message.includes("already registered")?me.error("This email is already registered. Please sign in instead."):me.error(ie.message);return}ae.user&&(await G.rpc("add_default_signup_tag",{user_id:ae.user.id}),I?await G.functions.invoke("assign-brokerage",{body:{userId:ae.user.id,brokerageId:I}}):q?await G.functions.invoke("assign-brokerage",{body:{userId:ae.user.id,trialDays:q}}):await G.functions.invoke("assign-brokerage",{body:{userId:ae.user.id,grandfathered:!0}}),C&&await G.from("invite_codes").update({uses_count:((Y=(await G.from("invite_codes").select("uses_count").eq("id",C).single()).data)==null?void 0:Y.uses_count)+1}).eq("id",C),me.success("Account created! You can now access the dashboard."),t("/dashboard"))}catch(ce){console.error("Signup error:",ce),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(Ie,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[e.jsx(Ft,{className:"text-2xl font-bold text-primary",children:O?`Join ${O}`:"Join LevelUp"}),e.jsx(mr,{children:w?O?`Create your account to join ${O}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(Be,{children:w?e.jsxs("form",{onSubmit:Z,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"name",children:"Full Name"}),e.jsx(Fe,{id:"name",type:"text",placeholder:"John Doe",value:d,onChange:J=>u(J.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"email",children:"Email"}),e.jsx(Fe,{id:"email",type:"email",placeholder:"you@example.com",value:a,onChange:J=>o(J.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{id:"password",type:p?"text":"password",placeholder:"••••••••",value:l,onChange:J=>i(J.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(hp,{className:"h-4 w-4"}):e.jsx(jn,{className:"h-4 w-4"})})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:y,children:y?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:ee,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"inviteCode",children:"Invite Code"}),e.jsx(Fe,{id:"inviteCode",type:"text",placeholder:"Enter your invite code",value:r,onChange:J=>n(J.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(ps,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},bLt="/assets/testimonial-avatar-1-BsCQFauB.jpg",wLt="/assets/testimonial-avatar-2-B6VPVc2t.jpg",jLt="/assets/testimonial-avatar-3-GuEFwYUE.jpg",NLt="/assets/testimonial-avatar-4-98iKMtkB.jpg",kLt="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",SLt=[bLt,wLt,jLt,NLt,kLt],CLt=SC({name:Yl().trim().min(2,"Name must be at least 2 characters").max(100),email:Yl().trim().email("Please enter a valid email address").max(255),phone:Yl().trim().min(10,"Please enter a valid phone number").max(20).optional().or(nle("")),brokerage:Yl().trim().max(200).optional().or(nle(""))}),MLt=[{icon:tp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Rl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:nn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:bc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:mn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:Vi,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],TLt=[{icon:cr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:qr,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Tn,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:lh,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:La,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:so,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Za,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Fh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],ALt=[{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."}],ELt=()=>{const t=br(),[s,r]=k.useState(!1),[n,a]=k.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=k.useState({}),i=async d=>{var p,f;d.preventDefault(),l({});const u=CLt.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(Nc,{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:xle,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var d;return(d=document.getElementById("features"))==null?void 0:d.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"grid lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{className:"space-y-8 text-center lg:text-left",children:[e.jsx("div",{className:"flex justify-center lg:justify-start",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-24 md:h-32 drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium",children:[e.jsx(qr,{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(Hn,{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(Hn,{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:SLt.map((d,u)=>e.jsx("img",{src:d,alt:`Agent ${u+1}`,className:"w-10 h-10 rounded-full border-2 border-white/20 object-cover"},u))}),e.jsxs("div",{children:[e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(d=>e.jsx(Gn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},d))}),e.jsx("p",{className:"text-sm text-white/60",children:"Trusted by 3,000+ agents"})]})]})]}),e.jsx("div",{className:"lg:pl-8",children:e.jsx(Ie,{className:"bg-white shadow-2xl border-0",children:e.jsxs(Be,{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(Jy,{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(ge,{htmlFor:"name",children:"Full Name *"}),e.jsx(Fe,{id:"name",type:"text",placeholder:"John Smith",value:n.name,onChange:d=>a({...n,name:d.target.value}),required:!0}),o.name&&e.jsx("p",{className:"text-sm text-destructive",children:o.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"email",children:"Email Address *"}),e.jsx(Fe,{id:"email",type:"email",placeholder:"john@example.com",value:n.email,onChange:d=>a({...n,email:d.target.value}),required:!0}),o.email&&e.jsx("p",{className:"text-sm text-destructive",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"phone",children:"Phone Number"}),e.jsx(Fe,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:d=>a({...n,phone:d.target.value})}),o.phone&&e.jsx("p",{className:"text-sm text-destructive",children:o.phone})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"brokerage",children:"Brokerage Name"}),e.jsx(Fe,{id:"brokerage",type:"text",placeholder:"Your brokerage or team name",value:n.brokerage,onChange:d=>a({...n,brokerage:d.target.value})}),o.brokerage&&e.jsx("p",{className:"text-sm text-destructive",children:o.brokerage})]}),e.jsx(K,{type:"submit",className:"w-full h-12 text-lg font-semibold bg-[#4a6b6d] hover:bg-[#3d5a5c]",disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(ti,{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:MLt.map((d,u)=>e.jsxs(Ie,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Lt,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx(d.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Ft,{className:"text-xl font-sans",children:d.title})]}),e.jsx(Be,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:d.description})})]},u))})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(qr,{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:TLt.map((d,u)=>e.jsxs(Ie,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx(d.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Ft,{className:"text-lg font-semibold text-white",children:d.title})]}),e.jsx(Be,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:d.description})})]},u))})]})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4 font-sans",children:"Loved by Top Producers"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"See what agents are saying about LevelUp"})]}),e.jsx("div",{className:"grid md:grid-cols-3 gap-8 max-w-5xl mx-auto",children:ALt.map((d,u)=>e.jsx(Ie,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(Be,{className:"p-6",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(p=>e.jsx(Gn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},p))}),e.jsxs("p",{className:"text-muted-foreground mb-4 italic",children:['"',d.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:d.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.role})]})]})},u))})]})}),e.jsx("section",{className:"py-16 bg-muted/30",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-wrap justify-center gap-8 md:gap-16",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(Ru,{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(Fh,{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(cr,{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(Ie,{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(Be,{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(ti,{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:Xje,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."})]})})})]})]})},PLt=()=>{const t=br();return e.jsxs(e.Fragment,{children:[e.jsx(Nc,{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:xle,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(Ie,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:e.jsxs(Be,{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(Hn,{className:"h-12 w-12 text-white"})}),e.jsx("div",{className:"absolute -top-2 -right-2 w-10 h-10 rounded-full bg-yellow-500 flex items-center justify-center animate-bounce",children:e.jsx(Bd,{className:"h-5 w-5 text-white"})})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-foreground mb-4 font-sans",children:"You're In! 🎉"}),e.jsx("p",{className:"text-xl text-muted-foreground mb-8",children:"Your 7-day LevelUp adventure starts now!"}),e.jsxs("div",{className:"bg-[#4a6b6d]/10 rounded-xl p-6 mb-8",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/20 flex items-center justify-center",children:e.jsx(tr,{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(ti,{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:Xje,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},ILt=SC({viewerName:Yl().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:Yl().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:Yl().max(20,"Phone must be less than 20 characters").optional(),message:Yl().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function LLt({shareToken:t,agentName:s,hasContact:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,d]=k.useState(null),u=Zue({resolver:Yue(ILt),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),p=async f=>{a(!0),d(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),d(y.message||"Something went wrong. Please try again.")}finally{a(!1)}};return o?e.jsx(Ie,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:e.jsxs(Be,{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(Hn,{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(Ie,{children:[e.jsxs(Lt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(bc,{className:"h-5 w-5 text-primary"}),e.jsx(Ft,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(mr,{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(Be,{children:e.jsx(Xue,{...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(Ic,{control:u.control,name:"viewerName",render:({field:f})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Your Name *"}),e.jsx(mc,{children:e.jsx(Fe,{placeholder:"John Smith",...f})}),e.jsx(gm,{})]})}),e.jsx(Ic,{control:u.control,name:"viewerEmail",render:({field:f})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Email *"}),e.jsx(mc,{children:e.jsx(Fe,{type:"email",placeholder:"john@example.com",...f})}),e.jsx(gm,{})]})})]}),!r&&e.jsx(Ic,{control:u.control,name:"viewerPhone",render:({field:f})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Phone (optional)"}),e.jsx(mc,{children:e.jsx(Fe,{type:"tel",placeholder:"(555) 123-4567",...f})}),e.jsx(gm,{})]})}),e.jsx(Ic,{control:u.control,name:"message",render:({field:f})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Message *"}),e.jsx(mc,{children:e.jsx(_r,{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(gm,{})]})}),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(ps,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Nn,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const DLt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsxs("div",{className:"absolute inset-0 opacity-[0.08]",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[16%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[32%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[48%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[64%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[80%] left-0 right-0 h-[8%] bg-red-600"})]}),e.jsx("div",{className:"absolute top-0 left-0 w-[35%] h-[45%] bg-blue-900/10 rounded-br-3xl"}),e.jsx(Gn,{className:"absolute top-[5%] left-[8%] w-6 h-6 text-blue-600/30 fill-blue-600/20"}),e.jsx(Gn,{className:"absolute top-[15%] left-[20%] w-4 h-4 text-blue-600/25 fill-blue-600/15"}),e.jsx(Gn,{className:"absolute top-[8%] left-[28%] w-5 h-5 text-blue-600/30 fill-blue-600/20"}),e.jsx(Gn,{className:"absolute top-[25%] left-[12%] w-4 h-4 text-blue-600/20 fill-blue-600/10"}),e.jsx(Gn,{className:"absolute top-[20%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse"}),e.jsx(Yv,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),RLt=()=>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(qr,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-8 text-red-400/40"})]}),e.jsxs("div",{className:"absolute top-[5%] right-[20%] w-24 h-24",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-blue-400/20 animate-ping",style:{animationDuration:"4s",animationDelay:"1s"}}),e.jsx(Gn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-6 h-6 text-blue-400/40 fill-blue-400/20"})]}),e.jsxs("div",{className:"absolute top-[20%] left-[50%] w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border border-white/10 animate-ping",style:{animationDuration:"3.5s",animationDelay:"0.5s"}}),e.jsx(qr,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-5 h-5 text-amber-400/40"})]}),e.jsx(Gn,{className:"absolute bottom-[25%] left-[10%] w-6 h-6 text-blue-500/25 fill-blue-500/15 animate-pulse"}),e.jsx(Gn,{className:"absolute bottom-[15%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse",style:{animationDelay:"0.5s"}}),e.jsx(Yv,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),OLt=()=>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(Tg,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(Tg,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(Tg,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(Tg,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(Za,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(Za,{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(Za,{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"})]}),FLt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/5 via-slate-800/3 to-indigo-900/5"}),e.jsx("div",{className:"absolute top-[5%] right-[10%] opacity-15",children:e.jsxs("div",{className:"w-12 h-24 relative",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-10 h-3 bg-blue-600 rounded-full"}),e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 w-0 h-0 border-l-[20px] border-r-[20px] border-t-[60px] border-l-transparent border-r-transparent border-t-blue-500"})]})}),e.jsx(rc,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),e.jsx(Gn,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),e.jsx(rc,{className:"absolute bottom-[20%] right-[8%] w-14 h-14 text-indigo-500/12"}),e.jsx("div",{className:"absolute top-[3%] left-[40%] opacity-12",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tr-none rotate-6"}),e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tl-none -rotate-6"})]})}),e.jsx(Gn,{className:"absolute bottom-[25%] left-[15%] w-6 h-6 text-blue-500/20 fill-blue-500/10 animate-pulse"}),e.jsx(Gn,{className:"absolute top-[20%] right-[22%] w-5 h-5 text-indigo-400/20 fill-indigo-400/10 animate-pulse",style:{animationDelay:"0.5s"}})]}),zLt=()=>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(Tg,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(Tg,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(SM,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),BLt=()=>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(sS,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(sS,{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(qr,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(qr,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),$Lt=()=>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(Db,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(Db,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(Db,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(Bv,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(Bv,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Bv,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(Bv,{className:"absolute top-[8%] left-[70%] w-8 h-8 text-blue-200/20 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[12%] left-[10%] w-5 h-5 rounded-full bg-red-500/25"}),e.jsx("div",{className:"absolute top-[15%] right-[15%] w-4 h-4 rounded-full bg-amber-400/25"}),e.jsx("div",{className:"absolute top-[20%] left-[55%] w-4 h-4 rounded-full bg-green-500/20"}),e.jsx(Gn,{className:"absolute top-[3%] left-[50%] -translate-x-1/2 w-10 h-10 text-amber-400/35 fill-amber-400/25"})]}),qLt=()=>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(Za,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(Za,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),ULt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-900/8 via-amber-900/4 to-purple-900/8"}),e.jsx(Gn,{className:"absolute top-[5%] left-[15%] w-12 h-12 text-yellow-400/35 fill-yellow-400/25 animate-pulse"}),e.jsx(Gn,{className:"absolute top-[8%] right-[12%] w-10 h-10 text-amber-400/30 fill-amber-400/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Gn,{className:"absolute top-[15%] left-[40%] w-7 h-7 text-yellow-300/25 fill-yellow-300/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(Gn,{className:"absolute top-[12%] right-[35%] w-8 h-8 text-amber-300/28 fill-amber-300/18 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[20%] left-[25%] w-4 h-4 rounded-full bg-pink-400/30"}),e.jsx("div",{className:"absolute top-[18%] right-[30%] w-3 h-3 rounded-full bg-sky-400/30"}),e.jsx("div",{className:"absolute top-[25%] left-[60%] w-2.5 h-2.5 rounded-full bg-emerald-400/30"}),e.jsx("div",{className:"absolute top-[22%] right-[42%] w-3 h-3 rounded-full bg-purple-400/30"}),e.jsx(qr,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(Bd,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(Bd,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),VLt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),e.jsxs("div",{className:"absolute bottom-[12%] left-1/2 -translate-x-1/2 flex items-end gap-3",children:[e.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"}),e.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),e.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),e.jsx("div",{className:"w-2.5 h-20 bg-blue-500/22 rounded-full"})," ",e.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),e.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),e.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"})]}),e.jsx("div",{className:"absolute bottom-[38%] left-[calc(50%-42px)] w-3 h-4 bg-yellow-400/30 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[35%] left-[calc(50%-28px)] w-2.5 h-3 bg-yellow-300/25 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[40%] left-[calc(50%-14px)] w-3 h-4 bg-amber-400/30 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[45%] left-1/2 -translate-x-1/2 w-4 h-5 bg-yellow-400/35 rounded-full blur-sm"}),e.jsx(Gn,{className:"absolute top-[8%] left-[50%] -translate-x-1/2 w-14 h-14 text-yellow-400/28 fill-yellow-400/18"}),e.jsx(qr,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(qr,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),HLt=()=>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(zv,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(zv,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(zv,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(zv,{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"})]})]})]}),GLt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),e.jsx("div",{className:"absolute top-[8%] left-[12%] w-16 h-16 rounded-full border-4 border-blue-500/18"}),e.jsx("div",{className:"absolute top-[10%] right-[10%] w-14 h-14 rounded-full border-4 border-indigo-500/15"}),e.jsx("div",{className:"absolute bottom-[18%] left-[18%] w-12 h-12 rounded-full border-3 border-sky-500/12"}),e.jsx(Gn,{className:"absolute top-[5%] left-[42%] w-10 h-10 text-amber-400/30 fill-amber-400/20"}),e.jsx(Gn,{className:"absolute top-[15%] right-[25%] w-7 h-7 text-yellow-400/25 fill-yellow-400/15"}),e.jsx(rc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(rc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(Yv,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),WLt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/6 via-rose-900/6 to-purple-900/6"}),e.jsx(lh,{className:"absolute bottom-[10%] left-[50%] -translate-x-1/2 w-20 h-20 text-amber-400/18"}),e.jsxs("div",{className:"absolute top-[5%] left-[15%]",children:[e.jsx("div",{className:"w-12 h-14 rounded-full bg-rose-400/25"}),e.jsx("div",{className:"w-0.5 h-10 bg-rose-400/18 mx-auto"})]}),e.jsxs("div",{className:"absolute top-[3%] left-[25%]",children:[e.jsx("div",{className:"w-10 h-12 rounded-full bg-sky-400/25"}),e.jsx("div",{className:"w-0.5 h-12 bg-sky-400/18 mx-auto"})]}),e.jsxs("div",{className:"absolute top-[8%] right-[18%]",children:[e.jsx("div",{className:"w-11 h-13 rounded-full bg-purple-400/25"}),e.jsx("div",{className:"w-0.5 h-9 bg-purple-400/18 mx-auto"})]}),e.jsxs("div",{className:"absolute top-[5%] right-[10%]",children:[e.jsx("div",{className:"w-10 h-12 rounded-full bg-amber-400/25"}),e.jsx("div",{className:"w-0.5 h-11 bg-amber-400/18 mx-auto"})]}),e.jsx("div",{className:"absolute top-[20%] left-[35%] w-3 h-3 bg-pink-400/35 rounded-full"}),e.jsx("div",{className:"absolute top-[18%] right-[40%] w-2.5 h-2.5 bg-emerald-400/35 rounded-full"}),e.jsx("div",{className:"absolute top-[25%] left-[55%] w-2 h-2 bg-amber-400/35 rounded-full"}),e.jsx("div",{className:"absolute top-[22%] right-[30%] w-2.5 h-2.5 bg-sky-400/35 rounded-full"}),e.jsx(Bd,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(Vi,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),KLt=()=>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(Za,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(Za,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(Za,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(Za,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(Za,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(Za,{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(Za,{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(Za,{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"})]}),ZLt=()=>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(t1,{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(t1,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(qr,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(t1,{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"})]}),YLt=()=>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(Mn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(Mn,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(mp,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(mp,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),e.jsx(Za,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(Za,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(qr,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(Bd,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),XLt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-900/10 via-teal-900/6 to-cyan-900/10"}),e.jsx(Bd,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(Bd,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),e.jsx(mp,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(Mn,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(qr,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(qr,{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"})]}),QLt=()=>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(mp,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(mp,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(mp,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(Mn,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(Bd,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(qr,{className:"absolute top-[5%] right-[35%] w-8 h-8 text-yellow-400/35"}),e.jsx(Gn,{className:"absolute top-[18%] left-[28%] w-6 h-6 text-amber-400/25 fill-amber-400/15"})]}),JLt=()=>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(Mn,{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(mp,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),e.jsx(Za,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(qr,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(Kv,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),vLe=()=>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"})]}),e8t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Za,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(Za,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(Za,{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(Za,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),t8t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Kv,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(qr,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(Mn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),s8t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(J4,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(LM,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(J4,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),n6=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(qr,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(Bd,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(qr,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),_Le=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Mn,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(qr,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(Mn,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),u_e=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(qr,{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(Za,{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(e8t,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(lL,{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(n6,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(J4,{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(s8t,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(so,{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(cr,{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(n6,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"So proud of your accomplishment",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(vLe,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(La,{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(_Le,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(LM,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Hey ${t}!`:"Hey There!",subText:"No reason needed – just wanted to connect",gradientClasses:"from-sky-50/70 via-blue-50/50 to-indigo-50/40 dark:from-sky-950/30 dark:via-blue-950/20 dark:to-indigo-950/20",accentColor:"sky",decorativeElement:e.jsx(n6,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(lh,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Birthday, ${t}!`:"Happy Birthday!",subText:"Wishing you an amazing year ahead",gradientClasses:"from-amber-50/80 via-rose-50/60 to-purple-50/40 dark:from-amber-950/30 dark:via-rose-950/20 dark:to-purple-950/20",accentColor:"amber",decorativeElement:e.jsx(WLt,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(Za,{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(KLt,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(t1,{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(ZLt,{})},{id:"new_years",name:"New Year's Day",description:"Ring in the new year",icon:e.jsx(Gn,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy New Year, ${t}!`:"Happy New Year!",subText:"Wishing you a year full of success and happiness",gradientClasses:"from-yellow-50/70 via-amber-50/50 to-orange-50/40 dark:from-yellow-950/30 dark:via-amber-950/20 dark:to-orange-950/20",accentColor:"yellow",decorativeElement:e.jsx(ULt,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(SM,{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(zLt,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(Tg,{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(OLt,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Father's Day, ${t}!`:"Happy Father's Day!",subText:"Celebrating the wonderful fathers in our lives",gradientClasses:"from-blue-50/70 via-sky-50/50 to-indigo-50/40 dark:from-blue-950/30 dark:via-sky-950/20 dark:to-indigo-950/20",accentColor:"blue",decorativeElement:e.jsx(FLt,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(Yv,{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(DLt,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx(ch,{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(RLt,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Labor Day, ${t}!`:"Happy Labor Day!",subText:"Celebrating the hard work that builds our communities",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue",decorativeElement:e.jsx(GLt,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(sS,{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(BLt,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(Za,{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(qLt,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(Db,{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($Lt,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(qr,{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(VLt,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(zv,{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(HLt,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(Mn,{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(YLt,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(Bd,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"You're under contract – exciting times ahead!",gradientClasses:"from-emerald-50/70 via-teal-50/50 to-cyan-50/40 dark:from-emerald-950/30 dark:via-teal-950/20 dark:to-cyan-950/20",accentColor:"emerald",decorativeElement:e.jsx(XLt,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(nn,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Exciting News, ${t}!`:"Just Listed!",subText:"A new property is now on the market",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-violet-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-violet-950/20",accentColor:"blue",decorativeElement:e.jsx(_Le,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(_c,{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(n6,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(jS,{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(Kv,{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(t8t,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(mp,{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(QLt,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(Mn,{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(JLt,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(Ou,{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(n6,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"You're pre-approved and ready to find your dream home",gradientClasses:"from-violet-50/70 via-purple-50/50 to-indigo-50/40 dark:from-violet-950/30 dark:via-purple-950/20 dark:to-indigo-950/20",accentColor:"violet",decorativeElement:e.jsx(vLe,{})}],r8t=[{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 n8t(t){return u_e.filter(s=>s.category===t)}function KM(t){return u_e.find(s=>s.id===t)||u_e[0]}function bLe(){const{shareToken:t,recipientToken:s}=ho(),[r,n]=k.useState(null),[a,o]=k.useState(null),[l,i]=k.useState(null),[d,u]=k.useState(!0),[p,f]=k.useState(null),[y,_]=k.useState(!0),b=k.useRef(null),N=k.useRef(0),w=k.useRef(0),S=(()=>{const Z=new URLSearchParams(window.location.search);return s||Z.get("rt")||null})(),C=k.useCallback((Z,J=!1)=>{if(!S||Z<=0)return;const Y=Math.max(1,Math.round(Z));if(Y<=w.current)return;const ae=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(S)}&e=watch&ws=${Y}`;J&&navigator.sendBeacon?navigator.sendBeacon(ae):fetch(ae,{method:"GET",keepalive:J}).catch(()=>{}),w.current=Math.max(w.current,Y)},[S]);k.useEffect(()=>{var le;if(!y||!(r!=null&&r.playback_url)||!S)return;let Z=!1;const J=()=>{N.current>0&&C(N.current,!0)},Y=()=>{document.visibilityState==="hidden"&&J()},ce=()=>{J()},ae=()=>{var xe;if(Z||!b.current||!((xe=window.playerjs)!=null&&xe.Player))return;const fe=new window.playerjs.Player(b.current);fe.on("timeupdate",he=>{const we=Math.floor(Number((he==null?void 0:he.seconds)??0));!Number.isFinite(we)||we<=0||(N.current=Math.max(N.current,we))}),fe.on("pause",()=>{N.current>0&&C(N.current)}),fe.on("ended",()=>{N.current>0&&C(N.current,!0)})},ie=document.querySelector('script[data-bunny-playerjs="true"]');if((le=window.playerjs)!=null&&le.Player)ae();else if(ie)ie.addEventListener("load",ae,{once:!0});else{const fe=document.createElement("script");fe.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",fe.async=!0,fe.defer=!0,fe.dataset.bunnyPlayerjs="true",fe.onload=ae,document.body.appendChild(fe)}return document.addEventListener("visibilitychange",Y),window.addEventListener("beforeunload",ce),()=>{Z=!0,document.removeEventListener("visibilitychange",Y),window.removeEventListener("beforeunload",ce),J()}},[y,r==null?void 0:r.playback_url,S,C]),k.useEffect(()=>{N.current=0,w.current=0},[S,t]),k.useEffect(()=>{const Z=()=>{['[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(ae=>{document.querySelectorAll(ae).forEach(ie=>{ie.style.display="none"})})};Z();const J=[setTimeout(Z,500),setTimeout(Z,1500),setTimeout(Z,3e3)],Y=new MutationObserver(Z);return Y.observe(document.body,{childList:!0,subtree:!0}),()=>{J.forEach(clearTimeout),Y.disconnect()}},[]),k.useEffect(()=>{(async()=>{if(!t){f("Invalid share link"),u(!1);return}const{data:J,error:Y}=await G.from("agent_videos").select("id, title, playback_url, thumbnail_url, preview_url, duration_seconds, share_token, owner_user_id, contact_id, page_template, recipient_name").eq("share_token",t).eq("is_deleted",!1).single();if(Y||!J){f("Video not found or has been removed"),u(!1);return}n(J);try{await G.rpc("log_video_view",{p_video_id:J.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch(ce){console.warn("Failed to log video view:",ce)}if(J.owner_user_id){const{data:ce}=await G.from("profiles").select("id, name, email, phone").eq("id",J.owner_user_id).single();if(ce){o(ce);try{const{data:ae}=await G.storage.from("avatars").list(`${J.owner_user_id}`);if(ae&&ae.length>0){const{data:ie}=G.storage.from("avatars").getPublicUrl(`${J.owner_user_id}/${ae[0].name}`);i(ie.publicUrl)}}catch{}}}u(!1)})()},[t]);const A=Z=>{if(!Z)return"0:00";const J=Math.floor(Z/60),Y=Z%60;return`${J}:${Y.toString().padStart(2,"0")}`},I=Z=>Z.includes("iframe.mediadelivery.net/play/")?Z.replace("/play/","/embed/")+"?autoplay=true&responsive=true":Z,L=Z=>{if(!Z)return"?";const J=Z.split(" ");return J.length>=2?`${J[0][0]}${J[1][0]}`.toUpperCase():Z.substring(0,2).toUpperCase()},O=KM((r==null?void 0:r.page_template)||"default"),U=(r==null?void 0:r.recipient_name)||null,q=O.headerText(U),V=`https://dashboard.relevelup.com/share/video/${t}`;if(d)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(ps,{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(Ie,{className:"max-w-md w-full",children:e.jsxs(Be,{className:"py-12 text-center",children:[e.jsx(hn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Video Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:p||"This video is no longer available."})]})})});const ee=O.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(Nc,{children:[e.jsx("title",{children:q}),e.jsx("meta",{name:"description",content:O.subText}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:O.subText}),e.jsx("meta",{property:"og:type",content:"video.other"}),e.jsx("meta",{property:"og:url",content:V}),r.preview_url&&e.jsx("meta",{property:"og:image",content:r.preview_url}),!r.preview_url&&r.thumbnail_url&&e.jsx("meta",{property:"og:image",content:r.thumbnail_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{property:"og:video",content:r.playback_url}),e.jsx("meta",{property:"og:video:type",content:"text/html"}),e.jsx("meta",{property:"og:video:width",content:"1280"}),e.jsx("meta",{property:"og:video:height",content:"720"})]}),e.jsx("meta",{name:"twitter:card",content:"player"}),e.jsx("meta",{name:"twitter:title",content:q}),e.jsx("meta",{name:"twitter:description",content:O.subText}),r.preview_url&&e.jsx("meta",{name:"twitter:image",content:r.preview_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{name:"twitter:player",content:r.playback_url}),e.jsx("meta",{name:"twitter:player:width",content:"1280"}),e.jsx("meta",{name:"twitter:player:height",content:"720"})]})]}),e.jsxs("div",{className:Rt("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",O.gradientClasses),children:[ee&&O.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[ee&&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:Rt("w-14 h-14 rounded-full flex items-center justify-center shadow-sm",O.accentColor==="primary"&&"bg-primary/10 text-primary",O.accentColor==="amber"&&"bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",O.accentColor==="teal"&&"bg-teal-100 text-teal-600 dark:bg-teal-900/50 dark:text-teal-400",O.accentColor==="rose"&&"bg-rose-100 text-rose-600 dark:bg-rose-900/50 dark:text-rose-400",O.accentColor==="emerald"&&"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/50 dark:text-emerald-400",O.accentColor==="yellow"&&"bg-yellow-100 text-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400",O.accentColor==="pink"&&"bg-pink-100 text-pink-600 dark:bg-pink-900/50 dark:text-pink-400",O.accentColor==="blue"&&"bg-blue-100 text-blue-600 dark:bg-blue-900/50 dark:text-blue-400",O.accentColor==="red"&&"bg-red-100 text-red-600 dark:bg-red-900/50 dark:text-red-400",O.accentColor==="orange"&&"bg-orange-100 text-orange-600 dark:bg-orange-900/50 dark:text-orange-400",O.accentColor==="green"&&"bg-green-100 text-green-600 dark:bg-green-900/50 dark:text-green-400",O.accentColor==="violet"&&"bg-violet-100 text-violet-600 dark:bg-violet-900/50 dark:text-violet-400",O.accentColor==="sky"&&"bg-sky-100 text-sky-600 dark:bg-sky-900/50 dark:text-sky-400"),children:e.jsx("div",{className:"scale-150",children:O.icon})})}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:q}),e.jsx("p",{className:"text-muted-foreground",children:O.subText})]}),a&&e.jsxs("div",{className:"flex items-center gap-4 p-4 bg-card/90 backdrop-blur-sm rounded-lg border shadow-sm",children:[e.jsxs(vn,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx(Ca,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(_n,{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:ee?"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(Tn,{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(tr,{className:"h-4 w-4"})})})]})]}),e.jsx(Ie,{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:Z=>{var Y;Z.currentTarget.style.display="none";const J=(Y=Z.currentTarget.parentElement)==null?void 0:Y.querySelector(".video-fallback");J&&(J.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(hn,{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(Co,{className:"h-10 w-10 text-primary ml-1"})})}),r.duration_seconds&&e.jsx("div",{className:"absolute bottom-3 right-3 bg-black/70 text-white text-sm px-2 py-1 rounded",children:A(r.duration_seconds)})]})}),!ee&&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(Co,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(LLt,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function a8t(){return k.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(c_t,{})}function i8t(){const{token:t}=ho();return k.useEffect(()=>{if(!t)return;const s=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/video-og-image?token=${t}`;window.location.replace(s)},[t]),e.jsx("main",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(ps,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}var rhe="Tabs",[o8t]=bd(rhe,[gw]),mXe=gw(),[l8t,dke]=o8t(rhe),pXe=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:d="automatic",...u}=t,p=xw(i),[f,y]=Bu({prop:n,onChange:a,defaultProp:o??"",caller:rhe});return e.jsx(l8t,{scope:r,baseId:mu(),value:f,onValueChange:y,orientation:l,dir:p,activationMode:d,children:e.jsx(dn.div,{dir:p,"data-orientation":l,...u,ref:s})})});pXe.displayName=rhe;var fXe="TabsList",xXe=k.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=dke(fXe,r),l=mXe(r);return e.jsx(gue,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(dn.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});xXe.displayName=fXe;var gXe="TabsTrigger",yXe=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=dke(gXe,r),i=mXe(r),d=bXe(l.baseId,n),u=wXe(l.baseId,n),p=n===l.value;return e.jsx(yue,{asChild:!0,...i,focusable:!a,active:p,children:e.jsx(dn.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...o,ref:s,onMouseDown:Tr(t.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:Tr(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:Tr(t.onFocus,()=>{const f=l.activationMode!=="manual";!p&&!a&&f&&l.onValueChange(n)})})})});yXe.displayName=gXe;var vXe="TabsContent",_Xe=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=dke(vXe,r),d=bXe(i.baseId,n),u=wXe(i.baseId,n),p=n===i.value,f=k.useRef(p);return k.useEffect(()=>{const y=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(y)},[]),e.jsx(wd,{present:a||p,children:({present:y})=>e.jsx(dn.div,{"data-state":p?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":d,hidden:!y,id:u,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:f.current?"0s":void 0},children:y&&o})})});_Xe.displayName=vXe;function bXe(t,s){return`${t}-trigger-${s}`}function wXe(t,s){return`${t}-content-${s}`}var c8t=pXe,jXe=xXe,NXe=yXe,kXe=_Xe;const ta=c8t,Qn=k.forwardRef(({className:t,...s},r)=>e.jsx(jXe,{ref:r,className:Rt("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));Qn.displayName=jXe.displayName;const ls=k.forwardRef(({className:t,...s},r)=>e.jsx(NXe,{ref:r,className:Rt("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}));ls.displayName=NXe.displayName;const js=k.forwardRef(({className:t,...s},r)=>e.jsx(kXe,{ref:r,className:Rt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));js.displayName=kXe.displayName;const d8t={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},u8t={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},v5={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function h8t(){var Ve,Te,Ae,ze;const{slugOrId:t}=ho(),[s]=Sc(),{data:r,isLoading:n}=CWe(t||""),a=MWe(),o=g4t(),l=s.get("ref"),[i,d]=k.useState(""),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(""),[N,w]=k.useState(""),[S,C]=k.useState(""),[A,I]=k.useState(""),[L,O]=k.useState("in_person"),[U,q]=k.useState("info"),[$,V]=k.useState(!1),[ee,Z]=k.useState(!1),[J,Y]=k.useState(null),[ce,ae]=k.useState(!1);k.useEffect(()=>{l&&o.mutate(l)},[l]);const ie=Ee=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Ee),le=async Ee=>{if(Ee.preventDefault(),!i.trim()||!f.trim()||!r)return;const ve=U==="showing";if(ve&&!S){me.error("Please pick a preferred date for your showing");return}V(!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,leadType:ve?"showing_request":"info_request",preferredDate:ve?S:null,preferredTime:ve&&A||null,showingMode:ve?L:null,message:N.trim()||null}),Z(!0),me.success(ve?"Showing request sent! The agent will confirm details shortly.":"Thanks! The agent will be in touch soon.")}catch(Re){console.error("Lead submission error:",Re),me.error(`Failed to submit: ${Re.message||"Please try again"}`)}finally{V(!1)}},fe=(r==null?void 0:r.photos)||[],xe=fe.find(Ee=>Ee.is_primary)||fe[0],he=()=>{J!==null&&Y(J===0?fe.length-1:J-1)},we=()=>{J!==null&&Y(J===fe.length-1?0:J+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(Ss,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(Ss,{className:"h-10 w-48 mb-6"}),e.jsx(Ss,{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(Ss,{className:"h-12 w-48"}),e.jsx(Ss,{className:"h-6 w-full"}),e.jsx(Ss,{className:"h-6 w-3/4"})]}),e.jsx(Ss,{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(da,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Xoe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Mn,{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(da,{to:"/public/listings",children:"Browse All Listings"})})]})]});const Ne=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(Nc,{children:[e.jsxs("title",{children:[Ne," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${ie(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${r.square_footage?r.square_footage.toLocaleString()+" sqft":""} ${v5[r.property_type]} in ${r.city}, ${r.state}. ${((Ve=r.description)==null?void 0:Ve.slice(0,150))||""}`}),e.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${r.slug||r.id}`}),e.jsx("meta",{property:"og:title",content:Ne}),e.jsx("meta",{property:"og:description",content:`${ie(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${v5[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}`}),xe&&e.jsx("meta",{property:"og:image",content:xe.photo_url}),xe&&e.jsx("meta",{property:"og:image:alt",content:`${r.property_address||r.city} - ${v5[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:Ne}),e.jsx("meta",{name:"twitter:description",content:`${ie(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA in ${r.city}, ${r.state}`}),xe&&e.jsx("meta",{name:"twitter:image",content:xe.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||`${v5[r.property_type]} for sale in ${r.city}, ${r.state}`,url:`https://listings.relevelup.com/${r.slug||r.id}`,datePosted:r.created_at,image:fe.map(Ee=>Ee.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:(Te=r.agent.brokerage)!=null&&Te.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(da,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Xoe,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(da,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),fe.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:()=>Y(0),children:e.jsx("img",{src:xe==null?void 0:xe.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${v5[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:fe.slice(1,5).map((Ee,ve)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>Y(ve+1),children:[e.jsx("img",{src:Ee.photo_url,alt:`${r.property_address||r.city} - Photo ${ve+2} of ${fe.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),ve===3&&fe.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",fe.length-5," more"]})]},Ee.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(Ye,{className:`${d8t[r.status]} text-white border-0`,children:u8t[r.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:ie(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(La,{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(Ky,{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(of,{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(r0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),r.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(nn,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Ye,{variant:"secondary",children:[e.jsx(ma,{className:"h-3 w-3 mr-1"}),v5[r.property_type]]}),r.lot_size&&e.jsxs(Ye,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(Ye,{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(Kr,{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(Ie,{className:"overflow-hidden bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:e.jsxs(Be,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>ae(!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(hn,{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(Co,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(K,{onClick:()=>ae(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(Co,{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(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ei,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Be,{children:[e.jsx("p",{className:"font-semibold text-lg",children:r.agent.name}),((Ae=r.agent.brokerage)==null?void 0:Ae.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(Ie,{className:"border-primary",children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(Ft,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Be,{children:ee?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(tr,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:U==="showing"?"Showing request sent!":"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:U==="showing"?"The listing agent will reach out to confirm your showing time.":"The listing agent will contact you soon."})]}):e.jsxs(ta,{value:U,onValueChange:Ee=>q(Ee),children:[e.jsxs(Qn,{className:"grid w-full grid-cols-2 mb-4",children:[e.jsxs(ls,{value:"info",className:"gap-1.5",children:[e.jsx(tr,{className:"h-3.5 w-3.5"}),"Get Info"]}),e.jsxs(ls,{value:"showing",className:"gap-1.5",children:[e.jsx(jM,{className:"h-3.5 w-3.5"}),"Request Tour"]})]}),e.jsxs("form",{onSubmit:le,className:"space-y-3",children:[e.jsxs(js,{value:"showing",className:"mt-0 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"preferredDate",children:"Preferred Date *"}),e.jsx(Fe,{id:"preferredDate",type:"date",value:S,onChange:Ee=>C(Ee.target.value),min:new Date().toISOString().split("T")[0],required:U==="showing"})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"preferredTime",children:"Preferred Time"}),e.jsxs(zs,{value:A,onValueChange:I,children:[e.jsx(Os,{id:"preferredTime",children:e.jsx(qs,{placeholder:"Any time"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"morning",children:"Morning (9am–12pm)"}),e.jsx(yt,{value:"afternoon",children:"Afternoon (12pm–5pm)"}),e.jsx(yt,{value:"evening",children:"Evening (5pm–8pm)"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"showingMode",children:"Tour Type"}),e.jsxs(zs,{value:L,onValueChange:Ee=>O(Ee),children:[e.jsx(Os,{id:"showingMode",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"in_person",children:"🏡 In-person showing"}),e.jsx(yt,{value:"video",children:"📱 Video tour (FaceTime/Zoom)"}),e.jsx(yt,{value:"either",children:"Either works for me"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Fe,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:Ee=>d(Ee.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Fe,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:Ee=>p(Ee.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"email",children:"Email *"}),e.jsx(Fe,{id:"email",type:"email",placeholder:"you@example.com",value:f,onChange:Ee=>y(Ee.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsxs(ge,{htmlFor:"phone",children:["Phone ",U==="showing"&&"*"]}),e.jsx(Fe,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:_,onChange:Ee=>b(Ee.target.value),required:U==="showing"})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"message",children:U==="showing"?"Anything else?":"Message (optional)"}),e.jsx(_r,{id:"message",placeholder:U==="showing"?"e.g. I have flexibility on weekends":"Any specific questions about the property?",value:N,onChange:Ee=>w(Ee.target.value),rows:2})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:$,children:$?"Submitting...":U==="showing"?"Request Showing":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})]})})]})]})]})]}),e.jsx(fs,{open:J!==null,onOpenChange:()=>Y(null),children:e.jsxs(ms,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(ks,{className:"sr-only",children:e.jsx(bs,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>Y(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(Sr,{className:"h-5 w-5"})}),J!==null&&fe[J]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:fe[J].photo_url,alt:`Photo ${J+1}`,className:"w-full max-h-[80vh] object-contain"}),fe.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:he,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(wl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:we,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(ja,{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," / ",fe.length]})]})]})]})}),e.jsx(fs,{open:ce,onOpenChange:ae,children:e.jsxs(ms,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(ks,{className:"sr-only",children:e.jsx(bs,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>ae(!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(Sr,{className:"h-5 w-5"})}),((ze=r==null?void 0:r.video)==null?void 0:ze.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 m8t(){var o;const{slug:t}=ho(),{data:s,isLoading:r,error:n}=PWe(t);if(k.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),k.useEffect(()=>{s!=null&&s.id&&Ui(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(Ss,{className:"h-28 w-28 rounded-full"}),e.jsx(Ss,{className:"h-6 w-48"}),e.jsx(Ss,{className:"h-4 w-36"})]}),e.jsx(Ss,{className:"h-12 w-full"}),e.jsx(Ss,{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(Nc,{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(Jje,{card:s})]})}function SXe({slugOverride:t}={}){var Ce;const{slug:s}=ho(),r=t||s,[n]=Sc(),a=n.get("t"),[o,l]=k.useState(!0),[i,d]=k.useState(null),[u,p]=k.useState(null),f=k.useRef(null),y=k.useRef(null),[_,b]=k.useState(null),[N,w]=k.useState(null),[S,C]=k.useState(!1),[A,I]=k.useState(!1),[L,O]=k.useState(0),[U,q]=k.useState(!1),[$,V]=k.useState(""),[ee,Z]=k.useState(""),[J,Y]=k.useState(""),[ce,ae]=k.useState(""),[ie,le]=k.useState(""),[fe,xe]=k.useState(""),[he,we]=k.useState(""),[Ne,Ve]=k.useState(""),[Te,Ae]=k.useState(""),[ze,Ee]=k.useState(""),[ve,Re]=k.useState(""),[Ue,ye]=k.useState("");k.useEffect(()=>{ct()},[r,a]);const ct=async()=>{if(!r)return;l(!0);const{data:et,error:Ct}=await G.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if(Ct||!et){q(!0),l(!1);return}p(et),y.current=et;const{data:Ot}=await G.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",et.user_id).single();if(Ot){let ut;if(Ot.brokerage_id){const{data:at}=await G.from("brokerages").select("name").eq("id",Ot.brokerage_id).single();ut=(at==null?void 0:at.name)||void 0}let Oe=Ot.avatar_url||null;if(!Oe){const{data:at}=G.storage.from("avatars").getPublicUrl(`${et.user_id}/avatar.jpg`);at!=null&&at.publicUrl&&(Oe=`${at.publicUrl}?t=${Date.now()}`)}const Xe={...Ot,avatar_url:Oe,brokerage_name:ut};d(Xe),f.current=Xe}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",et.id);const{data:ut,error:Oe}=await G.functions.invoke("process-intake-submissions",{body:{action:"resolve_token",token:a,page_id:et.id}});if(console.log("[ConnectPage] Resolve result:",{resolved:ut,resolveErr:Oe}),!Oe&&(ut!=null&&ut.contact_id)){w(ut.contact_id);const Xe=ut.contact;Xe&&(b(Xe),V(Xe.first_name||""),Z(Xe.last_name||""),Y(Xe.email||""),ae(Xe.phone||""),le(Xe.address||""),xe(Xe.city||""),we(Xe.state||""),Ve(Xe.zip||""),Ae(Xe.birthday||""),Ee(Xe.home_anniversary||""))}}catch(ut){console.error("Failed to resolve token:",ut)}l(!1)},pe=async()=>{var et,Ct;if(!$.trim()){me.error("Please enter your first name");return}if(!r){me.error("Invalid page. Please refresh.");return}I(!0);try{let Ot=(et=y.current)==null?void 0:et.id,ut=(Ct=y.current)==null?void 0:Ct.user_id;if(!Ot||!ut){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,ut=Xe.user_id}const{error:Oe}=await G.from("contact_intake_submissions").insert({intake_page_id:Ot,agent_user_id:ut,existing_contact_id:N,first_name:$.trim(),last_name:ee.trim()||null,email:J.trim()||null,phone:ce.trim()||null,address:ie.trim()||null,city:fe.trim()||null,state:he.trim()||null,zip:Ne.trim()||null,birthday:Te||null,home_anniversary:ze||null,real_estate_interest:ve||null,message:Ue.trim()||null});if(console.log("[ConnectPage] Insert result:",{error:Oe}),Oe)throw Oe;a&&await G.from("contact_intake_tokens").update({used_at:new Date().toISOString()}).eq("token",a);try{const Xe=[$.trim(),ee.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:ut,contactName:Xe,contactEmail:J.trim()||null,contactPhone:ce.trim()||null,slug:r})})}catch(Xe){console.warn("Connect page notification failed (non-blocking):",Xe)}C(!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(ps,{className:"h-8 w-8 animate-spin text-slate-400"})});if(U)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(S)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(Nc,{children:e.jsxs("title",{children:["Thank You | ",i==null?void 0:i.name]})}),e.jsxs(ur.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(ur.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(Hn,{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(Za,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})]})]});const Ge=!!a&&!!_,tt=3,st=[{title:Ge?"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:$,onChange:et=>V(et.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:ee,onChange:et=>Z(et.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:J,onChange:et=>Y(et.target.value),placeholder:"jane@email.com",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Phone"}),e.jsx("input",{type:"tel",value:ce,onChange:et=>ae(et.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:ie,onChange:et=>le(et.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:fe,onChange:et=>xe(et.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:he,onChange:et=>we(et.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:Ne,onChange:et=>Ve(et.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:Te,onChange:et=>Ae(et.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:ze,onChange:et=>Ee(et.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(et=>e.jsxs("button",{type:"button",onClick:()=>Re(ve===et.value?"":et.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${ve===et.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:et.label}),e.jsx("span",{className:"block text-xs text-slate-500 mt-0.5",children:et.desc})]},et.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:Ue,onChange:et=>ye(et.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(Nc,{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(ur.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-center mb-8",children:[i!=null&&i.avatar_url?e.jsx("img",{src:i.avatar_url,alt:i.name,className:"w-24 h-24 rounded-full object-cover mx-auto mb-4 ring-4 ring-white shadow-lg"}):e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-blue-500 to-indigo-600 mx-auto mb-4 flex items-center justify-center ring-4 ring-white shadow-lg",children:e.jsx("span",{className:"text-3xl font-bold text-white",children:((Ce=i==null?void 0:i.name)==null?void 0:Ce.charAt(0))||"?"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800",children:i==null?void 0:i.name}),(i==null?void 0:i.title)&&e.jsx("p",{className:"text-slate-500 mt-0.5",children:i.title}),(i==null?void 0:i.brokerage_name)&&e.jsx("p",{className:"text-sm text-slate-400",children:i.brokerage_name}),((i==null?void 0:i.phone)||(i==null?void 0:i.email))&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[(i==null?void 0:i.phone)&&e.jsx("a",{href:`tel:${i.phone}`,className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-50 hover:bg-blue-100 text-blue-600 transition-colors","aria-label":"Call agent",children:e.jsx(Tn,{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(tr,{className:"h-4.5 w-4.5"})})]})]}),e.jsx(ur.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:tt}).map((et,Ct)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${Ct<=L?"bg-blue-500":"bg-slate-200"}`},Ct))}),e.jsxs(ur.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(qNe,{mode:"wait",children:e.jsxs(ur.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(qr,{className:"h-5 w-5 text-blue-500"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-800",children:st[L].title})]}),st[L].fields]},L)}),e.jsxs("div",{className:"flex justify-between mt-8",children:[L>0?e.jsx("button",{type:"button",onClick:()=>O(et=>et-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&&!$.trim()){me.error("Please enter your first name");return}O(et=>et+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:A,className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm disabled:opacity-50 flex items-center gap-2",children:A?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Submit"})]}),L>0&&LO(et=>et+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(Za,{className:"h-3 w-3"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})})]})]})}const JA=()=>({trackEngagement:k.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)}},[])});function a6({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=k.useState(0),[o,l]=k.useState(!1),{trackEngagement:i}=JA(),d=k.useCallback(_=>{i("newsletter",_.id,_.title,"click_link")},[i]),u=k.useCallback(()=>{a(_=>(_+1)%t.length)},[t.length]),p=k.useCallback(()=>{a(_=>(_-1+t.length)%t.length)},[t.length]),f=k.useCallback(_=>{a(_)},[]);if(k.useEffect(()=>{if(t.length<=1||o)return;const _=setInterval(u,s);return()=>clearInterval(_)},[t.length,o,s,u]),!t||t.length===0)return null;const y=t[n];return e.jsxs("div",{className:Rt("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:y.image_url,alt:y.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:Rt("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:p,children:e.jsx(wl,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:Rt("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:u,children:e.jsx(ja,{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((_,b)=>e.jsx("button",{onClick:()=>f(b),className:Rt("w-2 h-2 rounded-full transition-all duration-300",b===n?"bg-white w-6":"bg-white/50 hover:bg-white/70"),"aria-label":`Go to slide ${b+1}`},b))})]}),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:y.title}),y.description&&e.jsx("p",{className:"text-xs text-background/70 truncate",children:y.description})]}),y.link_url&&e.jsx("a",{href:y.link_url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0",onClick:()=>d(y),children:e.jsx(K,{size:"sm",className:"bg-primary text-primary-foreground font-semibold transition-colors hover:bg-background hover:text-foreground",children:y.link_text||"Learn More"})})]})]})}function p8t(t){return"EST"}function uD(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=p8t();return`${r} ${n}`}function ZM(t){const s=new Date,r=new Date(t),n=tM(r,-15),a=tM(r,30);return s>a?"ended":wg(s,{start:r,end:a})?"live":wg(s,{start:n,end:r})?"starting_soon":"upcoming"}function uke(t){const s=ZM(t);return s==="starting_soon"||s==="live"}const wLe=uke,f8t=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=k.useState(new Date);k.useEffect(()=>{const _=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(_)},[]);const o=t.filter(_=>uke(_.event_date));if(o.length===0)return null;const l=o[0],i=ZM(l.event_date),d=s.find(_=>_.event_id===l.id),u=(d==null?void 0:d.zoom_join_url)||l.zoom_link,p=!!d,f=i==="live",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(e1,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(rn,{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 ${uD(new Date(l.event_date))}`:`Starts at ${uD(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(Kr,{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(cr,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};function x8t(t,s=[]){let r=[];function n(o,l){const i=k.createContext(l);i.displayName=o+"Context";const d=r.length;r=[...r,l];const u=f=>{var S;const{scope:y,children:_,...b}=f,N=((S=y==null?void 0:y[t])==null?void 0:S[d])||i,w=k.useMemo(()=>b,Object.values(b));return e.jsx(N.Provider,{value:w,children:_})};u.displayName=o+"Provider";function p(f,y){var N;const _=((N=y==null?void 0:y[t])==null?void 0:N[d])||i,b=k.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=>k.createContext(l));return function(i){const d=(i==null?void 0:i[t])||o;return k.useMemo(()=>({[`__scope${t}`]:{...i,[t]:d}}),[i,d])}};return a.scopeName=t,[n,g8t(a,...s)]}function g8t(...t){const s=t[0];if(t.length===1)return s;const r=()=>{const n=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const l=n.reduce((i,{useScope:d,scopeName:u})=>{const f=d(o)[`__scope${u}`];return{...i,...f}},{});return k.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}var y8t=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],CXe=y8t.reduce((t,s)=>{const r=qA(`Primitive.${s}`),n=k.forwardRef((a,o)=>{const{asChild:l,...i}=a,d=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{}),hke="Progress",mke=100,[v8t]=x8t(hke),[_8t,b8t]=v8t(hke),MXe=k.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=w8t,...l}=t;(a||a===0)&&!jLe(a)&&console.error(j8t(`${a}`,"Progress"));const i=jLe(a)?a:mke;n!==null&&!NLe(n,i)&&console.error(N8t(`${n}`,"Progress"));const d=NLe(n,i)?n:null,u=_le(d)?o(d,i):void 0;return e.jsx(_8t,{scope:r,value:d,max:i,children:e.jsx(CXe.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":_le(d)?d:void 0,"aria-valuetext":u,role:"progressbar","data-state":EXe(d,i),"data-value":d??void 0,"data-max":i,...l,ref:s})})});MXe.displayName=hke;var TXe="ProgressIndicator",AXe=k.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=b8t(TXe,r);return e.jsx(CXe.div,{"data-state":EXe(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});AXe.displayName=TXe;function w8t(t,s){return`${Math.round(t/s*100)}%`}function EXe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function _le(t){return typeof t=="number"}function jLe(t){return _le(t)&&!isNaN(t)&&t>0}function NLe(t,s){return _le(t)&&!isNaN(t)&&t<=s&&t>=0}function j8t(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${mke}\`.`}function N8t(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 ${mke} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var PXe=MXe,k8t=AXe;const pi=k.forwardRef(({className:t,value:s,...r},n)=>e.jsx(PXe,{ref:n,className:Rt("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(k8t,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));pi.displayName=PXe.displayName;function S8t(){const{user:t,isBrokerageManager:s}=$s(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState(!1),[d,u]=k.useState(!0),p=s?"brokerage_manager":"agent";k.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}f()},[t==null?void 0:t.id,p]);const f=async()=>{if(t!=null&&t.id)try{const{data:I,error:L}=await G.from("onboarding_checklist_items").select("*").eq("target_role",p).eq("is_active",!0).order("sort_order");if(L)throw L;const{data:O,error:U}=await G.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",t.id);if(U)throw U;const{data:q,error:$}=await G.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if($)throw $;n(I||[]),o(O||[]),i(!!q),I&&I.length>0&&await y(I,O||[])}catch(I){console.error("Error fetching checklist data:",I)}finally{u(!1)}},y=async(I,L)=>{var Ee,ve;if(!(t!=null&&t.id))return;const O=L.map(Re=>Re.item_id),U=I.filter(Re=>!O.includes(Re.id));if(U.length===0)return;const[q,$,V,ee,Z,J,Y,ce,ae,ie,le,fe,xe,he,we]=await Promise.all([G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle(),G.from("resource_shares").select("id",{count:"exact",head:!0}).eq("sender_id",t.id),G.from("community_posts").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("event_registrations").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","template"),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","academy_video"),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","toolbox"),G.from("activity_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("innercircle_contacts").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("agent_videos").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("contact_touch_logs").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("scorecard_transactions").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("listings").select("id",{count:"exact",head:!0}).eq("agent_id",t.id),G.from("innercircle_contacts").select("id").eq("owner_user_id",t.id),G.from("deal_pipeline").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id)]),Ne={},Ve=(Ee=q.data)==null?void 0:Ee.brokerage_id;Ne.share_resource=($.count||0)>0,Ne.post_community=(V.count||0)>0,Ne.register_event=(ee.count||0)>0,Ne.view_template=(Z.count||0)>0,Ne.watch_academy=(J.count||0)>0,Ne.use_toolbox=(Y.count||0)>0,Ne.launch_app=(ce.count||0)>0,Ne.add_contact=(ae.count||0)>0,Ne.create_video=(ie.count||0)>0,Ne.complete_touch=(le.count||0)>0,Ne.add_transaction=(fe.count||0)>0,Ne.add_listing=(xe.count||0)>0,Ne.add_deal=(we.count||0)>0;const Te=((ve=he.data)==null?void 0:ve.map(Re=>Re.id))||[],Ae=[];Ve?Ae.push(G.from("profiles").select("id").eq("brokerage_id",Ve).neq("id",t.id).then(Re=>{var Ue;Ne.add_agent=(((Ue=Re.data)==null?void 0:Ue.length)||0)>0})):Ne.add_agent=!1,Te.length>0?(Ae.push(G.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",Te).then(Re=>{Ne.add_plan=(Re.count||0)>0})),Ae.push(G.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",Te).then(Re=>{Ne.schedule_popby=(Re.count||0)>0}))):(Ne.add_plan=!1,Ne.schedule_popby=!1),await Promise.all(Ae);const ze=U.filter(Re=>Ne[Re.action_type]);if(ze.length>0){const Re=ze.map(ye=>({user_id:t.id,item_id:ye.id})),{error:Ue}=await G.from("onboarding_checklist_progress").upsert(Re,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!Ue){const ye=ze.map(ct=>({item_id:ct.id,completed_at:new Date().toISOString()}));o(ct=>[...ct,...ye])}}},_=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(O=>[...O,{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)}},N=a.length,w=r.length,S=w>0&&N>=w,C=w>0?N/w*100:0;return{items:r,progress:a,isDismissed:l,loading:d,completedCount:N,totalCount:w,isComplete:S,progressPercentage:C,isItemComplete:I=>a.some(L=>L.item_id===I),markComplete:_,dismiss:b,refetch:f}}const C8t={add_agent:e.jsx(cr,{className:"h-4 w-4"}),share_resource:e.jsx(vd,{className:"h-4 w-4"}),post_community:e.jsx(Si,{className:"h-4 w-4"}),register_event:e.jsx(nn,{className:"h-4 w-4"}),view_template:e.jsx(Mv,{className:"h-4 w-4"}),watch_academy:e.jsx(Dh,{className:"h-4 w-4"}),use_toolbox:e.jsx(Og,{className:"h-4 w-4"}),launch_app:e.jsx(sL,{className:"h-4 w-4"}),add_deal:e.jsx(Zy,{className:"h-4 w-4"}),add_listing:e.jsx(Mn,{className:"h-4 w-4"})},M8t={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function T8t(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:d,dismiss:u}=S8t(),p=br(),[f,y]=k.useState(!0);return r||s||a===0||o?null:e.jsxs(Ie,{className:"mb-6 border-primary/20 bg-gradient-to-r from-primary/5 to-transparent",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Jy,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ft,{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(lf,{className:"h-4 w-4"}):e.jsx(Fi,{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(Sr,{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(pi,{value:l,className:"h-2"})]})]}),f&&e.jsx(Be,{className:"pt-0",children:e.jsx("div",{className:"space-y-3",children:t.map(_=>{const b=i(_.id);return e.jsxs("div",{className:Rt("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 N=M8t[_.action_type];N?p(N):d(_.id)},children:[e.jsx("div",{className:"mt-0.5",children:b?e.jsx(Hn,{className:"h-5 w-5 text-primary"}):e.jsx(sd,{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:C8t[_.action_type]||e.jsx(sd,{className:"h-4 w-4"})}),e.jsx("span",{className:Rt("font-medium",b&&"line-through text-muted-foreground"),children:_.title})]}),_.description&&e.jsx("p",{className:Rt("text-sm text-muted-foreground mt-1",b&&"line-through"),children:_.description})]})]},_.id)})})})]})}const Mf=()=>ft({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}}),Uh=t=>{const s=_a(),r=1e3,n=async a=>{const o=[];let l=0;for(;;){const{data:i,error:d}=await a.range(l,l+r-1);if(d)throw d;const u=i??[];if(o.push(...u),u.length{let a=G.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("owner_user_id",s).order("created_at",{ascending:!1}).order("first_name");return await n(a)},enabled:!!s})},A8t=t=>ft({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}),IXe=()=>{const t=_a();return ft({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})},nhe=()=>{const t=es(),s=_a();return Et({mutationFn:async r=>{const{tagIds:n,...a}=r,o={...a,birthday:a.birthday||null,home_anniversary:a.home_anniversary||null,owner_user_id:s},{data:l,error:i}=await G.from("innercircle_contacts").insert(o).select().single();if(i)throw i;if(n&&n.length>0){const{error:d}=await G.from("innercircle_contact_tags").insert(n.map(u=>({contact_id:l.id,relationship_type_id:u})));if(d)throw d}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),cn({title:"Contact created successfully"})},onError:r=>{cn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},pke=()=>{const t=es();return Et({mutationFn:async({id:s,...r})=>{const{tagIds:n,tags:a,...o}=r,l={...o,birthday:o.birthday||null,home_anniversary:o.home_anniversary||null},{data:i,error:d}=await G.from("innercircle_contacts").update(l).eq("id",s).select().single();if(d)throw d;if(n!==void 0&&(await G.from("innercircle_contact_tags").delete().eq("contact_id",s),n.length>0)){const{error:u}=await G.from("innercircle_contact_tags").insert(n.map(p=>({contact_id:s,relationship_type_id:p})));if(u)throw u}return i},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),cn({title:"Contact updated successfully"})},onError:s=>{cn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},LXe=()=>{const t=es();return Et({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"]}),cn({title:"Spouse link updated"})},onError:s=>{cn({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},fke=()=>{const t=es();return Et({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"]}),cn({title:"Contact deleted successfully"})},onError:s=>{cn({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},KR=()=>ft({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}}),E8t=t=>ft({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}}),P8t=()=>ft({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}}),I8t=()=>{const t=es(),s=_a();return Et({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"]}),cn({title:"Plan created successfully"})},onError:r=>{cn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},L8t=()=>{const t=es(),s=_a();return Et({mutationFn:async({sourcePlanId:r,newName:n})=>{const{data:a,error:o}=await G.from("touchpoint_plans").select(` *, items:touchpoint_plan_items(*) `).eq("id",r).single();if(o)throw o;if(!a)throw new Error("Source plan not found");const{data:l,error:i}=await G.from("touchpoint_plans").insert({name:n,description:a.description,owner_user_id:s,active:!0,is_template:!1}).select().single();if(i)throw i;if(a.items&&a.items.length>0){const d=a.items.map(p=>({plan_id:l.id,month_number:p.month_number,action_type_id:p.action_type_id,default_script_id:p.default_script_id,notes:p.notes})),{error:u}=await G.from("touchpoint_plan_items").insert(d);if(u)throw u}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),cn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{cn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},D8t=()=>{const t=es();return Et({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"]}),cn({title:"Plan updated successfully"})}})},R8t=()=>{const t=es();return Et({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"]}),cn({title:"Plan deleted successfully"})}})},O8t=()=>{const t=es();return Et({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"]}),cn({title:"Plan schedule updated"})}})},F8t=()=>{const t=es();return Et({mutationFn:async({actionTypeId:s,title:r,scriptBody:n,emailSubject:a,tone:o})=>{const{data:{user:l}}=await G.auth.getUser(),{data:i,error:d}=await G.from("action_scripts").insert({action_type_id:s,title:r,script_body:n,email_subject:a||null,tone:o||null,active:!0,user_id:l==null?void 0:l.id}).select().single();if(d)throw d;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["action-scripts"]}),cn({title:"Script created successfully"})},onError:s=>{cn({title:"Error creating script",description:s.message,variant:"destructive"})}})},z8t=()=>{const t=_a();return ft({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})},B8t=()=>{const t=es(),s=_a();return Et({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"]}),cn({title:"Plan enrollment updated"})}})},ZR=(t=7)=>{const s=_a();return ft({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})},DXe=()=>{const t=_a();return ft({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})},$8t=(t=90)=>{const{data:s}=Uh(),{data:r}=DXe();if(!s||!r)return{contacts:[],count:0};const n=new Date;n.setDate(n.getDate()-t);const a=s.filter(o=>{const l=r[o.id];return l?new Date(l){const t=es(),s=_a();return Et({mutationFn:async({contactId:r,actionTypeId:n,scriptUsedId:a,notes:o,completedAt:l})=>{const{data:i,error:d}=await G.from("contact_touch_logs").insert({owner_user_id:s,contact_id:r,action_type_id:n,script_used_id:a,notes:o,completed_at:l||new Date().toISOString()}).select().single();if(d)throw d;return i},onSuccess:async(r,n)=>{var a,o;t.invalidateQueries({queryKey:["contact-touch-logs"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),t.invalidateQueries({queryKey:["today-actions"]}),cn({title:"Action completed!"});try{const[l,i]=await Promise.all([G.from("innercircle_contacts").select("email").eq("id",n.contactId).single(),G.from("action_types").select("name").eq("id",n.actionTypeId).single()]),d=(a=l.data)==null?void 0:a.email,u=((o=i.data)==null?void 0:o.name)||"Touch";d&&G.functions.invoke("boldtrail-sync",{body:{action:"push_touch",contact_email:d,touch_type:u,touch_notes:n.notes||null,touch_date:n.completedAt||r.completed_at}}).catch(()=>{})}catch{}}})},RXe="agentos_weekly_touch_goal",kLe=20,ble=()=>{if(typeof window>"u")return kLe;const t=localStorage.getItem(RXe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return kLe},OXe=t=>{localStorage.setItem(RXe,t.toString())},xke=()=>{const{data:t}=ZR(7),s=new Date;s.setHours(0,0,0,0);const r=new Date(s);r.setDate(s.getDate()-s.getDay());const n=(t==null?void 0:t.filter(l=>new Date(l.completed_at)>=r).length)||0;let a=0;if(t&&t.length>0){const l=new Set(t.map(d=>new Date(d.completed_at).toDateString()));let i=new Date(s);for(;l.has(i.toDateString());)a++,i.setDate(i.getDate()-1)}const o=ble();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},q8t=()=>{const t=_a();return ft({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})},U8t=()=>{const t=es();return _a(),Et({mutationFn:async()=>{const{data:s}=await G.from("user_plan_enrollments").select("*").eq("active",!0);if(!s||s.length===0)return;const{data:r}=await G.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(!r)return;const{data:n}=await G.from("contact_plan_cycles").select("contact_id, plan_id"),a=new Set((n==null?void 0:n.map(l=>`${l.contact_id}-${l.plan_id}`))||[]),o=[];for(const l of r)for(const i of l.tags||[]){const d=s.find(u=>u.relationship_type_id===i.relationship_type_id);d&&!a.has(`${l.id}-${d.plan_id}`)&&o.push({contact_id:l.id,plan_id:d.plan_id,relationship_type_id:i.relationship_type_id})}if(o.length>0){const{error:l}=await G.from("contact_plan_cycles").insert(o);if(l)throw l}return o.length},onSuccess:s=>{t.invalidateQueries({queryKey:["contact-plan-cycles"]}),s&&s>0&&cn({title:`${s} contact(s) enrolled in plans`})}})},FXe=()=>{const t=_a(),{data:s}=q8t(),{data:r}=ZR(30);return ft({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(N=>N.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),d=new Set((r==null?void 0:r.filter(N=>new Date(N.completed_at)>=i).map(N=>`${N.contact_id}-${N.action_type_id}`))||[]);for(const N of s){if(!((b=N.plan)!=null&&b.items)||N.plan.items.length===0||!N.contact||a.has(N.contact_id))continue;const w=new Date(N.cycle_start_date),C=Math.floor((o.getTime()-w.getTime())/(30.44*24*60*60*1e3))%12+1,A=N.plan.items.find(I=>I.month_number===C);if(A&&A.action_type){const I=`${N.contact_id}-${A.action_type_id}`;if(!d.has(I)){const{data:L}=await G.from("relationship_types").select("name").eq("id",N.relationship_type_id).single();l.push({contact:N.contact,actionType:A.action_type,script:A.default_script||void 0,planName:N.plan.name,relationshipTypeName:(L==null?void 0:L.name)||"",monthNumber:C})}}}const u=5,p=o.getDate(),f=l.sort((N,w)=>N.contact.first_name.localeCompare(w.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 V8t(){const t=br(),{data:s,isLoading:r}=FXe(),{data:n}=Uh(),a=xke(),[o,l]=k.useState(ble()),[i,d]=k.useState(""),[u,p]=k.useState(!1);k.useEffect(()=>{l(ble())},[]);const f=()=>{const O=parseInt(i,10);if(isNaN(O)||O<1){cn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(O),OXe(O),p(!1),cn({title:"Goal updated",description:`Weekly touch goal set to ${O}`})},y=()=>{d(o.toString()),p(!0)},_=Am(new Date),b=dl(_,7),N=O=>{if(!O)return null;const U=O.split(/[-/T]/);if(U.length<3)return null;const q=parseInt(U[1],10)-1,$=parseInt(U[2],10);return isNaN(q)||isNaN($)?null:new Date(_.getFullYear(),q,$)},w=(n==null?void 0:n.map(O=>{const U=N(O.birthday),q=N(O.home_anniversary),$=[];return U&&U>=_&&U<=b&&$.push({contact:O,type:"birthday",date:U,isToday:rl(U,_)}),q&&q>=_&&q<=b&&$.push({contact:O,type:"anniversary",date:q,isToday:rl(q,_)}),$}).flat().sort((O,U)=>O.date.getTime()-U.date.getTime()).slice(0,3))||[],S=(n==null?void 0:n.filter(O=>{const U=N(O.birthday),q=N(O.home_anniversary);return U&&rl(U,_)||q&&rl(q,_)}).length)||0,C=(s==null?void 0:s.length)||0,A=S+C,I=(a==null?void 0:a.actionsThisWeek)||0,L=(a==null?void 0:a.streak)||0;return r?e.jsx(Ie,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:e.jsx(Be,{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(Ie,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[e.jsxs(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:L>0&&e.jsxs(Ye,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(ch,{className:"h-3 w-3"}),L," day streak"]})})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[A>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary font-medium",children:[A," tasks"]})," for today"]}):"No tasks for today",I>0&&e.jsxs("span",{className:"ml-2",children:["• ",e.jsx("span",{className:"text-emerald-600 font-medium",children:I})," touches this week"]})]})]}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(il,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control")},children:[e.jsx(Tn,{className:"h-3.5 w-3.5"}),"Log Touch"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-emerald-200 text-emerald-700 hover:bg-emerald-50 hover:text-emerald-800",onClick:O=>{O.stopPropagation(),t("/mission-control/video/record")},children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"Quick Video"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(La,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-purple-200 text-purple-700 hover:bg-purple-50 hover:text-purple-800",onClick:O=>{O.stopPropagation(),t("/mission-control/pipeline")},children:[e.jsx(Zy,{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(Oh,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),e.jsxs(fs,{open:u,onOpenChange:p,children:[e.jsx(ui,{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(So,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(ms,{className:"sm:max-w-[360px]",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Set Weekly Goal"}),e.jsx(Rr,{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(ge,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),e.jsx(Fe,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:O=>d(O.target.value),placeholder:"20",onKeyDown:O=>{O.key==="Enter"&&f()}})]}),e.jsx(K,{onClick:f,className:"w-full",children:"Save Goal"})]})]})]})]}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium text-primary",children:I}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),e.jsx(pi,{value:Math.min(I/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),I>=o&&e.jsxs("p",{className:"text-xs text-emerald-600 mt-1.5 flex items-center gap-1",children:[e.jsx("span",{children:"🎉"})," Goal achieved! Keep the momentum going."]}),I0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-I," more to hit your weekly goal"]})]}),w.length>0&&e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(lh,{className:"h-4 w-4 text-pink-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Upcoming Milestones"})]}),e.jsx("div",{className:"space-y-2",children:w.map((O,U)=>e.jsxs("div",{className:`flex items-center justify-between p-2 rounded-lg cursor-pointer transition-colors ${O.isToday?"bg-pink-500/10 hover:bg-pink-500/15":"bg-muted/50 hover:bg-muted"}`,onClick:q=>{q.stopPropagation(),t(`/mission-control/contacts/${O.contact.id}`)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[O.type==="birthday"?e.jsx(lh,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(Mn,{className:"h-3.5 w-3.5 text-blue-500"}),e.jsxs("span",{className:"text-sm",children:[O.contact.first_name," ",O.contact.last_name]}),O.isToday&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-pink-500/20 text-pink-600",children:"Today!"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:O.isToday?O.type==="birthday"?"🎂":"🏠":gs(O.date,"EEE, MMM d")}),e.jsx(ja,{className:"h-3 w-3"})]})]},`${O.contact.id}-${O.type}-${U}`))})]}),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(ti,{className:"h-4 w-4"})]})]})]})}function H8t(t){return ft({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 G8t(t,s){return ft({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 W8t(t,s=4){return ft({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 K8t(t){const s=es();return Et({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 Z8t(){const t=es();return Et({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 Y8t(t){const s=es();return Et({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 X8t(){const t=es();return Et({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 Q8t(t){const s=es();return Et({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 J8t={video:Co,pdf:mn,link:Do,event:nn,graphic:Rl},eDt={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 tDt(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 sDt(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 rDt({item:t}){const s=br(),r=J8t[t.content_type]||Do,n=eDt[t.content_type]||"",[a,o]=k.useState(null),l=t.thumbnail_url||(t.content_type==="graphic"&&t.file_url?t.file_url:null)||(t.content_type==="video"?tDt(t.url):null);k.useEffect(()=>{l||!t.url||t.content_type!=="video"||!sDt(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(d=>d.ok?d.json():null).then(d=>{d!=null&&d.thumbnail_url&&o(d.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,l]);const i=l||a;return e.jsxs(Ie,{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(Be,{className:"p-3",children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsxs(Ye,{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:gs(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function nDt(){const{brokerageId:t}=$s(),s=br(),{data:r=[],isLoading:n}=W8t(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(ma,{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(ti,{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(rDt,{item:a},a.id))})]})}const zXe=()=>ft({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}}),BXe=t=>{const{user:s,brokerageId:r}=$s();return ft({queryKey:["listings",t,r],queryFn:async()=>{let n=G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0);t!=null&&t.status&&(n=n.eq("status",t.status)),t!=null&&t.propertyType&&(n=n.eq("property_type",t.propertyType)),t!=null&&t.city&&(n=n.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(n=n.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(n=n.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(n=n.eq("open_to_referrals",!0));const{data:a,error:o}=await n;if(o)throw o;let l=a||[];if(r){const{data:i}=await G.from("profiles").select("id").eq("brokerage_id",r);if(i&&i.length>0){const d=i.map(f=>f.id);let u=G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("share_with_brokerage",!0).eq("is_public",!1).in("agent_id",d);t!=null&&t.status&&(u=u.eq("status",t.status)),t!=null&&t.propertyType&&(u=u.eq("property_type",t.propertyType)),t!=null&&t.city&&(u=u.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(u=u.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(u=u.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(u=u.eq("open_to_referrals",!0));const{data:p}=await u;if(p){const f=new Set(l.map(_=>_.id)),y=p.filter(_=>!f.has(_.id));l=[...l,...y]}}}switch(t==null?void 0:t.sortBy){case"updated":l.sort((i,d)=>new Date(d.updated_at).getTime()-new Date(i.updated_at).getTime());break;case"price_asc":l.sort((i,d)=>i.price-d.price);break;case"price_desc":l.sort((i,d)=>d.price-i.price);break;default:l.sort((i,d)=>new Date(d.created_at).getTime()-new Date(i.created_at).getTime())}return l}})},$Xe=()=>{const{user:t}=$s();return ft({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})},qXe=t=>{const{user:s}=$s();return ft({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})},aDt=()=>{const t=es(),{user:s}=$s();return Et({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"]})}})},iDt=()=>{const t=es();return Et({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"]})}})},oDt=()=>{const t=es();return Et({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]})}})},UXe=()=>{const t=es();return Et({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"]})}})},lDt=()=>{const t=es();return Et({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"]})}})},cDt=()=>{const t=es();return Et({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"]})}})},dDt=()=>{const t=es();return Et({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"]})}})},uDt=()=>{const t=es();return Et({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"]})}})},hDt=()=>{const{user:t}=$s();return ft({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})},VXe=()=>{const t=es(),{user:s}=$s();return Et({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"]})}})},HXe=t=>{const{user:s}=$s();return ft({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})},mDt=()=>{const t=es(),{user:s}=$s();return Et({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"]})}})},pDt=t=>{const{user:s}=$s();return ft({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})},fDt=()=>{const{user:t}=$s();return Et({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}})},xDt=()=>{const{user:t}=$s();return ft({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})},gDt=()=>{const t=es(),{user:s}=$s();return Et({mutationFn:async({listingId:r,listingAgentId:n,buyerName:a,buyerType:o,notes:l})=>{if(!s)throw new Error("Not authenticated");const{data:i,error:d}=await G.from("listing_referrals").insert({listing_id:r,sender_agent_id:s.id,listing_agent_id:n,buyer_name:a,buyer_type:o,notes:l}).select().single();if(d)throw d;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["my-referrals"]})}})},yDt=()=>ft({queryKey:["listing-leaderboard"],queryFn:async()=>{const{data:t}=await G.from("listing_shares").select("sharing_agent_id, profiles!listing_shares_agent_id_fkey(name)").order("created_at",{ascending:!1}),s=new Map;t==null||t.forEach(l=>{var u;const i=l.sharing_agent_id;if(!i)return;const d=s.get(i);d?d.count++:s.set(i,{name:((u=l.profiles)==null?void 0:u.name)||"Unknown",count:1})});const r=Array.from(s.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10),{data:n}=await G.from("listings").select("agent_id, agent:profiles!listings_agent_id_fkey(name)").eq("is_approved",!0),a=new Map;n==null||n.forEach(l=>{var d;const i=a.get(l.agent_id);i?i.count++:a.set(l.agent_id,{name:((d=l.agent)==null?void 0:d.name)||"Unknown",count:1})});const o=Array.from(a.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10);return{topSharers:r,topListers:o}}}),vDt=()=>{const{user:t,brokerageId:s}=$s();return ft({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})},GXe=({className:t,variant:s="default"})=>e.jsx(Ye,{variant:"outline",className:Rt("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"}),_Dt={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"},bDt={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function wDt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function jDt(){const t=br(),{data:s,isLoading:r}=zXe(),{data:n,isLoading:a}=BXe({status:void 0,propertyType:void 0,sortBy:"newest"}),o=(n==null?void 0:n.filter(p=>p.is_approved&&p.is_public))||[],l=o.filter(p=>p.is_featured),i=o.filter(p=>!p.is_featured),d=[...l,...i].slice(0,6),u=r||a;return!u&&!s?null:u?e.jsx(Ie,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:e.jsx(Be,{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(GXe,{})]}),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(ti,{className:"h-4 w-4"})]})]}),d.length===0?e.jsx(Ie,{className:"bg-muted/30 border-dashed",children:e.jsx(Be,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Mn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No listings available yet"}),e.jsx(K,{variant:"link",size:"sm",onClick:()=>t("/mission-control/listings/new"),className:"mt-2",children:"Add the first listing"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:d.map(p=>{var 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(Mn,{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(Ye,{className:"gap-1 bg-amber-500 text-white border-0 text-[10px] px-1.5 py-0.5",children:[e.jsx(Gn,{className:"h-2.5 w-2.5 fill-current"}),"Featured"]})}),e.jsx("div",{className:"absolute top-1.5 right-1.5",children:e.jsx(Ye,{className:`text-[10px] px-1.5 py-0.5 ${_Dt[p.status]}`,children:bDt[p.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:wDt(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 WXe(t=10,s){return ft({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 d=i.slice(0,t),u=d.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 d.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 KXe(t){return ft({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 ZXe(t){return ft({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 YXe(t,s){return ft({queryKey:["user-rank",t,s],queryFn:async()=>{if(!t)return null;const{data:r}=await G.from("agent_attendance_stats").select("total_points").eq("user_id",t).single();if(!r)return null;const{data:n}=await G.from("user_roles").select("user_id").eq("role","admin"),a=new Set((n==null?void 0:n.map(d=>d.user_id))||[]),{data:o,error:l}=await G.from("agent_attendance_stats").select("user_id, total_points").gt("total_points",r.total_points);if(l)throw l;let i=(o==null?void 0:o.filter(d=>!a.has(d.user_id)))||[];if(s){const{data:d}=await G.from("profiles").select("id").eq("brokerage_id",s),u=new Set((d==null?void 0:d.map(p=>p.id))||[]);i=i.filter(p=>u.has(p.user_id))}return i.length+1},enabled:!!t})}function NDt(){const{user:t,brokerageId:s,isAdmin:r}=$s();br();const n=!!s,[a,o]=k.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:d}=WXe(5,l()),{data:u}=KXe(t==null?void 0:t.id),{data:p}=YXe(t==null?void 0:t.id,l()),{data:f}=ZXe(t==null?void 0:t.id),y=r||n,_=()=>r?"Agent Leaderboard":n?a==="global"?"All LevelUp":"My Brokerage":"My Points";if(d)return e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Hi,{className:"h-4 w-4 text-yellow-500"}),_()]})}),e.jsx(Be,{children:e.jsx("div",{className:"space-y-2",children:[...Array(y?5:3)].map((N,w)=>e.jsx(Ss,{className:"h-10 w-full"},w))})})]});const b=N=>N===0?e.jsx(Hi,{className:"h-4 w-4 text-yellow-500 mx-auto"}):N===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):N===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:N+1});if(y){const N=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"pb-2",children:[e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Hi,{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(Be,{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:[N.map((w,S)=>{var C,A,I;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${w.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":S===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:b(S)}),e.jsx(vn,{className:"h-6 w-6",children:e.jsx(_n,{className:"text-xs",children:((A=(C=w.profile)==null?void 0:C.name)==null?void 0:A.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((I=w.profile)==null?void 0:I.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:w.total_points})]},w.user_id)}),N.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),e.jsxs(da,{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(Vi,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(ja,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Hi,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx(Be,{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(ch,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Current Streak"})]}),e.jsxs("span",{className:"font-bold text-orange-500",children:[u.current_streak," 🔥"]})]}),f&&f.length>0&&e.jsxs("div",{className:"pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[e.jsx(rc,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Badges"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[f.slice(0,4).map(N=>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:N.badge_name},N.id)),f.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",f.length-4," more"]})]})]}),e.jsxs(da,{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(Vi,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(ja,{className:"h-4 w-4"})]})]}):e.jsxs("div",{className:"text-center text-muted-foreground py-4 text-sm",children:[e.jsx(Gn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{children:"Attend events to earn points!"}),e.jsxs(da,{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(Vi,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(ja,{className:"h-4 w-4"})]})]})})]})}const eE=()=>ft({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}}),gke=()=>{const t=es(),{user:s}=$s();return Et({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)}})},kDt=()=>{const t=es();return Et({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")}})},SDt=()=>{const t=es();return Et({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")}})},yke=(t,s)=>{const{user:r,isAdmin:n}=$s(),a=n&&s?s:r==null?void 0:r.id;return ft({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})},vke=t=>{const{user:s,isAdmin:r}=$s(),n=r&&t?t:s==null?void 0:s.id;return ft({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})},ihe=()=>{const t=es(),{user:s}=$s();return Et({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)}})},CDt=()=>{const t=es();return Et({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)}})},MDt=()=>{const t=es();return Et({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)}})},XXe=(t,s)=>{const{user:r,isAdmin:n}=$s(),a=n&&s?s:r==null?void 0:r.id;return ft({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})},TDt=()=>{const t=es(),{user:s}=$s();return Et({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)}})},ohe=()=>{const{user:t}=$s();return ft({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)})},ADt=()=>{const t=es(),{user:s}=$s();return Et({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)}})},QXe=(t,s)=>{const{data:r,isLoading:n}=yke(t,s),{data:a,isLoading:o}=vke(s),{data:l}=ohe(),i=(l==null?void 0:l.show_commission)??!0,d=u=>{if(!u||u.length===0)return{totalTransactions:0,buyerCount:0,sellerCount:0,totalVolume:0,averagePrice:0,totalCommission:0,totalNetToAgent:0,topLeadSource:null,transactionsByMonth:[],leadSourceBreakdown:[]};const p=u.filter(L=>L.transaction_type==="buyer").length,f=u.filter(L=>L.transaction_type==="seller").length,y=u.reduce((L,O)=>L+Number(O.sale_price),0),_=u.reduce((L,O)=>L+(Number(O.commission_amount)||0),0),b=u.reduce((L,O)=>{const U=Number(O.commission_amount)||0;if(!U)return L;let q=U;return O.brokerage_split_pct&&(q-=U*(O.brokerage_split_pct/100)),O.team_split_pct&&(q-=U*(O.team_split_pct/100)),O.franchise_fee_pct&&(q-=U*(O.franchise_fee_pct/100)),O.referral_fee_pct&&(q-=U*(O.referral_fee_pct/100)),O.transaction_fee&&(q-=O.transaction_fee),L+Math.max(0,q)},0),N={};u.forEach(L=>{var U;const O=((U=L.lead_source)==null?void 0:U.name)||"Unknown";N[O]=(N[O]||0)+1});const w=Object.entries(N).map(([L,O])=>({name:L,count:O})).sort((L,O)=>O.count-L.count),S=w[0]||null,C={};u.forEach(L=>{const O=pl(L.close_date).toLocaleString("default",{month:"short"});C[O]=(C[O]||0)+1});const I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(L=>({month:L,count:C[L]||0}));return{totalTransactions:u.length,buyerCount:p,sellerCount:f,totalVolume:y,averagePrice:u.length>0?y/u.length:0,totalCommission:i?_:0,totalNetToAgent:i?b:0,topLeadSource:S,transactionsByMonth:I,leadSourceBreakdown:w}};return{yearStats:d(r),lifetimeStats:d(a),isLoading:n||o,showCommission:i}},EDt=()=>{const{isAdmin:t}=$s();return ft({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})},z_={recency:40,touchpoints:30,transactions:20},SLe={warm:70,cooling:40};function PDt(t){return t===null?0:t<=14?z_.recency:t<=30?z_.recency*.85:t<=60?z_.recency*.65:t<=90?z_.recency*.4:t<=180?z_.recency*.2:z_.recency*.05}function IDt(t){const s=Math.min(t/12,1);return Math.round(z_.touchpoints*s)}function LDt(t){return t?z_.transactions:0}function DDt(){return 0}function RDt(t){return t>=SLe.warm?"warm":t>=SLe.cooling?"cooling":"at-risk"}function lhe(){const{data:t,isLoading:s}=Uh(),{data:r}=DXe(),{data:n}=ZR(365),{data:a}=vke(),o=k.useMemo(()=>{if(!t)return[];const i=new Date,d=v4(i,12),u={};n==null||n.forEach(f=>{new Date(f.completed_at)>=d&&(u[f.contact_id]=(u[f.contact_id]||0)+1)});const p=new Set((a==null?void 0:a.filter(f=>f.contact_id).map(f=>f.contact_id))||[]);return t.map(f=>{const y=(r==null?void 0:r[f.id])||null,_=y?Vg(i,new Date(y)):null,b=u[f.id]||0,N=p.has(f.id),w=PDt(_),S=IDt(b),C=LDt(N),A=DDt(),I=Math.round(w+S+C+A),L={score:I,status:RDt(I),breakdown:{recency:Math.round(w),touchpoints:Math.round(S),transactions:Math.round(C),referrals:Math.round(A)},lastTouchDate:y,daysSinceTouch:_,touchCountLast12Months:b,hasTransaction:N};return{...f,relationshipScore:L}})},[t,r,n,a]),l=k.useMemo(()=>{const i=o.filter(y=>y.relationshipScore.status==="warm").length,d=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:d,atRisk:u,total:p,averageScore:f}},[o]);return{contactsWithScores:o,stats:l,isLoading:s}}function JXe(){const t=br(),{stats:s,contactsWithScores:r,isLoading:n}=lhe();if(n)return e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ss,{className:"h-5 w-40"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsx(Ss,{className:"h-20 w-full"}),e.jsx(Ss,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(Be,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),e.jsx(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>t("/mission-control/contacts?new=true"),children:"Add Your First Contact"})]})]});const a=Math.round(s.warm/s.total*100),o=Math.round(s.cooling/s.total*100),l=Math.round(s.atRisk/s.total*100),i=r.filter(d=>d.relationshipScore.status==="at-risk").sort((d,u)=>d.relationshipScore.score-u.relationshipScore.score).slice(0,3);return e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(Yo,{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(Be,{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(pi,{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(pi,{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(pi,{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(jS,{className:"h-4 w-4 text-red-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Needs Attention"})]}),e.jsx("div",{className:"space-y-2",children:i.map(d=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-red-500/5 hover:bg-red-500/10 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${d.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),e.jsxs("span",{className:"text-sm",children:[d.first_name," ",d.last_name]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:d.relationshipScore.daysSinceTouch===null?"Never":`${d.relationshipScore.daysSinceTouch}d`}),e.jsx(ja,{className:"h-3 w-3"})]})]},d.id))})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/mission-control/contacts?filter=at-risk"),children:["View All At-Risk Contacts",e.jsx(ja,{className:"h-4 w-4 ml-1"})]})]})]})}const ODt=()=>{var ae;const{user:t,isAdmin:s}=$s(),r=br(),[n,a]=k.useState([]),[o,l]=k.useState([]),[i,d]=k.useState([]),[u,p]=k.useState([]),[f,y]=k.useState([]),[_,b]=k.useState([]),[N,w]=k.useState(new Set),[S,C]=k.useState([]),[A,I]=k.useState([]),[L,O]=k.useState([]),[U,q]=k.useState(null),[$,V]=k.useState(!0);k.useEffect(()=>{ee()},[t]);const ee=async()=>{var ie,le,fe,xe,he;try{const[we,Ne,Ve,Te,Ae,ze,Ee,ve,Re,Ue,ye]=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()]);(ie=ye.data)!=null&&ie.name&&q(ye.data.name);const ct=((le=we.data)==null?void 0:le.map(et=>et.tag))||[],pe=new Set(((fe=Ve.data)==null?void 0:fe.map(et=>et.app_id))||[]);w(pe);const tt=(((xe=Ne.data)==null?void 0:xe.filter(et=>!et.required_tags||et.required_tags.length===0?!0:et.required_tags.some(Ct=>ct.includes(Ct))))||[]).sort((et,Ct)=>et.name==="LevelUp Members Portal"?-1:Ct.name==="LevelUp Members Portal"?1:0);a(tt.slice(0,6));const st=((he=Te.data)==null?void 0:he.filter(et=>ZM(et.event_date)!=="ended"))||[];l(st.slice(0,4)),C(Ae.data||[]),d(ze.data||[]),p(Ee.data||[]),y(ve.data||[]),b(Re.data||[]);const Ce=Ue.data||[];I(Ce.filter(et=>et.placement==="top")),O(Ce.filter(et=>et.placement==="between"))}catch(we){console.error("Error loading dashboard:",we),me.error("Failed to load dashboard data")}finally{V(!1)}},Z=async ie=>{var fe;const le=window.open("about:blank","_blank");try{await G.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:ie.app_id,app_name:ie.name,user_agent:navigator.userAgent});const{data:xe,error:he}=await G.functions.invoke("sso-launch",{body:{app_id:ie.app_id}});if(he)throw he;xe!=null&&xe.redirect_url?le&&!le.closed?(le.location.href=xe.redirect_url,(fe=le.focus)==null||fe.call(le)):window.location.assign(xe.redirect_url):(le==null||le.close(),me.error("Launch link unavailable"))}catch(xe){le==null||le.close(),console.error("Error launching app:",xe),me.error("Failed to launch app")}},J=ie=>S==null?void 0:S.some(le=>le.event_id===ie),Y=ie=>{const le=S==null?void 0:S.find(fe=>fe.event_id===ie);return le==null?void 0:le.zoom_join_url};if($)return e.jsx(Ls,{title:"Dashboard",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading your dashboard..."})]})})});const ce=ie=>L.filter(le=>le.section_after===ie);return e.jsxs(Ls,{title:"Dashboard",children:[e.jsx(f8t,{events:o,registrations:S,onNavigateToEvents:()=>r("/events")}),A.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(a6,{banners:A})}),e.jsx(T8t,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",(U||((ae=t==null?void 0:t.user_metadata)==null?void 0:ae.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(V8t,{}),e.jsx(JXe,{}),e.jsx(NDt,{})]}),e.jsx(nDt,{}),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(ti,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Ie,{className:"bg-muted/30 border-dashed",children:e.jsx(Be,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(nn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"})]})})}):e.jsx("div",{className:"bg-card rounded-xl border border-border overflow-hidden divide-y divide-border max-w-full",children:o.map(ie=>{const le=J(ie.id),fe=Y(ie.id)||ie.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 ${wLe(ie.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[wLe(ie.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(e1,{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(ie.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(ie.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:ie.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(ie.event_date))," at ",uD(new Date(ie.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:le?e.jsxs(K,{size:"sm",variant:"default",className:"gap-1",onClick:xe=>{xe.stopPropagation(),window.open(fe,"_blank")},children:[e.jsx(Kr,{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(ja,{className:"h-4 w-4"})]})})]},ie.id)})})]}),ce("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(a6,{banners:ce("events")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Academy Videos"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/academy"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ti,{className:"h-4 w-4"})]})]}),f.length===0?e.jsx(Ie,{className:"bg-muted/30 border-dashed",children:e.jsx(Be,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(tp,{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(ie=>e.jsxs("div",{onClick:()=>r(`/academy/${ie.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:[ie.thumbnail_url?e.jsx("img",{src:ie.thumbnail_url,alt:ie.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(tp,{className:"h-8 w-8 text-muted-foreground/50"})}),ie.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:ie.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:ie.title})})]},ie.id))})]}),ce("academy").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(a6,{banners:ce("academy")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Resource Kits"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/toolbox"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ti,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(Ie,{className:"bg-muted/30 border-dashed",children:e.jsx(Be,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Sm,{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(ie=>e.jsxs("div",{onClick:()=>r(`/toolbox/${ie.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:ie.featured_image_url?e.jsx("img",{src:ie.featured_image_url,alt:ie.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Sm,{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:ie.name})})]},ie.id))})]}),ce("toolbox").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(a6,{banners:ce("toolbox")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"New Templates"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/templates"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ti,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Ie,{className:"bg-muted/30 border-dashed",children:e.jsx(Be,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Tb,{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(ie=>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:ie.preview_image_url?e.jsx("img",{src:ie.preview_image_url,alt:ie.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(Tb,{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:ie.name})})]},ie.id))})]}),ce("templates").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(a6,{banners:ce("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(jDt,{})}),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(ti,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Ie,{className:"bg-muted/30 border-dashed",children:e.jsx(Be,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(_x,{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(ie=>{const le=N.has(ie.id);return e.jsxs("div",{onClick:()=>Z(ie),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:ie.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:ie.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ie.description})]}),le&&e.jsx(_x,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},ie.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(ti,{className:"h-4 w-4"})]})]}),_.length===0?e.jsx(Ie,{className:"bg-muted/30 border-dashed",children:e.jsx(Be,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(qr,{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(ie=>e.jsxs("div",{onClick:()=>window.open(ie.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:ie.preview_image_url?e.jsx("img",{src:ie.preview_image_url,alt:ie.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(qr,{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:ie.name}),ie.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:ie.description})]})]},ie.id))})]})]})};var FDt=Symbol("radix.slottable");function zDt(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=FDt,s}var eQe="AlertDialog",[BDt]=bd(eQe,[NGe]),C1=NGe(),tQe=t=>{const{__scopeAlertDialog:s,...r}=t,n=C1(s);return e.jsx(kue,{...n,...r,modal:!0})};tQe.displayName=eQe;var $Dt="AlertDialogTrigger",sQe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(Yje,{...a,...n,ref:s})});sQe.displayName=$Dt;var qDt="AlertDialogPortal",rQe=t=>{const{__scopeAlertDialog:s,...r}=t,n=C1(s);return e.jsx(Sue,{...n,...r})};rQe.displayName=qDt;var UDt="AlertDialogOverlay",nQe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(UA,{...a,...n,ref:s})});nQe.displayName=UDt;var YM="AlertDialogContent",[VDt,HDt]=BDt(YM),GDt=zDt("AlertDialogContent"),aQe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=C1(r),l=k.useRef(null),i=Ma(s,l),d=k.useRef(null);return e.jsx(jkt,{contentName:YM,titleName:iQe,docsSlug:"alert-dialog",children:e.jsx(VDt,{scope:r,cancelRef:d,children:e.jsxs(VA,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Tr(a.onOpenAutoFocus,u=>{var p;u.preventDefault(),(p=d.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[e.jsx(GDt,{children:n}),e.jsx(KDt,{contentRef:l})]})})})});aQe.displayName=YM;var iQe="AlertDialogTitle",oQe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(OR,{...a,...n,ref:s})});oQe.displayName=iQe;var lQe="AlertDialogDescription",cQe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(FR,{...a,...n,ref:s})});cQe.displayName=lQe;var WDt="AlertDialogAction",dQe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(zR,{...a,...n,ref:s})});dQe.displayName=WDt;var uQe="AlertDialogCancel",hQe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=HDt(uQe,r),o=C1(r),l=Ma(s,a);return e.jsx(zR,{...o,...n,ref:l})});hQe.displayName=uQe;var KDt=({contentRef:t})=>{const s=`\`${YM}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${YM}\` by passing a \`${lQe}\` 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 \`${YM}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return k.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},ZDt=tQe,YDt=sQe,XDt=rQe,mQe=nQe,pQe=aQe,fQe=dQe,xQe=hQe,gQe=oQe,yQe=cQe;const Ll=ZDt,ym=YDt,QDt=XDt,vQe=k.forwardRef(({className:t,...s},r)=>e.jsx(mQe,{className:Rt("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}));vQe.displayName=mQe.displayName;const fl=k.forwardRef(({className:t,...s},r)=>e.jsxs(QDt,{children:[e.jsx(vQe,{}),e.jsx(pQe,{ref:r,className:Rt("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})]}));fl.displayName=pQe.displayName;const xl=({className:t,...s})=>e.jsx("div",{className:Rt("flex flex-col space-y-2 text-center sm:text-left",t),...s});xl.displayName="AlertDialogHeader";const gl=({className:t,...s})=>e.jsx("div",{className:Rt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});gl.displayName="AlertDialogFooter";const yl=k.forwardRef(({className:t,...s},r)=>e.jsx(gQe,{ref:r,className:Rt("text-lg font-semibold",t),...s}));yl.displayName=gQe.displayName;const vl=k.forwardRef(({className:t,...s},r)=>e.jsx(yQe,{ref:r,className:Rt("text-sm text-muted-foreground",t),...s}));vl.displayName=yQe.displayName;const nl=k.forwardRef(({className:t,...s},r)=>e.jsx(fQe,{ref:r,className:Rt(tD(),t),...s}));nl.displayName=fQe.displayName;const _l=k.forwardRef(({className:t,...s},r)=>e.jsx(xQe,{ref:r,className:Rt(tD({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));_l.displayName=xQe.displayName;const JDt=[{key:"contacts",label:"Contacts",icon:Tn,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:oS,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:Sm,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:hn,description:"View and upload videos"},{key:"listings",label:"Listings",icon:Mn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:Mb,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:La,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:jx,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:oh,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:Rg,description:"Create and manage smart presentations"}];function eRt(){var U;const{user:t}=$s(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState(null),[f,y]=k.useState({email:"",name:"",password:""}),[_,b]=k.useState("create"),[N,w]=k.useState(!1),[S,C]=k.useState(null);k.useEffect(()=>{t&&A()},[t]);const A=async()=>{if(t){a(!0);try{const{data:q,error:$}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions, created_at").eq("agent_id",t.id);if($)throw $;if(q&&q.length>0){const V=q.map(J=>J.assistant_id),{data:ee}=await G.from("profiles").select("id, name, email").in("id",V),Z=q.map(J=>{const Y=ee==null?void 0:ee.find(ce=>ce.id===J.assistant_id);return{...J,permissions:J.permissions,assistant_profile:Y?{name:Y.name||"",email:Y.email||""}:void 0}});r(Z)}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}w(!0);try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const{data:$,error:V}=await G.from("profiles").select("id, name, email").eq("email",f.email.trim().toLowerCase()).single();if(V||!$){me.error("No account found with that email. Try creating a new assistant instead.");return}const{data:ee}=await G.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",$.id);if(ee&&ee.length>0){me.error("This assistant is already assigned to you");return}const Z=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:$.id,role:"assistant",action:"add",agentId:t.id})}),J=await Z.json();if(!Z.ok)throw new Error(J.error||"Failed to assign assistant role");const{error:Y}=await G.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:$.id,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Y)throw Y;me.success(`${$.name||$.email} linked as your assistant`),l(!1),y({email:"",name:"",password:""}),A()}catch(q){console.error("Error linking assistant:",q),me.error(q.message||"Failed to link assistant")}finally{w(!1)}return}if(!f.email.trim()||!f.name.trim()||!f.password.trim()){me.error("Please fill in all fields");return}if(f.password.length<6){me.error("Password must be at least 6 characters");return}w(!0);try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const $=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 $.json();if(!$.ok)throw new Error(V.error||"Failed to create assistant account");const ee=V.userId||V.id;if(!ee)throw new Error("No user ID returned");const Z=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:ee,role:"assistant",action:"add",agentId:t.id})}),J=await Z.json();if(!Z.ok)throw new Error(J.error||"Failed to assign assistant role");const{error:Y}=await G.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:ee,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Y)throw Y;me.success(`Assistant account created for ${f.name.trim()}`),l(!1),y({email:"",name:"",password:""}),A()}catch(q){console.error("Error adding assistant:",q),me.error(q.message||"Failed to add assistant")}finally{w(!1)}}},L=async()=>{if(!(!u||!t))try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const{error:$}=await G.from("agent_assistant_assignments").delete().eq("id",u.id);if($)throw $;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"),d(!1),p(null),A()}catch(q){console.error("Error removing assistant:",q),me.error(q.message||"Failed to remove assistant")}},O=async(q,$,V)=>{C(q);try{const ee=s.find(Y=>Y.id===q);if(!ee)return;const Z={...ee.permissions,[$]:V},{error:J}=await G.from("agent_assistant_assignments").update({permissions:Z}).eq("id",q);if(J)throw J;r(Y=>Y.map(ce=>ce.id===q?{...ce,permissions:Z}:ce))}catch(ee){console.error("Error updating permissions:",ee),me.error("Failed to update permissions")}finally{C(null)}};return n?e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(Be,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ps,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(mr,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(K,{size:"sm",onClick:()=>{b("create"),l(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),e.jsx(Be,{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 $,V,ee,Z;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(vn,{className:"h-10 w-10",children:e.jsx(_n,{children:((V=($=q.assistant_profile)==null?void 0:$.name)==null?void 0:V.split(" ").map(J=>J[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((ee=q.assistant_profile)==null?void 0:ee.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((Z=q.assistant_profile)==null?void 0:Z.email)||""})]}),e.jsxs(Ye,{variant:"secondary",className:"ml-2",children:[e.jsx(Ru,{className:"h-3 w-3 mr-1"}),"Assistant"]})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{p(q),d(!0)},children:e.jsx(yr,{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:JDt.map(J=>{const Y=J.icon;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:J.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:J.description})]})]}),e.jsx(Lr,{checked:q.permissions[J.key]||!1,onCheckedChange:ce=>O(q.id,J.key,ce),disabled:S===q.id})]},J.key)})})]})]},q.id)})})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Add Assistant"}),e.jsx(Rr,{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(Bs,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(K,{variant:_==="link"?"default":"outline",size:"sm",onClick:()=>b("link"),children:[e.jsx(go,{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(ge,{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(ge,{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(ge,{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(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:I,disabled:N,children:[N&&e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),_==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(Ll,{open:i,onOpenChange:d,children:e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Remove Assistant?"}),e.jsxs(vl,{children:["This will remove ",(U=u==null?void 0:u.assistant_profile)==null?void 0:U.name,"'s access to your Agent OS. Their account will remain active but they won't be able to manage your data."]})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:L,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function Qu(t){this.content=t}Qu.prototype={constructor:Qu,find:function(t){for(var s=0;s>1}};Qu.from=function(t){if(t instanceof Qu)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new Qu(s)};function _Qe(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=_Qe(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function bQe(t,s,r,n){for(let a=t.childCount,o=s.childCount;;){if(a==0||o==0)return a==o?null:{a:r,b:n};let l=t.child(--a),i=s.child(--o),d=l.nodeSize;if(l==i){r-=d,n-=d;continue}if(!l.sameMarkup(i))return{a:r,b:n};if(l.isText&&l.text!=i.text){let u=0,p=Math.min(l.text.length,i.text.length);for(;us&&n(d,a+i,o||null,l)!==!1&&d.content.size){let p=i+1;d.nodesBetween(Math.max(0,s-p),Math.min(d.content.size,r-p),n,a+p)}i=u}}descendants(s){this.nodesBetween(0,this.size,s)}textBetween(s,r,n,a){let o="",l=!0;return this.nodesBetween(s,r,(i,d)=>{let u=i.isText?i.text.slice(Math.max(s,d)-d,r-d):i.isLeaf?a?typeof a=="function"?a(i):a:i.type.spec.leafText?i.type.spec.leafText(i):"":"";i.isBlock&&(i.isLeaf&&u||i.isTextblock)&&n&&(l?l=!1:o+=n),o+=u},0),o}append(s){if(!s.size)return this;if(!this.size)return s;let r=this.lastChild,n=s.firstChild,a=this.content.slice(),o=0;for(r.isText&&r.sameMarkup(n)&&(a[a.length-1]=r.withText(r.text+n.text),o=1);os)for(let o=0,l=0;ls&&((lr)&&(i.isText?i=i.cut(Math.max(0,s-l),Math.min(i.text.length,r-l)):i=i.cut(Math.max(0,s-l-1),Math.min(i.content.size,r-l-1))),n.push(i),a+=i.nodeSize),l=d}return new Er(n,a)}cutByIndex(s,r){return s==r?Er.empty:s==0&&r==this.content.length?this:new Er(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 Er(a,o)}addToStart(s){return new Er([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Er(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?Rz(r+1,o):Rz(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 Er.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Er(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Er.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}};hl.none=[];class jle extends Error{}class yn{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=jQe(this.content,s+this.openStart,r);return n&&new yn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new yn(wQe(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 yn.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 yn(Er.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 yn(s,n,a)}}yn.empty=new yn(Er.empty,0,0);function wQe(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(wQe(o.content,s-a-1,r-a-1)))}function jQe(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=jQe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function tRt(t,s,r){if(r.openStart>t.depth)throw new jle("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new jle("Inconsistent open depths");return NQe(t,s,r,0)}function NQe(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 i8(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&&(MS(t.nodeAfter,n),o++));for(let i=o;ia&&m_e(t,s,a+1),l=n.depth>a&&m_e(r,n,a+1),i=[];return i8(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(kQe(o,l),MS(TS(o,SQe(t,s,r,n,a+1)),i)):(o&&MS(TS(o,Nle(t,s,a+1)),i),i8(s,r,a,i),l&&MS(TS(l,Nle(r,n,a+1)),i)),i8(n,null,a,i),new Er(i)}function Nle(t,s,r){let n=[];if(i8(null,t,r,n),t.depth>r){let a=m_e(t,s,r+1);MS(TS(a,Nle(t,s,r+1)),n)}return i8(s,null,r,n),new Er(n)}function sRt(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(Er.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class hD{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 kle(this,s,n);return null}sameParent(s){return this.pos-this.parentOffset==s.pos-s.parentOffset}max(s){return s.pos>this.pos?s:this}min(s){return s.pos=0&&r<=s.content.size))throw new RangeError("Position "+r+" out of range");let n=[],a=0,o=r;for(let l=s;;){let{index:i,offset:d}=l.content.findIndex(o),u=o-d;if(n.push(l,i,a+d),!u||(l=l.child(i),l.isText))break;o=u-1,a+=d+1}return new hD(r,n,o)}static resolveCached(s,r){let n=CLe.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()+")"),CQe(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=Er.empty,a=0,o=n.childCount){let l=this.contentMatchAt(s).matchFragment(n,a,o),i=l&&l.matchFragment(this.content,r);if(!i||!i.validEnd)return!1;for(let d=a;dr.type.name)}`);this.content.forEach(r=>r.check())}toJSON(){let s={type:this.type.name};for(let r in this.attrs){s.attrs=this.attrs;break}return this.content.size&&(s.content=this.content.toJSON()),this.marks.length&&(s.marks=this.marks.map(r=>r.toJSON())),s}static fromJSON(s,r){if(!r)throw new RangeError("Invalid input for Node.fromJSON");let n;if(r.marks){if(!Array.isArray(r.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=r.marks.map(s.markFromJSON)}if(r.type=="text"){if(typeof r.text!="string")throw new RangeError("Invalid text node in JSON");return s.text(r.text,n)}let a=Er.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};qb.prototype.text=void 0;class Sle extends qb{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):CQe(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 Sle(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new Sle(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 CQe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class eC{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new iRt(s,r);if(n.next==null)return eC.empty;let a=MQe(n);n.next&&n.err("Unexpected trailing text");let o=mRt(hRt(a));return pRt(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(` `)}}eC.empty=new eC(!0);class iRt{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 MQe(t){let s=[];do s.push(oRt(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function oRt(t){let s=[];do s.push(lRt(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function lRt(t){let s=uRt(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=cRt(t,s);else break;return s}function MLe(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function cRt(t,s){let r=MLe(t),n=r;return t.eat(",")&&(t.next!="}"?n=MLe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function dRt(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 uRt(t){if(t.eat("(")){let s=MQe(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=dRt(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 hRt(t){let s=[[]];return a(o(t,0),r()),s;function r(){return s.push([])-1}function n(l,i,d){let u={term:d,to:i};return s[l].push(u),u}function a(l,i){l.forEach(d=>d.to=i)}function o(l,i){if(l.type=="choice")return l.exprs.reduce((d,u)=>d.concat(o(u,i)),[]);if(l.type=="seq")for(let d=0;;d++){let u=o(l.exprs[d],i);if(d==l.exprs.length-1)return u;a(u,i=r())}else if(l.type=="star"){let d=r();return n(i,d),a(o(l.expr,d),d),[n(d)]}else if(l.type=="plus"){let d=r();return a(o(l.expr,i),d),a(o(l.expr,d),d),[n(d)]}else{if(l.type=="opt")return[n(i)].concat(o(l.expr,i));if(l.type=="range"){let d=i;for(let u=0;u{t[l].forEach(({term:i,to:d})=>{if(!i)return;let u;for(let p=0;p{u||a.push([i,u=[]]),u.indexOf(p)==-1&&u.push(p)})})});let o=s[n.join(",")]=new eC(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:EQe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new qb(this,this.computeAttrs(s),Er.from(r),hl.setFrom(n))}createChecked(s=null,r,n){return r=Er.from(r),this.checkContent(r),new qb(this,this.computeAttrs(s),r,hl.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Er.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(Er.empty,!0);return o?new qb(this,s,r.append(o),hl.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 LQe(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 fRt(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 xRt{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?fRt(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class che{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=IQe(s,a.attrs),this.excluded=null;let o=AQe(this.attrs);this.instance=o?new hl(this,o):null}create(s=null){return!s&&this.instance?this.instance:new hl(this,EQe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new che(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class DQe{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=Qu.from(s.nodes),r.marks=Qu.from(s.marks||{}),this.nodes=ALe.compile(this.spec.nodes,this),this.marks=che.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]=eC.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?ELe(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==""?[]:ELe(this,l.split(" "))}this.nodeFromJSON=a=>qb.fromJSON(this,a),this.markFromJSON=a=>hl.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 ALe){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 Sle(n,n.defaultAttrs,s,hl.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 ELe(t,s){let r=[];for(let n=0;n-1)&&r.push(l=d)}if(!l)throw new SyntaxError("Unknown mark type: '"+s[n]+"'")}return r}function gRt(t){return t.tag!=null}function yRt(t){return t.style!=null}let o8=class f_e{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(gRt(a))this.tags.push(a);else if(yRt(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 ILe(this,r,!1);return n.addAll(s,hl.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new ILe(this,r,!0);return n.addAll(s,hl.none,r.from,r.to),yn.maxOpen(n.finish())}matchTag(s,r,n){for(let a=n?this.tags.indexOf(n)+1:0;as.length&&(i.charCodeAt(s.length)!=61||i.slice(s.length+1)!=r))){if(l.getAttrs){let d=l.getAttrs(r);if(d===!1)continue;l.attrs=d||void 0}return l}}}static schemaRules(s){let r=[];function n(a){let o=a.priority==null?50:a.priority,l=0;for(;l{n(l=LLe(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=LLe(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new f_e(s,f_e.schemaRules(s)))}};const RQe={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},vRt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},OQe={ol:!0,ul:!0},mD=1,x_e=2,l8=4;function PLe(t,s,r){return s!=null?(s?mD:0)|(s==="full"?x_e:0):t&&t.whitespace=="pre"?mD|x_e:r&~l8}class Oz{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=hl.none,this.match=o||(l&l8?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Er.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&mD)){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=Er.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Er.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&&!RQe.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class ILe{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=PLe(null,r.preserveWhitespace,0)|(n?l8:0);a?o=new Oz(a.type,a.attrs,hl.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new Oz(null,null,hl.none,!0,null,l):o=new Oz(s.schema.topNodeType,null,hl.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&x_e?"full":this.localPreserveWS||(a.options&mD)>0,{schema:l}=this.parser;if(o==="full"||a.inlineContext(s)||/[^ \t\r\n\u000c]/.test(n)){if(o)if(o==="full")n=n.replace(/\r\n?/g,` `);else if(l.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(l.linebreakReplacement.create())){let i=n.split(/\r?\n|\r/);for(let d=0;d!d.clearMark(u)):r=r.concat(this.parser.schema.marks[d.mark].create(d.attrs)),d.consuming===!1)i=d;else break}}return r}addElementByRule(s,r,n,a){let o,l;if(r.node)if(l=this.parser.schema.nodes[r.node],l.isLeaf)this.insertNode(l.create(r.attrs),n,s.nodeName=="BR")||this.leafFallback(s,n);else{let d=this.enter(l,r.attrs||null,n,r.preserveWhitespace);d&&(o=!0,n=d)}else{let d=this.parser.schema.marks[r.mark];n=n.concat(d.create(r.attrs))}let i=this.top;if(l&&l.isLeaf)this.findInside(s);else if(a)this.addElement(s,n,a);else if(r.getContent)this.findInside(s),r.getContent(s,this.parser.schema).forEach(d=>this.insertNode(d,n,!1));else{let d=s;typeof r.contentElement=="string"?d=s.querySelector(r.contentElement):typeof r.contentElement=="function"?d=r.contentElement(s):r.contentElement&&(d=r.contentElement),this.findAround(s,d,!0),this.addAll(d,n),this.findAround(s,d,!1)}o&&this.sync(i)&&this.open--}addAll(s,r,n,a){let o=n||0;for(let l=n?s.childNodes[n]:s.firstChild,i=a==null?null:s.childNodes[a];l!=i;l=l.nextSibling,++o)this.findAtPoint(s,o),this.addDOM(l,r);this.findAtPoint(s,o)}findPlace(s,r,n){let a,o;for(let l=this.open,i=0;l>=0;l--){let d=this.nodes[l],u=d.findWrapping(s);if(u&&(!a||a.length>u.length+i)&&(a=u,o=d,!u.length))break;if(d.solid){if(n)break;i+=2}}if(!a)return null;this.sync(o);for(let l=0;l(l.type?l.type.allowsMarkType(u.type):DLe(u.type,s))?(d=u.addToSet(d),!1):!0),this.nodes.push(new Oz(s,r,d,a,null,i)),this.open++,n}closeExtra(s=!1){let r=this.nodes.length-1;if(r>this.open){for(;r>this.open;r--)this.nodes[r-1].content.push(this.nodes[r].finish(s));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(s){for(let r=this.open;r>=0;r--){if(this.nodes[r]==s)return this.open=r,!0;this.localPreserveWS&&(this.nodes[r].options|=mD)}return!1}get currentPos(){this.closeExtra();let s=0;for(let r=this.open;r>=0;r--){let n=this.nodes[r].content;for(let a=n.length-1;a>=0;a--)s+=n[a].nodeSize;r&&s++}return s}findAtPoint(s,r){if(this.find)for(let n=0;n-1)return s.split(/\s*\|\s*/).some(this.matchesContext,this);let r=s.split("/"),n=this.options.context,a=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(a?0:1),l=(i,d)=>{for(;i>=0;i--){let u=r[i];if(u==""){if(i==r.length-1||i==0)continue;for(;d>=o;d--)if(l(i-1,d))return!0;return!1}else{let p=d>0||d==0&&a?this.nodes[d].type:n&&d>=o?n.node(d-o).type:null;if(!p||p.name!=u&&!p.isInGroup(u))return!1;d--}}return!0};return l(r.length-1,this.open)}textblockFromContext(){let s=this.options.context;if(s)for(let r=s.depth;r>=0;r--){let n=s.node(r).contentMatchAt(s.indexAfter(r)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let r in this.parser.schema.nodes){let n=this.parser.schema.nodes[r];if(n.isTextblock&&n.defaultAttrs)return n}}}function _Rt(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&OQe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function bRt(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function LLe(t){let s={};for(let r in t)s[r]=t[r];return s}function DLe(t,s){let r=s.schema.nodes;for(let n in r){let a=r[n];if(!a.allowsMarkType(t))continue;let o=[],l=i=>{o.push(i);for(let d=0;d{if(o.length||l.marks.length){let i=0,d=0;for(;i=0;a--){let o=this.serializeMark(s.marks[a],s.isInline,r);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(s,r,n={}){let a=this.marks[s.type.name];return a&&Jie(Hge(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return Jie(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new MC(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=RLe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return RLe(s.marks)}}function RLe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function Hge(t){return t.document||window.document}const OLe=new WeakMap;function wRt(t){let s=OLe.get(t);return s===void 0&&OLe.set(t,s=jRt(t)),s}function jRt(t){let s=null;function r(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")s||(s=[]),s.push(n);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=a.indexOf(" ");l>0&&(r=a.slice(0,l),a=a.slice(l+1));let i,d=r?t.createElementNS(r,a):t.createElement(a),u=s[1],p=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){p=2;for(let f in u)if(u[f]!=null){let y=f.indexOf(" ");y>0?d.setAttributeNS(f.slice(0,y),f.slice(y+1),u[f]):f=="style"&&d.style?d.style.cssText=u[f]:d.setAttribute(f,u[f])}}for(let f=p;fp)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:_,contentDOM:b}=Jie(t,y,r,n);if(d.appendChild(_),b){if(i)throw new RangeError("Multiple content holes");i=b}}}return{dom:d,contentDOM:i}}const FQe=65535,zQe=Math.pow(2,16);function NRt(t,s){return t+s*zQe}function FLe(t){return t&FQe}function kRt(t){return(t-(t&FQe))/zQe}const BQe=1,$Qe=2,eoe=4,qQe=8;class g_e{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&qQe)>0}get deletedBefore(){return(this.delInfo&(BQe|eoe))>0}get deletedAfter(){return(this.delInfo&($Qe|eoe))>0}get deletedAcross(){return(this.delInfo&eoe)>0}}class ef{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&ef.empty)return ef.empty}recover(s){let r=0,n=FLe(s);if(!this.inverted)for(let a=0;as)break;let u=this.ranges[i+o],p=this.ranges[i+l],f=d+u;if(s<=f){let y=u?s==d?-1:s==f?1:r:r,_=d+a+(y<0?0:p);if(n)return _;let b=s==(r<0?d:f)?null:NRt(i/3,s-d),N=s==d?$Qe:s==f?BQe:eoe;return(r<0?s!=d:s!=f)&&(N|=qQe),new g_e(_,N,b)}a+=p-u}return n?s+a:new g_e(s+a,0,null)}touches(s,r){let n=0,a=FLe(r),o=this.inverted?2:1,l=this.inverted?1:2;for(let i=0;is)break;let u=this.ranges[i+o],p=d+u;if(s<=p&&i==a*3)return!0;n+=this.ranges[i+l]-u}return!1}forEach(s){let r=this.inverted?2:1,n=this.inverted?1:2;for(let a=0,o=0;a=0;r--){let a=s.getMirror(r);this.appendMap(s._maps[r].invert(),a!=null&&a>r?n-a-1:void 0)}}invert(){let s=new pD;return s.appendMappingInverted(this),s}map(s,r=1){if(this.mirror)return this._map(s,r,!0);for(let n=this.from;no&&d!l.isAtom||!i.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),a),r.openStart,r.openEnd);return Fd.fromReplace(s,this.from,this.to,o)}invert(){return new Uy(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 fb(r.pos,n.pos,this.mark)}merge(s){return s instanceof fb&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new fb(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 fb(r.from,r.to,s.markFromJSON(r.mark))}}Vh.jsonID("addMark",fb);class Uy extends Vh{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 yn(_ke(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return Fd.fromReplace(s,this.from,this.to,n)}invert(){return new fb(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 Uy(r.pos,n.pos,this.mark)}merge(s){return s instanceof Uy&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new Uy(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 Uy(r.from,r.to,s.markFromJSON(r.mark))}}Vh.jsonID("removeMark",Uy);class xb extends Vh{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return Fd.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return Fd.fromReplace(s,this.pos,this.pos+1,new yn(Er.from(n),0,r.isLeaf?0:1))}invert(s){let r=s.nodeAt(this.pos);if(r){let n=this.mark.addToSet(r.marks);if(n.length==r.marks.length){for(let a=0;an.pos?null:new Fu(r.pos,n.pos,a,o,this.slice,this.insert,this.structure)}toJSON(){let s={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(s.slice=this.slice.toJSON()),this.structure&&(s.structure=!0),s}static fromJSON(s,r){if(typeof r.from!="number"||typeof r.to!="number"||typeof r.gapFrom!="number"||typeof r.gapTo!="number"||typeof r.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Fu(r.from,r.to,r.gapFrom,r.gapTo,yn.fromJSON(s,r.slice),r.insert,!!r.structure)}}Vh.jsonID("replaceAround",Fu);function y_e(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 SRt(t,s,r,n){let a=[],o=[],l,i;t.doc.nodesBetween(s,r,(d,u,p)=>{if(!d.isInline)return;let f=d.marks;if(!n.isInSet(f)&&p.type.allowsMarkType(n.type)){let y=Math.max(u,s),_=Math.min(u+d.nodeSize,r),b=n.addToSet(f);for(let N=0;Nt.step(d)),o.forEach(d=>t.step(d))}function CRt(t,s,r,n){let a=[],o=0;t.doc.nodesBetween(s,r,(l,i)=>{if(!l.isInline)return;o++;let d=null;if(n instanceof che){let u=l.marks,p;for(;p=n.isInSet(u);)(d||(d=[])).push(p),u=p.removeFromSet(u)}else n?n.isInSet(l.marks)&&(d=[n]):d=l.marks;if(d&&d.length){let u=Math.min(i+l.nodeSize,r);for(let p=0;pt.step(new Uy(l.from,l.to,l.style)))}function bke(t,s,r,n=r.contentMatch,a=!0){let o=t.doc.nodeAt(s),l=[],i=s+1;for(let d=0;d=0;d--)t.step(l[d])}function MRt(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function tE(t){let r=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth,a=0,o=0;;--n){let l=t.$from.node(n),i=t.$from.index(n)+a,d=t.$to.indexAfter(n)-o;if(nr;b--)N||n.index(b)>0?(N=!0,p=Er.from(n.node(b).copy(p)),f++):d--;let y=Er.empty,_=0;for(let b=o,N=!1;b>r;b--)N||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=Er.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new Fu(a,o,a,o,new yn(n,0,0),r.length,!0))}function IRt(t,s,r,n,a){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(s,r,(l,i)=>{let d=typeof a=="function"?a(l):a;if(l.isTextblock&&!l.hasMarkup(n,d)&&LRt(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&&VQe(t,l,i,o),bke(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 Fu(f,y,f+1,y-1,new yn(Er.from(n.create(d,null,l.marks)),0,0),1,!0)),u===!0&&UQe(t,l,i,o),!1}})}function UQe(t,s,r,n){s.forEach((a,o)=>{if(a.isText){let l,i=/\r?\n|\r/g;for(;l=i.exec(a.text);){let d=t.mapping.slice(n).map(r+1+o+l.index);t.replaceWith(d,d+1,s.type.schema.linebreakReplacement.create())}}})}function VQe(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 LRt(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function DRt(t,s,r,n,a){let o=t.doc.nodeAt(s);if(!o)throw new RangeError("No node at given position");r||(r=o.type);let l=r.create(n,null,a||o.marks);if(o.isLeaf)return t.replaceWith(s,s+o.nodeSize,l);if(!r.validContent(o.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new Fu(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new yn(Er.from(l),0,0),1,!0))}function s1(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 N=n&&n[p]||f;if(!f.canReplace(y+1,f.childCount)||!N.type.validContent(_))return!1}let i=a.indexAfter(o),d=n&&n[0];return a.node(o).canReplaceWith(i,i,d?d.type:a.node(o+1).type)}function RRt(t,s,r=1,n){let a=t.doc.resolve(s),o=Er.empty,l=Er.empty;for(let i=a.depth,d=a.depth-r,u=r-1;i>d;i--,u--){o=Er.from(a.node(i).copy(o));let p=n&&n[u];l=Er.from(p?p.type.create(p.attrs,l):a.node(i).copy(l))}t.step(new Dd(s,s,new yn(o.append(l),r,r),!0))}function ww(t,s){let r=t.resolve(s),n=r.index();return HQe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function ORt(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&&HQe(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 FRt(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);VQe(t,p.node(),p.before(),i)}l.inlineContent&&bke(t,s+r-1,l,o.node().contentMatchAt(o.index()),n==null);let d=t.mapping.slice(i),u=d.map(s-r);if(t.step(new Dd(u,d.map(s+r,-1),yn.empty,!0)),n===!0){let p=t.doc.resolve(u);UQe(t,p.node(),p.before(),t.steps.length)}return t}function zRt(t,s,r){let n=t.resolve(s);if(n.parent.canReplaceWith(n.index(),n.index(),r))return s;if(n.parentOffset==0)for(let a=n.depth-1;a>=0;a--){let o=n.index(a);if(n.node(a).canReplaceWith(o,o,r))return n.before(a+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let a=n.depth-1;a>=0;a--){let o=n.indexAfter(a);if(n.node(a).canReplaceWith(o,o,r))return n.after(a+1);if(o=0;l--){let i=l==n.depth?0:n.pos<=(n.start(l+1)+n.end(l+1))/2?-1:1,d=n.index(l)+(i>0?1:0),u=n.node(l),p=!1;if(o==1)p=u.canReplace(d,d,a);else{let f=u.contentMatchAt(d).findWrapping(a.firstChild.type);p=f&&u.canReplaceWith(d,d,f[0])}if(p)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function uhe(t,s,r=s,n=yn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return WQe(a,o,n)?new Dd(s,r,n):new BRt(a,o,n).fit()}function WQe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class BRt{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Er.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=Er.from(s.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let s=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,a=this.close(s<0?this.$to:n.doc.resolve(s));if(!a)return null;let o=this.placed,l=n.depth,i=a.depth;for(;l&&i&&o.childCount==1;)o=o.firstChild.content,l--,i--;let d=new yn(o,l,i);return s>-1?new Fu(n.pos,s,this.$to.pos,this.$to.end(),d,r):d.size||n.pos!=this.$to.pos?new Dd(n.pos,a.pos,d):null}findFittable(){let s=this.unplaced.openStart;for(let r=this.unplaced.content,n=0,a=this.unplaced.openEnd;n1&&(a=0),o.type.spec.isolating&&a<=n){s=n;break}r=o.content}for(let r=1;r<=2;r++)for(let n=r==1?s:this.unplaced.openStart;n>=0;n--){let a,o=null;n?(o=Wge(this.unplaced.content,n-1).firstChild,a=o.content):a=this.unplaced.content;let l=a.firstChild;for(let i=this.depth;i>=0;i--){let{type:d,match:u}=this.frontier[i],p,f=null;if(r==1&&(l?u.matchType(l.type)||(f=u.fillBefore(Er.from(l),!1)):o&&d.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:f};if(r==2&&l&&(p=u.findWrapping(l.type)))return{sliceDepth:n,frontierDepth:i,parent:o,wrap:p};if(o&&u.matchType(o.type))break}}}openMore(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=Wge(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new yn(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=Wge(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new yn(R6(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new yn(R6(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 N=0;N1||d==0||N.content.size)&&(f=w,p.push(KQe(N.mark(y.allowedMarks(N.marks)),u==1?d:0,u==i.childCount?_:-1)))}let b=u==i.childCount;b||(_=-1),this.placed=O6(this.placed,r,Er.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 N=0,w=i;N<_;N++){let S=w.lastChild;this.frontier.push({type:S.type,match:S.contentMatchAt(S.childCount)}),w=S.content}this.unplaced=b?s==0?yn.empty:new yn(R6(l.content,s-1,1),s-1,_<0?l.openEnd:s-1):new yn(R6(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||!Kge(this.$to,this.$to.depth,s.type,s.match,!1)||this.$to.depth==this.depth&&(r=this.findCloseLevel(this.$to))&&r.depth==this.depth)return-1;let{depth:n}=this.$to,a=this.$to.after(n);for(;n>1&&a==this.$to.end(--n);)++a;return a}findCloseLevel(s){e:for(let r=Math.min(this.depth,s.depth);r>=0;r--){let{match:n,type:a}=this.frontier[r],o=r=0;i--){let{match:d,type:u}=this.frontier[i],p=Kge(s,i,u,d,!0);if(!p||p.childCount)continue e}return{depth:r,fit:l,move:o?s.doc.resolve(s.after(r+1)):s}}}}close(s){let r=this.findCloseLevel(s);if(!r)return null;for(;this.depth>r.depth;)this.closeFrontierNode();r.fit.childCount&&(this.placed=O6(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=O6(this.placed,this.depth,Er.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Er.empty,!0);r.childCount&&(this.placed=O6(this.placed,this.frontier.length,r))}}function R6(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(R6(t.firstChild.content,s-1,r)))}function O6(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(O6(t.lastChild.content,s-1,r)))}function Wge(t,s){for(let r=0;r1&&(n=n.replaceChild(0,KQe(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(Er.empty,!0)))),t.copy(n)}function Kge(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&&!$Rt(r,o.content,l)?i:null}function $Rt(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 d=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=qRt(_.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 N=0;N=0&&(t.replace(s,r,n),!(t.steps.length>f));y--){let _=l[y];_<0||(s=a.before(_),r=o.after(_))}}function ZQe(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(Er.empty,!0))}return t}function VRt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=zRt(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new yn(Er.from(n),0,0))}function HRt(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r);if(n.parent.isTextblock&&a.parent.isTextblock&&n.start()!=a.start()&&n.parentOffset==0&&a.parentOffset==0){let l=n.sharedDepth(r),i=!1;for(let d=n.depth;d>l;d--)n.node(d).type.spec.isolating&&(i=!0);for(let d=a.depth;d>l;d--)a.node(d).type.spec.isolating&&(i=!0);if(!i){for(let d=n.depth;d>0&&s==n.start(d);d--)s=n.before(d);for(let d=a.depth;d>0&&r==a.start(d);d--)r=a.before(d);n=t.doc.resolve(s),a=t.doc.resolve(r)}}let o=YQe(n,a);for(let l=0;l0&&(d||n.node(i-1).canReplace(n.index(i-1),a.indexAfter(i-1))))return t.delete(n.before(i),a.after(i))}for(let l=1;l<=n.depth&&l<=a.depth;l++)if(s-n.start(l)==n.depth-l&&r>n.end(l)&&a.end(l)-r!=a.depth-l&&n.start(l-1)==a.start(l-1)&&n.node(l-1).canReplace(n.index(l-1),a.index(l-1)))return t.delete(n.before(l),r);t.delete(s,r)}function YQe(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 XM extends Vh{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 Fd.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 Fd.fromReplace(s,this.pos,this.pos+1,new yn(Er.from(a),0,r.isLeaf?0:1))}getMap(){return ef.empty}invert(s){return new XM(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 XM(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 XM(r.pos,r.attr,r.value)}}Vh.jsonID("attr",XM);class fD extends Vh{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 Fd.ok(n)}getMap(){return ef.empty}invert(s){return new fD(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 fD(r.attr,r.value)}}Vh.jsonID("docAttr",fD);let BT=class extends Error{};BT=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};BT.prototype=Object.create(Error.prototype);BT.prototype.constructor=BT;BT.prototype.name="TransformError";class jke{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new pD}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new BT(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}changedRange(){let s=1e9,r=-1e9;for(let n=0;n{s=Math.min(s,i),r=Math.max(r,d)})}return s==1e9?null:{from:s,to:r}}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=yn.empty){let a=uhe(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new yn(Er.from(n),0,0))}delete(s,r){return this.replace(s,r,yn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return URt(this,s,r,n),this}replaceRangeWith(s,r,n){return VRt(this,s,r,n),this}deleteRange(s,r){return HRt(this,s,r),this}lift(s,r){return TRt(this,s,r),this}join(s,r=1){return FRt(this,s,r),this}wrap(s,r){return PRt(this,s,r),this}setBlockType(s,r=s,n,a=null){return IRt(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return DRt(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new XM(s,r,n)),this}setDocAttribute(s,r){return this.step(new fD(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 hl)r.isInSet(n.marks)&&this.step(new tC(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new tC(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 RRt(this,s,r,n),this}addMark(s,r,n){return SRt(this,s,r,n),this}removeMark(s,r,n){return CRt(this,s,r,n),this}clearIncompatible(s,r,n){return bke(this,s,r,n),this}}const Zge=Object.create(null);class ei{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new XQe(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?F5(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):F5(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 pf(s.node(0))}static atStart(s){return F5(s,s,0,0,1)||new pf(s)}static atEnd(s){return F5(s,s,s.content.size,s.childCount,-1)||new pf(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Zge[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 Zge)throw new RangeError("Duplicate use of selection JSON ID "+s);return Zge[s]=r,r.prototype.jsonID=s,r}getBookmark(){return Oa.between(this.$anchor,this.$head).getBookmark()}}ei.prototype.visible=!0;class XQe{constructor(s,r){this.$from=s,this.$to=r}}let BLe=!1;function $Le(t){!BLe&&!t.parent.inlineContent&&(BLe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Oa extends ei{constructor(s,r=s){$Le(s),$Le(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 ei.near(n);let a=s.resolve(r.map(this.anchor));return new Oa(a.parent.inlineContent?a:n,n)}replace(s,r=yn.empty){if(super.replace(s,r),r==yn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof Oa&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new hhe(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 Oa(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=ei.findFrom(r,n,!0)||ei.findFrom(r,-n,!0);if(o)r=o.$head;else return ei.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(ei.findFrom(s,-n,!0)||ei.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&&Ea.isSelectable(i))return Ea.create(t,r-(a<0?i.nodeSize:0))}else{let d=F5(t,i,r+a,a<0?i.childCount:0,a,o);if(d)return d}r+=i.nodeSize*a}return null}function qLe(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=p)}),t.setSelection(ei.near(t.doc.resolve(l),r))}const ULe=1,Fz=2,VLe=4;class WRt extends jke{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|=Fz,this}ensureMarks(s){return hl.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&Fz)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~Fz,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)||hl.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(ei.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|=VLe,this}get scrolledIntoView(){return(this.updated&VLe)>0}}function HLe(t,s){return!s||!t?t:t.bind(s)}class F6{constructor(s,r,n){this.name=s,this.init=HLe(r.init,n),this.apply=HLe(r.apply,n)}}const KRt=[new F6("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new F6("selection",{init(t,s){return t.selection||ei.atStart(s.doc)},apply(t){return t.selection}}),new F6("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new F6("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class Yge{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=KRt.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 F6(n.key,n.spec.state,n))})}}class aM{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 Yge(s.schema,s.plugins),o=new aM(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=qb.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=ei.fromJSON(o.doc,r.selection);else if(l.name=="storedMarks")r.storedMarks&&(o.storedMarks=r.storedMarks.map(s.schema.markFromJSON));else{if(n)for(let i in n){let d=n[i],u=d.spec.state;if(d.key==l.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(r,i)){o[l.name]=u.fromJSON.call(d,s,r[i],o);return}}o[l.name]=l.init(s,o)}}),o}}function QQe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=QQe(a,s,{})),r[n]=a}return r}class gu{constructor(s){this.spec=s,this.props={},s.props&&QQe(s.props,this,this.props),this.key=s.key?s.key.key:JQe("plugin")}getState(s){return s[this.key]}}const Xge=Object.create(null);function JQe(t){return t in Xge?t+"$"+ ++Xge[t]:(Xge[t]=0,t+"$")}class Hh{constructor(s="key"){this.key=JQe(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const eh=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},$T=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let v_e=null;const jv=function(t,s,r){let n=v_e||(v_e=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},ZRt=function(){v_e=null},sC=function(t,s,r,n){return r&&(GLe(t,s,r,n,-1)||GLe(t,s,r,n,1))},YRt=/^(img|br|input|textarea|hr)$/i;function GLe(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:hx(t))){let l=t.parentNode;if(!l||l.nodeType!=1||YR(t)||YRt.test(t.nodeName)||t.contentEditable=="false")return!1;s=eh(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?hx(t):0}else return!1}}function hx(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function XRt(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=hx(t)}else if(t.parentNode&&!YR(t))s=eh(t),t=t.parentNode;else return null}}function QRt(t,s){for(;;){if(t.nodeType==3&&s2),ax=qT||(m0?/Mac/.test(m0.platform):!1),sJe=m0?/Win/.test(m0.platform):!1,$v=/Android \d/.test(jw),XR=!!WLe&&"webkitFontSmoothing"in WLe.documentElement.style,sOt=XR?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function rOt(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 hv(t,s){return typeof t=="number"?t:t[s]}function nOt(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 KLe(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=$T(l);continue}let i=l,d=i==o.body,u=d?rOt(o):nOt(i),p=0,f=0;if(s.topu.bottom-hv(n,"bottom")&&(f=s.bottom-s.top>u.bottom-u.top?s.top+hv(a,"top")-u.top:s.bottom-u.bottom+hv(a,"bottom")),s.leftu.right-hv(n,"right")&&(p=s.right-u.right+hv(a,"right")),p||f)if(d)o.defaultView.scrollBy(p,f);else{let _=i.scrollLeft,b=i.scrollTop;f&&(i.scrollTop+=f),p&&(i.scrollLeft+=p);let N=i.scrollLeft-_,w=i.scrollTop-b;s={left:s.left-N,top:s.top-w,right:s.right-N,bottom:s.bottom-w}}let y=d?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(y))break;l=y=="absolute"?l.offsetParent:$T(l)}}function aOt(t){let s=t.dom.getBoundingClientRect(),r=Math.max(0,s.top),n,a;for(let o=(s.left+s.right)/2,l=r+1;l=r-20){n=i,a=d.top;break}}return{refDOM:n,refTop:a,stack:rJe(t.dom)}}function rJe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=$T(n));return s}function iOt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;nJe(r,n==0?0:n-s)}function nJe(t,s){for(let r=0;r=i){l=Math.max(b.bottom,l),i=Math.min(b.top,i);let N=b.left>s.left?b.left-s.left:b.right=(b.left+b.right)/2?1:0));continue}}else b.top>s.top&&!d&&b.left<=s.left&&b.right>=s.left&&(d=p,u={left:Math.max(b.left,Math.min(b.right,s.left)),top:b.top});!r&&(s.left>=b.right&&s.top>=b.top||s.left>=b.left&&s.top>=b.bottom)&&(o=f+1)}}return!r&&d&&(r=d,a=u,n=0),r&&r.nodeType==3?lOt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:aJe(r,a)}function lOt(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 kke(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function cOt(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 uOt(t,s,r,n){let a=-1;for(let o=s,l=!1;o!=t.dom;){let i=t.docView.nearestDesc(o,!0),d;if(!i)return null;if(i.dom.nodeType==1&&(i.node.isBlock&&i.parent||!i.contentDOM)&&((d=i.dom.getBoundingClientRect()).width||d.height)&&(i.node.isBlock&&i.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(i.dom.nodeName)&&(!l&&d.left>n.left||d.top>n.top?a=i.posBefore:(!l&&d.right-1?a:t.docView.posFromDOM(s,r,-1)}function iJe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;XR&&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=uOt(t,n,a,s))}i==null&&(i=dOt(t,l,s));let d=t.docView.nearestDesc(l,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}function ZLe(t){return t.top=0&&a==n.nodeValue.length?(d--,p=1):r<0?d--:u++,i6(P_(jv(n,d,u),p),p<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==hx(n))){let d=n.childNodes[a-1];if(d.nodeType==1)return Qge(d.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==hx(n))){let d=n.childNodes[a-1],u=d.nodeType==3?jv(d,hx(d)-(l?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(u)return i6(P_(u,1),!1)}if(o==null&&a=0)}function i6(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 Qge(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 lJe(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 pOt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return lJe(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=oJe(t,a.pos,1);for(let i=o.firstChild;i;i=i.nextSibling){let d;if(i.nodeType==1)d=i.getClientRects();else if(i.nodeType==3)d=jv(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 fOt=/[\u0590-\u08ac]/;function xOt(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?!fOt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:lJe(t,s,()=>{let{focusNode:d,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:N}=t.domSelectionRange(),w=b&&!_.contains(b.nodeType==1?b:b.parentNode)||d==b&&u==N;try{i.collapse(p,f),d&&(d!=p||u!=f)&&i.extend&&i.extend(d,u)}catch{}return y!=null&&(i.caretBidiLevel=y),w}):n.pos==n.start()||n.pos==n.end()}let YLe=null,XLe=null,QLe=!1;function gOt(t,s,r){return YLe==s&&XLe==r?QLe:(YLe=s,XLe=r,QLe=r=="up"||r=="down"?pOt(t,s,r):xOt(t,s,r))}const Cx=0,JLe=1,j4=2,p0=3;class QR{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=Cx,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;reh(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 dJe){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 cJe&&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?eh(o.dom)+1:0}}else{let o,l=!0;for(;o=n=p&&r<=u-d.border&&d.node&&d.contentDOM&&this.contentDOM.contains(d.contentDOM))return d.parseRange(s,r,p);s=l;for(let f=i;f>0;f--){let y=this.children[f-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){a=eh(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=d,d=b}let _=document.createRange();_.setEnd(d.node,d.offset),_.setStart(i.node,i.offset),u.removeAllRanges(),u.addRange(_)}}ignoreMutation(s){return!this.contentDOM&&s.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(s,r){for(let n=0,a=0;a=n:sn){let i=n+o.border,d=l-o.border;if(s>=i&&r<=d){this.dirty=s==n||r==l?j4:JLe,s==i&&r==d&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=p0:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?j4:p0}n=l}this.dirty=j4}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?j4:JLe;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==Cx&&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 yOt extends QR{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 rC extends QR{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=MC.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new rC(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&p0||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=p0&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=Cx){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=N_e(o,0,s,n));for(let i=0;i{if(!d)return l;if(d.parent)return d.parent.posBeforeChild(d)},n,a),p=u&&u.dom,f=u&&u.contentDOM;if(r.isText){if(!p)p=document.createTextNode(r.text);else if(p.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else p||({dom:p,contentDOM:f}=MC.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=mJe(p,n,r),u?d=new vOt(s,r,n,a,p,f||null,y,u,o,l+1):r.isText?new phe(s,r,n,a,p,y,o):new Vb(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=()=>Er.empty)}return s}matchesNode(s,r,n){return this.dirty==Cx&&s.eq(this.node)&&Cle(r,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(s,r){let n=this.node.inlineContent,a=r,o=s.composing?this.localCompositionInfo(s,r):null,l=o&&o.pos>-1?o:null,i=o&&o.pos<0,d=new bOt(this,l&&l.node,s);NOt(this.node,this.innerDeco,(u,p,f)=>{u.spec.marks?d.syncToMarks(u.spec.marks,n,s,p):u.type.side>=0&&!f&&d.syncToMarks(p==this.node.childCount?hl.none:this.node.child(p).marks,n,s,p),d.placeWidget(u,s,a)},(u,p,f,y)=>{d.syncToMarks(u.marks,n,s,y);let _;d.findNodeMatch(u,p,f,y)||i&&s.state.selection.from>a&&s.state.selection.to-1&&d.updateNodeAt(u,p,f,_,s)||d.updateNextNode(u,p,f,s,y,a)||d.addNode(u,p,f,s,a),a+=u.nodeSize}),d.syncToMarks([],n,s,0),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==j4)&&(l&&this.protectLocalComposition(s,l),uJe(this.contentDOM,this.children,s),qT&&kOt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof Oa)||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=SOt(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 yOt(this,o,r,a);s.input.compositionNodes.push(l),this.children=N_e(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==p0||!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=Cx}updateOuterDeco(s){if(Cle(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=hJe(this.dom,this.nodeDOM,j_e(this.outerDeco,this.node,r),j_e(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 e8e(t,s,r,n,a){mJe(n,s,t);let o=new Vb(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class phe extends Vb{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==p0||this.dirty!=Cx&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=Cx||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=Cx,!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 phe(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=p0)}get domAtom(){return!1}isText(s){return this.node.text==s}}class dJe extends QR{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==Cx&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class vOt extends Vb{constructor(s,r,n,a,o,l,i,d,u,p){super(s,r,n,a,o,l,i,u,p),this.spec=d}update(s,r,n,a){if(this.dirty==p0)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 uJe(t,s,r){let n=t.firstChild,a=!1;for(let o=0;o>1,i=Math.min(l,s.length);for(;o-1)d>this.index&&(this.changed=!0,this.destroyBetween(this.index,d)),this.top=this.top.children[this.index];else{let p=rC.create(this.top,s[l],r,n);this.top.children.splice(this.index,0,p),this.top=p,this.changed=!0}this.index=0,l++}}findNodeMatch(s,r,n,a){let o=-1,l;if(a>=this.preMatch.index&&(l=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&l.matchesNode(s,r,n))o=this.top.children.indexOf(l,this.index);else for(let i=this.index,d=Math.min(this.top.children.length,i+5);i0;){let i;for(;;)if(n){let u=r.children[n-1];if(u instanceof rC)r=u,n=u.children.length;else{i=u,n--;break}}else{if(r==s)break e;n=r.parent.children.indexOf(r),r=r.parent}let d=i.node;if(d){if(d!=t.child(a-1))break;--a,o.set(i,a),l.push(i)}}return{index:a,matched:o,matches:l.reverse()}}function jOt(t,s){return t.type.side-s.type.side}function NOt(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 w=b;l!w.inline):i.slice();n(y,N,s.forChild(o,y),_),o=b}}function kOt(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 SOt(t,s,r,n){for(let a=0,o=0;a=r){if(o>=n&&d.slice(n-s.length-i,n-i)==s)return n-s.length;let u=i=0&&u+s.length+i>=r)return i+u;if(r==n&&d.length>=n+s.length-i&&d.slice(n-i,n-i+s.length)==s)return n}}return-1}function N_e(t,s,r,n,a){let o=[];for(let l=0,i=0;l=r||p<=s?o.push(d):(ur&&o.push(d.slice(r-u,d.size,n)))}return o}function Ske(t,s=null){let r=t.domSelectionRange(),n=t.state.doc;if(!r.focusNode)return null;let a=t.docView.nearestDesc(r.focusNode),o=a&&a.size==0,l=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(l<0)return null;let i=n.resolve(l),d,u;if(mhe(r)){for(d=l;a&&!a.node;)a=a.parent;let f=a.node;if(a&&f.isAtom&&Ea.isSelectable(f)&&a.parent&&!(f.isInline&&JRt(r.focusNode,r.focusOffset,a.dom))){let y=a.posBefore;u=new Ea(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(()=>{(!pJe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function MOt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,eh(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&xp&&Ub<=11&&(r.disabled=!0,r.disabled=!1)}function fJe(t,s){if(s instanceof Ea){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(a8e(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else a8e(t)}function a8e(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Cke(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||Oa.between(s,r,n)}function i8e(t){return t.editable&&!t.hasFocus()?!1:xJe(t)}function xJe(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 TOt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return sC(s.node,s.offset,r.anchorNode,r.anchorOffset)}function k_e(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&&ei.findFrom(o,s)}function B_(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function o8e(t,s,r){let n=t.state.selection;if(n instanceof Oa)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 B_(t,new Oa(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=k_e(t.state,s);return a&&a instanceof Ea?B_(t,a):!1}else if(!(ax&&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?Ea.isSelectable(o)?B_(t,new Ea(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):XR?B_(t,new Oa(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Ea&&n.node.isInline)return B_(t,new Oa(s>0?n.$to:n.$from));{let a=k_e(t.state,s);return a?B_(t,a):!1}}}function Mle(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function d8(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function b5(t,s){return s<0?AOt(t):EOt(t)}function AOt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(Sx&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(d8(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(gJe(r))break;{let i=r.previousSibling;for(;i&&d8(i,-1);)a=r.parentNode,o=eh(i),i=i.previousSibling;if(i)r=i,n=Mle(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?S_e(t,r,n):a&&S_e(t,a,o)}function EOt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=Mle(r),o,l;for(;;)if(n{t.state==a&&r1(t)},50)}function l8e(t,s){let r=t.state.doc.resolve(s);if(!(nh||sJe)&&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 c8e(t,s,r){let n=t.state.selection;if(n instanceof Oa&&!n.empty||r.indexOf("s")>-1||ax&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=k_e(t.state,s);if(l&&l instanceof Ea)return B_(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof pf?ei.near(l,s):ei.findFrom(l,s);return i?B_(t,i):!1}return!1}function d8e(t,s){if(!(t.state.selection instanceof Oa))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 u8e(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function LOt(t){if(!$h||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;u8e(t,n,"true"),setTimeout(()=>u8e(t,n,"false"),20)}return!1}function DOt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function ROt(t,s){let r=s.keyCode,n=DOt(s);if(r==8||ax&&r==72&&n=="c")return d8e(t,-1)||b5(t,-1);if(r==46&&!s.shiftKey||ax&&r==68&&n=="c")return d8e(t,1)||b5(t,1);if(r==13||r==27)return!0;if(r==37||ax&&r==66&&n=="c"){let a=r==37?l8e(t,t.state.selection.from)=="ltr"?-1:1:-1;return o8e(t,a,n)||b5(t,a)}else if(r==39||ax&&r==70&&n=="c"){let a=r==39?l8e(t,t.state.selection.from)=="ltr"?1:-1:1;return o8e(t,a,n)||b5(t,a)}else{if(r==38||ax&&r==80&&n=="c")return c8e(t,-1,n)||b5(t,-1);if(r==40||ax&&r==78&&n=="c")return LOt(t)||c8e(t,1,n)||b5(t,1);if(n==(ax?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function Mke(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")||MC.fromSchema(t.state.schema),i=jJe(),d=i.createElement("div");d.appendChild(l.serializeFragment(n,{document:i}));let u=d.firstChild,p,f=0;for(;u&&u.nodeType==1&&(p=wJe[u.nodeName.toLowerCase()]);){for(let _=p.length-1;_>=0;_--){let b=i.createElement(p[_]);for(;d.firstChild;)b.appendChild(d.firstChild);d.appendChild(b),f++}u=d.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${a} ${o}${f?` -${f}`:""} ${JSON.stringify(r)}`);let y=t.someProp("clipboardTextSerializer",_=>_(s,t))||s.content.textBetween(0,s.content.size,` `);return{dom:d,text:y,slice:s}}function yJe(t,s,r,n,a){let o=a.parent.type.spec.code,l,i;if(!r&&!s)return null;let d=!!s&&(n||o||!r);if(d){if(t.someProp("transformPastedText",y=>{s=y(s,o||n,t)}),o)return i=new yn(Er.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=MC.fromSchema(_);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(N=>{let w=l.appendChild(document.createElement("p"));N&&w.appendChild(b.serializeNode(_.text(N,y)))})}}else t.someProp("transformPastedHTML",f=>{r=f(r,t)}),l=BOt(r),XR&&$Ot(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")||o8.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(d||p),context:a,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!OOt.test(y.parentNode.nodeName)?{ignore:!0}:null}})),p)i=qOt(h8e(i,+p[1],+p[2]),p[4]);else if(i=yn.maxOpen(FOt(i.content,a),!0),i.openStart||i.openEnd){let f=0,y=0;for(let _=i.content.firstChild;f{i=f(i,t,d)}),i}const OOt=/^(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 FOt(t,s){if(t.childCount<2)return t;for(let r=s.depth;r>=0;r--){let a=s.node(r).contentMatchAt(s.index(r)),o,l=[];if(t.forEach(i=>{if(!l)return;let d=a.findWrapping(i.type),u;if(!d)return l=null;if(u=l.length&&o.length&&_Je(d,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=bJe(l[l.length-1],o.length));let p=vJe(i,d);l.push(p),a=a.matchType(p.type),o=d}}),l)return Er.from(l)}return t}function vJe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Er.from(t));return t}function _Je(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(Er.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function h8e(t,s,r){return sr})),eye.createHTML(t)):t}function BOt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=jJe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&wJe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=zOt(t),a)for(let o=0;o=0;i-=2){let d=r.nodes[n[i]];if(!d||d.hasRequiredAttrs())break;a=Er.from(d.create(n[i+1],a)),o++,l++}return new yn(a,o,l)}const Em={},Pm={},UOt={touchstart:!0,touchmove:!0};class VOt{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.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function HOt(t){for(let s in Em){let r=Em[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{WOt(t,n)&&!Tke(t,n)&&(t.editable||!(n.type in Pm))&&r(t,n)},UOt[s]?{passive:!0}:void 0)}$h&&t.dom.addEventListener("input",()=>null),M_e(t)}function gb(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function GOt(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 M_e(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>Tke(t,n))})}function Tke(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function WOt(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 KOt(t,s){!Tke(t,s)&&Em[s.type]&&(t.editable||!(s.type in Pm))&&Em[s.type](t,s)}Pm.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!kJe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!($v&&nh&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),qT&&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,u4(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||ROt(t,r)?r.preventDefault():gb(t,"key")};Pm.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Pm.keypress=(t,s)=>{let r=s;if(kJe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||ax&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof Oa)||!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 fhe(t){return{left:t.clientX,top:t.clientY}}function ZOt(t,s){let r=s.x-t.clientX,n=s.y-t.clientY;return r*r+n*n<100}function Ake(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 QM(t,s,r){if(t.focused||t.focus(),t.state.selection.eq(s))return;let n=t.state.tr.setSelection(s);n.setMeta("pointer",!0),t.dispatch(n)}function YOt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&Ea.isSelectable(n)?(QM(t,new Ea(r)),!0):!1}function XOt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof Ea&&(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(Ea.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?(QM(t,Ea.create(t.state.doc,a)),!0):!1}function QOt(t,s,r,n,a){return Ake(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?XOt(t,r):YOt(t,r))}function JOt(t,s,r,n){return Ake(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function eFt(t,s,r,n){return Ake(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||tFt(t,r,n)}function tFt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(QM(t,Oa.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)QM(t,Oa.create(n,i+1,i+1+l.content.size));else if(Ea.isSelectable(l))QM(t,Ea.create(n,i));else continue;return!0}}function Eke(t){return Tle(t)}const NJe=ax?"metaKey":"ctrlKey";Em.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=Eke(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&ZOt(r,t.input.lastClick)&&!r[NJe]&&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(fhe(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new sFt(t,l,r,!!n)):(o=="doubleClick"?JOt:eFt)(t,l.pos,l.inside,r)?r.preventDefault():gb(t,"pointer"))};class sFt{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[NJe],this.allowDefault=n.shiftKey;let o,l;if(r.inside>-1)o=s.state.doc.nodeAt(r.inside),l=r.inside;else{let p=s.state.doc.resolve(r.pos);o=p.parent,l=p.depth?p.before():0}const i=a?null:n.target,d=i?s.docView.nearestDesc(i,!0):null;this.target=d&&d.nodeDOM.nodeType==1?d.nodeDOM:null;let{selection:u}=s.state;n.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof Ea&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Sx&&!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)),gb(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(()=>r1(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(fhe(s))),this.updateAllowDefault(s),this.allowDefault||!r?gb(this.view,"pointer"):QOt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||$h&&this.mightDrag&&!this.mightDrag.node.isAtom||nh&&!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)?(QM(this.view,ei.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):gb(this.view,"pointer")}move(s){this.updateAllowDefault(s),gb(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)}}Em.touchstart=t=>{t.input.lastTouch=Date.now(),Eke(t),gb(t,"pointer")};Em.touchmove=t=>{t.input.lastTouch=Date.now(),gb(t,"pointer")};Em.contextmenu=t=>Eke(t);function kJe(t,s){return t.composing?!0:$h&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const rFt=$v?5e3:-1;Pm.compositionstart=Pm.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof Oa&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||nh&&sJe&&nFt(t)))t.markCursor=t.state.storedMarks||r.marks(),Tle(t,!0),t.markCursor=null;else if(Tle(t,!s.selection.empty),Sx&&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}SJe(t,rFt)};function nFt(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"}Pm.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.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,SJe(t,20))};function SJe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>Tle(t),s))}function CJe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=iFt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function aFt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=XRt(s.focusNode,s.focusOffset),n=QRt(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 iFt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Tle(t,s=!1){if(!($v&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),CJe(t),s||t.docView&&t.docView.dirty){let r=Ske(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 oFt(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 xD=xp&&Ub<15||qT&&sOt<604;Em.copy=Pm.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=xD?null:r.clipboardData,l=n.content(),{dom:i,text:d}=Mke(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",d)):oFt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function lFt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function cFt(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?gD(t,n.value,null,a,s):gD(t,n.textContent,n.innerHTML,a,s)},50)}function gD(t,s,r,n,a){let o=yJe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,a,o||yn.empty)))return!0;if(!o)return!1;let l=lFt(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 MJe(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," "):""}Pm.paste=(t,s)=>{let r=s;if(t.composing&&!$v)return;let n=xD?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&gD(t,MJe(n),n.getData("text/html"),a,r)?r.preventDefault():cFt(t,r)};class TJe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const dFt=ax?"altKey":"ctrlKey";function AJe(t,s){let r;return t.someProp("dragCopies",n=>{r=r||n(s)}),r!=null?!r:!s[dFt]}Em.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(fhe(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof Ea?a.to-1:a.to))){if(n&&n.mightDrag)l=Ea.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=Ea.create(t.state.doc,f.posBefore))}}let i=(l||t.state.selection).content(),{dom:d,text:u,slice:p}=Mke(t,i);(!r.dataTransfer.files.length||!nh||tJe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(xD?"Text":"text/html",d.innerHTML),r.dataTransfer.effectAllowed="copyMove",xD||r.dataTransfer.setData("text/plain",u),t.dragging=new TJe(p,AJe(t,r),l)};Em.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Pm.dragover=Pm.dragenter=(t,s)=>s.preventDefault();Pm.drop=(t,s)=>{try{uFt(t,s,t.dragging)}finally{t.dragging=null}};function uFt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(fhe(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=yJe(t,MJe(s.dataTransfer),xD?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&AJe(t,s));if(t.someProp("handleDrop",_=>_(t,s,o||yn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?GQe(t.state.doc,a.pos,o):a.pos;i==null&&(i=a.pos);let d=t.state.tr;if(l){let{node:_}=r;_?_.replace(d):d.deleteSelection()}let u=d.mapping.map(i),p=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=d.doc;if(p?d.replaceRangeWith(u,u,o.content.firstChild):d.replaceRange(u,u,o),d.doc.eq(f))return;let y=d.doc.resolve(u);if(p&&Ea.isSelectable(o.content.firstChild)&&y.nodeAfter&&y.nodeAfter.sameMarkup(o.content.firstChild))d.setSelection(new Ea(y));else{let _=d.mapping.map(i);d.mapping.maps[d.mapping.maps.length-1].forEach((b,N,w,S)=>_=S),d.setSelection(Cke(t,y,d.doc.resolve(_)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}Em.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())&&r1(t)},20))};Em.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)};Em.beforeinput=(t,s)=>{if(nh&&$v&&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,u4(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 Pm)Em[t]=Pm[t];function yD(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 Ale{constructor(s,r){this.toDOM=s,this.spec=r||AS,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 vm(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof Ale&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&yD(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class Hb{constructor(s,r){this.attrs=s,this.spec=r||AS}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 vm(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==Sh||s.maps.length==0?this:this.mapInner(s,r,0,0,n||AS)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=d+n,p;if(p=PJe(r,i,u)){for(a||(a=this.children.slice());oi&&f.to=s){this.children[i]==s&&(n=this.children[i+2]);break}let o=s+1,l=o+r.content.size;for(let i=0;io&&d.type instanceof Hb){let u=Math.max(o,d.from)-o,p=Math.min(l,d.to)-o;ua.map(s,r,AS));return Y_.from(n)}forChild(s,r){if(r.isLeaf)return Yc.empty;let n=[];for(let a=0;ar instanceof Yc)?s:s.reduce((r,n)=>r.concat(n instanceof Yc?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let w=N-b-(_-y);for(let S=0;SC+p-f)continue;let A=i[S]+p-f;_>=A?i[S+1]=y<=A?-2:-1:y>=p&&w&&(i[S]+=w,i[S+1]+=w)}f+=w}),p=r.maps[u].map(p,-1)}let d=!1;for(let u=0;u=n.content.size){d=!0;continue}let y=r.map(t[u+1]+o,-1),_=y-a,{index:b,offset:N}=n.content.findIndex(f),w=n.maybeChild(b);if(w&&N==f&&N+w.nodeSize==_){let S=i[u+2].mapInner(r,w,p+1,t[u]+o+1,l);S!=Sh?(i[u]=f,i[u+1]=_,i[u+2]=S):(i[u+1]=-2,d=!0)}else d=!0}if(d){let u=mFt(i,t,s,r,a,o,l),p=Ele(u,n,0,l);s=p.local;for(let f=0;fr&&l.to{let u=PJe(t,i,d+r);if(u){o=!0;let p=Ele(u,i,r+d+1,n);p!=Sh&&a.push(d,d+i.nodeSize,p)}});let l=EJe(o?IJe(t):t,-r).sort(ES);for(let i=0;i0;)s++;t.splice(s,0,r)}function tye(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=Sh&&s.push(n)}),t.cursorWrapper&&s.push(Yc.create(t.state.doc,[t.cursorWrapper.deco])),Y_.from(s)}const pFt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},fFt=xp&&Ub<=11;class xFt{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 gFt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new xFt,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():$h&&s.composing&&n.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(s.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),fFt&&(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,pFt)),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(i8e(this.view)){if(this.suppressingSelectionUpdates)return r1(this.view);if(xp&&Ub<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&sC(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=$T(o))r.add(o);for(let o=s.anchorNode;o;o=$T(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)&&i8e(s)&&!this.ignoreSelectionChange(n),o=-1,l=-1,i=!1,d=[];if(s.editable)for(let p=0;pp.nodeName=="BR")&&(s.input.lastKeyCode==8||s.input.lastKeyCode==46)){for(let p of d)if(p.nodeName=="BR"&&p.parentNode){let f=p.nextSibling;for(;f&&f.nodeType==1;){if(f.contentEditable=="false"){p.parentNode.removeChild(p);break}f=f.firstChild}}}else if(Sx&&d.length){let p=d.filter(f=>f.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||_Ft(s,f)!=_)&&y.remove()}}}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),yFt(s)),s.input.badSafariComposition&&(s.input.badSafariComposition=!1,bFt(s,d)),this.handleDOMChange(o,l,i,d),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||r1(s),this.currentSelection.set(n))}registerMutation(s,r){if(r.indexOf(s.target)>-1)return null;let n=this.view.docView.nearestDesc(s.target);if(s.type=="attributes"&&(n==this.view.docView||s.attributeName=="contenteditable"||s.attributeName=="style"&&!s.oldValue&&!s.target.getAttribute("style"))||!n||n.ignoreMutation(s))return null;if(s.type=="childList"){for(let p=0;pa;w--){let S=n.childNodes[w-1],C=S.pmViewDesc;if(S.nodeName=="BR"&&!C){o=w;break}if(!C||C.size)break}let f=t.state.doc,y=t.someProp("domParser")||o8.fromSchema(t.state.schema),_=f.resolve(l),b=null,N=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:jFt,context:_});if(u&&u[0].pos!=null){let w=u[0].pos,S=u[1]&&u[1].pos;S==null&&(S=w),b={anchor:w+l,head:S+l}}return{doc:N,sel:b,from:l,to:i}}function jFt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if($h&&/^(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||$h&&/^(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 NFt=/^(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 kFt(t,s,r,n,a){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,s<0){let U=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,q=Ske(t,U);if(q&&!t.state.selection.eq(q)){if(nh&&$v&&t.input.lastKeyCode===13&&Date.now()-100V(t,u4(13,"Enter"))))return;let $=t.state.tr.setSelection(q);U=="pointer"?$.setMeta("pointer",!0):U=="key"&&$.scrollIntoView(),o&&$.setMeta("composition",o),t.dispatch($)}return}let l=t.state.doc.resolve(s),i=l.sharedDepth(r);s=l.before(i+1),r=t.state.doc.resolve(r).after(i+1);let d=t.state.selection,u=wFt(t,s,r),p=t.state.doc,f=p.slice(u.from,u.to),y,_;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||$v)&&a.some(U=>U.nodeType==1&&!NFt.test(U.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",U=>U(t,u4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(n&&d instanceof Oa&&!d.empty&&d.$head.sameParent(d.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))b={start:d.from,endA:d.to,endB:d.to};else{if(u.sel){let U=y8e(t,t.state.doc,u.sel);if(U&&!U.eq(t.state.selection)){let q=t.state.tr.setSelection(U);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)),xp&&Ub<=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 N=u.doc.resolveNoCache(b.start-u.from),w=u.doc.resolveNoCache(b.endB-u.from),S=p.resolve(b.start),C=N.sameParent(w)&&N.parent.inlineContent&&S.end()>=b.endA;if((qT&&t.input.lastIOSEnter>Date.now()-225&&(!C||a.some(U=>U.nodeName=="DIV"||U.nodeName=="P"))||!C&&N.posU(t,u4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&CFt(p,b.start,b.endA,N,w)&&t.someProp("handleKeyDown",U=>U(t,u4(8,"Backspace")))){$v&&nh&&t.domObserver.suppressSelectionUpdates();return}nh&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),$v&&!C&&N.start()!=w.start()&&w.parentOffset==0&&N.depth==w.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,w=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(U){return U(t,u4(13,"Enter"))})},20));let A=b.start,I=b.endA,L=U=>{let q=U||t.state.tr.replace(A,I,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let $=y8e(t,q.doc,u.sel);$&&!(nh&&t.composing&&$.empty&&(b.start!=b.endB||t.input.lastChromeDeleter1(t),20));let U=L(t.state.tr.delete(A,I)),q=p.resolve(b.start).marksAcross(p.resolve(b.endA));q&&U.ensureMarks(q),t.dispatch(U)}else if(b.endA==b.endB&&(O=SFt(N.parent.content.cut(N.parentOffset,w.parentOffset),S.parent.content.cut(S.parentOffset,b.endA-S.start())))){let U=L(t.state.tr);O.type=="add"?U.addMark(A,I,O.mark):U.removeMark(A,I,O.mark),t.dispatch(U)}else if(N.parent.child(N.index()).isText&&N.index()==w.index()-(w.textOffset?0:1)){let U=N.parent.textBetween(N.parentOffset,w.parentOffset),q=()=>L(t.state.tr.insertText(U,A,I));t.someProp("handleTextInput",$=>$(t,A,I,U,q))||t.dispatch(q())}else t.dispatch(L());else t.dispatch(L())}function y8e(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:Cke(t,s.resolve(r.anchor),s.resolve(r.head))}function SFt(t,s){let r=t.firstChild.marks,n=s.firstChild.marks,a=r,o=n,l,i,d;for(let p=0;pp.mark(i.addToSet(p.marks));else if(a.length==0&&o.length==1)i=o[0],l="remove",d=p=>p.mark(i.removeFromSet(p.marks));else return null;let u=[];for(let p=0;pr||sye(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 MFt(t,s,r,n,a){let o=t.findDiffStart(s,r);if(o==null)return null;let{a:l,b:i}=t.findDiffEnd(s,r+t.size,r+s.size);if(a=="end"){let d=Math.max(0,o-Math.min(l,i));n-=l+d-o}if(l=l?o-n:0;o-=d,o&&o=i?o-n:0;o-=d,o&&o=56320&&s<=57343&&r>=55296&&r<=56319}class LJe{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 VOt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(N8e),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=w8e(this),b8e(this),this.nodeViews=j8e(this),this.docView=e8e(this.state.doc,_8e(this),tye(this),this.dom,this),this.domObserver=new gFt(this,(n,a,o,l)=>kFt(this,n,a,o,l)),this.domObserver.start(),HOt(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&&M_e(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(N8e),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&&(CJe(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 _=j8e(this);AFt(_,this.nodeViews)&&(this.nodeViews=_,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&M_e(this),this.editable=w8e(this),b8e(this);let d=tye(this),u=_8e(this),p=a.plugins!=s.plugins&&!a.doc.eq(s.doc)?"reset":s.scrollToSelection>a.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(s.doc,u,d);(f||!s.selection.eq(a.selection))&&(l=!0);let y=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&aOt(this);if(l){this.domObserver.stop();let _=f&&(xp||nh)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&TFt(a.selection,s.selection);if(f){let b=nh?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=aFt(this)),(o||!this.docView.update(s.doc,u,d,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=e8e(s.doc,u,d,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(_=!0)}_||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&TOt(this))?r1(this,_):(fJe(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&&iOt(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 Ea){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&KLe(this,r.getBoundingClientRect(),s)}else KLe(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&&or.ownerDocument.getSelection()),this._root=r}return s||document}updateRoot(){this._root=null}posAtCoords(s){return hOt(this,s)}coordsAtPos(s,r=1){return oJe(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 gOt(this,r||this.state,s)}pasteHTML(s,r){return gD(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return gD(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return Mke(this,s)}destroy(){this.docView&&(GOt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],tye(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ZRt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return KOt(this,s)}domSelectionRange(){let s=this.domSelection();return s?$h&&this.root.nodeType===11&&eOt(this.dom.ownerDocument)==this.dom&&vFt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}LJe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function _8e(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"),[vm.node(0,t.state.doc.content.size,s)]}function b8e(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:vm.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function w8e(t){return!t.someProp("editable",s=>s(t.state)===!1)}function TFt(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 j8e(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 AFt(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 N8e(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 iw={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:"'"},Ple={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},EFt=typeof navigator<"u"&&/Mac/.test(navigator.platform),PFt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var th=0;th<10;th++)iw[48+th]=iw[96+th]=String(th);for(var th=1;th<=24;th++)iw[th+111]="F"+th;for(var th=65;th<=90;th++)iw[th]=String.fromCharCode(th+32),Ple[th]=String.fromCharCode(th);for(var rye in iw)Ple.hasOwnProperty(rye)||(Ple[rye]=iw[rye]);function IFt(t){var s=EFt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||PFt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?Ple:iw)[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 LFt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),DFt=typeof navigator<"u"&&/Win/.test(navigator.platform);function RFt(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 DJe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const RJe=(t,s,r)=>{let n=DJe(t,r);if(!n)return!1;let a=Rke(n);if(!a){let l=n.blockRange(),i=l&&tE(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(HJe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(UT(o,"end")||Ea.isSelectable(o)))for(let l=n.depth;;l--){let i=uhe(t.doc,n.before(l),n.after(l),yn.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},zFt=(t,s,r)=>{let n=DJe(t,r);if(!n)return!1;let a=Rke(n);return a?OJe(t,a,s):!1},BFt=(t,s,r)=>{let n=zJe(t,r);if(!n)return!1;let a=Oke(n);return a?OJe(t,a,s):!1};function OJe(t,s,r){let n=s.nodeBefore,a=n,o=s.pos-1;for(;!a.isTextblock;o--){if(a.type.spec.isolating)return!1;let p=a.lastChild;if(!p)return!1;a=p}let l=s.nodeAfter,i=l,d=s.pos+1;for(;!i.isTextblock;d++){if(i.type.spec.isolating)return!1;let p=i.firstChild;if(!p)return!1;i=p}let u=uhe(t.doc,o,d,yn.empty);if(!u||u.from!=o||u instanceof Dd&&u.slice.size>=d-o)return!1;if(r){let p=t.tr.step(u);p.setSelection(Oa.create(p.doc,o)),r(p.scrollIntoView())}return!0}function UT(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 FJe=(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=Rke(n)}let l=o&&o.nodeBefore;return!l||!Ea.isSelectable(l)?!1:(s&&s(t.tr.setSelection(Ea.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function Rke(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 zJe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=zJe(t,r);if(!n)return!1;let a=Oke(n);if(!a)return!1;let o=a.nodeAfter;if(HJe(t,a,s,1))return!0;if(n.parent.content.size==0&&(UT(o,"start")||Ea.isSelectable(o))){let l=uhe(t.doc,n.before(),n.after(),yn.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 Ea,a;if(n){if(r.node.isTextblock||!ww(t.doc,r.from))return!1;a=r.from}else if(a=dhe(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(Ea.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},qFt=(t,s)=>{let r=t.selection,n;if(r instanceof Ea){if(r.node.isTextblock||!ww(t.doc,r.to))return!1;n=r.to}else if(n=dhe(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},UFt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&tE(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},qJe=(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 Fke(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=Fke(a.contentMatchAt(o));if(!l||!a.canReplaceWith(o,o,l))return!1;if(s){let i=r.after(),d=t.tr.replaceWith(i,i,l.createAndFill());d.setSelection(ei.near(d.doc.resolve(i),1)),s(d.scrollIntoView())}return!0},UJe=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof pf||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=Fke(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(s1(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&tE(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)};function HFt(t){return(s,r)=>{let{$from:n,$to:a}=s.selection;if(s.selection instanceof Ea&&s.selection.node.isBlock)return!n.parentOffset||!s1(s.doc,n.pos)?!1:(r&&r(s.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],l,i,d=!1,u=!1;for(let _=n.depth;;_--)if(n.node(_).isBlock){d=n.end(_)==n.pos+(n.depth-_),u=n.start(_)==n.pos-(n.depth-_),i=Fke(n.node(_-1).contentMatchAt(n.indexAfter(_-1))),o.unshift(d&&i?{type:i}:null),l=_;break}else{if(_==1)return!1;o.unshift(null)}let p=s.tr;(s.selection instanceof Oa||s.selection instanceof pf)&&p.deleteSelection();let f=p.mapping.map(n.pos),y=s1(p.doc,f,o.length,o);if(y||(o[0]=i?{type:i}:null,y=s1(p.doc,f,o.length,o)),!y)return!1;if(p.split(f,o.length,o),!d&&u&&n.node(l).type!=i){let _=p.mapping.map(n.before(l)),b=p.doc.resolve(_);i&&n.node(l-1).canReplaceWith(b.index(),b.index()+1,i)&&p.setNodeMarkup(p.mapping.map(n.before(l)),i)}return r&&r(p.scrollIntoView()),!0}}const GFt=HFt(),WFt=(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(Ea.create(t.doc,a))),!0)};function KFt(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||ww(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function HJe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,d=a.type.spec.isolating||o.type.spec.isolating;if(!d&&KFt(t,s,r))return!0;let u=!d&&s.parent.canReplace(s.index(),s.index()+1);if(u&&(l=(i=a.contentMatchAt(a.childCount)).findWrapping(o.type))&&i.matchType(l[0]||o.type).validEnd){if(r){let _=s.pos+o.nodeSize,b=Er.empty;for(let S=l.length-1;S>=0;S--)b=Er.from(l[S].create(null,b));b=Er.from(a.copy(b));let N=t.tr.step(new Fu(s.pos-1,_,s.pos,_,new yn(b,1,0),l.length,!0)),w=N.doc.resolve(_+2*l.length);w.nodeAfter&&w.nodeAfter.type==a.type&&ww(N.doc,w.pos)&&N.join(w.pos),r(N.scrollIntoView())}return!0}let p=o.type.spec.isolating||n>0&&d?null:ei.findFrom(s,1),f=p&&p.$from.blockRange(p.$to),y=f&&tE(f);if(y!=null&&y>=s.depth)return r&&r(t.tr.lift(f,y).scrollIntoView()),!0;if(u&&UT(o,"start",!0)&&UT(a,"end")){let _=a,b=[];for(;b.push(_),!_.isTextblock;)_=_.lastChild;let N=o,w=1;for(;!N.isTextblock;N=N.firstChild)w++;if(_.canReplace(_.childCount,_.childCount,N.content)){if(r){let S=Er.empty;for(let A=b.length-1;A>=0;A--)S=Er.from(b[A].copy(S));let C=t.tr.step(new Fu(s.pos-b.length,s.pos+o.nodeSize,s.pos+w,s.pos+o.nodeSize-w,new yn(S,b.length,0),0,!0));r(C.scrollIntoView())}return!0}}return!1}function GJe(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(Oa.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const ZFt=GJe(-1),YFt=GJe(1);function XFt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&wke(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function k8e(t,s=null){return function(r,n){let a=!1;for(let o=0;o{if(a)return!1;if(!(!d.isTextblock||d.hasMarkup(t,s)))if(d.type==t)a=!0;else{let p=r.doc.resolve(u),f=p.index();a=p.parent.canReplaceWith(f,f+1,t)}})}if(!a)return!1;if(n){let o=r.tr;for(let l=0;l=2&&s.$from.node(s.depth-1).type.compatibleContent(r)&&s.startIndex==0){if(s.$from.index(s.depth-1)==0)return!1;let d=l.resolve(s.start-2);o=new kle(d,d,s.depth),s.endIndex=0;p--)o=Er.from(r[p].type.create(r[p].attrs,o));t.step(new Fu(s.start-(n?2:0),s.end,s.start,s.end,new yn(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?s7t(s,r,t,o):r7t(s,r,o):!0:!1}}function s7t(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);oN;b--)_-=a.child(b).nodeSize,n.delete(_-1,_+1);let o=n.doc.resolve(r.start),l=o.nodeAfter;if(n.mapping.map(r.end)!=r.start+o.nodeAfter.nodeSize)return!1;let i=r.startIndex==0,d=r.endIndex==a.childCount,u=o.node(-1),p=o.index(-1);if(!u.canReplace(p+(i?0:1),p+1,l.content.append(d?Er.empty:Er.from(a))))return!1;let f=o.pos,y=f+l.nodeSize;return n.step(new Fu(f-(i?1:0),y+(d?1:0),f+1,y-1,new yn((i?Er.empty:Er.from(a.copy(Er.empty))).append(d?Er.empty:Er.from(a.copy(Er.empty))),i?0:1,d?0:1),i?0:1)),s(n.scrollIntoView()),!0}function n7t(t){return function(s,r){let{$from:n,$to:a}=s.selection,o=n.blockRange(a,u=>u.childCount>0&&u.firstChild.type==t);if(!o)return!1;let l=o.startIndex;if(l==0)return!1;let i=o.parent,d=i.child(l-1);if(d.type!=t)return!1;if(r){let u=d.lastChild&&d.lastChild.type==i.type,p=Er.from(u?t.create():null),f=new yn(Er.from(t.create(null,Er.from(i.type.create(null,p)))),u?3:1,0),y=o.start,_=o.end;r(s.tr.step(new Fu(y-(u?3:1),_,y,_,f,1,!0)).scrollIntoView())}return!0}}function xhe(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 ghe{constructor(s){this.editor=s.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=s.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:s,editor:r,state:n}=this,{view:a}=r,{tr:o}=n,l=this.buildProps(o);return Object.fromEntries(Object.entries(s).map(([i,d])=>[i,(...p)=>{const f=d(...p)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i=[],d=!!s,u=s||o.tr,p=()=>(!d&&r&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(u),i.every(y=>y===!0)),f={...Object.fromEntries(Object.entries(n).map(([y,_])=>[y,(...N)=>{const w=this.buildProps(u,r),S=_(...N)(w);return i.push(S),f}])),run:p};return f}createCan(s){const{rawCommands:r,state:n}=this,a=!1,o=s||n.tr,l=this.buildProps(o,a);return{...Object.fromEntries(Object.entries(r).map(([d,u])=>[d,(...p)=>u(...p)({...l,dispatch:void 0})])),chain:()=>this.createChain(o,a)}}buildProps(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i={tr:s,editor:a,view:l,state:xhe({state:o,transaction:s}),dispatch:r?()=>{}:void 0,chain:()=>this.createChain(s,r),can:()=>this.createCan(s),get commands(){return Object.fromEntries(Object.entries(n).map(([d,u])=>[d,(...p)=>u(...p)(i)]))}};return i}}let a7t=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 na(t,s,r){return t.config[s]===void 0&&t.parent?na(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?na(t.parent,s,r):null}):t.config[s]}function yhe(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 WJe(t){const s=[],{nodeExtensions:r,markExtensions:n}=yhe(t),a=[...r,...n],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage,extensions:a},d=na(l,"addGlobalAttributes",i);if(!d)return;d().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},d=na(l,"addAttributes",i);if(!d)return;const u=d();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 $u(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 kc(...t){return t.filter(s=>!!s).reduce((s,r)=>{const n={...s};return Object.entries(r).forEach(([a,o])=>{if(!n[a]){n[a]=o;return}if(a==="class"){const i=o?String(o).split(" "):[],d=n[a]?n[a].split(" "):[],u=i.filter(p=>!d.includes(p));n[a]=[...d,...u].join(" ")}else if(a==="style"){const i=o?o.split(";").map(p=>p.trim()).filter(Boolean):[],d=n[a]?n[a].split(";").map(p=>p.trim()).filter(Boolean):[],u=new Map;d.forEach(p=>{const[f,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 T_e(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)=>kc(r,n),{})}function KJe(t){return typeof t=="function"}function Li(t,s=void 0,...r){return KJe(t)?s?t.bind(s)(...r):t(...r):t}function i7t(t={}){return Object.keys(t).length===0&&t.constructor===Object}function o7t(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function S8e(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):o7t(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function C8e(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&i7t(r)?!1:r!=null))}function l7t(t,s){var r;const n=WJe(t),{nodeExtensions:a,markExtensions:o}=yhe(t),l=(r=a.find(u=>na(u,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(u=>{const p=n.filter(S=>S.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},y=t.reduce((S,C)=>{const A=na(C,"extendNodeSchema",f);return{...S,...A?A(u):{}}},{}),_=C8e({...y,content:Li(na(u,"content",f)),marks:Li(na(u,"marks",f)),group:Li(na(u,"group",f)),inline:Li(na(u,"inline",f)),atom:Li(na(u,"atom",f)),selectable:Li(na(u,"selectable",f)),draggable:Li(na(u,"draggable",f)),code:Li(na(u,"code",f)),whitespace:Li(na(u,"whitespace",f)),linebreakReplacement:Li(na(u,"linebreakReplacement",f)),defining:Li(na(u,"defining",f)),isolating:Li(na(u,"isolating",f)),attrs:Object.fromEntries(p.map(S=>{var C;return[S.name,{default:(C=S==null?void 0:S.attribute)===null||C===void 0?void 0:C.default}]}))}),b=Li(na(u,"parseHTML",f));b&&(_.parseDOM=b.map(S=>S8e(S,p)));const N=na(u,"renderHTML",f);N&&(_.toDOM=S=>N({node:S,HTMLAttributes:T_e(S,p)}));const w=na(u,"renderText",f);return w&&(_.toText=w),[u.name,_]})),d=Object.fromEntries(o.map(u=>{const p=n.filter(w=>w.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},y=t.reduce((w,S)=>{const C=na(S,"extendMarkSchema",f);return{...w,...C?C(u):{}}},{}),_=C8e({...y,inclusive:Li(na(u,"inclusive",f)),excludes:Li(na(u,"excludes",f)),group:Li(na(u,"group",f)),spanning:Li(na(u,"spanning",f)),code:Li(na(u,"code",f)),attrs:Object.fromEntries(p.map(w=>{var S;return[w.name,{default:(S=w==null?void 0:w.attribute)===null||S===void 0?void 0:S.default}]}))}),b=Li(na(u,"parseHTML",f));b&&(_.parseDOM=b.map(w=>S8e(w,p)));const N=na(u,"renderHTML",f);return N&&(_.toDOM=w=>N({mark:w,HTMLAttributes:T_e(w,p)})),[u.name,_]}));return new DQe({topNode:l,nodes:i,marks:d})}function aye(t,s){return s.nodes[t]||s.marks[t]||null}function M8e(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function Bke(t,s){const r=MC.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const c7t=(t,s=500)=>{let r="";const n=t.parentOffset;return t.parent.nodesBetween(Math.max(0,n-s),n,(a,o,l,i)=>{var d,u;const p=((u=(d=a.type.spec).toText)===null||u===void 0?void 0:u.call(d,{node:a,pos:o,parent:l,index:i}))||a.textContent||"%leaf%";r+=a.isAtom&&!a.isText?p:p.slice(0,Math.max(0,n-o))}),r};function $ke(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class vhe{constructor(s){this.find=s.find,this.handler=s.handler}}const d7t=(t,s)=>{if($ke(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 zz(t){var s;const{editor:r,from:n,to:a,text:o,rules:l,plugin:i}=t,{view:d}=r;if(d.composing)return!1;const u=d.state.doc.resolve(n);if(u.parent.type.spec.code||!((s=u.nodeBefore||u.nodeAfter)===null||s===void 0)&&s.marks.find(y=>y.type.spec.code))return!1;let p=!1;const f=c7t(u)+o;return l.forEach(y=>{if(p)return;const _=d7t(f,y.find);if(!_)return;const b=d.state.tr,N=xhe({state:d.state,transaction:b}),w={from:n-(_[0].length-o.length),to:a},{commands:S,chain:C,can:A}=new ghe({editor:r,state:N});y.handler({state:N,range:w,match:_,commands:S,chain:C,can:A})===null||!b.steps.length||(b.setMeta(i,{transform:b,from:n,to:a,text:o}),d.dispatch(b),p=!0)}),p}function u7t(t){const{editor:s,rules:r}=t,n=new gu({state:{init(){return null},apply(a,o,l){const i=a.getMeta(n);if(i)return i;const d=a.getMeta("applyInputRules");return!!d&&setTimeout(()=>{let{text:p}=d;typeof p=="string"?p=p:p=Bke(Er.from(p),l.schema);const{from:f}=d,y=f+p.length;zz({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 zz({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&zz({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?zz({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function h7t(t){return Object.prototype.toString.call(t).slice(8,-1)}function Bz(t){return h7t(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function _he(t,s){const r={...t};return Bz(t)&&Bz(s)&&Object.keys(s).forEach(n=>{Bz(s[n])&&Bz(t[n])?r[n]=_he(t[n],s[n]):r[n]=s[n]}),r}class Hg{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=Li(na(this,"addOptions",{name:this.name}))),this.storage=Li(na(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new Hg(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>_he(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new Hg(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=Li(na(r,"addOptions",{name:r.name})),r.storage=Li(na(r,"addStorage",{name:r.name,options:r.options})),r}static handleExit({editor:s,mark:r}){const{tr:n}=s.state,a=s.state.selection.$from;if(a.pos===a.end()){const l=a.marks();if(!!!l.find(u=>(u==null?void 0:u.type.name)===r.name))return!1;const d=l.find(u=>(u==null?void 0:u.type.name)===r.name);return d&&n.removeStoredMark(d),n.insertText(" ",a.pos),s.view.dispatch(n),!0}return!1}}function m7t(t){return typeof t=="number"}class p7t{constructor(s){this.find=s.find,this.handler=s.handler}}const f7t=(t,s,r)=>{if($ke(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 x7t(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:d,chain:u,can:p}=new ghe({editor:s,state:r}),f=[];return r.doc.nodesBetween(n,a,(_,b)=>{if(!_.isTextblock||_.type.spec.code)return;const N=Math.max(n,b),w=Math.min(a,b+_.content.size),S=_.textBetween(N-b,w-b,void 0,"");f7t(S,o.find,l).forEach(A=>{if(A.index===void 0)return;const I=N+A.index+1,L=I+A[0].length,O={from:r.tr.mapping.map(I),to:r.tr.mapping.map(L)},U=o.handler({state:r,range:O,match:A,commands:d,chain:u,can:p,pasteEvent:l,dropEvent:i});f.push(U)})}),f.every(_=>_!==null)}let $z=null;const g7t=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 y7t(t){const{editor:s,rules:r}=t;let n=null,a=!1,o=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,i;try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}const d=({state:p,from:f,to:y,rule:_,pasteEvt:b})=>{const N=p.tr,w=xhe({state:p,transaction:N});if(!(!x7t({editor:s,state:w,from:Math.max(f-1,0),to:y.b-1,rule:_,pasteEvent:b,dropEvent:i})||!N.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,N}};return r.map(p=>new gu({view(f){const y=b=>{var N;n=!((N=f.dom.parentElement)===null||N===void 0)&&N.contains(b.target)?f.dom.parentElement:null,n&&($z=s)},_=()=>{$z&&($z=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 _=$z;_!=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],N=b.getMeta("uiEvent")==="paste"&&!a,w=b.getMeta("uiEvent")==="drop"&&!o,S=b.getMeta("applyPasteRules"),C=!!S;if(!N&&!w&&!C)return;if(C){let{text:L}=S;typeof L=="string"?L=L:L=Bke(Er.from(L),_.schema);const{from:O}=S,U=O+L.length,q=g7t(L);return d({rule:p,state:_,from:O,to:{b:U},pasteEvt:q})}const A=y.doc.content.findDiffStart(_.doc.content),I=y.doc.content.findDiffEnd(_.doc.content);if(!(!m7t(A)||!I||A===I.b))return d({rule:p,state:_,from:A,to:I,pasteEvt:l})}}))}function v7t(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class iM{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=iM.resolve(s),this.schema=l7t(this.extensions,r),this.setupExtensions()}static resolve(s){const r=iM.sort(iM.flatten(s)),n=v7t(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=na(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=na(n,"priority")||100,l=na(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:aye(r.name,this.schema)},a=na(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=iM.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:aye(l.name,this.schema)},d=[],u=na(l,"addKeyboardShortcuts",i);let p={};if(l.type==="mark"&&na(l,"exitable",i)&&(p.ArrowRight=()=>Hg.handleExit({editor:s,mark:l})),u){const N=Object.fromEntries(Object.entries(u()).map(([w,S])=>[w,()=>S({editor:s})]));p={...p,...N}}const f=FFt(p);d.push(f);const y=na(l,"addInputRules",i);M8e(l,s.options.enableInputRules)&&y&&n.push(...y());const _=na(l,"addPasteRules",i);M8e(l,s.options.enablePasteRules)&&_&&a.push(..._());const b=na(l,"addProseMirrorPlugins",i);if(b){const N=b();d.push(...N)}return d}).flat();return[u7t({editor:s,rules:n}),...y7t({editor:s,rules:a}),...o]}get attributes(){return WJe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=yhe(this.extensions);return Object.fromEntries(r.filter(n=>!!na(n,"addNodeView")).map(n=>{const a=this.attributes.filter(d=>d.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:s,type:$u(n.name,this.schema)},l=na(n,"addNodeView",o);if(!l)return[];const i=(d,u,p,f,y)=>{const _=T_e(d,a);return l()({node:d,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:aye(s.name,this.schema)};s.type==="mark"&&(!((r=Li(na(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=na(s,"onBeforeCreate",n),o=na(s,"onCreate",n),l=na(s,"onUpdate",n),i=na(s,"onSelectionUpdate",n),d=na(s,"onTransaction",n),u=na(s,"onFocus",n),p=na(s,"onBlur",n),f=na(s,"onDestroy",n);a&&this.editor.on("beforeCreate",a),o&&this.editor.on("create",o),l&&this.editor.on("update",l),i&&this.editor.on("selectionUpdate",i),d&&this.editor.on("transaction",d),u&&this.editor.on("focus",u),p&&this.editor.on("blur",p),f&&this.editor.on("destroy",f)})}}class fh{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=Li(na(this,"addOptions",{name:this.name}))),this.storage=Li(na(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new fh(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>_he(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new fh({...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=Li(na(r,"addOptions",{name:r.name})),r.storage=Li(na(r,"addStorage",{name:r.name,options:r.options})),r}}function ZJe(t,s,r){const{from:n,to:a}=s,{blockSeparator:o=` `,textSerializers:l={}}=r||{};let i="";return t.nodesBetween(n,a,(d,u,p,f)=>{var y;d.isBlock&&u>n&&(i+=o);const _=l==null?void 0:l[d.type.name];if(_)return p&&(i+=_({node:d,pos:u,parent:p,index:f,range:s})),!1;d.isText&&(i+=(y=d==null?void 0:d.text)===null||y===void 0?void 0:y.slice(Math.max(n,u)-u,a-u))}),i}function YJe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const _7t=fh.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new gu({key:new Hh("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:s,schema:r}=t,{doc:n,selection:a}=s,{ranges:o}=a,l=Math.min(...o.map(p=>p.$from.pos)),i=Math.max(...o.map(p=>p.$to.pos)),d=YJe(r);return ZJe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),b7t=()=>({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),w7t=(t=!1)=>({commands:s})=>s.setContent("",t),j7t=()=>({state:t,tr:s,dispatch:r})=>{const{selection:n}=s,{ranges:a}=n;return r&&a.forEach(({$from:o,$to:l})=>{t.doc.nodesBetween(o.pos,l.pos,(i,d)=>{if(i.type.isText)return;const{doc:u,mapping:p}=s,f=u.resolve(p.map(d)),y=u.resolve(p.map(d+i.nodeSize)),_=f.blockRange(y);if(!_)return;const b=tE(_);if(i.type.isTextblock){const{defaultType:N}=f.parent.contentMatchAt(f.index());s.setNodeMarkup(_.start,N)}(b||b===0)&&s.lift(_,b)})}),!0},N7t=t=>s=>t(s),k7t=()=>({state:t,dispatch:s})=>UJe(t,s),S7t=(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 Oa(n.doc.resolve(Math.max(l-1,0)))),!0},C7t=()=>({tr:t,dispatch:s})=>{const{selection:r}=t,n=r.$anchor.node();if(n.content.size>0)return!1;const a=t.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===n.type){if(s){const i=a.before(o),d=a.after(o);t.delete(i,d).scrollIntoView()}return!0}return!1},M7t=t=>({tr:s,state:r,dispatch:n})=>{const a=$u(t,r.schema),o=s.selection.$anchor;for(let l=o.depth;l>0;l-=1)if(o.node(l).type===a){if(n){const d=o.before(l),u=o.after(l);s.delete(d,u).scrollIntoView()}return!0}return!1},T7t=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},A7t=()=>({state:t,dispatch:s})=>Dke(t,s),E7t=()=>({commands:t})=>t.keyboardShortcut("Enter"),P7t=()=>({state:t,dispatch:s})=>VFt(t,s);function Ile(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:$ke(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function XJe(t,s,r={}){return t.find(n=>n.type===s&&Ile(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function T8e(t,s,r={}){return!!XJe(t,s,r)}function qke(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),!XJe([...a.node.marks],s,r)))return;let l=a.index,i=t.start()+a.offset,d=l+1,u=i+a.node.nodeSize;for(;l>0&&T8e([...t.parent.child(l-1).marks],s,r);)l-=1,i-=t.parent.child(l).nodeSize;for(;d({tr:r,state:n,dispatch:a})=>{const o=Nw(t,n.schema),{doc:l,selection:i}=r,{$from:d,from:u,to:p}=i;if(a){const f=qke(d,o,s);if(f&&f.from<=u&&f.to>=p){const y=Oa.create(l,f.from,f.to);r.setSelection(y)}}return!0},L7t=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=()=>{(Lle()||A8e())&&n.dom.focus(),requestAnimationFrame(()=>{r.isDestroyed||(n.focus(),D7t()&&!Lle()&&!A8e()&&n.dom.focus({preventScroll:!0}))})};if(n.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!QJe(r.state.selection))return l(),!0;const i=JJe(a.doc,t)||r.state.selection,d=r.state.selection.eq(i);return o&&(d||a.setSelection(i),d&&a.storedMarks&&a.setStoredMarks(a.storedMarks),l()),!0},O7t=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),F7t=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),eet=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&&eet(n)}return t};function qz(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return eet(r)}function vD(t,s,r){if(t instanceof qb||t instanceof Er)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 Er.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),vD("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const d=new DQe({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?o8.fromSchema(d).parseSlice(qz(t),r.parseOptions):o8.fromSchema(d).parse(qz(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=o8.fromSchema(s);return r.slice?o.parseSlice(qz(t),r.parseOptions).content:o.parse(qz(t),r.parseOptions)}return vD("",s,r)}function z7t(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=p)}),t.setSelection(ei.near(t.doc.resolve(l),r))}const B7t=t=>!("type"in t),$7t=(t,s,r)=>({tr:n,dispatch:a,editor:o})=>{var l;if(a){r={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...r};let i;const d=w=>{o.emit("contentError",{editor:o,error:w,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{vD(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(w){d(w)}try{i=vD(s,o.schema,{parseOptions:u,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(w){return d(w),!1}let{from:p,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},y=!0,_=!0;if((B7t(i)?i:[i]).forEach(w=>{w.check(),y=y?w.isText&&w.marks.length===0:!1,_=_?w.isBlock:!1}),p===f&&_){const{parent:w}=n.doc.resolve(p);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(p-=1,f+=1)}let N;if(y){if(Array.isArray(s))N=s.map(w=>w.text||"").join("");else if(s instanceof Er){let w="";s.forEach(S=>{S.text&&(w+=S.text)}),N=w}else typeof s=="object"&&s&&s.text?N=s.text:N=s;n.insertText(N,p,f)}else N=i,n.replaceWith(p,f,N);r.updateSelection&&z7t(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:p,text:N}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:p,text:N})}return!0},q7t=()=>({state:t,dispatch:s})=>$Ft(t,s),U7t=()=>({state:t,dispatch:s})=>qFt(t,s),V7t=()=>({state:t,dispatch:s})=>RJe(t,s),H7t=()=>({state:t,dispatch:s})=>BJe(t,s),G7t=()=>({state:t,dispatch:s,tr:r})=>{try{const n=dhe(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},W7t=()=>({state:t,dispatch:s,tr:r})=>{try{const n=dhe(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},K7t=()=>({state:t,dispatch:s})=>zFt(t,s),Z7t=()=>({state:t,dispatch:s})=>BFt(t,s);function tet(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Y7t(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=Y7t(t).split(/-(?!$)/),l=o.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),i=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),d=s.captureTransaction(()=>{r.someProp("handleKeyDown",u=>u(r,i))});return d==null||d.steps.forEach(u=>{const p=u.map(n.mapping);p&&a&&n.maybeStep(p)}),!0};function _D(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?$u(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 d=a-n,u=i.filter(f=>l?l.name===f.node.type.name:!0).filter(f=>Ile(f.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((f,y)=>f+y.to-y.from,0)>=d}const Q7t=(t,s={})=>({state:r,dispatch:n})=>{const a=$u(t,r.schema);return _D(r,a,s)?UFt(r,n):!1},J7t=()=>({state:t,dispatch:s})=>VJe(t,s),ezt=t=>({state:s,dispatch:r})=>{const n=$u(t,s.schema);return t7t(n)(s,r)},tzt=()=>({state:t,dispatch:s})=>qJe(t,s);function bhe(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function E8e(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 szt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=bhe(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=$u(t,n.schema)),i==="mark"&&(l=Nw(t,n.schema)),a&&r.selection.ranges.forEach(d=>{n.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,p)=>{o&&o===u.type&&r.setNodeMarkup(p,void 0,E8e(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(f=>{l===f.type&&r.addMark(p,p+u.nodeSize,l.create(E8e(f.attrs,s)))})})}),!0):!1},rzt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),nzt=()=>({tr:t,dispatch:s})=>{if(s){const r=new pf(t.doc);t.setSelection(r)}return!0},azt=()=>({state:t,dispatch:s})=>FJe(t,s),izt=()=>({state:t,dispatch:s})=>$Je(t,s),ozt=()=>({state:t,dispatch:s})=>WFt(t,s),lzt=()=>({state:t,dispatch:s})=>YFt(t,s),czt=()=>({state:t,dispatch:s})=>ZFt(t,s);function A_e(t,s,r={},n={}){return vD(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const dzt=(t,s=!1,r={},n={})=>({editor:a,tr:o,dispatch:l,commands:i})=>{var d,u;const{doc:p}=o;if(r.preserveWhitespace!=="full"){const f=A_e(t,a.schema,r,{errorOnInvalidContent:(d=n.errorOnInvalidContent)!==null&&d!==void 0?d:a.options.enableContentCheck});return l&&o.replaceWith(0,p.content.size,f).setMeta("preventUpdate",!s),!0}return l&&o.setMeta("preventUpdate",!s),i.insertContentAt({from:0,to:p.content.size},t,{parseOptions:r,errorOnInvalidContent:(u=n.errorOnInvalidContent)!==null&&u!==void 0?u:a.options.enableContentCheck})};function set(t,s){const r=Nw(s,t.schema),{from:n,to:a,empty:o}=t.selection,l=[];o?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(n,a,d=>{l.push(...d.marks)});const i=l.find(d=>d.type.name===r.name);return i?{...i.attrs}:{}}function uzt(t,s){const r=new jke(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function hzt(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function ret(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 Uke(t){return s=>ret(s.$from,t)}function pzt(t,s){const r={from:0,to:t.content.size};return ZJe(t,r,s)}function fzt(t,s){const r=$u(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 net(t,s){const r=bhe(typeof s=="string"?s:s.name,t.schema);return r==="node"?fzt(t,s):r==="mark"?set(t,s):{}}function xzt(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 gzt(t){const s=xzt(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 yzt(t){const{mapping:s,steps:r}=t,n=[];return s.maps.forEach((a,o)=>{const l=[];if(a.ranges.length)a.forEach((i,d)=>{l.push({from:i,to:d})});else{const{from:i,to:d}=r[o];if(i===void 0||d===void 0)return;l.push({from:i,to:d})}l.forEach(({from:i,to:d})=>{const u=s.slice(o).map(i,-1),p=s.slice(o).map(d),f=s.invert().map(u,-1),y=s.invert().map(p);n.push({oldRange:{from:f,to:y},newRange:{from:u,to:p}})})}),gzt(n)}function Vke(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=qke(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 toe(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 E_e(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?Nw(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>Ile(f.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:f,$to:y})=>{const _=f.pos,b=y.pos;t.doc.nodesBetween(_,b,(N,w)=>{if(!N.isText&&!N.marks.length)return;const S=Math.max(_,w),C=Math.min(b,w+N.nodeSize),A=C-S;l+=A,i.push(...N.marks.map(I=>({mark:I,from:S,to:C})))})}),l===0)return!1;const d=i.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>Ile(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(d>0?d+u:d)>=l}function vzt(t,s,r={}){if(!s)return _D(t,null,r)||E_e(t,null,r);const n=bhe(s,t.schema);return n==="node"?_D(t,s,r):n==="mark"?E_e(t,s,r):!1}function P8e(t,s){const{nodeExtensions:r}=yhe(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=Li(na(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function Hke(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&&(Hke(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function _zt(t){return t instanceof Ea}function bzt(t,s,r){var n;const{selection:a}=s;let o=null;if(QJe(a)&&(o=a.$cursor),o){const i=(n=t.storedMarks)!==null&&n!==void 0?n:o.marks();return!!r.isInSet(i)||!i.some(d=>d.type.excludes(r))}const{ranges:l}=a;return l.some(({$from:i,$to:d})=>{let u=i.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):!1;return t.doc.nodesBetween(i.pos,d.pos,(p,f,y)=>{if(u)return!1;if(p.isInline){const _=!y||y.type.allowsMarkType(r),b=!!r.isInSet(p.marks)||!p.marks.some(N=>N.type.excludes(r));u=_&&b}return!u}),u})}const wzt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,d=Nw(t,n.schema);if(a)if(l){const u=set(n,d);r.addStoredMark(d.create({...u,...s}))}else i.forEach(u=>{const p=u.$from.pos,f=u.$to.pos;n.doc.nodesBetween(p,f,(y,_)=>{const b=Math.max(_,p),N=Math.min(_+y.nodeSize,f);y.marks.find(S=>S.type===d)?y.marks.forEach(S=>{d===S.type&&r.addMark(b,N,d.create({...S.attrs,...s}))}):r.addMark(b,N,d.create(s))})});return bzt(n,r,d)},jzt=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),Nzt=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=$u(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})=>k8e(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>k8e(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},kzt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=k4(t,0,n.content.size),o=Ea.create(n,a);s.setSelection(o)}return!0},Szt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=Oa.atStart(n).from,i=Oa.atEnd(n).to,d=k4(a,l,i),u=k4(o,l,i),p=Oa.create(n,d,u);s.setSelection(p)}return!0},Czt=t=>({state:s,dispatch:r})=>{const n=$u(t,s.schema);return n7t(n)(s,r)};function I8e(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 Mzt=({keepMarks:t=!0}={})=>({tr:s,state:r,dispatch:n,editor:a})=>{const{selection:o,doc:l}=s,{$from:i,$to:d}=o,u=a.extensionManager.attributes,p=toe(u,i.node().type.name,i.node().attrs);if(o instanceof Ea&&o.node.isBlock)return!i.parentOffset||!s1(l,i.pos)?!1:(n&&(t&&I8e(r,a.extensionManager.splittableMarks),s.split(i.pos).scrollIntoView()),!0);if(!i.parent.isBlock)return!1;const f=d.parentOffset===d.parent.content.size,y=i.depth===0?void 0:hzt(i.node(-1).contentMatchAt(i.indexAfter(-1)));let _=f&&y?[{type:y,attrs:p}]:void 0,b=s1(s.doc,s.mapping.map(i.pos),1,_);if(!_&&!b&&s1(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 Oa&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,_),y&&!f&&!i.parentOffset&&i.parent.type!==y)){const N=s.mapping.map(i.before()),w=s.doc.resolve(N);i.node(-1).canReplaceWith(w.index(),w.index()+1,y)&&s.setNodeMarkup(s.mapping.map(i.before()),y)}t&&I8e(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return b},Tzt=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=$u(t,n.schema),{$from:d,$to:u}=n.selection,p=n.selection.node;if(p&&p.isBlock||d.depth<2||!d.sameParent(u))return!1;const f=d.node(-1);if(f.type!==i)return!1;const y=o.extensionManager.attributes;if(d.parent.content.size===0&&d.node(-1).childCount===d.indexAfter(-1)){if(d.depth===2||d.node(-3).type!==i||d.index(-2)!==d.node(-2).childCount-1)return!1;if(a){let S=Er.empty;const C=d.index(-1)?1:d.index(-2)?2:3;for(let q=d.depth-C;q>=d.depth-3;q-=1)S=Er.from(d.node(q).copy(S));const A=d.indexAfter(-1){if(U>-1)return!1;q.isTextblock&&q.content.size===0&&(U=$+1)}),U>-1&&r.setSelection(Oa.near(r.doc.resolve(U))),r.scrollIntoView()}return!0}const _=u.pos===d.end()?f.contentMatchAt(0).defaultType:null,b={...toe(y,f.type.name,f.attrs),...s},N={...toe(y,d.node().type.name,d.node().attrs),...s};r.delete(d.pos,u.pos);const w=_?[{type:i,attrs:b},{type:_,attrs:N}]:[{type:i,attrs:b}];if(!s1(r.doc,d.pos,2))return!1;if(a){const{selection:S,storedMarks:C}=n,{splittableMarks:A}=o.extensionManager,I=C||S.$to.parentOffset&&S.$from.marks();if(r.split(d.pos,2,w).scrollIntoView(),!I||!a)return!0;const L=I.filter(O=>A.includes(O.type.name));r.ensureMarks(L)}return!0},iye=(t,s)=>{const r=Uke(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)&&ww(t.doc,r.pos)&&t.join(r.pos),!0},oye=(t,s)=>{const r=Uke(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)&&ww(t.doc,n)&&t.join(n),!0},Azt=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:d,commands:u,can:p})=>{const{extensions:f,splittableMarks:y}=a.extensionManager,_=$u(t,l.schema),b=$u(s,l.schema),{selection:N,storedMarks:w}=l,{$from:S,$to:C}=N,A=S.blockRange(C),I=w||N.$to.parentOffset&&N.$from.marks();if(!A)return!1;const L=Uke(O=>P8e(O.type.name,f))(N);if(A.depth>=1&&L&&A.depth-L.depth<=1){if(L.node.type===_)return u.liftListItem(b);if(P8e(L.node.type.name,f)&&_.validContent(L.node.content)&&i)return d().command(()=>(o.setNodeMarkup(L.pos,_),!0)).command(()=>iye(o,_)).command(()=>oye(o,_)).run()}return!r||!I||!i?d().command(()=>p().wrapInList(_,n)?!0:u.clearNodes()).wrapInList(_,n).command(()=>iye(o,_)).command(()=>oye(o,_)).run():d().command(()=>{const O=p().wrapInList(_,n),U=I.filter(q=>y.includes(q.type.name));return o.ensureMarks(U),O?!0:u.clearNodes()}).wrapInList(_,n).command(()=>iye(o,_)).command(()=>oye(o,_)).run()},Ezt=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=Nw(t,n.schema);return E_e(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},Pzt=(t,s,r={})=>({state:n,commands:a})=>{const o=$u(t,n.schema),l=$u(s,n.schema),i=_D(n,o,r);let d;return n.selection.$anchor.sameParent(n.selection.$head)&&(d=n.selection.$anchor.parent.attrs),i?a.setNode(l,d):a.setNode(o,{...d,...r})},Izt=(t,s={})=>({state:r,commands:n})=>{const a=$u(t,r.schema);return _D(r,a,s)?n.lift(a):n.wrapIn(a,s)},Lzt=()=>({state:t,dispatch:s})=>{const r=t.plugins;for(let n=0;n=0;d-=1)l.step(i.steps[d].invert(i.docs[d]));if(o.text){const d=l.doc.resolve(o.from).marks();l.replaceWith(o.from,o.to,t.schema.text(o.text,d))}else l.delete(o.from,o.to)}return!0}}return!1},Dzt=()=>({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},Rzt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,d=Nw(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(w=>w.type===d))===null||o===void 0?void 0:o.attrs,N=qke(u,d,b);N&&(y=N.from,_=N.to),r.removeMark(y,_,d)}else f.forEach(y=>{r.removeMark(y.$from.pos,y.$to.pos,d)});return r.removeStoredMark(d),!0},Ozt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=bhe(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=$u(t,n.schema)),i==="mark"&&(l=Nw(t,n.schema)),a&&r.selection.ranges.forEach(d=>{const u=d.$from.pos,p=d.$to.pos;let f,y,_,b;r.selection.empty?n.doc.nodesBetween(u,p,(N,w)=>{o&&o===N.type&&(_=Math.max(w,u),b=Math.min(w+N.nodeSize,p),f=w,y=N)}):n.doc.nodesBetween(u,p,(N,w)=>{w=u&&w<=p&&(o&&o===N.type&&r.setNodeMarkup(w,void 0,{...N.attrs,...s}),l&&N.marks.length&&N.marks.forEach(S=>{if(l===S.type){const C=Math.max(w,u),A=Math.min(w+N.nodeSize,p);r.addMark(C,A,l.create({...S.attrs,...s}))}}))}),y&&(f!==void 0&&r.setNodeMarkup(f,void 0,{...y.attrs,...s}),l&&y.marks.length&&y.marks.forEach(N=>{l===N.type&&r.addMark(_,b,l.create({...N.attrs,...s}))}))}),!0):!1},Fzt=(t,s={})=>({state:r,dispatch:n})=>{const a=$u(t,r.schema);return XFt(a,s)(r,n)},zzt=(t,s={})=>({state:r,dispatch:n})=>{const a=$u(t,r.schema);return QFt(a,s)(r,n)};var Bzt=Object.freeze({__proto__:null,blur:b7t,clearContent:w7t,clearNodes:j7t,command:N7t,createParagraphNear:k7t,cut:S7t,deleteCurrentNode:C7t,deleteNode:M7t,deleteRange:T7t,deleteSelection:A7t,enter:E7t,exitCode:P7t,extendMarkRange:I7t,first:L7t,focus:R7t,forEach:O7t,insertContent:F7t,insertContentAt:$7t,joinBackward:V7t,joinDown:U7t,joinForward:H7t,joinItemBackward:G7t,joinItemForward:W7t,joinTextblockBackward:K7t,joinTextblockForward:Z7t,joinUp:q7t,keyboardShortcut:X7t,lift:Q7t,liftEmptyBlock:J7t,liftListItem:ezt,newlineInCode:tzt,resetAttributes:szt,scrollIntoView:rzt,selectAll:nzt,selectNodeBackward:azt,selectNodeForward:izt,selectParentNode:ozt,selectTextblockEnd:lzt,selectTextblockStart:czt,setContent:dzt,setMark:wzt,setMeta:jzt,setNode:Nzt,setNodeSelection:kzt,setTextSelection:Szt,sinkListItem:Czt,splitBlock:Mzt,splitListItem:Tzt,toggleList:Azt,toggleMark:Ezt,toggleNode:Pzt,toggleWrap:Izt,undoInputRule:Lzt,unsetAllMarks:Dzt,unsetMark:Rzt,updateAttributes:Ozt,wrapIn:Fzt,wrapInList:zzt});const $zt=fh.create({name:"commands",addCommands(){return{...Bzt}}}),qzt=fh.create({name:"drop",addProseMirrorPlugins(){return[new gu({key:new Hh("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),Uzt=fh.create({name:"editable",addProseMirrorPlugins(){return[new gu({key:new Hh("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Vzt=new Hh("focusEvents"),Hzt=fh.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new gu({key:Vzt,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}}}})]}}),Gzt=fh.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:i})=>{const{selection:d,doc:u}=i,{empty:p,$anchor:f}=d,{pos:y,parent:_}=f,b=f.parent.isTextblock&&y>0?i.doc.resolve(y-1):f,N=b.parent.type.spec.isolating,w=f.pos-f.parentOffset,S=N&&b.parent.childCount===1?w===f.pos:ei.atStart(u).from===y;return!p||!_.type.isTextblock||_.textContent.length||!S||S&&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 Lle()||tet()?o:a},addProseMirrorPlugins(){return[new gu({key:new Hh("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(N=>N.getMeta("composition")))return;const n=t.some(N=>N.docChanged)&&!s.doc.eq(r.doc),a=t.some(N=>N.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=s.selection,d=ei.atStart(s.doc).from,u=ei.atEnd(s.doc).to;if(o||!(l===d&&i===u)||!Hke(r.doc))return;const y=r.tr,_=xhe({state:r,transaction:y}),{commands:b}=new ghe({editor:this.editor,state:_});if(b.clearNodes(),!!y.steps.length)return y}})]}}),Wzt=fh.create({name:"paste",addProseMirrorPlugins(){return[new gu({key:new Hh("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),Kzt=fh.create({name:"tabindex",addProseMirrorPlugins(){return[new gu({key:new Hh("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class h4{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 h4(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 h4(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 h4(s,this.editor)}get children(){const s=[];return this.node.content.forEach((r,n)=>{const a=r.isBlock&&!r.isTextblock,o=r.isAtom&&!r.isText,l=this.pos+n+(o?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const i=this.resolvedPos.doc.resolve(l);if(!a&&i.depth<=this.depth)return;const d=new h4(i,this.editor,a,a?r:null);a&&(d.actualDepth=this.depth+1),s.push(new h4(i,this.editor,a,a?r:null))}),s}get firstChild(){return this.children[0]||null}get lastChild(){const s=this.children;return s[s.length-1]||null}closest(s,r={}){let n=null,a=this.parent;for(;a&&!n;){if(a.node.type.name===s)if(Object.keys(r).length>0){const o=a.node.attrs,l=Object.keys(r);for(let i=0;i{n&&a.length>0||(l.node.type.name===s&&o.every(d=>r[d]===l.node.attrs[d])&&a.push(l),!(n&&a.length>0)&&(a=a.concat(l.querySelectorAll(s,r,n))))}),a}setAttribute(s){const{tr:r}=this.editor.state;r.setNodeMarkup(this.from,void 0,{...this.node.attrs,...s}),this.editor.view.dispatch(r)}}const Zzt=`.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 Yzt(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 Xzt extends a7t{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=Yzt(Zzt,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=KJe(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?[Uzt,_7t.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),$zt,Hzt,Gzt,Kzt,qzt,Wzt].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 iM(a,this)}createCommandManager(){this.commandManager=new ghe({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=A_e(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=A_e(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=JJe(r,this.options.autofocus);this.view=new LJe(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:aM.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 net(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return vzt(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Bke(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return pzt(this.state.doc,{blockSeparator:r,textSerializers:{...YJe(this.schema),...n}})}get isEmpty(){return Hke(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 h4(r,this)}get $doc(){return this.$pos(0)}}function VT(t){return new vhe({find:t.find,handler:({state:s,range:r,match:n})=>{const a=Li(t.getAttributes,void 0,n);if(a===!1||a===null)return null;const{tr:o}=s,l=n[n.length-1],i=n[0];if(l){const d=i.search(/\S/),u=r.from+i.indexOf(l),p=u+l.length;if(Vke(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(N=>N===t.type&&N!==_.mark.type)).filter(_=>_.to>u).length)return null;pr.from&&o.delete(r.from+d,u);const y=r.from+d+l.length;o.addMark(r.from+d,y,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}function aet(t){return new vhe({find:t.find,handler:({state:s,range:r,match:n})=>{const a=Li(t.getAttributes,void 0,n)||{},{tr:o}=s,l=r.from;let i=r.to;const d=t.type.create(a);if(n[1]){const u=n[0].lastIndexOf(n[1]);let p=l+u;p>i?p=i:i=p+n[1].length;const f=n[0][n[0].length-1];o.insertText(f,l+n[0].length-1),o.replaceWith(p,i,d)}else if(n[0]){const u=t.type.isInline?l:l-1;o.insert(u,t.type.create(a)).delete(o.mapping.map(l),o.mapping.map(i))}o.scrollIntoView()}})}function P_e(t){return new vhe({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=Li(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 bD(t){return new vhe({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=Li(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),d=l.doc.resolve(r.from).blockRange(),u=d&&wke(d,t.type,o);if(!u)return null;if(l.wrap(d,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 N=b.filter(w=>_.includes(w.type.name));l.ensureMarks(N)}}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&&ww(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,p))&&l.join(r.from-1)}})}let Gh=class I_e{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=Li(na(this,"addOptions",{name:this.name}))),this.storage=Li(na(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new I_e(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>_he(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new I_e(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=Li(na(r,"addOptions",{name:r.name})),r.storage=Li(na(r,"addStorage",{name:r.name,options:r.options})),r}};function nC(t){return new p7t({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=Li(t.getAttributes,void 0,n,a);if(o===!1||o===null)return null;const{tr:l}=s,i=n[n.length-1],d=n[0];let u=r.to;if(i){const p=d.search(/\S/),f=r.from+d.indexOf(i),y=f+i.length;if(Vke(r.from,r.to,s.doc).filter(b=>b.mark.type.excluded.find(w=>w===t.type&&w!==b.mark.type)).filter(b=>b.to>f).length)return null;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 Qzt(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof Ea){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 Jzt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var iet={exports:{}},lye={};/** * @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 L8e;function e9t(){if(L8e)return lye;L8e=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}}),N=b[0].inst,w=b[1];return o(function(){N.value=_,N.getSnapshot=y,d(N)&&w({inst:N})},[f,_,y]),a(function(){return d(N)&&w({inst:N}),f(function(){d(N)&&w({inst:N})})},[f]),l(_),_}function d(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 lye.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,lye}iet.exports=e9t();var Gke=iet.exports;const t9t=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},s9t=({contentComponent:t})=>{const s=Gke.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return ht.createElement(ht.Fragment,null,Object.values(s))};function r9t(){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]:rje.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 n9t 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=r9t(),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:t9t(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&ht.createElement(s9t,{contentComponent:s.contentComponent}))}}const a9t=k.forwardRef((t,s)=>{const r=ht.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ht.createElement(n9t,{key:r,innerRef:s,...t})}),Wke=ht.memo(a9t);var i9t=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},o9t=Jzt(i9t),oet={exports:{}},cye={};/** * @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 D8e;function l9t(){if(D8e)return cye;D8e=1;var t=ht,s=Gke;function r(u,p){return u===p&&(u!==0||1/u===1/p)||u!==u&&p!==p}var n=typeof Object.is=="function"?Object.is:r,a=s.useSyncExternalStore,o=t.useRef,l=t.useEffect,i=t.useMemo,d=t.useDebugValue;return cye.useSyncExternalStoreWithSelector=function(u,p,f,y,_){var b=o(null);if(b.current===null){var N={hasValue:!1,value:null};b.current=N}else N=b.current;b=i(function(){function S(O){if(!C){if(C=!0,A=O,O=y(O),_!==void 0&&N.hasValue){var U=N.value;if(_(U,O))return I=U}return I=O}if(U=I,n(A,O))return U;var q=y(O);return _!==void 0&&_(U,q)?U:(A=O,I=q)}var C=!1,A,I,L=f===void 0?null:f;return[function(){return S(p())},L===null?void 0:function(){return S(L())}]},[p,f,y,_]);var w=a(u,b[0],b[1]);return l(function(){N.hasValue=!0,N.value=w},[w]),d(w),w},cye}oet.exports=l9t();var c9t=oet.exports;const d9t=typeof window<"u"?k.useLayoutEffect:k.useEffect;class u9t{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 h9t(t){var s;const[r]=k.useState(()=>new u9t(t.editor)),n=c9t.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:o9t);return d9t(()=>r.watch(t.editor),[t.editor,r]),k.useDebugValue(n),n}const m9t=!1,L_e=typeof window>"u",p9t=L_e||!!(typeof window<"u"&&window.next);class Kke{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?L_e||p9t?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 Xzt(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?Kke.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 Zke(t={},s=[]){const r=k.useRef(t);r.current=t;const[n]=k.useState(()=>new Kke(r)),a=Gke.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return k.useDebugValue(a),k.useEffect(n.onRender(s)),h9t({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const f9t=k.createContext({editor:null});f9t.Consumer;const x9t=k.createContext({onDragStart:void 0}),g9t=()=>k.useContext(x9t);ht.forwardRef((t,s)=>{const{onDragStart:r}=g9t(),n=t.as||"div";return ht.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const y9t=/^\s*>\s$/,v9t=Gh.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",kc(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[bD({find:y9t,type:this.type})]}}),_9t=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,b9t=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,w9t=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,j9t=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,N9t=Hg.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",kc(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[VT({find:_9t,type:this.type}),VT({find:w9t,type:this.type})]},addPasteRules(){return[nC({find:b9t,type:this.type}),nC({find:j9t,type:this.type})]}}),k9t="listItem",R8e="textStyle",O8e=/^\s*([-+*])\s$/,S9t=Gh.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",kc(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(k9t,this.editor.getAttributes(R8e)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=bD({find:O8e,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=bD({find:O8e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(R8e),editor:this.editor})),[t]}}),C9t=/(^|[^`])`([^`]+)`(?!`)/,M9t=/(^|[^`])`([^`]+)`(?!`)/g,T9t=Hg.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",kc(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[VT({find:C9t,type:this.type})]},addPasteRules(){return[nC({find:M9t,type:this.type})]}}),A9t=/^```([a-z]+)?[\s\n]$/,E9t=/^~~~([a-z]+)?[\s\n]$/,P9t=Gh.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",kc(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(ei.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[P_e({find:A9t,type:this.type,getAttributes:t=>({language:t[1]})}),P_e({find:E9t,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new gu({key:new Hh("codeBlockVSCodeHandler"),props:{handlePaste:(t,s)=>{if(!s.clipboardData||this.editor.isActive(this.type.name))return!1;const r=s.clipboardData.getData("text/plain"),n=s.clipboardData.getData("vscode-editor-data"),a=n?JSON.parse(n):void 0,o=a==null?void 0:a.mode;if(!r||!o)return!1;const{tr:l,schema:i}=t.state,d=i.text(r.replace(/\r\n?/g,` `));return l.replaceSelectionWith(this.type.create({language:o},d)),l.selection.$from.parent.type!==this.type&&l.setSelection(Oa.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),I9t=Gh.create({name:"doc",topNode:!0,content:"block+"});function L9t(t={}){return new gu({view(s){return new D9t(s,t)}})}class D9t{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(),N=f?b.bottom:b.top;f&&y&&(N=(N+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*i;n={left:b.left,right:b.right,top:N-w,bottom:N+w}}}}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 d=this.editorView.dom.offsetParent;this.element||(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r);let u,p;if(!d||d==document.body&&getComputedStyle(d).position=="static")u=-pageXOffset,p=-pageYOffset;else{let f=d.getBoundingClientRect(),y=f.width/d.offsetWidth,_=f.height/d.offsetHeight;u=f.left-d.scrollLeft*y,p=f.top-d.scrollTop*_}this.element.style.left=(n.left-u)/l+"px",this.element.style.top=(n.top-p)/i+"px",this.element.style.width=(n.right-n.left)/l+"px",this.element.style.height=(n.bottom-n.top)/i+"px"}scheduleRemoval(s){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),s)}dragover(s){if(!this.editorView.editable)return;let r=this.editorView.posAtCoords({left:s.clientX,top:s.clientY}),n=r&&r.inside>=0&&this.editorView.state.doc.nodeAt(r.inside),a=n&&n.type.spec.disableDropCursor,o=typeof a=="function"?a(this.editorView,r,s):a;if(r&&!o){let l=r.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let i=GQe(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 R9t=fh.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[L9t(this.options)]}});class Xc extends ei{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return Xc.valid(n)?new Xc(n):ei.near(n)}content(){return yn.empty}eq(s){return s instanceof Xc&&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 Xc(s.resolve(r.pos))}getBookmark(){return new Yke(this.anchor)}static valid(s){let r=s.parent;if(r.inlineContent||!O9t(s)||!F9t(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&&Xc.valid(s))return s;let a=s.pos,o=null;for(let l=s.depth;;l--){let i=s.node(l);if(r>0?s.indexAfter(l)0){o=i.child(r>0?s.indexAfter(l):s.index(l)-1);break}else if(l==0)return null;a+=r;let d=s.doc.resolve(a);if(Xc.valid(d))return d}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!Ea.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(Xc.valid(i))return i}return null}}}Xc.prototype.visible=!1;Xc.findFrom=Xc.findGapCursorFrom;ei.jsonID("gapcursor",Xc);class Yke{constructor(s){this.pos=s}map(s){return new Yke(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return Xc.valid(r)?new Xc(r):ei.near(r)}}function cet(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function O9t(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||cet(a.type))return!0;if(a.inlineContent)return!1}}return!0}function F9t(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||cet(a.type))return!0;if(a.inlineContent)return!1}}return!0}function z9t(){return new gu({props:{decorations:U9t,createSelectionBetween(t,s,r){return s.pos==r.pos&&Xc.valid(r)?new Xc(r):null},handleClick:$9t,handleKeyDown:B9t,handleDOMEvents:{beforeinput:q9t}}})}const B9t=Lke({ArrowLeft:Uz("horiz",-1),ArrowRight:Uz("horiz",1),ArrowUp:Uz("vert",-1),ArrowDown:Uz("vert",1)});function Uz(t,s){const r=t=="vert"?s>0?"down":"up":s>0?"right":"left";return function(n,a,o){let l=n.selection,i=s>0?l.$to:l.$from,d=l.empty;if(l instanceof Oa){if(!o.endOfTextblock(r)||i.depth==0)return!1;d=!1,i=n.doc.resolve(s>0?i.after():i.before())}let u=Xc.findGapCursorFrom(i,s,d);return u?(a&&a(n.tr.setSelection(new Xc(u))),!0):!1}}function $9t(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!Xc.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&Ea.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Xc(n))),!0)}function q9t(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof Xc))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=Er.empty;for(let l=n.length-1;l>=0;l--)a=Er.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new yn(a,0,0));return o.setSelection(Oa.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function U9t(t){if(!(t.selection instanceof Xc))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",Yc.create(t.doc,[vm.widget(t.selection.head,s,{key:"gapcursor"})])}const V9t=fh.create({name:"gapCursor",addProseMirrorPlugins(){return[z9t()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=Li(na(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),H9t=Gh.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",kc(this.options.HTMLAttributes,t)]},renderText(){return` `},addCommands(){return{setHardBreak:()=>({commands:t,chain:s,state:r,editor:n})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:a,storedMarks:o}=r;if(a.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:i}=n.extensionManager,d=o||a.$to.parentOffset&&a.$from.marks();return s().insertContent({type:this.name}).command(({tr:u,dispatch:p})=>{if(p&&d&&l){const f=d.filter(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()}}}),G9t=Gh.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]}`,kc(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=>P_e({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Dle=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 det(s):zu.empty};var det=function(t){function s(n){t.call(this),this.values=n}t&&(s.__proto__=t),s.prototype=Object.create(t&&t.prototype),s.prototype.constructor=s;var r={length:{configurable:!0},depth:{configurable:!0}};return s.prototype.flatten=function(){return this.values},s.prototype.sliceInner=function(a,o){return a==0&&o==this.length?this:new s(this.values.slice(a,o))},s.prototype.getInner=function(a){return this.values[a]},s.prototype.forEachInner=function(a,o,l,i){for(var d=o;d=l;d--)if(a(this.values[d],i+d)===!1)return!1},s.prototype.leafAppend=function(a){if(this.length+a.length<=Dle)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=Dle)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 det([]);var W9t=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 K9t=500;class Cg{constructor(s,r){this.items=s,this.eventCount=r}popEvent(s,r){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let a,o;r&&(a=this.remapping(n,this.items.length),o=a.maps.length);let l=s.tr,i,d,u=[],p=[];return this.items.forEach((f,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 Ty(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 Ty(b,void 0,void 0,u.length+p.length))),o--,b&&a.appendMap(b,o)}else l.maybeStep(f.step);if(f.selection)return i=a?f.selection.map(a.slice(o)):f.selection,d=new Cg(this.items.slice(0,n).append(p.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:d,transform:l,selection:i}}addTransform(s,r,n,a){let o=[],l=this.eventCount,i=this.items,d=!a&&i.length?i.get(i.length-1):null;for(let p=0;pY9t&&(i=Z9t(i,u),l-=u),new Cg(i.append(o),l)}remapping(s,r){let n=new pD;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 Cg(this.items.append(s.map(r=>new Ty(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 d=r;this.items.forEach(y=>{let _=o.getMirror(--d);if(_==null)return;l=Math.min(l,_);let b=o.maps[_];if(y.step){let N=s.steps[_].invert(s.docs[_]),w=y.selection&&y.selection.map(o.slice(d+1,_));w&&i++,n.push(new Ty(b,N,w))}else n.push(new Ty(b))},a);let u=[];for(let y=r;yK9t&&(f=f.compress(this.items.length-n.length)),f}emptyItemCount(){let s=0;return this.items.forEach(r=>{r.step||s++}),s}compress(s=this.items.length){let r=this.remapping(0,s),n=r.maps.length,a=[],o=0;return this.items.forEach((l,i)=>{if(i>=s)a.push(l),l.selection&&o++;else if(l.step){let d=l.step.map(r.slice(n)),u=d&&d.getMap();if(n--,u&&r.appendMap(u,n),d){let p=l.selection&&l.selection.map(r.slice(n));p&&o++;let f=new Ty(u.invert(),d,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 Cg(zu.from(a.reverse()),o)}}Cg.empty=new Cg(zu.empty,0);function Z9t(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class Ty{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 Ty(r.getMap().invert(),r,this.selection)}}}class $_{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const Y9t=20;function X9t(t,s,r,n){let a=r.getMeta(PS),o;if(a)return a.historyState;r.getMeta(eBt)&&(t=new $_(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(PS))return l.getMeta(PS).redo?new $_(t.done.addTransform(r,void 0,n,soe(s)),t.undone,F8e(r.mapping.maps),t.prevTime,t.prevComposition):new $_(t.done,t.undone.addTransform(r,void 0,n,soe(s)),null,t.prevTime,t.prevComposition);if(r.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let i=r.getMeta("composition"),d=t.prevTime==0||!l&&t.prevComposition!=i&&(t.prevTime<(r.time||0)-n.newGroupDelay||!Q9t(r,t.prevRanges)),u=l?dye(t.prevRanges,r.mapping):F8e(r.mapping.maps);return new $_(t.done.addTransform(r,d?s.selection.getBookmark():void 0,n,soe(s)),Cg.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new $_(t.done.rebased(r,o),t.undone.rebased(r,o),dye(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new $_(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),dye(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function Q9t(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 F8e(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 dye(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=PS.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=J9t(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const het=uet(!1,!0),met=uet(!0,!0),sBt=fh.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>het(t,s),redo:()=>({state:t,dispatch:s})=>met(t,s)}},addProseMirrorPlugins(){return[tBt(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()}}}),rBt=Gh.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",kc(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!Qzt(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}):_zt(r)?o.insertContentAt(a.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:l,dispatch:i})=>{var d;if(i){const{$to:u}=l.selection,p=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?l.setSelection(Oa.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Ea.create(l.doc,u.pos)):l.setSelection(Oa.create(l.doc,u.pos));else{const f=(d=u.parent.type.contentMatch.defaultType)===null||d===void 0?void 0:d.create();f&&(l.insert(p,f),l.setSelection(Oa.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[aet({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),nBt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,aBt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,iBt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,oBt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,lBt=Hg.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",kc(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[VT({find:nBt,type:this.type}),VT({find:iBt,type:this.type})]},addPasteRules(){return[nC({find:aBt,type:this.type}),nC({find:oBt,type:this.type})]}}),cBt=Gh.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",kc(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)}}}),dBt="listItem",B8e="textStyle",$8e=/^(\d+)\.\s$/,uBt=Gh.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",kc(this.options.HTMLAttributes,r),0]:["ol",kc(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(dBt,this.editor.getAttributes(B8e)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=bD({find:$8e,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=bD({find:$8e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(B8e)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),hBt=Gh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",kc(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),mBt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,pBt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,fBt=Hg.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",kc(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[VT({find:mBt,type:this.type})]},addPasteRules(){return[nC({find:pBt,type:this.type})]}}),xBt=Gh.create({name:"text",group:"inline"}),Xke=fh.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(N9t.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(v9t.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(S9t.configure(this.options.bulletList)),this.options.code!==!1&&t.push(T9t.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(P9t.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(I9t.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(R9t.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(V9t.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(H9t.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(G9t.configure(this.options.heading)),this.options.history!==!1&&t.push(sBt.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(rBt.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(lBt.configure(this.options.italic)),this.options.listItem!==!1&&t.push(cBt.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(uBt.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(hBt.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(fBt.configure(this.options.strike)),this.options.text!==!1&&t.push(xBt.configure(this.options.text)),t}}),gBt="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",yBt="ελ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",D_e="numeric",R_e="ascii",O_e="alpha",u8="asciinumeric",z6="alphanumeric",F_e="domain",pet="emoji",vBt="scheme",_Bt="slashscheme",hye="whitespace";function bBt(t,s){return t in s||(s[t]=[]),s[t]}function S4(t,s,r){s[D_e]&&(s[u8]=!0,s[z6]=!0),s[R_e]&&(s[u8]=!0,s[O_e]=!0),s[u8]&&(s[z6]=!0),s[O_e]&&(s[z6]=!0),s[z6]&&(s[F_e]=!0),s[pet]&&(s[F_e]=!0);for(const n in s){const a=bBt(n,r);a.indexOf(t)<0&&a.push(t)}}function wBt(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function rp(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}rp.groups={};rp.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),qc=(t,s,r,n,a)=>t.tr(s,r,n,a),q8e=(t,s,r,n,a)=>t.ts(s,r,n,a),Vr=(t,s,r,n,a)=>t.tt(s,r,n,a),vv="WORD",z_e="UWORD",fet="ASCIINUMERICAL",xet="ALPHANUMERICAL",wD="LOCALHOST",B_e="TLD",$_e="UTLD",roe="SCHEME",B5="SLASH_SCHEME",Qke="NUM",q_e="WS",Jke="NL",h8="OPENBRACE",m8="CLOSEBRACE",Rle="OPENBRACKET",Ole="CLOSEBRACKET",Fle="OPENPAREN",zle="CLOSEPAREN",Ble="OPENANGLEBRACKET",$le="CLOSEANGLEBRACKET",qle="FULLWIDTHLEFTPAREN",Ule="FULLWIDTHRIGHTPAREN",Vle="LEFTCORNERBRACKET",Hle="RIGHTCORNERBRACKET",Gle="LEFTWHITECORNERBRACKET",Wle="RIGHTWHITECORNERBRACKET",Kle="FULLWIDTHLESSTHAN",Zle="FULLWIDTHGREATERTHAN",Yle="AMPERSAND",Xle="APOSTROPHE",Qle="ASTERISK",q_="AT",Jle="BACKSLASH",ece="BACKTICK",tce="CARET",X_="COLON",e4e="COMMA",sce="DOLLAR",Ay="DOT",rce="EQUALS",t4e="EXCLAMATION",ex="HYPHEN",p8="PERCENT",nce="PIPE",ace="PLUS",ice="POUND",f8="QUERY",s4e="QUOTE",get="FULLWIDTHMIDDLEDOT",r4e="SEMI",Ey="SLASH",x8="TILDE",oce="UNDERSCORE",yet="EMOJI",lce="SYM";var vet=Object.freeze({__proto__:null,ALPHANUMERICAL:xet,AMPERSAND:Yle,APOSTROPHE:Xle,ASCIINUMERICAL:fet,ASTERISK:Qle,AT:q_,BACKSLASH:Jle,BACKTICK:ece,CARET:tce,CLOSEANGLEBRACKET:$le,CLOSEBRACE:m8,CLOSEBRACKET:Ole,CLOSEPAREN:zle,COLON:X_,COMMA:e4e,DOLLAR:sce,DOT:Ay,EMOJI:yet,EQUALS:rce,EXCLAMATION:t4e,FULLWIDTHGREATERTHAN:Zle,FULLWIDTHLEFTPAREN:qle,FULLWIDTHLESSTHAN:Kle,FULLWIDTHMIDDLEDOT:get,FULLWIDTHRIGHTPAREN:Ule,HYPHEN:ex,LEFTCORNERBRACKET:Vle,LEFTWHITECORNERBRACKET:Gle,LOCALHOST:wD,NL:Jke,NUM:Qke,OPENANGLEBRACKET:Ble,OPENBRACE:h8,OPENBRACKET:Rle,OPENPAREN:Fle,PERCENT:p8,PIPE:nce,PLUS:ace,POUND:ice,QUERY:f8,QUOTE:s4e,RIGHTCORNERBRACKET:Hle,RIGHTWHITECORNERBRACKET:Wle,SCHEME:roe,SEMI:r4e,SLASH:Ey,SLASH_SCHEME:B5,SYM:lce,TILDE:x8,TLD:B_e,UNDERSCORE:oce,UTLD:$_e,UWORD:z_e,WORD:vv,WS:q_e});const mv=/[a-z]/,o6=new RegExp("\\p{L}","u"),mye=new RegExp("\\p{Emoji}","u"),pv=/\d/,pye=/\s/,U8e="\r",fye=` `,jBt="️",NBt="‍",xye="";let Vz=null,Hz=null;function kBt(t=[]){const s={};rp.groups=s;const r=new rp;Vz==null&&(Vz=V8e(gBt)),Hz==null&&(Hz=V8e(yBt)),Vr(r,"'",Xle),Vr(r,"{",h8),Vr(r,"}",m8),Vr(r,"[",Rle),Vr(r,"]",Ole),Vr(r,"(",Fle),Vr(r,")",zle),Vr(r,"<",Ble),Vr(r,">",$le),Vr(r,"(",qle),Vr(r,")",Ule),Vr(r,"「",Vle),Vr(r,"」",Hle),Vr(r,"『",Gle),Vr(r,"』",Wle),Vr(r,"<",Kle),Vr(r,">",Zle),Vr(r,"&",Yle),Vr(r,"*",Qle),Vr(r,"@",q_),Vr(r,"`",ece),Vr(r,"^",tce),Vr(r,":",X_),Vr(r,",",e4e),Vr(r,"$",sce),Vr(r,".",Ay),Vr(r,"=",rce),Vr(r,"!",t4e),Vr(r,"-",ex),Vr(r,"%",p8),Vr(r,"|",nce),Vr(r,"+",ace),Vr(r,"#",ice),Vr(r,"?",f8),Vr(r,'"',s4e),Vr(r,"/",Ey),Vr(r,";",r4e),Vr(r,"~",x8),Vr(r,"_",oce),Vr(r,"\\",Jle),Vr(r,"・",get);const n=qc(r,pv,Qke,{[D_e]:!0});qc(n,pv,n);const a=qc(n,mv,fet,{[u8]:!0}),o=qc(n,o6,xet,{[z6]:!0}),l=qc(r,mv,vv,{[R_e]:!0});qc(l,pv,a),qc(l,mv,l),qc(a,pv,a),qc(a,mv,a);const i=qc(r,o6,z_e,{[O_e]:!0});qc(i,mv),qc(i,pv,o),qc(i,o6,i),qc(o,pv,o),qc(o,mv),qc(o,o6,o);const d=Vr(r,fye,Jke,{[hye]:!0}),u=Vr(r,U8e,q_e,{[hye]:!0}),p=qc(r,pye,q_e,{[hye]:!0});Vr(r,xye,p),Vr(u,fye,d),Vr(u,xye,p),qc(u,pye,p),Vr(p,U8e),Vr(p,fye),qc(p,pye,p),Vr(p,xye,p);const f=qc(r,mye,yet,{[pet]:!0});Vr(f,"#"),qc(f,mye,f),Vr(f,jBt,f);const y=Vr(f,NBt);Vr(y,"#"),qc(y,mye,f);const _=[[mv,l],[pv,a]],b=[[mv,null],[o6,i],[pv,o]];for(let N=0;NN[0]>w[0]?1:-1);for(let N=0;N=0?C[F_e]=!0:mv.test(w)?pv.test(w)?C[u8]=!0:C[R_e]=!0:C[D_e]=!0,q8e(r,w,w,C)}return q8e(r,"localhost",wD,{ascii:!0}),r.jd=new rp(lce),{start:r,tokens:Object.assign({groups:s},vet)}}function _et(t,s){const r=SBt(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 SBt(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 w_(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 jD={defaultProtocol:"http",events:null,format:H8e,formatHref:H8e,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function n4e(t,s=null){let r=Object.assign({},jD);t&&(r=Object.assign(r,t instanceof n4e?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=jD.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const s=this,r=this.toHref(t.get("defaultProtocol")),n=t.get("formatHref",r,this),a=t.get("tagName",r,s),o=this.toFormattedString(t),l={},i=t.get("className",r,s),d=t.get("target",r,s),u=t.get("rel",r,s),p=t.getObj("attributes",r,s),f=t.getObj("events",r,s);return l.href=n,i&&(l.class=i),d&&(l.target=d),u&&(l.rel=u),p&&Object.assign(l,p),{tagName:a,attributes:l,content:o,eventListeners:f}}};function whe(t,s){class r extends bet{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 G8e=whe("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),W8e=whe("text"),CBt=whe("nl"),Gz=whe("url",{isLink:!0,toHref(t=jD.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==wD&&t[1].t===X_}}),Wf=t=>new rp(t);function MBt({groups:t}){const s=t.domain.concat([Yle,Qle,q_,Jle,ece,tce,sce,rce,ex,Qke,p8,nce,ace,ice,Ey,lce,x8,oce]),r=[Xle,X_,e4e,Ay,t4e,p8,f8,s4e,r4e,Ble,$le,h8,m8,Ole,Rle,Fle,zle,qle,Ule,Vle,Hle,Gle,Wle,Kle,Zle],n=[Yle,Xle,Qle,Jle,ece,tce,sce,rce,ex,h8,m8,p8,nce,ace,ice,f8,Ey,lce,x8,oce],a=Wf(),o=Vr(a,x8);Ii(o,n,o),Ii(o,t.domain,o);const l=Wf(),i=Wf(),d=Wf();Ii(a,t.domain,l),Ii(a,t.scheme,i),Ii(a,t.slashscheme,d),Ii(l,n,o),Ii(l,t.domain,l);const u=Vr(l,q_);Vr(o,q_,u),Vr(i,q_,u),Vr(d,q_,u);const p=Vr(o,Ay);Ii(p,n,o),Ii(p,t.domain,o);const f=Wf();Ii(u,t.domain,f),Ii(f,t.domain,f);const y=Vr(f,Ay);Ii(y,t.domain,f);const _=Wf(G8e);Ii(y,t.tld,_),Ii(y,t.utld,_),Vr(u,wD,_);const b=Vr(f,ex);Vr(b,ex,b),Ii(b,t.domain,f),Ii(_,t.domain,f),Vr(_,Ay,y),Vr(_,ex,b);const N=Vr(_,X_);Ii(N,t.numeric,G8e);const w=Vr(l,ex),S=Vr(l,Ay);Vr(w,ex,w),Ii(w,t.domain,l),Ii(S,n,o),Ii(S,t.domain,l);const C=Wf(Gz);Ii(S,t.tld,C),Ii(S,t.utld,C),Ii(C,t.domain,l),Ii(C,n,o),Vr(C,Ay,S),Vr(C,ex,w),Vr(C,q_,u);const A=Vr(C,X_),I=Wf(Gz);Ii(A,t.numeric,I);const L=Wf(Gz),O=Wf();Ii(L,s,L),Ii(L,r,O),Ii(O,s,L),Ii(O,r,O),Vr(C,Ey,L),Vr(I,Ey,L);const U=Vr(i,X_),q=Vr(d,X_),$=Vr(q,Ey),V=Vr($,Ey);Ii(i,t.domain,l),Vr(i,Ay,S),Vr(i,ex,w),Ii(d,t.domain,l),Vr(d,Ay,S),Vr(d,ex,w),Ii(U,t.domain,L),Vr(U,Ey,L),Vr(U,f8,L),Ii(V,t.domain,L),Ii(V,s,L),Vr(V,Ey,L);const ee=[[h8,m8],[Rle,Ole],[Fle,zle],[Ble,$le],[qle,Ule],[Vle,Hle],[Gle,Wle],[Kle,Zle]];for(let Z=0;Z=0&&y++,a++,p++;if(y<0)a-=p,a0&&(o.push(gye(W8e,s,l)),l=[]),a-=y,p-=y;const _=f.t,b=r.slice(a-p,a);o.push(gye(_,s,b))}}return l.length>0&&o.push(gye(W8e,s,l)),o}function gye(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 ABt=typeof console<"u"&&console&&console.warn||(()=>{}),EBt="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Zl={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function PBt(){return rp.groups={},Zl.scanner=null,Zl.parser=null,Zl.tokenQueue=[],Zl.pluginQueue=[],Zl.customSchemes=[],Zl.initialized=!1,Zl}function K8e(t,s=!1){if(Zl.initialized&&ABt(`linkifyjs: already initialized - will not register custom scheme "${t}" ${EBt}`),!/^[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`);Zl.customSchemes.push([t,s])}function IBt(){Zl.scanner=kBt(Zl.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=uzt(r.doc,[...s]);if(yzt(i).forEach(({newRange:u})=>{const p=mzt(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(!DBt.test(_))return;f=p[0],y=n.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&y){const _=y.split(LBt).filter(Boolean);if(_.length<=0)return!1;const b=_[_.length-1],N=f.pos+y.lastIndexOf(b);if(!b)return!1;const w=a4e(b).map(S=>S.toObject(t.defaultProtocol));if(!OBt(w))return!1;w.filter(S=>S.isLink).map(S=>({...S,from:N+S.start+1,to:N+S.end+1})).filter(S=>n.schema.marks.code?!n.doc.rangeHasMark(S.from,S.to,n.schema.marks.code):!0).filter(S=>t.validate(S.value)).filter(S=>t.shouldAutoLink(S.value)).forEach(S=>{Vke(S.from,S.to,n.doc).some(C=>C.mark.type===t.type)||l.addMark(S.from,S.to,t.type.create({href:S.href}))})}}),!!l.steps.length)return l}})}function zBt(t){return new gu({key:new Hh("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 d=net(s.state,t.type.name),u=n.target,p=(a=u==null?void 0:u.href)!==null&&a!==void 0?a:d.href,f=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:d.target;return u&&p?(window.open(p,f),!0):!1}}})}function BBt(t){return new gu({key:new Hh("handlePasteLink"),props:{handlePaste:(s,r,n)=>{const{state:a}=s,{selection:o}=a,{empty:l}=o;if(l)return!1;let i="";n.content.forEach(u=>{i+=u.textContent});const d=wet(i,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===i);return!i||!d?!1:t.editor.commands.setMark(t.type,{href:d.href})}}})}function $2(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(RBt,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const o4e=Hg.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"){K8e(t);return}K8e(t.scheme,t.optionalSlashes)})},onDestroy(){PBt()},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)=>!!$2(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=>!!$2(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=>!!$2(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",kc(this.options.HTMLAttributes,t),0]:["a",kc(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!$2(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=>!!$2(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[nC({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=wet(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!$2(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(FBt({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!$2(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(zBt({type:this.type})),this.options.linkOnPaste&&t.push(BBt({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),l4e=fh.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")}}}),$Bt=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}`)})},c4e=Hg.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&$Bt(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",kc(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}}}}),qBt=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,UBt=Gh.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",kc(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[aet({find:qBt,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let U_e,V_e;if(typeof WeakMap<"u"){let t=new WeakMap;U_e=s=>t.get(s),V_e=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;U_e=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var Jc=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:S-A});break}const I=a+A*s;for(let L=0;Ln&&(o+=u.attrs.colspan)}}for(let l=0;l1&&(r=!0)}s==-1?s=o:s!=o&&(s=Math.max(s,o))}return s}function GBt(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 KBt(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 Zg(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 jhe(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=aC(s.$head)||ZBt(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function ZBt(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 H_e(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function YBt(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function d4e(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function jet(t,s,r){const n=t.node(-1),a=Jc.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 iC(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 Net(t,s,r=1){const n={...t,colspan:t.colspan+r};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let a=0;ap!=r.pos-o);d.unshift(r.pos-o);const u=d.map(p=>{const f=n.nodeAt(p);if(!f)throw new RangeError(`No cell with offset ${p} found`);const y=o+p+1;return new XQe(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(H_e(n)&&H_e(a)&&d4e(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?_v.rowSelection(n,a):o&&this.isColSelection()?_v.colSelection(n,a):new _v(n,a)}return Oa.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=Jc.get(s),n=this.$anchorCell.start(-1),a=r.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},l=[];for(let d=a.top;d0||w>0){let S=b.attrs;if(N>0&&(S=iC(S,0,N)),w>0&&(S=iC(S,S.colspan-w,w)),_.lefta.bottom){const S={...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=Jc.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),d=s.node(0);return l.top<=i.top?(l.top>0&&(s=d.resolve(o+a.map[l.left])),i.bottom0&&(r=d.resolve(o+a.map[i.left])),l.bottom0)return!1;const l=a+this.$anchorCell.nodeAfter.attrs.colspan,i=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,i)==r.width}eq(s){return s instanceof _v&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=Jc.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),d=s.node(0);return l.left<=i.left?(l.left>0&&(s=d.resolve(o+a.map[l.top*a.width])),i.right0&&(r=d.resolve(o+a.map[i.top*a.width])),l.right{s.push(vm.node(n,n+r.nodeSize,{class:"selectedCell"}))}),Yc.create(t.doc,s)}function e$t({$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 t$t({$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 s$t(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof Ea&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=Ol.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=Ol.rowSelection(i,i)}else if(!r){const i=Jc.get(n.node),d=n.from+1,u=d+i.map[i.width*i.height-1];o=Ol.create(a,d+1,u)}}else n instanceof Oa&&e$t(n)?o=Oa.create(a,n.from):n instanceof Oa&&t$t(n)&&(o=Oa.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const r$t=new Hh("fix-tables");function Cet(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=n$t(t,a,o,r))};return s?s.doc!=t.doc&&Cet(s.doc,t.doc,0,n):t.doc.descendants(n),r}function n$t(t,s,r,n){const a=Jc.get(s);if(!a.problems)return n;n||(n=t.tr);const o=[];for(let d=0;d0){let _="cell";p.firstChild&&(_=p.firstChild.type.spec.tableRole);const b=[];for(let w=0;w0?-1:0;XBt(s,n,a+o)&&(o=a==0||a==s.width?null:0);for(let l=0;l0&&a0&&s.map[i-1]==d||a0?-1:0;c$t(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=d+1+u.content.size,f=Z8e(u)?d+1:p;o.replaceWith(f+n.tableStart,p+n.tableStart,i)}o.setSelection(new Ol(o.doc.resolve(d+n.tableStart))),s(o)}return!0}function X8e(t,s){const r=qh(t.schema);return f$t(({node:n})=>r[n.type.spec.tableRole])(t,s)}function f$t(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof Ol){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=KBt(n.$from),!a)return!1;o=(l=aC(n.$from))===null||l===void 0?void 0:l.pos}if(a==null||o==null||a.attrs.colspan==1&&a.attrs.rowspan==1)return!1;if(r){let i=a.attrs;const d=[],u=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const p=j0(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 g$t(t){return function(s,r){if(!Zg(s))return!1;if(r){const n=qh(s.schema),a=j0(s),o=s.tr,l=a.map.cellsInRect(t=="column"?{left:a.left,top:0,right:a.right,bottom:a.map.height}:t=="row"?{left:0,top:a.top,right:a.map.width,bottom:a.bottom}:a),i=l.map(d=>a.table.nodeAt(d));for(let d=0;d{const _=y+o.tableStart,b=l.doc.nodeAt(_);b&&l.setNodeMarkup(_,f,b.attrs)}),n(l)}return!0}}ND("row",{useDeprecatedLogic:!0});ND("column",{useDeprecatedLogic:!0});const y$t=ND("cell",{useDeprecatedLogic:!0});function v$t(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 Wz(t,s){const r=t.selection;if(!(r instanceof Ol))return!1;if(s){const n=t.tr,a=qh(t.schema).cell.createAndFill().content;r.forEachCell((o,l)=>{o.content.eq(a)||n.replace(n.mapping.map(l+1),n.mapping.map(l+o.nodeSize-1),new yn(a,0,0))}),n.docChanged&&s(n)}return!0}function b$t(t){if(t.size===0)return null;let{content:s,openStart:r,openEnd:n}=t;for(;s.childCount==1&&(r>0&&n>0||s.child(0).type.spec.tableRole=="table");)r--,n--,s=s.child(0).content;const a=s.child(0),o=a.type.spec.tableRole,l=a.type.schema,i=[];if(o=="row")for(let d=0;d=0;l--){const{rowspan:i,colspan:d}=o.child(l).attrs;for(let u=a;u=s.length&&s.push(Er.empty),r[a]n&&(y=y.type.createChecked(iC(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)),d.push(f)}o.push(Er.from(d))}r=o,s=a}return{width:t,height:s,rows:r}}function N$t(t,s,r,n,a,o,l){const i=t.doc.type.schema,d=qh(i);let u,p;if(a>s.width)for(let f=0,y=0;fs.height){const f=[];for(let b=0,N=(s.height-1)*s.width;b=s.width?!1:r.nodeAt(s.map[N+b]).type==d.header_cell;f.push(w?p||(p=d.header_cell.createAndFill()):u||(u=d.cell.createAndFill()))}const y=d.row.create(null,Er.from(f)),_=[];for(let b=s.height;b{if(!a)return!1;const o=r.selection;if(o instanceof Ol)return noe(r,n,ei.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=Eet(a,t,s);if(l==null)return!1;if(t=="horiz")return noe(r,n,ei.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),d=jet(i,t,s);let u;return d?u=ei.near(d,1):s<0?u=ei.near(r.doc.resolve(i.before(-1)),-1):u=ei.near(r.doc.resolve(i.after(-1)),1),noe(r,n,u)}}}function Zz(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof Ol)l=o;else{const d=Eet(a,t,s);if(d==null)return!1;l=new Ol(r.doc.resolve(d))}const i=jet(l.$headCell,t,s);return i?noe(r,n,new Ol(l.$anchorCell,i)):!1}}function S$t(t,s){const r=t.state.doc,n=aC(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new Ol(n))),!0):!1}function C$t(t,s,r){if(!Zg(t.state))return!1;let n=b$t(r);const a=t.state.selection;if(a instanceof Ol){n||(n={width:1,height:1,rows:[Er.from(G_e(qh(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=Jc.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=j$t(n,i.right-i.left,i.bottom-i.top),sDe(t.state,t.dispatch,l,i,n),!0}else if(n){const o=jhe(t.state),l=o.start(-1);return sDe(t.state,t.dispatch,l,Jc.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function M$t(t,s){var r;if(s.button!=0||s.ctrlKey||s.metaKey)return;const n=rDe(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof Ol)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=aC(t.state.selection.$anchor))!=null&&((r=yye(t,s))===null||r===void 0?void 0:r.pos)!=a.pos)o(a,s),s.preventDefault();else if(!n)return;function o(d,u){let p=yye(t,u);const f=Q_.getState(t.state)==null;if(!p||!d4e(d,p))if(f)p=d;else return;const y=new Ol(d,p);if(f||!t.state.selection.eq(y)){const _=t.state.tr.setSelection(y);f&&_.setMeta(Q_,d.pos),t.dispatch(_)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),Q_.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Q_,-1))}function i(d){const u=d,p=Q_.getState(t.state);let f;if(p!=null)f=t.state.doc.resolve(p);else if(rDe(t,u.target)!=n&&(f=yye(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 Eet(t,s,r){if(!(t.state.selection instanceof Oa))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 rDe(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function yye(t,s){const r=t.posAtCoords({left:s.clientX,top:s.clientY});if(!r)return null;let{inside:n,pos:a}=r;return n>=0&&aC(t.state.doc.resolve(n))||aC(t.state.doc.resolve(a))}var T$t=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")),W_e(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,W_e(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function W_e(t,s,r,n,a,o){let l=0,i=!0,d=s.firstChild;const u=t.firstChild;if(u){for(let f=0,y=0;fnew n(f,r,y)),new E$t(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=tf.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{P$t(l,i,t,a)},mouseleave:l=>{I$t(l)},mousedown:(l,i)=>{L$t(l,i,s,r)}},decorations:l=>{const i=tf.getState(l);if(i&&i.activeHandle>-1)return z$t(l,i.activeHandle)},nodeViews:{}}});return o}var E$t=class aoe{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(tf);if(n&&n.setHandle!=null)return new aoe(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new aoe(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return H_e(s.doc.resolve(a))||(a=-1),new aoe(a,r.dragging)}return r}};function P$t(t,s,r,n){if(!t.editable)return;const a=tf.getState(t.state);if(a&&!a.dragging){const o=R$t(s.target);let l=-1;if(o){const{left:i,right:d}=o.getBoundingClientRect();s.clientX-i<=r?l=nDe(t,s,"left",r):d-s.clientX<=r&&(l=nDe(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),d=i.node(-1),u=Jc.get(d),p=i.start(-1);if(u.colCount(i.pos-p)+i.nodeAfter.attrs.colspan-1==u.width-1)return}Pet(t,l)}}}function I$t(t){if(!t.editable)return;const s=tf.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&Pet(t,-1)}function L$t(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=tf.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),d=D$t(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(tf,{setDragging:{startX:s.clientX,startWidth:d}}));function u(f){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",p);const y=tf.getState(t.state);y!=null&&y.dragging&&(O$t(t,y.activeHandle,aDe(y.dragging,f,r)),t.dispatch(t.state.tr.setMeta(tf,{setDragging:null})))}function p(f){if(!f.which)return u(f);const y=tf.getState(t.state);if(y&&y.dragging){const _=aDe(y.dragging,f,r);iDe(t,y.activeHandle,_,n)}}return iDe(t,l.activeHandle,d,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",p),s.preventDefault(),!0}function D$t(t,s,{colspan:r,colwidth:n}){const a=n&&n[n.length-1];if(a)return a;const o=t.domAtPos(s);let l=o.node.childNodes[o.offset].offsetWidth,i=r;if(n)for(let d=0;d{const n=t.nodes[r];n.spec.tableRole&&(s[n.spec.tableRole]=n)}),t.cached.tableNodeTypes=s,s}function V$t(t,s,r,n,a){const o=U$t(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!H$t(s))return!1;let r=0;const n=ret(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},G$t=Gh.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:$$t,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}=q$t(t,this.options.cellMinWidth),o=["table",kc(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=V$t(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(Oa.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>a$t(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>i$t(t,s),deleteColumn:()=>({state:t,dispatch:s})=>l$t(t,s),addRowBefore:()=>({state:t,dispatch:s})=>d$t(t,s),addRowAfter:()=>({state:t,dispatch:s})=>u$t(t,s),deleteRow:()=>({state:t,dispatch:s})=>m$t(t,s),deleteTable:()=>({state:t,dispatch:s})=>_$t(t,s),mergeCells:()=>({state:t,dispatch:s})=>Y8e(t,s),splitCell:()=>({state:t,dispatch:s})=>X8e(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>ND("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>ND("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>y$t(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>Y8e(t,s)?!0:X8e(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>x$t(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>J8e(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>J8e(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&Met(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=Ol.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:Yz,"Mod-Backspace":Yz,Delete:Yz,"Mod-Delete":Yz}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[A$t({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],B$t({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:Li(na(t,"tableRole",s))}}}),W$t=Gh.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",kc(this.options.HTMLAttributes,t),0]}}),K$t=Gh.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",kc(this.options.HTMLAttributes,t),0]}}),Z$t=Gh.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",kc(this.options.HTMLAttributes,t),0]}});function Yg({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=k.useState(!1),[i,d]=k.useState(""),[u,p]=k.useState(!0),f=Zke({extensions:[Xke,o4e.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),l4e.configure({types:["heading","paragraph"]}),c4e,UBt.extend({addAttributes(){var N;return{...(N=this.parent)==null?void 0:N.call(this),width:{default:null},height:{default:null},style:{default:null}}}}).configure({inline:!0,allowBase64:!0}),G$t.extend({addAttributes(){var N;return{...(N=this.parent)==null?void 0:N.call(this),style:{default:null},width:{default:null},cellpadding:{default:null},cellspacing:{default:null},border:{default:null}}}}).configure({resizable:!1}),W$t.extend({addAttributes(){var N;return{...(N=this.parent)==null?void 0:N.call(this),style:{default:null}}}}),K$t.extend({addAttributes(){var N;return{...(N=this.parent)==null?void 0:N.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1},valign:{default:null}}}}),Z$t.extend({addAttributes(){var N;return{...(N=this.parent)==null?void 0:N.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1}}}})],content:t,onUpdate:({editor:N})=>{s(N.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(N,w)=>{var C;const S=(C=w.clipboardData)==null?void 0:C.items;if(!S)return!1;for(const A of Array.from(S))if(A.type.startsWith("image/")){w.preventDefault();const I=A.getAsFile();if(!I)continue;const L=new FileReader;return L.onload=O=>{var q;const U=(q=O.target)==null?void 0:q.result;N.dispatch(N.state.tr.replaceSelectionWith(N.state.schema.nodes.image.create({src:U})))},L.readAsDataURL(I),!0}return!1}}});k.useEffect(()=>{f&&t!==f.getHTML()&&f.commands.setContent(t)},[t,f]);const y=()=>{if(!f)return;const N=f.getAttributes("link").href||"",w=f.getAttributes("link").target;d(N),p(w==="_blank"),l(!0)},_=()=>{f&&(i===""?f.chain().focus().extendMarkRange("link").unsetLink().run():f.chain().focus().extendMarkRange("link").setLink({href:i,target:u?"_blank":null,rel:u?"noopener noreferrer nofollow":null}).run(),l(!1),d(""))},b=()=>{f&&f.chain().focus().extendMarkRange("link").unsetLink().run()};return f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:1}).run(),className:f.isActive("heading",{level:1})?"bg-muted":"",title:"Heading 1",children:e.jsx(MM,{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(TM,{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(Y4,{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(aS,{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(Rh,{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(Yy,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("left").run(),className:f.isActive({textAlign:"left"})?"bg-muted":"",title:"Align Left",children:e.jsx(W4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("center").run(),className:f.isActive({textAlign:"center"})?"bg-muted":"",title:"Align Center",children:e.jsx(G4,{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(K4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:y,className:f.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(go,{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(go,{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(NS,{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(gS,{className:"h-4 w-4"})})]}),e.jsx(Wke,{editor:f,className:"prose prose-sm max-w-none p-3 focus:outline-none [&_.ProseMirror]:outline-none [&_.ProseMirror_img]:max-w-none [&_.ProseMirror_table]:border-none [&_.ProseMirror_table]:border-collapse [&_.ProseMirror_td]:border-none [&_.ProseMirror_td]:p-0 [&_.ProseMirror_td]:align-top [&_.ProseMirror_th]:border-none [&_.ProseMirror_th]:p-0 [&_.ProseMirror_tr]:border-none",style:{minHeight:n}})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Insert Link"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"link-url",children:"URL"}),e.jsx(Fe,{id:"link-url",value:i,onChange:N=>d(N.target.value),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Lr,{id:"link-new-tab",checked:u,onCheckedChange:p}),e.jsx(ge,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(gn,{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 Y$t=Object.defineProperty,X$t=(t,s,r)=>s in t?Y$t(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,dc=(t,s,r)=>X$t(t,typeof s!="symbol"?s+"":s,r);const cce={x:0,y:0,width:0,height:0,unit:"px"},w5=(t,s,r)=>Math.min(Math.max(t,s),r),Q$t=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),cDe=(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 J$t(t,s,r,n){const a=Py(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==="%"?U_(a,r,n):a}function eqt(t,s,r){const n=Py(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?U_(n,s,r):n}function U_(t,s,r){return t.unit==="%"?{...cce,...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 Py(t,s,r){return t.unit?t.unit==="px"?{...cce,...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}:{...cce,...t,unit:"px"}}function dDe(t,s,r,n,a,o=0,l=0,i=n,d=a){const u={...t};let p=Math.min(o,n),f=Math.min(l,a),y=Math.min(i,n),_=Math.min(d,a);s&&(s>1?(p=l?l*s:p,f=p/s,y=i*s):(f=o?o/s:f,p=f*s,_=d/s)),u.y<0&&(u.height=Math.max(u.height+u.y,f),u.y=0),u.x<0&&(u.width=Math.max(u.width+u.x,p),u.x=0);const b=n-(u.x+u.width);b<0&&(u.x=Math.min(u.x,n-p),u.width+=b);const N=a-(u.y+u.height);if(N<0&&(u.y=Math.min(u.y,a-f),u.height+=N),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 w=u.width/u.height;if(ws){const S=Math.max(u.height*s,p);(r==="sw"||r=="nw")&&(u.x-=S-u.width),u.width=S}}return u}function tqt(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 j5={capture:!0,passive:!1};let sqt=0;const I_=class pg extends k.PureComponent{constructor(){super(...arguments),dc(this,"docMoveBound",!1),dc(this,"mouseDownOnCrop",!1),dc(this,"dragStarted",!1),dc(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),dc(this,"componentRef",k.createRef()),dc(this,"mediaRef",k.createRef()),dc(this,"resizeObserver"),dc(this,"initChangeCalled",!1),dc(this,"instanceId",`rc-${sqt++}`),dc(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),dc(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=Py(r,a.width,a.height);if(n)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const l=s.target.dataset.ord,i=!!l;let d=s.clientX,u=s.clientY,p=o.x,f=o.y;if(l){const y=s.clientX-a.x,_=s.clientY-a.y;let b=0,N=0;l==="ne"||l=="e"?(b=y-(o.x+o.width),N=_-o.y,p=o.x,f=o.y+o.height):l==="se"||l==="s"?(b=y-(o.x+o.width),N=_-(o.y+o.height),p=o.x,f=o.y):l==="sw"||l=="w"?(b=y-o.x,N=_-(o.y+o.height),p=o.x+o.width,f=o.y):(l==="nw"||l=="n")&&(b=y-o.x,N=_-o.y,p=o.x+o.width,f=o.y+o.height),d=p+a.x+b,u=f+a.y+N}this.evData={startClientX:d,startClientY:u,startCropX:p,startCropY:f,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),dc(this,"onComponentPointerDown",s=>{const{crop:r,disabled:n,locked:a,keepSelection:o,onChange:l}=this.props,i=this.getBox();if(n||a||o&&r)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const d=s.clientX-i.x,u=s.clientY-i.y,p={unit:"px",x:d,y:u,width:0,height:0};this.evData={startClientX:s.clientX,startClientY:s.clientY,startCropX:d,startCropY:u,clientX:s.clientX,clientY:s.clientY,isResize:!0},this.mouseDownOnCrop=!0,l(Py(p,i.width,i.height),U_(p,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),dc(this,"onDocPointerMove",s=>{const{crop:r,disabled:n,onChange:a,onDragStart:o}=this.props,l=this.getBox();if(n||!r||!this.mouseDownOnCrop)return;s.cancelable&&s.preventDefault(),this.dragStarted||(this.dragStarted=!0,o&&o(s));const{evData:i}=this;i.clientX=s.clientX,i.clientY=s.clientY;let d;i.isResize?d=this.resizeCrop():d=this.dragCrop(),cDe(r,d)||a(Py(d,l.width,l.height),U_(d,l.width,l.height))}),dc(this,"onComponentKeyDown",s=>{const{crop:r,disabled:n,onChange:a,onComplete:o}=this.props;if(n)return;const l=s.key;let i=!1;if(!r)return;const d=this.getBox(),u=this.makePixelCrop(d),p=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?pg.nudgeStepLarge:s.shiftKey?pg.nudgeStepMedium:pg.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=w5(u.x,0,d.width-u.width),u.y=w5(u.y,0,d.height-u.height);const f=Py(u,d.width,d.height),y=U_(u,d.width,d.height);a(f,y),o&&o(f,y)}}),dc(this,"onHandlerKeyDown",(s,r)=>{const{aspect:n=0,crop:a,disabled:o,minWidth:l=0,minHeight:i=0,maxWidth:d,maxHeight:u,onChange:p,onComplete:f}=this.props,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)?pg.nudgeStepLarge:s.shiftKey?pg.nudgeStepMedium:pg.nudgeStep,b=Py(a,y.width,y.height),N=tqt(b,s.key,_,r),w=dDe(N,n,r,y.width,y.height,l,i,d,u);if(!cDe(a,w)){const S=U_(w,y.width,y.height);p(w,S),f&&f(w,S)}}),dc(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(Py(r,l.width,l.height),U_(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),dc(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(Py(r,a,o),U_(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,j5),this.document.addEventListener("pointerup",this.onDocPointerDone,j5),this.document.addEventListener("pointercancel",this.onDocPointerDone,j5),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,j5),this.document.removeEventListener("pointerup",this.onDocPointerDone,j5),this.document.removeEventListener("pointercancel",this.onDocPointerDone,j5),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=w5(s.startCropX+a,0,r.width-n.width),n.y=w5(s.startCropY+o,0,r.height-n.height),n}getPointRegion(s,r,n,a){const{evData:o}=this,l=o.clientX-s.x,i=o.clientY-s.y;let d;a&&r?d=r==="nw"||r==="n"||r==="ne":d=i1?o?[o,o/r]:[l*r,l]:l?[l*r,l]:[o,o/r]}resizeCrop(){const{evData:s}=this,{aspect:r=0,maxWidth:n,maxHeight:a}=this.props,o=this.getBox(),[l,i]=this.resolveMinDimensions(o,r,this.props.minWidth,this.props.minHeight);let d=this.makePixelCrop(o);const u=this.getPointRegion(o,s.ord,l,i),p=s.ord||u;let f=s.clientX-s.startClientX,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=dDe(_,r,u,o.width,o.height,l,i,n,a);return r||pg.xyOrds.indexOf(p)>-1?d=b:pg.xOrds.indexOf(p)>-1?(d.x=b.x,d.width=b.width):pg.yOrds.indexOf(p)>-1&&(d.y=b.y,d.height=b.height),d.x=w5(d.x,0,o.width-d.width),d.y=w5(d.y,0,o.height-d.height),d}renderCropSelection(){const{ariaLabels:s=pg.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:d=>this.onHandlerKeyDown(d,"nw"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":s.nDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"n"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":s.neDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"ne"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":s.eDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"e"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":s.seDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"se"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":s.sDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"s"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":s.swDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"sw"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":s.wDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"w"),role:"button"})),a&&ht.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:d=>d.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={...cce,...this.props.crop||{}};return Py(r,s.width,s.height)}render(){const{aspect:s,children:r,circularCrop:n,className:a,crop:o,disabled:l,locked:i,style:d,ruleOfThirds:u}=this.props,{cropIsActive:p,newCropIsBeingDrawn:f}=this.state,y=o?this.renderCropSelection():null,_=Q$t("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:d},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)}};dc(I_,"xOrds",["e","w"]),dc(I_,"yOrds",["n","s"]),dc(I_,"xyOrds",["nw","ne","se","sw"]),dc(I_,"nudgeStep",1),dc(I_,"nudgeStepMedium",10),dc(I_,"nudgeStepLarge",100),dc(I_,"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 rqt=I_;var Iet=["PageUp","PageDown"],Let=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Det={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},sE="Slider",[Z_e,nqt,aqt]=jR(sE),[Ret]=bd(sE,[aqt]),[iqt,Nhe]=Ret(sE),Oet=k.forwardRef((t,s)=>{const{name:r,min:n=0,max:a=100,step:o=1,orientation:l="horizontal",disabled:i=!1,minStepsBetweenThumbs:d=0,defaultValue:u=[n],value:p,onValueChange:f=()=>{},onValueCommit:y=()=>{},inverted:_=!1,form:b,...N}=t,w=k.useRef(new Set),S=k.useRef(0),A=l==="horizontal"?oqt:lqt,[I=[],L]=Bu({prop:p,defaultProp:u,onChange:ee=>{var J;(J=[...w.current][S.current])==null||J.focus(),f(ee)}}),O=k.useRef(I);function U(ee){const Z=mqt(I,ee);V(ee,Z)}function q(ee){V(ee,S.current)}function $(){const ee=O.current[S.current];I[S.current]!==ee&&y(I)}function V(ee,Z,{commit:J}={commit:!1}){const Y=gqt(o),ce=yqt(Math.round((ee-n)/o)*o+n,Y),ae=nD(ce,[n,a]);L((ie=[])=>{const le=uqt(ie,ae,Z);if(xqt(le,d*o)){S.current=le.indexOf(ae);const fe=String(le)!==String(ie);return fe&&J&&y(le),fe?le:ie}else return ie})}return e.jsx(iqt,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:S,thumbs:w.current,values:I,orientation:l,form:b,children:e.jsx(Z_e.Provider,{scope:t.__scopeSlider,children:e.jsx(Z_e.Slot,{scope:t.__scopeSlider,children:e.jsx(A,{"aria-disabled":i,"data-disabled":i?"":void 0,...N,ref:s,onPointerDown:Tr(N.onPointerDown,()=>{i||(O.current=I)}),min:n,max:a,inverted:_,onSlideStart:i?void 0:U,onSlideMove:i?void 0:q,onSlideEnd:i?void 0:$,onHomeKeyDown:()=>!i&&V(n,0,{commit:!0}),onEndKeyDown:()=>!i&&V(a,I.length-1,{commit:!0}),onStepKeyDown:({event:ee,direction:Z})=>{if(!i){const ce=Iet.includes(ee.key)||ee.shiftKey&&Let.includes(ee.key)?10:1,ae=S.current,ie=I[ae],le=o*ce*Z;V(ie+le,ae,{commit:!0})}}})})})})});Oet.displayName=sE;var[Fet,zet]=Ret(sE,{startEdge:"left",endEdge:"right",size:"width",direction:1}),oqt=k.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:d,onStepKeyDown:u,...p}=t,[f,y]=k.useState(null),_=Ma(s,A=>y(A)),b=k.useRef(void 0),N=xw(a),w=N==="ltr",S=w&&!o||!w&&o;function C(A){const I=b.current||f.getBoundingClientRect(),L=[0,I.width],U=u4e(L,S?[r,n]:[n,r]);return b.current=I,U(A-I.left)}return e.jsx(Fet,{scope:t.__scopeSlider,startEdge:S?"left":"right",endEdge:S?"right":"left",direction:S?1:-1,size:"width",children:e.jsx(Bet,{dir:N,"data-orientation":"horizontal",...p,ref:_,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:A=>{const I=C(A.clientX);l==null||l(I)},onSlideMove:A=>{const I=C(A.clientX);i==null||i(I)},onSlideEnd:()=>{b.current=void 0,d==null||d()},onStepKeyDown:A=>{const L=Det[S?"from-left":"from-right"].includes(A.key);u==null||u({event:A,direction:L?-1:1})}})})}),lqt=k.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:d,...u}=t,p=k.useRef(null),f=Ma(s,p),y=k.useRef(void 0),_=!a;function b(N){const w=y.current||p.current.getBoundingClientRect(),S=[0,w.height],A=u4e(S,_?[n,r]:[r,n]);return y.current=w,A(N-w.top)}return e.jsx(Fet,{scope:t.__scopeSlider,startEdge:_?"bottom":"top",endEdge:_?"top":"bottom",size:"height",direction:_?1:-1,children:e.jsx(Bet,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:N=>{const w=b(N.clientY);o==null||o(w)},onSlideMove:N=>{const w=b(N.clientY);l==null||l(w)},onSlideEnd:()=>{y.current=void 0,i==null||i()},onStepKeyDown:N=>{const S=Det[_?"from-bottom":"from-top"].includes(N.key);d==null||d({event:N,direction:S?-1:1})}})})}),Bet=k.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:d,...u}=t,p=Nhe(sE,r);return e.jsx(dn.span,{...u,ref:s,onKeyDown:Tr(t.onKeyDown,f=>{f.key==="Home"?(l(f),f.preventDefault()):f.key==="End"?(i(f),f.preventDefault()):Iet.concat(Let).includes(f.key)&&(d(f),f.preventDefault())}),onPointerDown:Tr(t.onPointerDown,f=>{const y=f.target;y.setPointerCapture(f.pointerId),f.preventDefault(),p.thumbs.has(y)?y.focus():n(f)}),onPointerMove:Tr(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Tr(t.onPointerUp,f=>{const y=f.target;y.hasPointerCapture(f.pointerId)&&(y.releasePointerCapture(f.pointerId),o(f))})})}),$et="SliderTrack",qet=k.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Nhe($et,r);return e.jsx(dn.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});qet.displayName=$et;var Y_e="SliderRange",Uet=k.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Nhe(Y_e,r),o=zet(Y_e,r),l=k.useRef(null),i=Ma(s,l),d=a.values.length,u=a.values.map(y=>Get(y,a.min,a.max)),p=d>1?Math.min(...u):0,f=100-Math.max(...u);return e.jsx(dn.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...t.style,[o.startEdge]:p+"%",[o.endEdge]:f+"%"}})});Uet.displayName=Y_e;var X_e="SliderThumb",Vet=k.forwardRef((t,s)=>{const r=nqt(t.__scopeSlider),[n,a]=k.useState(null),o=Ma(s,i=>a(i)),l=k.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(cqt,{...t,ref:o,index:l})}),cqt=k.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=Nhe(X_e,r),i=zet(X_e,r),[d,u]=k.useState(null),p=Ma(s,C=>u(C)),f=d?l.form||!!d.closest("form"):!0,y=SR(d),_=l.values[n],b=_===void 0?0:Get(_,l.min,l.max),N=hqt(n,l.values.length),w=y==null?void 0:y[i.size],S=w?pqt(w,b,i.direction):0;return k.useEffect(()=>{if(d)return l.thumbs.add(d),()=>{l.thumbs.delete(d)}},[d,l.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${b}% + ${S}px)`},children:[e.jsx(Z_e.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(dn.span,{role:"slider","aria-label":t["aria-label"]||N,"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:Tr(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),f&&e.jsx(Het,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:_},n)]})});Vet.displayName=X_e;var dqt="RadioBubbleInput",Het=k.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=k.useRef(null),o=Ma(a,n),l=BR(s);return k.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&p){const f=new Event("input",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(dn.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});Het.displayName=dqt;function uqt(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function Get(t,s,r){const o=100/(r-s)*(t-s);return nD(o,[0,100])}function hqt(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function mqt(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 pqt(t,s,r){const n=t/2,o=u4e([0,50],[0,n]);return(n-o(s)*r)*r}function fqt(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function xqt(t,s){if(s>0){const r=fqt(t);return Math.min(...r)>=s}return!0}function u4e(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 gqt(t){return(String(t).split(".")[1]||"").length}function yqt(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var Wet=Oet,vqt=qet,_qt=Uet,bqt=Vet;const Eg=k.forwardRef(({className:t,...s},r)=>e.jsxs(Wet,{ref:r,className:Rt("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(vqt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(_qt,{className:"absolute h-full bg-primary"})}),e.jsx(bqt,{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"})]}));Eg.displayName=Wet.displayName;function wqt(t,s,r){return eqt(J$t({unit:"%",width:90},r,t,s),t,s)}const h4e=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=k.useRef(null),[l,i]=k.useState(),[d,u]=k.useState(),[p,f]=k.useState(1),[y,_]=k.useState(0),b=k.useCallback(S=>{const{width:C,height:A}=S.currentTarget;i(wqt(C,A,a))},[a]),N=k.useCallback(async()=>{const S=o.current;if(!S||!d)return;const C=document.createElement("canvas"),A=C.getContext("2d");if(!A)return;const I=S.naturalWidth/S.width,L=S.naturalHeight/S.height,O=400;C.width=O,C.height=O,A.imageSmoothingQuality="high";const U=d.x*I,q=d.y*L,$=d.width*I,V=d.height*L,ee=y*Math.PI/180,Z=C.width/2,J=C.height/2;return A.save(),A.translate(Z,J),A.rotate(ee),A.scale(p,p),A.translate(-Z,-J),A.drawImage(S,U,q,$,V,0,0,O,O),A.restore(),new Promise((Y,ce)=>{C.toBlob(ae=>{ae?Y(ae):ce(new Error("Canvas is empty"))},"image/jpeg",.95)})},[d,p,y]),w=async()=>{try{const S=await N();S&&(n(S),s())}catch(S){console.error("Error cropping image:",S)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Crop Your Photo"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative max-h-[400px] overflow-hidden rounded-lg bg-muted flex items-center justify-center",children:e.jsx(rqt,{crop:l,onChange:(S,C)=>i(C),onComplete:S=>u(S),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($M,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Eg,{value:[p],min:.5,max:3,step:.1,onValueChange:([S])=>f(S),className:"flex-1"}),e.jsx(Ob,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(LL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Eg,{value:[y],min:-180,max:180,step:1,onValueChange:([S])=>_(S),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[y,"°"]})]})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(K,{onClick:w,children:"Save Photo"})]})]})})},jqt=()=>{const{user:t}=$s(),{toast:s}=va(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(null);k.useEffect(()=>{t&&d()},[t]);const d=async()=>{n(!0);try{const{data:f}=await G.from("profiles").select("subscription_status, subscription_product_id, subscription_end_date, is_grandfathered").eq("id",t==null?void 0:t.id).single();f&&i({status:f.subscription_status||"none",productId:f.subscription_product_id,endDate:f.subscription_end_date,isGrandfathered:f.is_grandfathered||!1})}catch(f){console.error("Error loading subscription:",f)}finally{n(!1)}},u=async()=>{o(!0);try{const{data:{session:f}}=await G.auth.getSession();if(!f)throw new Error("Not authenticated");const{data: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(Ye,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(Ye,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(Ye,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(Ye,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(Ye,{variant:"secondary",children:"Canceled"});default:return e.jsx(Ye,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(jx,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(Be,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ps,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(jx,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(mr,{children:"Manage your subscription and billing"})]}),e.jsxs(Be,{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(ps,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Kr,{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."})]})]})},Nqt=()=>{const{user:t}=$s(),s=br(),{toast:r}=va(),[n]=Sc(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:d,subscribe:u,unsubscribe:p}=dXe(),[f,y]=k.useState(!1),[_,b]=k.useState(""),[N,w]=k.useState(!1),[S,C]=k.useState(!1),[A,I]=k.useState(""),[L,O]=k.useState({name:"",email:"",phone:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[U,q]=k.useState(!1),[$,V]=k.useState(!1),[ee,Z]=k.useState({newPassword:"",confirmPassword:""});k.useEffect(()=>{t&&J()},[t]),k.useEffect(()=>{o&&t&&setTimeout(()=>{var le;(le=document.getElementById("change-password-section"))==null||le.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,t]);const J=async()=>{var le,fe,xe;if(!(t!=null&&t.id)){console.log("No user ID available yet");return}try{console.log("Loading profile for user:",t.id);const{data:he,error:we}=await G.from("profiles").select("name, email, phone, digest_opt_out, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url, email_signature, use_email_signature").eq("id",t.id).maybeSingle();if(we)throw console.error("Profile query error:",we),we;he?(console.log("Profile loaded successfully:",he),O({name:he.name||"",email:he.email||"",phone:he.phone||"",title:he.title||"",bio:he.bio||"",areas_served:he.areas_served||"",years_experience:((le=he.years_experience)==null?void 0:le.toString())||"",instagram_url:he.instagram_url||"",facebook_url:he.facebook_url||"",linkedin_url:he.linkedin_url||"",email_signature:he.email_signature||"",use_email_signature:he.use_email_signature||!1}),q(he.digest_opt_out||!1)):(console.warn("No profile found for user"),O({name:((fe=t.user_metadata)==null?void 0:fe.name)||((xe=t.email)==null?void 0:xe.split("@")[0])||"",email:t.email||"",phone:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}));const{data:Ne}=await G.storage.from("avatars").list(`${t.id}`);if(Ne&&Ne.length>0){const{data:Ve}=G.storage.from("avatars").getPublicUrl(`${t.id}/${Ne[0].name}`);b(Ve.publicUrl)}}catch(he){console.error("Error loading profile:",he),r({title:"Error",description:he.message||"Failed to load profile",variant:"destructive"})}},Y=le=>{var he;const fe=(he=le.target.files)==null?void 0:he[0];if(!fe)return;const xe=new FileReader;xe.onloadend=()=>{I(xe.result),C(!0)},xe.readAsDataURL(fe),le.target.value=""},ce=async le=>{if(t){w(!0);try{const{data:fe}=await G.storage.from("avatars").list(`${t.id}`);fe&&fe.length>0&&await G.storage.from("avatars").remove(fe.map(Te=>`${t.id}/${Te.name}`));const he=`${t.id}/avatar.jpg`,{error:we}=await G.storage.from("avatars").upload(he,le,{upsert:!0,contentType:"image/jpeg"});if(we)throw we;const{data:Ne}=G.storage.from("avatars").getPublicUrl(he),Ve=Ne.publicUrl;b(`${Ve}?t=${Date.now()}`),await G.from("profiles").update({avatar_url:Ve}).eq("id",t.id),r({title:"Success",description:"Profile photo updated successfully"})}catch(fe){console.error("Error uploading avatar:",fe),r({title:"Error",description:fe.message||"Failed to upload photo",variant:"destructive"})}finally{w(!1)}}},ae=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(),phone:L.phone.trim()||null,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)}},ie=async()=>{if(!ee.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(ee.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(ee.newPassword!==ee.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}y(!0);try{const{error:le}=await G.auth.updateUser({password:ee.newPassword});if(le)throw le;r({title:"Success",description:"Password updated successfully"}),Z({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(Ls,{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(iS,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Profile Photo"}),e.jsx(mr,{children:"Upload a professional photo for your profile"})]}),e.jsxs(Be,{className:"flex items-center gap-6",children:[e.jsxs(vn,{className:"h-24 w-24",children:[e.jsx(Ca,{src:_}),e.jsx(_n,{className:"text-2xl",children:L.name.split(" ").map(le=>le[0]).join("").toUpperCase()||"U"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:Y,disabled:N}),e.jsxs(K,{variant:"outline",onClick:()=>{var le;return(le=document.getElementById("avatar-upload"))==null?void 0:le.click()},disabled:N,children:[e.jsx(Da,{className:"mr-2 h-4 w-4"}),N?"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(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Personal Information"}),e.jsx(mr,{children:"Update your profile details"})]}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"name",children:"Name"}),e.jsx(Fe,{id:"name",value:L.name,onChange:le=>O({...L,name:le.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"email",children:"Email"}),e.jsx(Fe,{id:"email",type:"email",value:L.email,onChange:le=>O({...L,email:le.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"phone",children:"Phone Number"}),e.jsx(Fe,{id:"phone",type:"tel",value:L.phone,onChange:le=>O({...L,phone:le.target.value}),placeholder:"e.g., +14155551234",maxLength:20}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for SMS lead notifications from your website — if you have a local authority site"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"title",children:"Job Title"}),e.jsx(Fe,{id:"title",value:L.title,onChange:le=>O({...L,title:le.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"bio",children:"Bio"}),e.jsx(_r,{id:"bio",value:L.bio,onChange:le=>O({...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(ge,{htmlFor:"areas_served",children:"Areas Served"}),e.jsx(Fe,{id:"areas_served",value:L.areas_served,onChange:le=>O({...L,areas_served:le.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"years_experience",children:"Years Experience"}),e.jsx(Fe,{id:"years_experience",type:"number",min:"0",value:L.years_experience,onChange:le=>O({...L,years_experience:le.target.value}),placeholder:"e.g., 5"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Social Links"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsx(Fe,{value:L.linkedin_url,onChange:le=>O({...L,linkedin_url:le.target.value}),placeholder:"LinkedIn URL"}),e.jsx(Fe,{value:L.instagram_url,onChange:le=>O({...L,instagram_url:le.target.value}),placeholder:"Instagram URL"}),e.jsx(Fe,{value:L.facebook_url,onChange:le=>O({...L,facebook_url:le.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(K,{onClick:ae,disabled:f,children:[e.jsx(wc,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Tv,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(mr,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs(Be,{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(Lr,{checked:L.use_email_signature,onCheckedChange:le=>O({...L,use_email_signature:le})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Signature"}),e.jsx(Yg,{content:L.email_signature,onChange:le=>O({...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:ae,disabled:f,children:[e.jsx(wc,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Ie,{id:"change-password-section",children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:a?"Set Your Password":"Change Password"}),e.jsx(mr,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"newPassword",children:"New Password"}),e.jsx(Fe,{id:"newPassword",type:"password",value:ee.newPassword,onChange:le=>Z({...ee,newPassword:le.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(Fe,{id:"confirmPassword",type:"password",value:ee.confirmPassword,onChange:le=>Z({...ee,confirmPassword:le.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(K,{onClick:ie,disabled:f,children:[e.jsx(wc,{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(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[i?e.jsx(Nm,{className:"h-5 w-5"}):e.jsx(Wv,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(mr,{children:"Receive browser notifications when new content is added"})]}),e.jsx(Be,{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(Lr,{checked:i,onCheckedChange:le=>{le?u():p()},disabled:d})]}):e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"Push notifications are not available in this browser."}),e.jsxs("p",{className:"text-xs space-y-1",children:[e.jsx("strong",{children:"Desktop:"})," Use Chrome, Firefox, or Edge.",e.jsx("br",{}),e.jsx("strong",{children:"Android:"})," Use Chrome or Firefox.",e.jsx("br",{}),e.jsx("strong",{children:"iPhone/iPad:"})," Push notifications on iOS ",e.jsx("em",{children:"only"})," work when this site is installed as an app from ",e.jsx("strong",{children:"Safari"}),". Open this site in Safari → tap the ",e.jsx("strong",{children:"Share"})," button → ",e.jsx("strong",{children:"Add to Home Screen"}),". Other browsers (Chrome, Firefox, etc.) on iOS do not support push notifications due to Apple restrictions."]})]})})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[U?e.jsx(bL,{className:"h-5 w-5"}):e.jsx(tr,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(mr,{children:"Manage your email subscription settings"})]}),e.jsx(Be,{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:U?"You won't receive weekly digest emails":"Receive a weekly summary of new content, events, and your progress"})]}),e.jsx(Lr,{checked:!U,onCheckedChange:async le=>{V(!0);try{const{error:fe}=await G.from("profiles").update({digest_opt_out:!le}).eq("id",t==null?void 0:t.id);if(fe)throw fe;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(fe){r({title:"Error",description:fe.message||"Failed to update preference",variant:"destructive"})}finally{V(!1)}},disabled:$})]})})]}),e.jsx(eRt,{}),e.jsx(jqt,{})]}),e.jsx(h4e,{open:S,onClose:()=>C(!1),imageSrc:A,onCropComplete:ce,aspectRatio:1})]})})};var kqt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Sqt=kqt.reduce((t,s)=>{const r=qA(`Primitive.${s}`),n=k.forwardRef((a,o)=>{const{asChild:l,...i}=a,d=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{}),Cqt="AspectRatio",Ket=k.forwardRef((t,s)=>{const{ratio:r=1/1,style:n,...a}=t;return e.jsx("div",{style:{position:"relative",width:"100%",paddingBottom:`${100/r}%`},"data-radix-aspect-ratio-wrapper":"",children:e.jsx(Sqt.div,{...a,ref:s,style:{...n,position:"absolute",top:0,right:0,bottom:0,left:0}})})});Ket.displayName=Cqt;var Mqt=Ket;const Tqt=Mqt;function Aqt(){const{user:t}=$s(),s=es(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),{data:l,isLoading:i}=ft({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:b,error:N}=await G.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(N)throw N;return b},enabled:!!t&&a}),d=Et({mutationFn:async()=>{const b=new Uint8Array(12);crypto.getRandomValues(b);const N=btoa(String.fromCharCode(...b)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:w}=await G.from("profiles").update({calendar_token:N}).eq("id",t==null?void 0:t.id);if(w)throw w;return N},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://"),N=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(b)}`;window.open(N,"_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(fs,{open:a,onOpenChange:o,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-5 w-5 text-primary"}),"Subscribe to Events Calendar"]}),e.jsx(Rr,{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(ps,{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(ea,{className:"h-4 w-4 text-green-500"}):e.jsx(Ya,{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(Kr,{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(Kr,{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(Kr,{className:"h-3 w-3 ml-auto opacity-50"})]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center pt-2",children:"Events sync automatically. If your membership expires, the calendar will show as empty."})]}):e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate your personal calendar subscription URL to get started."}),e.jsx(K,{onClick:()=>d.mutate(),disabled:d.isPending,className:"w-full",children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(nn,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}const Eqt={first_timer:Gn,regular:Qv,dedicated:rc,veteran:Hi,streak_master:ch,century:Hi},Pqt={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 uDe(t){return t===1?e.jsx(Hi,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(Qv,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(rc,{className:"h-5 w-5 text-amber-600"}):e.jsx("span",{className:"w-5 text-center text-sm font-medium text-muted-foreground",children:t})}function Zet({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=$s(),{data:o,isLoading:l}=WXe(s?5:10,r),{data:i}=KXe(a==null?void 0:a.id),{data:d}=YXe(a==null?void 0:a.id),{data:u}=ZXe(a==null?void 0:a.id);return l?e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Hi,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(Be,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((p,f)=>e.jsx(Ss,{className:"h-12 w-full"},f))})})]}):e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Hi,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs(Be,{children:[t&&i&&e.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-primary/5 border border-primary/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Your Stats"}),d&&e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:["Rank #",d]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:i.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Points"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold",children:i.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Events"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(ch,{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=Eqt[p.badge_type]||Gn;return e.jsxs(Ye,{variant:"outline",className:`text-xs ${Pqt[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(Ye,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(ta,{defaultValue:"points",className:"w-full",children:[e.jsxs(Qn,{className:"w-full mb-3",children:[e.jsx(ls,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(ls,{value:"events",className:"flex-1",children:"By Events"})]}),e.jsx(js,{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:uDe(f+1)}),e.jsx(vn,{className:"h-8 w-8",children:e.jsx(_n,{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(js,{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:uDe(f+1)}),e.jsx(vn,{className:"h-8 w-8",children:e.jsx(_n,{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 Iqt(){const t=br(),{user:s,isAdmin:r}=$s(),n=es(),{data:a,isLoading:o}=ft({queryKey:["public-events"],queryFn:async()=>{const{data:N,error:w}=await G.from("events").select("*").order("event_date",{ascending:!0});if(w)throw w;return N}}),{data:l}=ft({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:N,error:w}=await G.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(w)throw w;return N},enabled:!!s}),{data:i}=ft({queryKey:["event-registration-counts"],queryFn:async()=>{let N=[],w=0;const S=1e3;for(;;){const{data:A,error:I}=await G.from("event_registrations").select("event_id").range(w,w+S-1);if(I)throw I;if(!A||A.length===0||(N=N.concat(A),A.length{C[A.event_id]=(C[A.event_id]||0)+1}),C}}),d=Et({mutationFn:async N=>{await G.auth.refreshSession();const{data:w,error:S}=await G.functions.invoke("zoom-register",{body:{event_id:N}});if(S)throw S;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:N=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),N!=null&&N.join_url?me.success("Successfully registered! You'll receive a Zoom confirmation email."):me.success("Successfully registered for the event!")},onError:N=>{me.error("Failed to register: "+N.message)}}),u=Et({mutationFn:async N=>{const{data:w,error:S}=await G.functions.invoke("zoom-unregister",{body:{event_id:N}});if(S)throw S;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),me.success("Registration cancelled and removed from Zoom")},onError:N=>{me.error("Failed to cancel: "+N.message)}}),p=N=>l==null?void 0:l.some(w=>w.event_id===N),f=N=>{const w=l==null?void 0:l.find(S=>S.event_id===N);return w==null?void 0:w.zoom_join_url},y=N=>N.capacity?((i==null?void 0:i[N.id])||0)>=N.capacity:!1,_=(a==null?void 0:a.filter(N=>ZM(N.event_date)!=="ended"))||[],b=(a==null?void 0:a.filter(N=>ZM(N.event_date)==="ended"))||[];return e.jsx(Ls,{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(Aqt,{}),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(Ie,{className:"text-center py-12",children:e.jsx(Be,{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(N=>{const w=ZM(N.event_date),S=uke(N.event_date),C=w==="live",A=w==="starting_soon";return e.jsxs(Ie,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${C?"border-red-500 ring-2 ring-red-500/20":A?"border-amber-500 ring-2 ring-amber-500/20":"hover:border-primary/50"}`,onClick:()=>t(`/events/${N.id}`),children:[S&&e.jsxs("div",{className:`${C?"bg-red-500":"bg-amber-500"} text-white px-3 py-1.5 flex items-center gap-2 text-sm font-medium`,children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-white opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-white"})]}),C?e.jsxs(e.Fragment,{children:[e.jsx(e1,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(rn,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),N.image_url&&e.jsx(Tqt,{ratio:3/2,className:"overflow-hidden",children:e.jsx("img",{src:N.image_url,alt:N.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs(Lt,{children:[e.jsx(Ft,{className:"line-clamp-2",children:N.title}),N.description&&e.jsx(mr,{className:"line-clamp-2",children:N.description.replace(/<[^>]*>/g,"")})]}),e.jsxs(Be,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(nn,{className:"h-4 w-4"}),new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(N.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(rn,{className:"h-4 w-4"}),uD(new Date(N.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(cr,{className:"h-4 w-4"}),(i==null?void 0:i[N.id])||0," registered",N.capacity&&` / ${N.capacity} spots`]})]}),e.jsx(YL,{className:"flex gap-2",onClick:I=>I.stopPropagation(),children:p(N.id)?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>u.mutate(N.id),disabled:u.isPending,children:[e.jsx(Sr,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(K,{className:"flex-1",onClick:()=>window.open(f(N.id)||N.zoom_link,"_blank"),children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(K,{className:"w-full",onClick:()=>d.mutate(N.id),disabled:d.isPending||y(N),children:y(N)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(ea,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},N.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(N=>e.jsx(Ie,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${N.id}`),children:e.jsxs(Lt,{children:[e.jsx(Ft,{className:"text-base line-clamp-1",children:N.title}),e.jsx(mr,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(N.event_date))})]})},N.id))})]})]}),r&&e.jsx("div",{className:"lg:col-span-1",children:e.jsx(Zet,{showUserStats:!0})})]})]})})}const vye=[{value:"all",label:"All Roles",icon:cr},{value:"newest",label:"Newest Members",icon:rn},{value:"brokerage_manager",label:"Brokerage Managers",icon:VL},{value:"admin",label:"Admins",icon:Ru}];function Lqt({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var Re,Ue;const{user:o,isAdmin:l,isBrokerageManager:i}=$s(),[d,u]=k.useState([]),[p,f]=k.useState([]),[y,_]=k.useState([]),[b,N]=k.useState([]),[w,S]=k.useState(""),[C,A]=k.useState(""),[I,L]=k.useState(""),[O,U]=k.useState(!1),[q,$]=k.useState(!1),[V,ee]=k.useState("agents"),[Z,J]=k.useState("all"),[Y,ce]=k.useState({}),ae=l||i;k.useEffect(()=>{t&&o&&(l?ie():le())},[t,o,l]),k.useEffect(()=>{t||(_([]),N([]),S(""),A(""),L(""),ee("agents"),J("all"))},[t]);const ie=async()=>{if(o){U(!0);try{const{data:ye,error:ct}=await G.from("brokerages").select("id, name").order("name");if(ct)throw ct;const pe=1e3,Ge={};let tt=0,st=!0;for(;st;){const{data:Ct,error:Ot}=await G.from("profiles").select("brokerage_id").range(tt*pe,(tt+1)*pe-1);if(Ot)throw Ot;Ct==null||Ct.forEach(ut=>{ut.brokerage_id&&(Ge[ut.brokerage_id]=(Ge[ut.brokerage_id]||0)+1)}),st=(Ct==null?void 0:Ct.length)===pe,tt++}f((ye==null?void 0:ye.map(Ct=>({...Ct,agent_count:Ge[Ct.id]||0})))||[]);const Ce=[];for(tt=0,st=!0;st;){const{data:Ct,error:Ot}=await G.from("profiles").select("id, name, email, brokerage_id, created_at, brokerages(name)").neq("id",o.id).order("name").range(tt*pe,(tt+1)*pe-1);if(Ot)throw Ot;Ct&&Ce.push(...Ct),st=(Ct==null?void 0:Ct.length)===pe,tt++}const et={};for(tt=0,st=!0;st;){const{data:Ct,error:Ot}=await G.from("user_roles").select("user_id, role").range(tt*pe,(tt+1)*pe-1);if(Ot)throw Ot;Ct==null||Ct.forEach(ut=>{et[ut.user_id]||(et[ut.user_id]=[]),et[ut.user_id].push(ut.role)}),st=(Ct==null?void 0:Ct.length)===pe,tt++}ce(et),u(Ce.map(Ct=>{var Ot;return{id:Ct.id,name:Ct.name,email:Ct.email,brokerage_name:((Ot=Ct.brokerages)==null?void 0:Ot.name)||"No Brokerage",roles:et[Ct.id]||[],created_at:Ct.created_at}}))}catch(ye){console.error("Error loading data:",ye),me.error("Failed to load agents and brokerages")}finally{U(!1)}}},le=async()=>{if(o){U(!0);try{const{data:ye}=await G.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(ye!=null&&ye.brokerage_id)){me.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:ct,error:pe}=await G.from("profiles").select("id, name, email").eq("brokerage_id",ye.brokerage_id).neq("id",o.id).order("name");if(pe)throw pe;u(ct||[])}catch(ye){console.error("Error loading agents:",ye),me.error("Failed to load agents")}finally{U(!1)}}},fe=d.filter(ye=>{var pe;const ct=ye.name.toLowerCase().includes(w.toLowerCase())||ye.email.toLowerCase().includes(w.toLowerCase())||((pe=ye.brokerage_name)==null?void 0:pe.toLowerCase().includes(w.toLowerCase()));if(l&&Z!=="all"&&Z!=="newest"){const Ge=Y[ye.id]||[];return ct&&Ge.includes(Z)}return ct}).sort((ye,ct)=>Z==="newest"?(ct.created_at||"").localeCompare(ye.created_at||""):0),xe=p.filter(ye=>ye.name.toLowerCase().includes(C.toLowerCase())),he=()=>{y.length===fe.length?_([]):_(fe.map(ye=>ye.id))},we=()=>{b.length===xe.length?N([]):N(xe.map(ye=>ye.id))},Ne=ye=>{if(!ae){_([ye]);return}_(ct=>ct.includes(ye)?ct.filter(pe=>pe!==ye):[...ct,ye])},Ve=ye=>{N(ct=>ct.includes(ye)?ct.filter(pe=>pe!==ye):[...ct,ye])},Te=async()=>{if(!(y.length>0||b.length>0)){me.error("Please select at least one agent or brokerage to share with");return}$(!0);try{const{data:ct,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 Ge=(ct==null?void 0:ct.sharesCreated)||y.length;me.success(`Shared with ${Ge} agent${Ge!==1?"s":""}`),s(!1)}catch(ct){console.error("Error sharing resource:",ct),me.error("Failed to share resource")}finally{$(!1)}},Ae=ye=>ye.split(" ").map(ct=>ct[0]).join("").toUpperCase().slice(0,2),ze=ye=>{const ct=Y[ye]||[];return ct.includes("admin")?e.jsx(Ye,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):ct.includes("brokerage_manager")?e.jsx(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Ee=y.length+b.length,ve=Z!=="all"&&Z!=="newest"?fe.length:null;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs(ks,{className:"flex-shrink-0",children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Nn,{className:"h-5 w-5 text-primary"}),"Share Resource"]}),e.jsxs(Rr,{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(ta,{value:V,onValueChange:ee,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(Qn,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(ls,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),y.length>0&&e.jsx(Ye,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:y.length})]}),e.jsxs(ls,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(ma,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),b.length>0&&e.jsx(Ye,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:b.length})]})]}),e.jsxs(js,{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(tn,{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:w,onChange:ye=>S(ye.target.value),className:"pl-9"})]}),e.jsxs(zs,{value:Z,onValueChange:J,children:[e.jsxs(Os,{className:"w-[180px]",children:[e.jsx(Dg,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(qs,{placeholder:"Filter by role"})]}),e.jsx(Fs,{children:vye.map(ye=>e.jsx(yt,{value:ye.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye.icon,{className:"h-4 w-4"}),e.jsx("span",{children:ye.label})]})},ye.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:he,className:"text-xs h-8",disabled:fe.length===0,children:[e.jsx(cr,{className:"h-3.5 w-3.5 mr-1.5"}),y.length===fe.length&&fe.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[ve!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[ve," ",(Re=vye.find(ye=>ye.value===Z))==null?void 0:Re.label]}),e.jsxs("span",{className:"font-medium",children:[y.length," selected"]})]})]}),e.jsx(di,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(ps,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):fe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(cr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:Z!=="all"?`No ${(Ue=vye.find(ye=>ye.value===Z))==null?void 0:Ue.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:fe.map(ye=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${y.includes(ye.id)?"bg-accent":""}`,onClick:()=>Ne(ye.id),children:[e.jsx(Gi,{checked:y.includes(ye.id),onCheckedChange:()=>Ne(ye.id),className:"flex-shrink-0"}),e.jsx(vn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(_n,{className:"text-xs bg-primary/10 text-primary",children:Ae(ye.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:ye.name}),ze(ye.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[ye.email,ye.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",ye.brokerage_name]})]})]})]},ye.id))})})]}),e.jsxs(js,{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(tn,{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:C,onChange:ye=>A(ye.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:we,className:"text-xs h-8",disabled:xe.length===0,children:[e.jsx(ma,{className:"h-3.5 w-3.5 mr-1.5"}),b.length===xe.length&&xe.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(di,{className:"h-[250px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(ps,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):xe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[e.jsx(ma,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No brokerages found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:xe.map(ye=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${b.includes(ye.id)?"bg-accent":""}`,onClick:()=>Ve(ye.id),children:[e.jsx(Gi,{checked:b.includes(ye.id),onCheckedChange:()=>Ve(ye.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(ma,{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:ye.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ye.agent_count," agent",ye.agent_count!==1?"s":""]})]})]},ye.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(tn,{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:w,onChange:ye=>S(ye.target.value),className:"pl-9"})]}),ae&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:he,className:"text-xs h-8",disabled:fe.length===0,children:[e.jsx(cr,{className:"h-3.5 w-3.5 mr-1.5"}),y.length===fe.length&&fe.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[y.length," selected"]})]}),e.jsx(di,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(ps,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):fe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(cr,{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:fe.map(ye=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${y.includes(ye.id)?"bg-accent":""}`,onClick:()=>Ne(ye.id),children:[e.jsx(Gi,{checked:y.includes(ye.id),onCheckedChange:()=>Ne(ye.id),className:"flex-shrink-0"}),e.jsx(vn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(_n,{className:"text-xs bg-primary/10 text-primary",children:Ae(ye.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:ye.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:ye.email})]})]},ye.id))})})]}),e.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[e.jsx(ge,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),e.jsx(_r,{id:"message",placeholder:"I thought you might find this useful...",value:I,onChange:ye=>L(ye.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:Te,disabled:Ee===0||q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function rE({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=k.useState(!1),{user:d}=$s();return d?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(vd,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(Lqt,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function Dqt(){const{eventId:t}=ho(),s=br(),{user:r}=$s(),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,d]=k.useState(0),[u,p]=k.useState(!0),[f,y]=k.useState(!1);k.useEffect(()=>{t&&_()},[t,r]);const _=async()=>{try{const{data:A,error:I}=await G.from("events").select("*").eq("id",t).single();if(I)throw I;a(A);const{count:L}=await G.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(d(L||0),r){const{data:O}=await G.from("event_registrations").select("id, zoom_join_url").eq("event_id",t).eq("user_id",r.id).maybeSingle();l(O)}}catch(A){console.error("Error loading event:",A),me.error("Failed to load event"),s("/events")}finally{p(!1)}},b=async()=>{if(!(!r||!n)){y(!0);try{const{error:A}=await G.auth.refreshSession();if(A){console.error("Session refresh failed:",A),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),d(L=>L-1)}else{const{data:I,error:L}=await G.functions.invoke("zoom-register",{body:{event_id:n.id}});if(L)throw L;me.success("Successfully registered for event!"),l({id:I.registration_id,zoom_join_url:I.zoom_join_url}),d(O=>O+1)}}catch(A){console.error("Registration error:",A),me.error(o?"Failed to cancel registration":"Failed to register for event")}finally{y(!1)}}},N=A=>{var I,L,O;if(A.includes("iframe.mediadelivery.net")||A.includes("video.bunnycdn.com")){const U=A.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(U)return`https://iframe.mediadelivery.net/embed/${U[1]}/${U[2]}?autoplay=false&preload=true`}if(A.includes("youtube.com")||A.includes("youtu.be")){const U=A.includes("youtu.be")?(I=A.split("youtu.be/")[1])==null?void 0:I.split("?")[0]:(L=A.split("v=")[1])==null?void 0:L.split("&")[0];if(U)return`https://www.youtube.com/embed/${U}`}if(A.includes("vimeo.com")){const U=(O=A.split("vimeo.com/")[1])==null?void 0:O.split("?")[0];if(U)return`https://player.vimeo.com/video/${U}`}return A};if(u)return e.jsx(Ls,{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(Ls,{title:"Event Not Found",children:e.jsxs("div",{className:"text-center py-16",children:[e.jsx("p",{className:"text-muted-foreground",children:"Event not found"}),e.jsx(K,{onClick:()=>s("/events"),className:"mt-4",children:"Back to Events"})]})});const w=a0(new Date(n.event_date)),S=n.capacity&&i>=n.capacity,C=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(Ls,{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(Ra,{className:"h-4 w-4"}),"Back to Events"]}),n.image_url&&e.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-6",children:[e.jsx("img",{src:n.image_url,alt:n.title,className:"w-full h-full object-cover"}),w&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(Ye,{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(rE,{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(tp,{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:N(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(Ie,{children:e.jsxs(Be,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(nn,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(n.event_date))}),e.jsx("p",{className:"text-sm text-muted-foreground",children:uD(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(cr,{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(si,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:"You're registered!"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[!w&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"w-full gap-2",onClick:()=>window.open(C,"_blank"),children:[e.jsx(Kr,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:b,disabled:f,children:[f?e.jsx(ps,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(K,{className:"w-full gap-2",onClick:b,disabled:f||(S??!1),children:f?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):S?"Event Full":"Register Now"})}),w&&o&&e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(Kr,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const Rqt=[{id:"quickvid",name:"QuickVid",description:"Record, manage, and share personalized video messages",icon:e.jsx(hn,{className:"h-6 w-6"}),path:"/mission-control/video/record",category:"Marketing",color:"bg-rose-500/15 text-rose-600"},{id:"smart-card",name:"Smart Card",description:"Your digital business card — share your info with a single link",icon:e.jsx(jx,{className:"h-6 w-6"}),path:"/mission-control/my-card",category:"Marketing",color:"bg-sky-500/15 text-sky-600"},{id:"smart-presentations",name:"Smart Presentations",description:"Create beautiful listing and buyer presentations",icon:e.jsx(Rg,{className:"h-6 w-6"}),path:"/mission-control/presentations",category:"Marketing",color:"bg-amber-500/15 text-amber-600"},{id:"landing-pages",name:"Landing Pages",description:"Build custom landing pages to capture leads",icon:e.jsx(mn,{className:"h-6 w-6"}),path:"/mission-control/landing-pages",category:"Marketing",color:"bg-emerald-500/15 text-emerald-600"},{id:"guest-book",name:"Guest Book",description:"Digital open house sign-in to capture visitor info",icon:e.jsx(oh,{className:"h-6 w-6"}),path:"/mission-control/guest-book",category:"Open House",color:"bg-orange-500/15 text-orange-600"},{id:"card-studio",name:"Card Studio",description:"Send beautiful animated digital cards for birthdays, anniversaries & milestones",icon:e.jsx(qr,{className:"h-6 w-6"}),path:"/mission-control/card-studio",category:"Marketing",color:"bg-pink-500/15 text-pink-600"},{id:"direct-mail",name:"Direct Mail",description:"Send professional postcards to your contacts via direct mail",icon:e.jsx(tr,{className:"h-6 w-6"}),path:"/mission-control/direct-mail",category:"Marketing",adminOnly:!0,beta:!0,color:"bg-indigo-500/15 text-indigo-600"},{id:"reelflow",name:"ReelFlow",description:"Turn property photos into cinematic video clips and reels — powered by AI",icon:e.jsx(Ld,{className:"h-6 w-6"}),path:"/admin/beta/homereel",category:"Marketing",beta:!0,isNew:!0,color:"bg-violet-500/15 text-violet-600"},{id:"mass-emails",name:"Mass Emails",description:"Create and send bulk email campaigns to your contacts",icon:e.jsx(Nn,{className:"h-6 w-6"}),path:"/admin/email-campaigns",category:"Marketing",beta:!0,color:"bg-teal-500/15 text-teal-600"}],Oqt=()=>{const{user:t,isAdmin:s}=$s(),r=br(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,d]=k.useState(""),[u,p]=k.useState("all"),[f,y]=k.useState(new Set),[_,b]=k.useState(new Set);k.useEffect(()=>{N()},[t]);const N=async()=>{try{const{data:$}=await G.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),V=($==null?void 0:$.map(fe=>fe.tag))||[],{data:ee,error:Z}=await G.from("app_tiles").select("*").order("name");if(Z)throw Z;const[{data:J},{data:Y}]=await Promise.all([G.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),G.from("user_tool_favorites").select("tool_id").eq("user_id",t==null?void 0:t.id)]),ce=new Set((J==null?void 0:J.map(fe=>fe.app_id))||[]);y(ce);const ae=new Set((Y||[]).map(fe=>fe.tool_id));b(ae);const le=((ee==null?void 0:ee.filter(fe=>!fe.required_tags||fe.required_tags.length===0?!0:fe.required_tags.some(xe=>V.includes(xe))))||[]).sort((fe,xe)=>fe.name==="LevelUp Members Portal"?-1:xe.name==="LevelUp Members Portal"?1:0);a(le)}catch($){console.error("Error loading apps:",$),me.error("Failed to load apps")}finally{l(!1)}},w=async $=>{var ee;const V=window.open("about:blank","_blank");try{const{data:Z,error:J}=await G.auth.getSession();if(J||!Z.session){V==null||V.close(),me.error("Session expired. Please refresh the page and try again.");return}const Y=Z.session.access_token;await G.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:$.app_id,app_name:$.name,user_agent:navigator.userAgent});const{data:ce,error:ae}=await G.functions.invoke("sso-launch",{body:{app_id:$.app_id},headers:{Authorization:`Bearer ${Y}`}});if(ae)throw ae;ce!=null&&ce.redirect_url?V&&!V.closed?(V.location.href=ce.redirect_url,(ee=V.focus)==null||ee.call(V)):window.location.assign(ce.redirect_url):(V==null||V.close(),me.error("Launch link unavailable"))}catch(Z){V==null||V.close(),console.error("Error launching app:",Z),me.error("Failed to launch app. Please try again.")}},S=async($,V)=>{$.stopPropagation();const ee=f.has(V);try{if(ee){const{error:Z}=await G.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",V);if(Z)throw Z;y(J=>{const Y=new Set(J);return Y.delete(V),Y}),me.success("Removed from favorites")}else{const{error:Z}=await G.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:V});if(Z)throw Z;y(J=>new Set(J).add(V)),me.success("Added to favorites")}}catch(Z){console.error("Error toggling favorite:",Z),me.error("Failed to update favorites")}},C=async($,V)=>{$.stopPropagation();const ee=_.has(V);try{if(ee){const{error:Z}=await G.from("user_tool_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("tool_id",V);if(Z)throw Z;b(J=>{const Y=new Set(J);return Y.delete(V),Y}),me.success("Removed from favorites")}else{const{error:Z}=await G.from("user_tool_favorites").insert({user_id:t==null?void 0:t.id,tool_id:V});if(Z)throw Z;b(J=>new Set(J).add(V)),me.success("Added to favorites")}}catch(Z){console.error("Error toggling tool favorite:",Z),me.error("Failed to update favorites")}},A=n.filter($=>{var ee;const V=$.name.toLowerCase().includes(i.toLowerCase())||((ee=$.description)==null?void 0:ee.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?V&&f.has($.id):V}),I=Rqt.filter($=>{if($.adminOnly&&!s)return!1;const V=$.name.toLowerCase().includes(i.toLowerCase())||$.description.toLowerCase().includes(i.toLowerCase());return u==="favorites"?V&&_.has($.id):V}),L=I.reduce(($,V)=>($[V.category]||($[V.category]=[]),$[V.category].push(V),$),{}),O=[{id:"all",label:"All"},{id:"tools",label:"Built-in Tools"},{id:"apps",label:"Connected Apps"},{id:"favorites",label:"Favorites"}];if(o)return e.jsx(Ls,{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 U=u==="all"||u==="tools"||u==="favorites",q=u==="all"||u==="apps"||u==="favorites";return e.jsxs(Ls,{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(tn,{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:$=>d($.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:O.map($=>e.jsxs("button",{onClick:()=>p($.id),className:Rt("pb-3 text-sm font-medium transition-colors relative",u===$.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[$.label,u===$.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},$.id))}),U&&Object.keys(L).length>0&&e.jsxs("div",{className:"mb-10",children:[u==="all"&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(Og,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Built-in Tools"})]}),Object.entries(L).map(([$,V])=>e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground bg-muted px-2.5 py-1 rounded-full",children:$})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:V.map(ee=>{const Z=_.has(ee.id);return e.jsxs("div",{onClick:()=>r(ee.path),className:Rt("group flex items-start gap-4 p-5 bg-card rounded-xl border transition-all duration-200 hover:shadow-lg cursor-pointer relative overflow-hidden",ee.isNew?"border-primary/40 ring-1 ring-primary/20 hover:border-primary/60":"border-border hover:border-primary/30"),children:[ee.isNew&&e.jsx("div",{className:"absolute top-0 right-0 bg-gradient-to-r from-violet-500 to-indigo-500 text-white text-[10px] font-bold uppercase px-3 py-0.5 rounded-bl-lg tracking-wider shadow-sm",children:"✨ New"}),e.jsx("div",{className:Rt("flex-shrink-0 w-14 h-14 rounded-xl flex items-center justify-center transition-transform group-hover:scale-105",ee.color||"bg-primary/10 text-primary"),children:ee.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:[ee.name,ee.beta&&e.jsx("span",{className:"text-[10px] font-semibold bg-amber-100 text-amber-700 px-1.5 py-0.5 rounded-full border border-amber-200",children:"Beta"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ee.description})]}),e.jsx("button",{className:Rt("flex-shrink-0 p-1 transition-colors",Z?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:J=>C(J,ee.id),children:e.jsx(_x,{className:Rt("h-5 w-5",Z&&"fill-current")})})]},ee.id)})})]},$))]}),q&&e.jsxs("div",{children:[u==="all"&&A.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(Kr,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Connected Apps"})]}),A.length===0&&u!=="all"&&!(u==="favorites"&&I.length>0)?e.jsx("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:u==="favorites"?e.jsxs(e.Fragment,{children:[e.jsx(_x,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No favorites yet"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:"Click the bookmark icon on any app or tool to add it to your favorites"})]}):e.jsxs(e.Fragment,{children:[e.jsx(yd,{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:A.map($=>{const V=f.has($.id),ee=$.name.toLowerCase().includes("agent review")||$.app_id==="agent_review";return e.jsxs("div",{className:"group flex flex-col p-5 bg-card rounded-xl border border-border transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"flex items-start gap-4 cursor-pointer",onClick:()=>w($),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:$.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:$.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:$.description})]}),e.jsx("button",{className:Rt("flex-shrink-0 p-1 transition-colors",V?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:Z=>S(Z,$.id),children:e.jsx(_x,{className:Rt("h-5 w-5",V&&"fill-current")})})]}),ee&&e.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:Z=>Z.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},$.id)})})]}),U&&q&&A.length===0&&I.length===0&&i&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:[e.jsx(tn,{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"})]})]})},Fqt=()=>{const t=br(),[s,r]=k.useState(""),[n,a]=k.useState("all"),[o,l]=k.useState("all"),[i,d]=k.useState("grid"),{data:u=[]}=ft({queryKey:["template-categories"],queryFn:async()=>{const{data:S,error:C}=await G.from("template_categories").select("*").order("name");if(C)throw C;return S}}),{data:p=[]}=ft({queryKey:["template-types"],queryFn:async()=>{const{data:S,error:C}=await G.from("template_types").select("*").order("name");if(C)throw C;return S}}),{data:f=[],isLoading:y}=ft({queryKey:["canva-templates"],queryFn:async()=>{const{data:S,error:C}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(C)throw C;const{data:A,error:I}=await G.from("template_links").select("*").order("sort_order");if(I)throw I;const{data:L}=await G.from("template_likes").select("template_id"),{data:O}=await G.from("template_comments").select("template_id"),U=new Map;L==null||L.forEach(V=>{U.set(V.template_id,(U.get(V.template_id)||0)+1)});const q=new Map;return O==null||O.forEach(V=>{q.set(V.template_id,(q.get(V.template_id)||0)+1)}),(S||[]).map(V=>({...V,links:(A||[]).filter(ee=>ee.template_id===V.id)||[],likesCount:U.get(V.id)||0,commentsCount:q.get(V.id)||0}))}}),_=f.filter(S=>{var L;const C=S.name.toLowerCase().includes(s.toLowerCase())||((L=S.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase())),A=n==="all"||S.category_id===n,I=o==="all"||S.type_id===o;return C&&A&&I}),b=()=>{r(""),a("all"),l("all")},N=s||n!=="all"||o!=="all",w=S=>{t(`/templates/${S}`)};return e.jsx(Ls,{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(tn,{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:S=>r(S.target.value),className:"pl-9"})]}),e.jsxs(zs,{value:n,onValueChange:a,children:[e.jsx(Os,{className:"w-full sm:w-48",children:e.jsx(qs,{placeholder:"All Categories"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Categories"}),u.map(S=>e.jsx(yt,{value:S.id,children:S.name},S.id))]})]}),e.jsxs(zs,{value:o,onValueChange:l,children:[e.jsx(Os,{className:"w-full sm:w-48",children:e.jsx(qs,{placeholder:"All Types"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Types"}),p.map(S=>e.jsx(yt,{value:S.id,children:S.name},S.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[N&&e.jsx(K,{variant:"outline",size:"sm",onClick:b,children:"Clear Filters"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>d("grid"),className:"rounded-full",children:e.jsx(pp,{className:"h-4 w-4"})}),e.jsx(K,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>d("list"),className:"rounded-full",children:e.jsx(Rh,{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((S,C)=>e.jsx(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsx(Ss,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(Ss,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ss,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ss,{className:"h-5 w-16"}),e.jsx(Ss,{className:"h-5 w-20"})]})]})},C))}),!y&&_.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:N?"No templates match your filters":"No templates available yet"}),N&&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(S=>e.jsxs(Ie,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>w(S.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[S.preview_image_url?e.jsx("img",{src:S.preview_image_url,alt:S.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"}),S.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Ye,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(go,{className:"h-3 w-3"}),S.links.length]})})]}),e.jsxs(Be,{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:S.name}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:Jde(S.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[S.category&&e.jsx(Ye,{variant:"secondary",className:"text-xs",children:S.category.name}),S.type&&e.jsx(Ye,{variant:"outline",className:"text-xs",children:S.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(Ou,{className:"h-3.5 w-3.5"}),S.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(bc,{className:"h-3.5 w-3.5"}),S.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:C=>{C.stopPropagation(),w(S.id)},children:[e.jsx(Kr,{className:"h-4 w-4"}),"View Template"]})]})]},S.id))})]})})};var zqt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Bqt=zqt.reduce((t,s)=>{const r=qA(`Primitive.${s}`),n=k.forwardRef((a,o)=>{const{asChild:l,...i}=a,d=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{}),$qt="Separator",hDe="horizontal",qqt=["horizontal","vertical"],Yet=k.forwardRef((t,s)=>{const{decorative:r,orientation:n=hDe,...a}=t,o=Uqt(n)?n:hDe,i=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return e.jsx(Bqt.div,{"data-orientation":o,...i,...a,ref:s})});Yet.displayName=$qt;function Uqt(t){return qqt.includes(t)}var Xet=Yet;const jo=k.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(Xet,{ref:a,decorative:r,orientation:s,className:Rt("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));jo.displayName=Xet.displayName;const Vqt=()=>{const{templateId:t}=ho(),s=br(),{user:r,isAdmin:n}=$s(),{toast:a}=va(),o=es(),{trackEngagement:l}=JA(),[i,d]=k.useState(""),{data:u,isLoading:p}=ft({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:O}=await G.from("template_links").select("*").eq("template_id",t).order("sort_order"),{data:U}=await G.from("template_guides").select("*").eq("template_id",t).order("sort_order");return{...I,links:O||[],guides:U||[]}},enabled:!!t}),{data:f=[]}=ft({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(O=>O.resource_kits).filter(Boolean)},enabled:!!t});k.useEffect(()=>{u&&l("template",u.id,u.name,"view")},[u==null?void 0:u.id]);const{data:y=[]}=ft({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:_=[]}=ft({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 O=[...new Set(I.map($=>$.user_id))],{data:U}=await G.from("profiles").select("id, name").in("id",O),q=new Map((U==null?void 0:U.map($=>[$.id,$.name]))||[]);return I.map($=>({...$,user_name:q.get($.user_id)||"Unknown User"}))},enabled:!!t}),b=Et({mutationFn:async I=>{const{error:L}=await G.from("template_comments").insert({template_id:t,user_id:r.id,content:I});if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),d(""),a({title:"Comment added!"})},onError:I=>{a({title:"Error adding comment",description:I.message,variant:"destructive"})}}),N=Et({mutationFn:async I=>{const{error:L}=await G.from("template_comments").delete().eq("id",I);if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),a({title:"Comment deleted"})}}),w=Et({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]})}}),S=y.some(I=>I.user_id===(r==null?void 0:r.id)),C=I=>I.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),A=I=>{I.preventDefault(),!(!i.trim()||!r)&&b.mutate(i.trim())};return p?e.jsx(Ls,{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(Ls,{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(da,{to:"/templates",children:[e.jsx(Ra,{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(Ye,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(Ye,{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(da,{to:`/admin/templates?edit=${u.id}`,children:[e.jsx(pa,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(rE,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:S?"default":"outline",className:"gap-2 rounded-full",onClick:()=>w.mutate(),disabled:!r||w.isPending,children:[e.jsx(Ou,{className:`h-4 w-4 ${S?"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(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(go,{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(Kr,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),u.video_url&&e.jsx(Ie,{children:e.jsx(Be,{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(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(mn,{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(mn,{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(Xa,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),f.length>0&&e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(al,{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(al,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"font-medium",children:I.name})]},I.id))})]})}),e.jsx(jo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(bc,{className:"h-5 w-5"}),"Comments (",_.length,")"]}),r?e.jsxs("form",{onSubmit:A,className:"flex gap-2",children:[e.jsx(_r,{placeholder:"Add a comment...",value:i,onChange:I=>d(I.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!i.trim()||b.isPending,children:e.jsx(Nn,{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(Ie,{children:e.jsx(Be,{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(Ie,{children:e.jsx(Be,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(vn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(_n,{className:"text-sm",children:C(I.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:I.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:jl(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:()=>N.mutate(I.id),children:e.jsx(yr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:I.content})]})]})})},I.id))})]})]})}):e.jsx(Ls,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(go,{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(da,{to:"/templates",children:"Back to Templates"})})]})})},Hqt=()=>{const{user:t}=$s(),[s,r]=k.useState(""),[n,a]=k.useState("all"),{data:o=[]}=ft({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}=ft({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:N}=await G.from("academy_resources").select("*").order("sort_order");if(N)throw N;return y.map(S=>({...S,resources:(b==null?void 0:b.filter(C=>C.video_id===S.id))||[]}))}}),{data:d=[]}=ft({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 N;const _=s===""||y.title.toLowerCase().includes(s.toLowerCase())||((N=y.description)==null?void 0:N.toLowerCase().includes(s.toLowerCase())),b=n==="all"||y.category_id===n;return _&&b}),p=y=>d.filter(_=>_.video_id===y).length,f=y=>d.some(_=>_.video_id===y&&_.user_id===(t==null?void 0:t.id));return e.jsx(Ls,{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(tn,{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(ta,{value:n,onValueChange:a,children:e.jsxs(Qn,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(ls,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(y=>e.jsx(ls,{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(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hn,{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(da,{to:`/academy/${y.id}`,children:e.jsxs(Ie,{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(hn,{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(Co,{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(rn,{className:"h-3 w-3"}),y.duration]})]}),e.jsxs(Lt,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(Ft,{className:"text-lg line-clamp-2",children:y.title})}),y.category&&e.jsx(Ye,{variant:"secondary",className:"w-fit",children:y.category.name})]}),e.jsxs(Be,{className:"pt-0",children:[y.description&&e.jsx(mr,{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(Ou,{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(mn,{className:"h-4 w-4"}),y.resources.length]})]})]})]})},y.id))})]})})};function Qet({resourceType:t,resourceId:s}){const{data:r=[]}=ft({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(Rl,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(da,{to:`/templates/${n.id}`,children:e.jsxs(Ye,{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(Rl,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const Gqt=(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},Wqt=()=>{const{videoId:t}=ho();br();const{user:s,isAdmin:r}=$s(),{toast:n}=va(),a=es(),{trackEngagement:o}=JA(),[l,i]=k.useState(""),{data:d,isLoading:u}=ft({queryKey:["academy-video",t],queryFn:async()=>{const{data:A,error:I}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:L}=await G.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...A,resources:L||[]}},enabled:!!t});k.useEffect(()=>{d&&o("academy_video",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p=[]}=ft({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:A,error:I}=await G.from("academy_video_likes").select("*").eq("video_id",t);if(I)throw I;return A},enabled:!!t}),{data:f=[]}=ft({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:A,error:I}=await G.from("academy_video_comments").select("*").eq("video_id",t).order("created_at",{ascending:!1});if(I)throw I;const L=[...new Set(A.map(q=>q.user_id))],{data:O}=await G.from("profiles").select("id, name").in("id",L),U=new Map((O==null?void 0:O.map(q=>[q.id,q.name]))||[]);return A.map(q=>({...q,user_name:U.get(q.user_id)||"Unknown User"}))},enabled:!!t}),y=Et({mutationFn:async A=>{const{error:I}=await G.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:A});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),i(""),n({title:"Comment added!"})},onError:A=>{n({title:"Error adding comment",description:A.message,variant:"destructive"})}}),_=Et({mutationFn:async A=>{const{error:I}=await G.from("academy_video_comments").delete().eq("id",A);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),b=Et({mutationFn:async()=>{const A=p.find(I=>I.user_id===(s==null?void 0:s.id));if(A){const{error:I}=await G.from("academy_video_likes").delete().eq("id",A.id);if(I)throw I}else{const{error:I}=await G.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),N=p.some(A=>A.user_id===(s==null?void 0:s.id)),w=A=>{switch(A==null?void 0:A.toLowerCase()){case"pdf":return"📄";case"pptx":case"ppt":return"📊";case"xlsx":case"xls":return"📈";case"docx":case"doc":return"📝";case"zip":return"📦";default:return"📁"}},S=A=>A.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),C=A=>{A.preventDefault(),!(!l.trim()||!s)&&y.mutate(l.trim())};return u?e.jsx(Ls,{title:"Academy",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):d?e.jsx(Ls,{title:d.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(da,{to:"/academy",children:[e.jsx(Ra,{className:"h-4 w-4"}),"Back to Academy"]})}),e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-black",style:{paddingTop:"56.25%"},children:["youtube","vimeo","loom","bunny_stream"].includes(d.video_type)?e.jsx("iframe",{src:Gqt(d.video_url,d.video_type),loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,height:"100%",width:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-white gap-4",children:[e.jsx(hn,{className:"h-16 w-16 opacity-50"}),e.jsx(K,{variant:"secondary",asChild:!0,children:e.jsxs("a",{href:d.video_url,target:"_blank",rel:"noopener noreferrer",className:"gap-2",children:[e.jsx(Kr,{className:"h-4 w-4"}),"Open Video"]})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:d.title}),d.category&&e.jsx(Ye,{variant:"secondary",children:d.category.name})]}),e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(da,{to:`/admin/academy?edit=${d.id}`,children:[e.jsx(pa,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(rE,{resourceType:"academy_video",resourceId:d.id,resourceTitle:d.title}),e.jsxs(K,{variant:N?"default":"outline",className:"gap-2 w-fit",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(Ou,{className:`h-4 w-4 ${N?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),d.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:d.description}})]}),d.resources&&d.resources.length>0&&e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(mn,{className:"h-4 w-4"}),"Resources"]}),e.jsx("div",{className:"grid gap-2",children:d.resources.map(A=>e.jsxs("a",{href:A.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-muted transition-colors",children:[e.jsx("span",{className:"text-2xl",children:w(A.file_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:A.title}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:A.file_type})]}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"})]},A.id))})]})}),e.jsx(Qet,{resourceType:"academy_video",resourceId:d.id}),e.jsx(jo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(bc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(_r,{placeholder:"Add a comment...",value:l,onChange:A=>i(A.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||y.isPending,children:e.jsx(Nn,{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(Ie,{children:e.jsx(Be,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(A=>e.jsx(Ie,{children:e.jsx(Be,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(vn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(_n,{className:"text-sm",children:S(A.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:A.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:jl(new Date(A.created_at),{addSuffix:!0})}),A.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(A.id),children:e.jsx(yr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:A.content})]})]})})},A.id))})]})]})}):e.jsx(Ls,{title:"Academy",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hn,{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(da,{to:"/academy",children:"Back to Academy"})})]})})};function Kqt(){const t=br(),[s,r]=k.useState(""),{data:n,isLoading:a}=ft({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}=ft({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}=ft({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}=ft({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kit_comments").select("kit_id");if(b)throw b;return _}}),d=n==null?void 0:n.filter(_=>{var b;return _.name.toLowerCase().includes(s.toLowerCase())||((b=_.description)==null?void 0:b.toLowerCase().includes(s.toLowerCase()))}),u=_=>(o==null?void 0:o.filter(b=>b.kit_id===_))||[],p=_=>(l==null?void 0:l.filter(b=>b.kit_id===_).length)||0,f=_=>(i==null?void 0:i.filter(b=>b.kit_id===_).length)||0,y=_=>{t(`/toolbox/${_}`)};return e.jsx(Ls,{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(tn,{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:[(d==null?void 0:d.length)||0," resource kit",(d==null?void 0:d.length)!==1?"s":""," available"]}),a?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((_,b)=>e.jsx(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsx(Ss,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(Ss,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ss,{className:"h-4 w-full mb-4"}),e.jsx(Ss,{className:"h-4 w-2/3"})]})},b))}):(d==null?void 0:d.length)===0?e.jsxs(Ie,{className:"p-12 text-center",children:[e.jsx(al,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resource kits found"}),e.jsx("p",{className:"text-muted-foreground",children:s?"Try adjusting your search terms":"Check back later for new resources"})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:d==null?void 0:d.map(_=>{const b=u(_.id).length,N=p(_.id),w=f(_.id);return e.jsxs(Ie,{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(al,{className:"h-16 w-16 text-muted-foreground"})})}),e.jsxs(Be,{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:Jde(_.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(mn,{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(Ou,{className:"h-3.5 w-3.5"}),N]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(bc,{className:"h-3.5 w-3.5"}),w]})]})]})]})]},_.id)})})]})})}const Zqt=()=>{const{kitId:t}=ho(),{user:s,isAdmin:r}=$s(),{toast:n}=va(),a=es(),{trackEngagement:o}=JA(),[l,i]=k.useState(""),{data:d,isLoading:u}=ft({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:A,error:I}=await G.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:L}=await G.from("resource_kit_files").select("*").eq("kit_id",t).order("sort_order"),{data:O}=await G.from("resource_kit_links").select("*").eq("kit_id",t).order("sort_order");return{...A,files:L||[],links:O||[]}},enabled:!!t});k.useEffect(()=>{d&&o("toolbox",d.id,d.name,"view")},[d==null?void 0:d.id]);const{data:p=[]}=ft({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:A,error:I}=await G.from("resource_kit_likes").select("*").eq("kit_id",t);if(I)throw I;return A},enabled:!!t}),{data:f=[]}=ft({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:A,error:I}=await G.from("resource_kit_comments").select("*").eq("kit_id",t).order("created_at",{ascending:!1});if(I)throw I;const L=[...new Set(A.map(q=>q.user_id))],{data:O}=await G.from("profiles").select("id, name").in("id",L),U=new Map((O==null?void 0:O.map(q=>[q.id,q.name]))||[]);return A.map(q=>({...q,user_name:U.get(q.user_id)||"Unknown User"}))},enabled:!!t}),y=Et({mutationFn:async A=>{const{error:I}=await G.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:A});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),i(""),n({title:"Comment added!"})},onError:A=>{n({title:"Error adding comment",description:A.message,variant:"destructive"})}}),_=Et({mutationFn:async A=>{const{error:I}=await G.from("resource_kit_comments").delete().eq("id",A);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),b=Et({mutationFn:async()=>{const A=p.find(I=>I.user_id===(s==null?void 0:s.id));if(A){const{error:I}=await G.from("resource_kit_likes").delete().eq("id",A.id);if(I)throw I}else{const{error:I}=await G.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),N=p.some(A=>A.user_id===(s==null?void 0:s.id)),w=A=>A.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),S=A=>A?A<1024?A+" B":A<1024*1024?(A/1024).toFixed(1)+" KB":(A/(1024*1024)).toFixed(1)+" MB":"",C=A=>{A.preventDefault(),!(!l.trim()||!s)&&y.mutate(l.trim())};return u?e.jsx(Ls,{title:"Toolbox",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):d?e.jsx(Ls,{title:d.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(da,{to:"/toolbox",children:[e.jsx(Ra,{className:"h-4 w-4"}),"Back to Toolbox"]})}),d.featured_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:d.featured_image_url,alt:d.name,className:"w-full max-h-[400px] object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:d.name})}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(da,{to:`/admin/toolbox?edit=${d.id}`,children:[e.jsx(pa,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(rE,{resourceType:"resource_kit",resourceId:d.id,resourceTitle:d.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:N?"default":"outline",className:"gap-2 rounded-full",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(Ou,{className:`h-4 w-4 ${N?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),d.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:d.description}})]}),d.files&&d.files.length>0&&e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(mn,{className:"h-4 w-4"}),"Included Resources (",d.files.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.files.map(A=>e.jsxs("a",{href:A.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",d.id,d.name,"click_pdf"),className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(mn,{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:S(A.file_size)})]})]}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},A.id))})]})}),d.links&&d.links.length>0&&e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Kr,{className:"h-4 w-4"}),"Canva Templates (",d.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.links.map(A=>e.jsxs("a",{href:A.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",d.id,d.name,"click_canva"),className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-purple-500/10",children:e.jsx(Kr,{className:"h-4 w-4 text-purple-600"})}),e.jsx("div",{className:"font-medium text-sm",children:A.title})]}),e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary transition-colors",children:"Open in Canva"})]},A.id))})]})}),e.jsx(Qet,{resourceType:"resource_kit",resourceId:d.id}),e.jsx(jo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(bc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(_r,{placeholder:"Add a comment...",value:l,onChange:A=>i(A.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||y.isPending,children:e.jsx(Nn,{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(Ie,{children:e.jsx(Be,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(A=>e.jsx(Ie,{children:e.jsx(Be,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(vn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(_n,{className:"text-sm",children:w(A.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:A.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:jl(new Date(A.created_at),{addSuffix:!0})}),A.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(A.id),children:e.jsx(yr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:A.content})]})]})})},A.id))})]})]})}):e.jsx(Ls,{title:"Toolbox",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(al,{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(da,{to:"/toolbox",children:"Back to Toolbox"})})]})})},Yqt=()=>{const t=br(),[s,r]=k.useState(""),[n,a]=k.useState("grid"),{data:o=[],isLoading:l}=ft({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"),N=new Map;_==null||_.forEach(C=>{N.set(C.swag_id,(N.get(C.swag_id)||0)+1)});const w=new Map;return b==null||b.forEach(C=>{w.set(C.swag_id,(w.get(C.swag_id)||0)+1)}),(u||[]).map(C=>({...C,links:(f||[]).filter(A=>A.swag_id===C.id)||[],likesCount:N.get(C.id)||0,commentsCount:w.get(C.id)||0}))}}),i=o.filter(u=>{var f;return u.title.toLowerCase().includes(s.toLowerCase())||((f=u.description)==null?void 0:f.toLowerCase().includes(s.toLowerCase()))}),d=u=>{t(`/social-swag/${u}`)};return e.jsx(Ls,{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(tn,{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(pp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Rh,{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(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsx(Ss,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(Ss,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ss,{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(Ie,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${n==="list"?"flex flex-row":""}`,onClick:()=>d(u.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${n==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[u.preview_image_url?e.jsx("img",{src:u.preview_image_url,alt:u.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),u.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Ye,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(go,{className:"h-3 w-3"}),u.links.length]})})]}),e.jsxs(Be,{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(Ou,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(bc,{className:"h-3.5 w-3.5"}),u.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:p=>{p.stopPropagation(),d(u.id)},children:[e.jsx(Kr,{className:"h-4 w-4"}),"View Details"]})]})]},u.id))})]})})};var ni=function(){return ni=Object.assign||function(s){for(var r,n=1,a=arguments.length;n1&&(d||!u),f=s>1&&(u||!d),y=function(){n&&o(n)},_=function(){a&&o(a)};return e.jsx(TUt,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:f,nextMonth:a,previousMonth:n,onPreviousClick:y,onNextClick:_})}function AUt(t){var s,r=zl(),n=r.classNames,a=r.disableNavigation,o=r.styles,l=r.captionLayout,i=r.components,d=(s=i==null?void 0:i.CaptionLabel)!==null&&s!==void 0?s:ttt,u;return a?u=e.jsx(d,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(mDe,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(mDe,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(pDe,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):u=e.jsxs(e.Fragment,{children:[e.jsx(d,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(pDe,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function EUt(t){var s=zl(),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 PUt(t,s,r){for(var n=r?f1(new Date):Bh(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=dl(n,o);a.push(l)}return a}function IUt(){var t=zl(),s=t.classNames,r=t.styles,n=t.showWeekNumber,a=t.locale,o=t.weekStartsOn,l=t.ISOWeek,i=t.formatters.formatWeekdayName,d=t.labels.labelWeekday,u=PUt(a,o,l);return e.jsxs("tr",{style:r.head_row,className:s.head_row,children:[n&&e.jsx("td",{style:r.head_cell,className:s.head_cell}),u.map(function(p,f){return e.jsx("th",{scope:"col",className:s.head_cell,style:r.head_cell,"aria-label":d(p,{locale:a}),children:i(p,{locale:a})},f)})]})}function LUt(){var t,s=zl(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:IUt;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function DUt(t){var s=zl(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var m4e=k.createContext(void 0);function RUt(t){if(!JR(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(m4e.Provider,{value:s,children:t.children})}return e.jsx(OUt,{initialProps:t.initialProps,children:t.children})}function OUt(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 N=!!(!p.selected&&o&&(n==null?void 0:n.length)===o);if(!N){var w=n?Jet([],n):[];if(p.selected){var S=w.findIndex(function(C){return rl(u,C)});w.splice(S,1)}else w.push(u);(_=s.onSelect)===null||_===void 0||_.call(s,w,u,p,f)}}},i={disabled:[]};n&&i.disabled.push(function(u){var p=o&&n.length>o-1,f=n.some(function(y){return rl(y,u)});return!!(p&&!f)});var d={selected:n,onDayClick:l,modifiers:i};return e.jsx(m4e.Provider,{value:d,children:r})}function p4e(){var t=k.useContext(m4e);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function FUt(t,s){var r=s||{},n=r.from,a=r.to;return n&&a?rl(a,t)&&rl(n,t)?void 0:rl(a,t)?{from:a,to:void 0}:rl(n,t)?void 0:YS(n,t)?{from:t,to:a}:{from:n,to:t}:a?YS(t,a)?{from:a,to:t}:{from:t,to:a}:n?XS(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var f4e=k.createContext(void 0);function zUt(t){if(!eO(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(f4e.Provider,{value:s,children:t.children})}return e.jsx(BUt,{initialProps:t.initialProps,children:t.children})}function BUt(t){var s=t.initialProps,r=t.children,n=s.selected,a=n||{},o=a.from,l=a.to,i=s.min,d=s.max,u=function(_,b,N){var w,S;(w=s.onDayClick)===null||w===void 0||w.call(s,_,b,N);var C=FUt(_,n);(S=s.onSelect)===null||S===void 0||S.call(s,C,_,b,N)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(p.range_start=[o],l?(p.range_end=[l],rl(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:Uie(o,i-1),before:dl(o,i-1)}),o&&l&&p.disabled.push({after:o,before:dl(o,i-1)}),!o&&l&&p.disabled.push({after:Uie(l,i-1),before:dl(l,i-1)})),d){if(o&&!l&&(p.disabled.push({before:dl(o,-d+1)}),p.disabled.push({after:dl(o,d-1)})),o&&l){var f=nf(l,o)+1,y=d-f;p.disabled.push({before:Uie(o,y)}),p.disabled.push({after:dl(l,y)})}!o&&l&&(p.disabled.push({before:dl(l,-d+1)}),p.disabled.push({after:dl(l,d-1)}))}return e.jsx(f4e.Provider,{value:{selected:n,onDayClick:u,modifiers:p},children:r})}function x4e(){var t=k.useContext(f4e);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function ioe(t){return Array.isArray(t)?Jet([],t):t!==void 0?[t]:[]}function $Ut(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=ioe(a)}),s}var Gg;(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"})(Gg||(Gg={}));var qUt=Gg.Selected,fv=Gg.Disabled,UUt=Gg.Hidden,VUt=Gg.Today,_ye=Gg.RangeEnd,bye=Gg.RangeMiddle,wye=Gg.RangeStart,HUt=Gg.Outside;function GUt(t,s,r){var n,a=(n={},n[qUt]=ioe(t.selected),n[fv]=ioe(t.disabled),n[UUt]=ioe(t.hidden),n[VUt]=[t.today],n[_ye]=[],n[bye]=[],n[wye]=[],n[HUt]=[],n);return t.fromDate&&a[fv].push({before:t.fromDate}),t.toDate&&a[fv].push({after:t.toDate}),JR(t)?a[fv]=a[fv].concat(s.modifiers[fv]):eO(t)&&(a[fv]=a[fv].concat(r.modifiers[fv]),a[wye]=r.modifiers[wye],a[bye]=r.modifiers[bye],a[_ye]=r.modifiers[_ye]),a}var ntt=k.createContext(void 0);function WUt(t){var s=zl(),r=p4e(),n=x4e(),a=GUt(s,r,n),o=$Ut(s.modifiers),l=ni(ni({},a),o);return e.jsx(ntt.Provider,{value:l,children:t.children})}function att(){var t=k.useContext(ntt);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function KUt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function ZUt(t){return!!(t&&typeof t=="object"&&"from"in t)}function YUt(t){return!!(t&&typeof t=="object"&&"after"in t)}function XUt(t){return!!(t&&typeof t=="object"&&"before"in t)}function QUt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function JUt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=nf(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=nf(t,n)>=0&&nf(a,t)>=0;return l}return a?rl(a,t):n?rl(n,t):!1}function eVt(t){return sNe(t)}function tVt(t){return Array.isArray(t)&&t.every(sNe)}function sVt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(eVt(r))return rl(t,r);if(tVt(r))return r.includes(t);if(ZUt(r))return JUt(t,r);if(QUt(r))return r.dayOfWeek.includes(t.getDay());if(KUt(r)){var n=nf(r.before,t),a=nf(r.after,t),o=n>0,l=a<0,i=YS(r.before,r.after);return i?l&&o:o||l}return YUt(r)?nf(t,r.after)>0:XUt(r)?nf(r.before,t)>0:typeof r=="function"?r(t):!1})}function g4e(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return sVt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!Fue(t,r)&&(a.outside=!0),a}function rVt(t,s){for(var r=xc(t[0]),n=nx(t[t.length-1]),a,o,l=r;l<=n;){var i=g4e(l,s),d=!i.disabled&&!i.hidden;if(!d){l=dl(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=dl(l,1)}return o||a}var nVt=365;function itt(t,s){var r=s.moveBy,n=s.direction,a=s.context,o=s.modifiers,l=s.retry,i=l===void 0?{count:0,lastFocused:t}:l,d=a.weekStartsOn,u=a.fromDate,p=a.toDate,f=a.locale,y={day:dl,week:y4,month:Tm,year:ESt,startOfWeek:function(w){return a.ISOWeek?f1(w):Bh(w,{locale:f,weekStartsOn:d})},endOfWeek:function(w){return a.ISOWeek?YWe(w):Rue(w,{locale:f,weekStartsOn:d})}},_=y[r](t,n==="after"?1:-1);n==="before"&&u?_=PSt([u,_]):n==="after"&&p&&(_=ISt([p,_]));var b=!0;if(o){var N=g4e(_,o);b=!N.disabled&&!N.hidden}return b?_:i.count>nVt?i.lastFocused:itt(_,{moveBy:r,direction:n,context:a,modifiers:o,retry:ni(ni({},i),{count:i.count+1})})}var ott=k.createContext(void 0);function aVt(t){var s=tO(),r=att(),n=k.useState(),a=n[0],o=n[1],l=k.useState(),i=l[0],d=l[1],u=rVt(s.displayMonths,r),p=a??(i&&s.isDateDisplayed(i))?i:u,f=function(){d(a),o(void 0)},y=function(w){o(w)},_=zl(),b=function(w,S){if(a){var C=itt(a,{moveBy:w,direction:S,context:_,modifiers:r});rl(a,C)||(s.goToDate(C,a),y(C))}},N={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(ott.Provider,{value:N,children:t.children})}function y4e(){var t=k.useContext(ott);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function iVt(t,s){var r=att(),n=g4e(t,r,s);return n}var v4e=k.createContext(void 0);function oVt(t){if(!khe(t.initialProps)){var s={selected:void 0};return e.jsx(v4e.Provider,{value:s,children:t.children})}return e.jsx(lVt,{initialProps:t.initialProps,children:t.children})}function lVt(t){var s=t.initialProps,r=t.children,n=function(o,l,i){var d,u,p;if((d=s.onDayClick)===null||d===void 0||d.call(s,o,l,i),l.selected&&!s.required){(u=s.onSelect)===null||u===void 0||u.call(s,void 0,o,l,i);return}(p=s.onSelect)===null||p===void 0||p.call(s,o,o,l,i)},a={selected:s.selected,onDayClick:n};return e.jsx(v4e.Provider,{value:a,children:r})}function ltt(){var t=k.useContext(v4e);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function cVt(t,s){var r=zl(),n=ltt(),a=p4e(),o=x4e(),l=y4e(),i=l.focusDayAfter,d=l.focusDayBefore,u=l.focusWeekAfter,p=l.focusWeekBefore,f=l.blur,y=l.focus,_=l.focusMonthBefore,b=l.focusMonthAfter,N=l.focusYearBefore,w=l.focusYearAfter,S=l.focusStartOfWeek,C=l.focusEndOfWeek,A=function(ie){var le,fe,xe,he;khe(r)?(le=n.onDayClick)===null||le===void 0||le.call(n,t,s,ie):JR(r)?(fe=a.onDayClick)===null||fe===void 0||fe.call(a,t,s,ie):eO(r)?(xe=o.onDayClick)===null||xe===void 0||xe.call(o,t,s,ie):(he=r.onDayClick)===null||he===void 0||he.call(r,t,s,ie)},I=function(ie){var le;y(t),(le=r.onDayFocus)===null||le===void 0||le.call(r,t,s,ie)},L=function(ie){var le;f(),(le=r.onDayBlur)===null||le===void 0||le.call(r,t,s,ie)},O=function(ie){var le;(le=r.onDayMouseEnter)===null||le===void 0||le.call(r,t,s,ie)},U=function(ie){var le;(le=r.onDayMouseLeave)===null||le===void 0||le.call(r,t,s,ie)},q=function(ie){var le;(le=r.onDayPointerEnter)===null||le===void 0||le.call(r,t,s,ie)},$=function(ie){var le;(le=r.onDayPointerLeave)===null||le===void 0||le.call(r,t,s,ie)},V=function(ie){var le;(le=r.onDayTouchCancel)===null||le===void 0||le.call(r,t,s,ie)},ee=function(ie){var le;(le=r.onDayTouchEnd)===null||le===void 0||le.call(r,t,s,ie)},Z=function(ie){var le;(le=r.onDayTouchMove)===null||le===void 0||le.call(r,t,s,ie)},J=function(ie){var le;(le=r.onDayTouchStart)===null||le===void 0||le.call(r,t,s,ie)},Y=function(ie){var le;(le=r.onDayKeyUp)===null||le===void 0||le.call(r,t,s,ie)},ce=function(ie){var le;switch(ie.key){case"ArrowLeft":ie.preventDefault(),ie.stopPropagation(),r.dir==="rtl"?i():d();break;case"ArrowRight":ie.preventDefault(),ie.stopPropagation(),r.dir==="rtl"?d():i();break;case"ArrowDown":ie.preventDefault(),ie.stopPropagation(),u();break;case"ArrowUp":ie.preventDefault(),ie.stopPropagation(),p();break;case"PageUp":ie.preventDefault(),ie.stopPropagation(),ie.shiftKey?N():_();break;case"PageDown":ie.preventDefault(),ie.stopPropagation(),ie.shiftKey?w():b();break;case"Home":ie.preventDefault(),ie.stopPropagation(),S();break;case"End":ie.preventDefault(),ie.stopPropagation(),C();break}(le=r.onDayKeyDown)===null||le===void 0||le.call(r,t,s,ie)},ae={onClick:A,onFocus:I,onBlur:L,onKeyDown:ce,onKeyUp:Y,onMouseEnter:O,onMouseLeave:U,onPointerEnter:q,onPointerLeave:$,onTouchCancel:V,onTouchEnd:ee,onTouchMove:Z,onTouchStart:J};return ae}function dVt(){var t=zl(),s=ltt(),r=p4e(),n=x4e(),a=khe(t)?s.selected:JR(t)?r.selected:eO(t)?n.selected:void 0;return a}function uVt(t){return Object.values(Gg).includes(t)}function hVt(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(uVt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function mVt(t,s){var r=ni({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=ni(ni({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function pVt(t,s,r){var n,a,o,l=zl(),i=y4e(),d=iVt(t,s),u=cVt(t,d),p=dVt(),f=!!(l.onDayClick||l.mode!=="default");k.useEffect(function(){var O;d.outside||i.focusedDay&&f&&rl(i.focusedDay,t)&&((O=r.current)===null||O===void 0||O.focus())},[i.focusedDay,t,r,f,d.outside]);var y=hVt(l,d).join(" "),_=mVt(l,d),b=!!(d.outside&&!l.showOutsideDays||d.hidden),N=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:DUt,w=e.jsx(N,{date:t,displayMonth:s,activeModifiers:d}),S={style:_,className:y,children:w,role:"gridcell"},C=i.focusTarget&&rl(i.focusTarget,t)&&!d.outside,A=i.focusedDay&&rl(i.focusedDay,t),I=ni(ni(ni({},S),(n={disabled:d.disabled,role:"gridcell"},n["aria-selected"]=d.selected,n.tabIndex=A||C?0:-1,n)),u),L={isButton:f,isHidden:b,activeModifiers:d,selectedDays:p,buttonProps:I,divProps:S};return L}function fVt(t){var s=k.useRef(null),r=pVt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(dce,ni({name:"day",ref:s},r.buttonProps)):e.jsx("div",ni({},r.divProps))}function xVt(t){var s=t.number,r=t.dates,n=zl(),a=n.onWeekNumberClick,o=n.styles,l=n.classNames,i=n.locale,d=n.labels.labelWeekNumber,u=n.formatters.formatWeekNumber,p=u(Number(s),{locale:i});if(!a)return e.jsx("span",{className:l.weeknumber,style:o.weeknumber,children:p});var f=d(Number(s),{locale:i}),y=function(_){a(s,r,_)};return e.jsx(dce,{name:"week-number","aria-label":f,className:l.weeknumber,style:o.weeknumber,onClick:y,children:p})}function gVt(t){var s,r,n=zl(),a=n.styles,o=n.classNames,l=n.showWeekNumber,i=n.components,d=(s=i==null?void 0:i.Day)!==null&&s!==void 0?s:fVt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:xVt,p;return l&&(p=e.jsx("td",{className:o.cell,style:a.cell,children:e.jsx(u,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:o.row,style:a.row,children:[p,t.dates.map(function(f){return e.jsx("td",{className:o.cell,style:a.cell,role:"presentation",children:e.jsx(d,{displayMonth:t.displayMonth,date:f})},RCt(f))})]})}function fDe(t,s,r){for(var n=r!=null&&r.ISOWeek?YWe(s):Rue(s,r),a=r!=null&&r.ISOWeek?f1(t):Bh(t,r),o=nf(n,a),l=[],i=0;i<=o;i++)l.push(dl(a,i));var d=l.reduce(function(u,p){var f=r!=null&&r.ISOWeek?rNe(p):aNe(p,r),y=u.find(function(_){return _.weekNumber===f});return y?(y.dates.push(p),u):(u.push({weekNumber:f,dates:[p]}),u)},[]);return d}function yVt(t,s){var r=fDe(xc(t),nx(t),s);if(s!=null&&s.useFixedWeeks){var n=FCt(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=y4(o,6-n),i=fDe(y4(o,1),l,s);r.push.apply(r,i)}}return r}function vVt(t){var s,r,n,a=zl(),o=a.locale,l=a.classNames,i=a.styles,d=a.hideHead,u=a.fixedWeeks,p=a.components,f=a.weekStartsOn,y=a.firstWeekContainsDate,_=a.ISOWeek,b=yVt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:_,locale:o,weekStartsOn:f,firstWeekContainsDate:y}),N=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:LUt,w=(r=p==null?void 0:p.Row)!==null&&r!==void 0?r:gVt,S=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:EUt;return e.jsxs("table",{id:t.id,className:l.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!d&&e.jsx(N,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:b.map(function(C){return e.jsx(w,{displayMonth:t.displayMonth,dates:C.dates,weekNumber:C.weekNumber},C.weekNumber)})}),e.jsx(S,{displayMonth:t.displayMonth})]})}function _Vt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var bVt=_Vt()?k.useLayoutEffect:k.useEffect,jye=!1,wVt=0;function xDe(){return"react-day-picker-".concat(++wVt)}function jVt(t){var s,r=t??(jye?xDe():null),n=k.useState(r),a=n[0],o=n[1];return bVt(function(){a===null&&o(xDe())},[]),k.useEffect(function(){jye===!1&&(jye=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function NVt(t){var s,r,n=zl(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,d=tO().displayMonths,u=jVt(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===d.length-1,N=!_&&!b;a==="rtl"&&(s=[_,b],b=s[0],_=s[1]),_&&(f.push(o.caption_start),y=ni(ni({},y),l.caption_start)),b&&(f.push(o.caption_end),y=ni(ni({},y),l.caption_end)),N&&(f.push(o.caption_between),y=ni(ni({},y),l.caption_between));var w=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:AUt;return e.jsxs("div",{className:f.join(" "),style:y,children:[e.jsx(w,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(vVt,{id:p,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function kVt(t){var s=zl(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function SVt(t){var s,r,n=t.initialProps,a=zl(),o=y4e(),l=tO(),i=k.useState(!1),d=i[0],u=i[1];k.useEffect(function(){a.initialFocus&&o.focusTarget&&(d||(o.focus(o.focusTarget),u(!0)))},[a.initialFocus,d,o.focus,o.focusTarget,o]);var p=[a.classNames.root,a.className];a.numberOfMonths>1&&p.push(a.classNames.multiple_months),a.showWeekNumber&&p.push(a.classNames.with_weeknumber);var f=ni(ni({},a.styles.root),a.style),y=Object.keys(n).filter(function(b){return b.startsWith("data-")}).reduce(function(b,N){var w;return ni(ni({},b),(w={},w[N]=n[N],w))},{}),_=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:kVt;return e.jsx("div",ni({className:p.join(" "),style:f,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},y,{children:e.jsx(_,{children:l.displayMonths.map(function(b,N){return e.jsx(NVt,{displayIndex:N,displayMonth:b},N)})})}))}function CVt(t){var s=t.children,r=Xqt(t,["children"]);return e.jsx(xUt,{initialProps:r,children:e.jsx(SUt,{children:e.jsx(oVt,{initialProps:r,children:e.jsx(RUt,{initialProps:r,children:e.jsx(zUt,{initialProps:r,children:e.jsx(WUt,{children:e.jsx(aVt,{children:s})})})})})})})}function MVt(t){return e.jsx(CVt,ni({},t,{children:e.jsx(SVt,{initialProps:t})}))}function ff({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(MVt,{showOutsideDays:r,className:Rt("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:Rt(tD({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:Rt(tD({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(wl,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(ja,{className:"h-4 w-4"})},...n})}ff.displayName="Calendar";function TVt(t){const s=AVt(t),r=k.forwardRef((n,a)=>{const{children:o,...l}=n,i=k.Children.toArray(o),d=i.find(PVt);if(d){const u=d.props.children,p=i.map(f=>f===d?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:k.isValidElement(u)?k.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}function AVt(t){const s=k.forwardRef((r,n)=>{const{children:a,...o}=r;if(k.isValidElement(a)){const l=LVt(a),i=IVt(o,a.props);return a.type!==k.Fragment&&(i.ref=n?Mm(n,l):l),k.cloneElement(a,i)}return k.Children.count(a)>1?k.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var EVt=Symbol("radix.slottable");function PVt(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===EVt}function IVt(t,s){const r={...s};for(const n in s){const a=t[n],o=s[n];/^on[A-Z]/.test(n)?a&&o?r[n]=(...i)=>{const d=o(...i);return a(...i),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function LVt(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 She="Popover",[ctt]=bd(She,[_0]),sO=_0(),[DVt,kw]=ctt(She),dtt=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=sO(s),d=k.useRef(null),[u,p]=k.useState(!1),[f,y]=Bu({prop:n,defaultProp:a??!1,onChange:o,caller:She});return e.jsx(CR,{...i,children:e.jsx(DVt,{scope:s,contentId:mu(),triggerRef:d,open:f,onOpenChange:y,onOpenToggle:k.useCallback(()=>y(_=>!_),[y]),hasCustomAnchor:u,onCustomAnchorAdd:k.useCallback(()=>p(!0),[]),onCustomAnchorRemove:k.useCallback(()=>p(!1),[]),modal:l,children:r})})};dtt.displayName=She;var utt="PopoverAnchor",RVt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=kw(utt,r),o=sO(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return k.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(RA,{...o,...n,ref:s})});RVt.displayName=utt;var htt="PopoverTrigger",mtt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=kw(htt,r),o=sO(r),l=Ma(s,a.triggerRef),i=e.jsx(dn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":ytt(a.open),...n,ref:l,onClick:Tr(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(RA,{asChild:!0,...o,children:i})});mtt.displayName=htt;var _4e="PopoverPortal",[OVt,FVt]=ctt(_4e,{forceMount:void 0}),ptt=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=kw(_4e,s);return e.jsx(OVt,{scope:s,forceMount:r,children:e.jsx(wd,{present:r||o.open,children:e.jsx(PA,{asChild:!0,container:a,children:n})})})};ptt.displayName=_4e;var HT="PopoverContent",ftt=k.forwardRef((t,s)=>{const r=FVt(HT,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=kw(HT,t.__scopePopover);return e.jsx(wd,{present:n||o.open,children:o.modal?e.jsx(BVt,{...a,ref:s}):e.jsx($Vt,{...a,ref:s})})});ftt.displayName=HT;var zVt=TVt("PopoverContent.RemoveScroll"),BVt=k.forwardRef((t,s)=>{const r=kw(HT,t.__scopePopover),n=k.useRef(null),a=Ma(s,n),o=k.useRef(!1);return k.useEffect(()=>{const l=n.current;if(l)return vue(l)},[]),e.jsx(LR,{as:zVt,allowPinchZoom:!0,children:e.jsx(xtt,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Tr(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Tr(t.onPointerDownOutside,l=>{const i=l.detail.originalEvent,d=i.button===0&&i.ctrlKey===!0,u=i.button===2||d;o.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Tr(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),$Vt=k.forwardRef((t,s)=>{const r=kw(HT,t.__scopePopover),n=k.useRef(!1),a=k.useRef(!1);return e.jsx(xtt,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var d,u;(d=t.onInteractOutside)==null||d.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((u=r.triggerRef.current)==null?void 0:u.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),xtt=k.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:p,...f}=t,y=kw(HT,r),_=sO(r);return xue(),e.jsx(PR,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(mw,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>y.onOpenChange(!1),children:e.jsx(MR,{"data-state":ytt(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)"}})})})}),gtt="PopoverClose",qVt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=kw(gtt,r);return e.jsx(dn.button,{type:"button",...n,ref:s,onClick:Tr(t.onClick,()=>a.onOpenChange(!1))})});qVt.displayName=gtt;var UVt="PopoverArrow",VVt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=sO(r);return e.jsx(TR,{...a,...n,ref:s})});VVt.displayName=UVt;function ytt(t){return t?"open":"closed"}var HVt=dtt,GVt=mtt,WVt=ptt,vtt=ftt;const yo=HVt,vo=GVt,uo=k.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(WVt,{children:e.jsx(vtt,{ref:a,align:s,sideOffset:r,className:Rt("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})}));uo.displayName=vtt.displayName;const KVt=wC("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"}}),b4e=k.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:Rt(KVt({variant:s}),t),...r}));b4e.displayName="Alert";const ZVt=k.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:Rt("mb-1 font-medium leading-none tracking-tight",t),...s}));ZVt.displayName="AlertTitle";const w4e=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Rt("text-sm [&_p]:leading-relaxed",t),...s}));w4e.displayName="AlertDescription";function YVt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=es(),[d,u]=k.useState(a),[p,f]=k.useState([]),[y,_]=k.useState(null),[b,N]=k.useState("now"),[w,S]=k.useState(cIe(fIe(new Date),1)),[C,A]=k.useState("12"),[I,L]=k.useState("00"),[O,U]=k.useState("PM");k.useEffect(()=>{if(t){u(a),N("now"),f([]);const Ne=cIe(fIe(new Date),1);S(Ne);const Ve=Ne.getHours();A(String(Ve>12?Ve-12:Ve===0?12:Ve)),L("00"),U(Ve>=12?"PM":"AM")}},[t,a]);const q=()=>{if(!w)return null;let Ne=parseInt(C);const Ve=parseInt(I);return O==="PM"&&Ne!==12&&(Ne+=12),O==="AM"&&Ne===12&&(Ne=0),QL(XL(w,Ne),Ve)},{data:$,isLoading:V}=ft({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:Ne}}=await G.auth.getUser();if(!Ne)return[];const{data:Ve,error:Te}=await G.from("social_accounts").select("*").eq("user_id",Ne.id).eq("is_active",!0).order("platform",{ascending:!0});if(Te)throw Te;return console.log("Fetched social accounts for posting:",Ve),Ve},enabled:t,staleTime:0}),ee=Et({mutationFn:async({accountId:Ne,platform:Ve})=>{_(Ne);const{data:Te,error:Ae}=await G.functions.invoke("social-post",{body:{platform:Ve,accountId:Ne,imageUrl:r,caption:d}});if(Ae)throw Ae;if(Te!=null&&Te.error)throw new Error(Te.error);return Te},onSuccess:Ne=>{const Ve=Ne.platform==="facebook"?"Facebook":Ne.platform==="instagram"?"Instagram":Ne.platform==="linkedin"?"LinkedIn":"Google Business";me.success(`Posted to ${Ve}!`)},onError:Ne=>{me.error(`Failed to post: ${Ne.message}`)},onSettled:()=>{_(null)}}),Z=Et({mutationFn:async({accountId:Ne,platform:Ve,scheduledFor:Te})=>{const{data:{user:Ae}}=await G.auth.getUser();if(!Ae)throw new Error("Not authenticated");const{error:ze}=await G.from("scheduled_posts").insert({user_id:Ae.id,social_account_id:Ne,platform:Ve,image_url:r,caption:d,swag_item_id:o||null,reel_id:l||null,scheduled_for:Te.toISOString(),status:"scheduled"});if(ze)throw ze;return{platform:Ve}},onSuccess:Ne=>{const Ve=Ne.platform==="facebook"?"Facebook":Ne.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Post scheduled for ${Ve}!`)},onError:Ne=>{me.error(`Failed to schedule: ${Ne.message}`)}}),J=async()=>{if(p.length===0){me.error("Please select at least one account");return}if(b==="schedule"){const Ne=q();if(!Ne||Ne<=new Date){me.error("Please select a future date and time");return}for(const Ve of p){const Te=$==null?void 0:$.find(Ae=>Ae.id===Ve);Te&&await Z.mutateAsync({accountId:Ve,platform:Te.platform,scheduledFor:Ne})}i.invalidateQueries({queryKey:["scheduled-posts"]}),me.success(`${p.length} post(s) scheduled for ${gs(Ne,"PPp")}`)}else for(const Ne of p){const Ve=$==null?void 0:$.find(Te=>Te.id===Ne);Ve&&await ee.mutateAsync({accountId:Ne,platform:Ve.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),f([]),s(!1)},Y=Ne=>{f(Ve=>Ve.includes(Ne)?Ve.filter(Te=>Te!==Ne):[...Ve,Ne])},ce=($==null?void 0:$.filter(Ne=>Ne.platform==="facebook"))||[],ae=($==null?void 0:$.filter(Ne=>Ne.platform==="instagram"))||[],ie=($==null?void 0:$.filter(Ne=>Ne.platform==="linkedin"))||[],le=($==null?void 0:$.filter(Ne=>Ne.platform==="google_business"))||[],fe=(($==null?void 0:$.length)||0)>0,xe=ee.isPending||Z.isPending,he=Array.from({length:12},(Ne,Ve)=>String(Ve+1)),we=["00","15","30","45"];return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Create Social Post"}),e.jsx(Rr,{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(ge,{htmlFor:"caption",children:"Caption"}),e.jsx(_r,{id:"caption",placeholder:"Write a caption for your post...",value:d,onChange:Ne=>u(Ne.target.value),rows:3}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.length,"/2200 characters"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ge,{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:()=>N("now"),className:Rt("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:()=>N("schedule"),className:Rt("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(rn,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Rt("justify-start text-left font-normal flex-1",!w&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),w?gs(w,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(ff,{mode:"single",selected:w,onSelect:S,disabled:Ne=>Nee.jsx(yt,{value:Ne,children:Ne},Ne))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(zs,{value:I,onValueChange:L,children:[e.jsx(Os,{className:"w-[70px]",children:e.jsx(qs,{})}),e.jsx(Fs,{children:we.map(Ne=>e.jsx(yt,{value:Ne,children:Ne},Ne))})]}),e.jsxs(zs,{value:O,onValueChange:Ne=>U(Ne),children:[e.jsx(Os,{className:"w-[70px]",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"AM",children:"AM"}),e.jsx(yt,{value:"PM",children:"PM"})]})]})]})]}),w&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",gs(q()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ge,{children:"Post to"}),V&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ps,{className:"h-6 w-6 animate-spin"})}),!V&&!fe&&e.jsxs(b4e,{children:[e.jsx(co,{className:"h-4 w-4"}),e.jsxs(w4e,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(da,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx(So,{className:"h-3.5 w-3.5"}),"Connect your Facebook, Instagram & LinkedIn"]})]})]}),ce.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(du,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),ce.map(Ne=>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(Gi,{checked:p.includes(Ne.id),onCheckedChange:()=>Y(Ne.id),disabled:y===Ne.id}),e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ca,{src:Ne.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(du,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Ne.page_name||Ne.platform_username}),y===Ne.id&&e.jsx(ps,{className:"h-4 w-4 animate-spin"})]},Ne.id))]}),ae.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(hu,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),ae.map(Ne=>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(Gi,{checked:p.includes(Ne.id),onCheckedChange:()=>Y(Ne.id),disabled:y===Ne.id}),e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ca,{src:Ne.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(hu,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",Ne.platform_username]}),y===Ne.id&&e.jsx(ps,{className:"h-4 w-4 animate-spin"})]},Ne.id))]}),ie.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(fp,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),ie.map(Ne=>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(Gi,{checked:p.includes(Ne.id),onCheckedChange:()=>Y(Ne.id),disabled:y===Ne.id}),e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ca,{src:Ne.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(fp,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Ne.platform_username}),y===Ne.id&&e.jsx(ps,{className:"h-4 w-4 animate-spin"})]},Ne.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(La,{className:"h-4 w-4 text-red-600"})," Google Business"]}),le.map(Ne=>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(Gi,{checked:p.includes(Ne.id),onCheckedChange:()=>Y(Ne.id),disabled:y===Ne.id}),e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ca,{src:Ne.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(La,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Ne.page_name||Ne.platform_username}),y===Ne.id&&e.jsx(ps,{className:"h-4 w-4 animate-spin"})]},Ne.id))]})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:J,disabled:p.length===0||xe,className:"gap-2",children:[xe?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):b==="schedule"?e.jsx(nn,{className:"h-4 w-4"}):e.jsx(Nn,{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 XVt(){const t=es(),[s,r]=k.useState(void 0),[n,a]=k.useState("all"),[o,l]=k.useState(null),[i,d]=k.useState(""),[u,p]=k.useState(void 0),[f,y]=k.useState("12"),[_,b]=k.useState("00"),[N,w]=k.useState("PM"),{data:S=[],isLoading:C}=ft({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:le,error:fe}=await G.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(fe)throw fe;return le}}),A=S.filter(le=>{if(n!=="all"&&le.status!==n)return!1;if(s&&le.scheduled_for){const fe=new Date(le.scheduled_for);if(!rl(fe,s))return!1}return!0}),I=S.filter(le=>le.scheduled_for).map(le=>Am(new Date(le.scheduled_for))),L=Et({mutationFn:async le=>{const{error:fe}=await G.from("scheduled_posts").update({caption:le.caption,scheduled_for:le.scheduled_for}).eq("id",le.id);if(fe)throw fe},onSuccess:()=>{me.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:le=>{me.error(`Failed to update: ${le.message}`)}}),O=Et({mutationFn:async le=>{const{error:fe}=await G.from("scheduled_posts").update({status:"cancelled"}).eq("id",le);if(fe)throw fe},onSuccess:()=>{me.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{me.error(`Failed to cancel: ${le.message}`)}}),U=Et({mutationFn:async le=>{const{error:fe}=await G.from("scheduled_posts").delete().eq("id",le);if(fe)throw fe},onSuccess:()=>{me.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{me.error(`Failed to delete: ${le.message}`)}}),q=Et({mutationFn:async le=>{const{data:fe,error:xe}=await G.functions.invoke("social-post",{body:{platform:le.platform,accountId:le.social_account_id,imageUrl:le.image_url,caption:le.caption}});if(xe)throw xe;if(fe!=null&&fe.error)throw new Error(fe.error);return await G.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:fe.postId}).eq("id",le.id),fe},onSuccess:le=>{const fe=le.platform==="facebook"?"Facebook":le.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Posted to ${fe}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{me.error(`Failed to post: ${le.message}`)}}),$=le=>{if(l(le),d(le.caption||""),le.scheduled_for){const fe=new Date(le.scheduled_for);p(fe);const xe=fe.getHours();y(String(xe>12?xe-12:xe===0?12:xe)),b(String(fe.getMinutes()).padStart(2,"0")),w(xe>=12?"PM":"AM")}},V=()=>{if(!o||!u)return;let le=parseInt(f);const fe=parseInt(_);N==="PM"&&le!==12&&(le+=12),N==="AM"&&le===12&&(le=0);const xe=QL(XL(u,le),fe);L.mutate({id:o.id,caption:i,scheduled_for:xe.toISOString()})},ee=le=>{switch(le){case"facebook":return e.jsx(du,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(hu,{className:"h-4 w-4 text-pink-600"});case"linkedin":return e.jsx(fp,{className:"h-4 w-4 text-blue-700"});default:return null}},Z=le=>{switch(le){case"scheduled":return e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(rn,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(Ye,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(si,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(Ye,{variant:"destructive",className:"gap-1",children:[e.jsx(Ql,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(Ye,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(co,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(Ye,{variant:"outline",children:le})}},J=Array.from({length:12},(le,fe)=>String(fe+1)),Y=["00","15","30","45"],ce=S.filter(le=>le.status==="scheduled").length,ae=S.filter(le=>le.status==="posted").length,ie=S.filter(le=>le.status==="scheduled"&&le.scheduled_for&&zCt(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(Ie,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ce}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Scheduled"})]}),e.jsxs(Ie,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ie}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Upcoming"})]}),e.jsxs(Ie,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ae}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Posted"})]}),e.jsxs(Ie,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:S.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(Ie,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(xd,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(ff,{mode:"single",selected:s,onSelect:r,className:Rt("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(Dg,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(le=>e.jsx(K,{variant:n===le?"default":"outline",size:"sm",onClick:()=>a(le),className:"capitalize",children:le},le))})]}),C&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ps,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!C&&A.length===0&&e.jsxs(Ie,{className:"p-8 text-center",children:[e.jsx(nn,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"font-medium mb-2",children:"No posts found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?`No posts scheduled for ${gs(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:A.map(le=>{var fe,xe;return e.jsx(Ie,{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(Be,{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:[ee(le.platform),e.jsx("span",{className:"font-medium",children:((fe=le.social_accounts)==null?void 0:fe.page_name)||((xe=le.social_accounts)==null?void 0:xe.platform_username)||"Unknown"}),Z(le.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[le.status==="scheduled"&&e.jsxs(S1,{children:[e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$(le),children:e.jsx(pa,{className:"h-4 w-4"})})}),e.jsx(Il,{children:"Edit post"})]}),e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>q.mutate(le),disabled:q.isPending,children:q.isPending?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(Nn,{className:"h-4 w-4"})})}),e.jsx(Il,{children:"Post now"})]}),e.jsxs(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Cancel this scheduled post?"}),e.jsx(vl,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Keep"}),e.jsx(nl,{onClick:()=>O.mutate(le.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(nl,{onClick:()=>U.mutate(le.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(le.status==="posted"||le.status==="cancelled"||le.status==="failed")&&e.jsxs(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Delete this post?"}),e.jsx(vl,{children:"This will permanently remove this post from your history."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:()=>U.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(rn,{className:"h-3 w-3"}),le.status==="posted"&&le.posted_at?`Posted ${gs(new Date(le.posted_at),"PPp")}`:le.scheduled_for?`Scheduled for ${gs(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(fs,{open:!!o,onOpenChange:le=>!le&&l(null),children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Edit Scheduled Post"}),e.jsx(Rr,{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(ge,{children:"Caption"}),e.jsx(_r,{value:i,onChange:le=>d(le.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[e.jsx(ge,{children:"Schedule for"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Rt("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),u?gs(u,"PPP"):"Pick a date"]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(ff,{mode:"single",selected:u,onSelect:p,disabled:le=>lee.jsx(yt,{value:le,children:le},le))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(zs,{value:_,onValueChange:b,children:[e.jsx(Os,{className:"w-[70px]",children:e.jsx(qs,{})}),e.jsx(Fs,{children:Y.map(le=>e.jsx(yt,{value:le,children:le},le))})]}),e.jsxs(zs,{value:N,onValueChange:le=>w(le),children:[e.jsx(Os,{className:"w-[70px]",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"AM",children:"AM"}),e.jsx(yt,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{onClick:V,disabled:L.isPending,children:[L.isPending?e.jsx(ps,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function Xz(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 _tt={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 Xz=="function"&&Xz;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 N=n[u][1][b];return l(N||b)},_,_.exports,r,n,a,o)}return a[u].exports}for(var i=typeof Xz=="function"&&Xz,d=0;d>2,_=(3&u)<<4|p>>4,b=1>6:64,N=2>4,p=(15&y)<<4|(_=i.indexOf(d.charAt(N++)))>>2,f=(3&_)<<6|(b=i.indexOf(d.charAt(N++))),C[w++]=u,_!==64&&(C[w++]=p),b!==64&&(C[w++]=f);return C}},{"./support":30,"./utils":32}],2:[function(r,n,a){var o=r("./external"),l=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),d=r("./stream/DataLengthProbe");function u(p,f,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 d("data_length")),f=this;return p.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),p},getCompressedWorker:function(){return new l(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(p,f,y){return p.pipe(new i).pipe(new d("uncompressedSize")).pipe(f.compressWorker(y)).pipe(new d("compressedSize")).withStreamInfo("compression",f)},n.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,n,a){var o=r("./stream/GenericWorker");a.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},a.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,n,a){var o=r("./utils"),l=function(){for(var i,d=[],u=0;u<256;u++){i=u;for(var p=0;p<8;p++)i=1&i?3988292384^i>>>1:i>>>1;d[u]=i}return d}();n.exports=function(i,d){return i!==void 0&&i.length?o.getTypeOf(i)!=="string"?function(u,p,f,y){var _=l,b=y+f;u^=-1;for(var N=y;N>>8^_[255&(u^p[N])];return-1^u}(0|d,i,i.length,0):function(u,p,f,y){var _=l,b=y+f;u^=-1;for(var N=y;N>>8^_[255&(u^p.charCodeAt(N))];return-1^u}(0|d,i,i.length,0):0}},{"./utils":32}],5:[function(r,n,a){a.base64=!1,a.binary=!1,a.dir=!1,a.createFolders=!0,a.date=null,a.compression=null,a.compressionOptions=null,a.comment=null,a.unixPermissions=null,a.dosPermissions=null},{}],6:[function(r,n,a){var o=null;o=typeof Promise<"u"?Promise:r("lie"),n.exports={Promise:o}},{lie:37}],7:[function(r,n,a){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",l=r("pako"),i=r("./utils"),d=r("./stream/GenericWorker"),u=o?"uint8array":"array";function p(f,y){d.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=y,this.meta={}}a.magic="\b\0",i.inherits(p,d),p.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(u,f.data),!1)},p.prototype.flush=function(){d.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},p.prototype.cleanUp=function(){d.prototype.cleanUp.call(this),this._pako=null},p.prototype._createPako=function(){this._pako=new l[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(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 N,w="";for(N=0;N>>=8;return w}function l(_,b,N,w,S,C){var A,I,L=_.file,O=_.compression,U=C!==u.utf8encode,q=i.transformTo("string",C(L.name)),$=i.transformTo("string",u.utf8encode(L.name)),V=L.comment,ee=i.transformTo("string",C(V)),Z=i.transformTo("string",u.utf8encode(V)),J=$.length!==L.name.length,Y=Z.length!==V.length,ce="",ae="",ie="",le=L.dir,fe=L.date,xe={crc32:0,compressedSize:0,uncompressedSize:0};b&&!N||(xe.crc32=_.crc32,xe.compressedSize=_.compressedSize,xe.uncompressedSize=_.uncompressedSize);var he=0;b&&(he|=8),U||!J&&!Y||(he|=2048);var we=0,Ne=0;le&&(we|=16),S==="UNIX"?(Ne=798,we|=function(Te,Ae){var ze=Te;return Te||(ze=Ae?16893:33204),(65535&ze)<<16}(L.unixPermissions,le)):(Ne=20,we|=function(Te){return 63&(Te||0)}(L.dosPermissions)),A=fe.getUTCHours(),A<<=6,A|=fe.getUTCMinutes(),A<<=5,A|=fe.getUTCSeconds()/2,I=fe.getUTCFullYear()-1980,I<<=4,I|=fe.getUTCMonth()+1,I<<=5,I|=fe.getUTCDate(),J&&(ae=o(1,1)+o(p(q),4)+$,ce+="up"+o(ae.length,2)+ae),Y&&(ie=o(1,1)+o(p(ee),4)+Z,ce+="uc"+o(ie.length,2)+ie);var Ve="";return Ve+=` \0`,Ve+=o(he,2),Ve+=O.magic,Ve+=o(A,2),Ve+=o(I,2),Ve+=o(xe.crc32,4),Ve+=o(xe.compressedSize,4),Ve+=o(xe.uncompressedSize,4),Ve+=o(q.length,2),Ve+=o(ce.length,2),{fileRecord:f.LOCAL_FILE_HEADER+Ve+q+ce,dirRecord:f.CENTRAL_FILE_HEADER+o(Ne,2)+Ve+o(ee.length,2)+"\0\0\0\0"+o(we,4)+o(w,4)+q+ce+ee}}var i=r("../utils"),d=r("../stream/GenericWorker"),u=r("../utf8"),p=r("../crc32"),f=r("../signature");function y(_,b,N,w){d.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=N,this.encodeFileName=w,this.streamFiles=_,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(y,d),y.prototype.push=function(_){var b=_.meta.percent||0,N=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(_):(this.bytesWritten+=_.data.length,d.prototype.push.call(this,{data:_.data,meta:{currentFile:this.currentFile,percent:N?(b+100*(N-w-1))/N:100}}))},y.prototype.openedSource=function(_){this.currentSourceOffset=this.bytesWritten,this.currentFile=_.file.name;var b=this.streamFiles&&!_.file.dir;if(b){var N=l(_,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:N.fileRecord,meta:{percent:0}})}else this.accumulate=!0},y.prototype.closedSource=function(_){this.accumulate=!1;var b=this.streamFiles&&!_.file.dir,N=l(_,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(N.dirRecord),b)this.push({data:function(w){return f.DATA_DESCRIPTOR+o(w.crc32,4)+o(w.compressedSize,4)+o(w.uncompressedSize,4)}(_),meta:{percent:100}});else for(this.push({data:N.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;d--)u=(u<<8)+this.byteAt(d);return this.index+=i,u},readString:function(i){return o.transformTo("string",this.readData(i))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var i=this.readInt(4);return new Date(Date.UTC(1980+(i>>25&127),(i>>21&15)-1,i>>16&31,i>>11&31,i>>5&63,(31&i)<<1))}},n.exports=l},{"../utils":32}],19:[function(r,n,a){var o=r("./Uint8ArrayReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.readData=function(i){this.checkOffset(i);var d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},n.exports=l},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,n,a){var o=r("./DataReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},l.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},l.prototype.readAndCheckSignature=function(i){return i===this.readData(4)},l.prototype.readData=function(i){this.checkOffset(i);var d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},n.exports=l},{"../utils":32,"./DataReader":18}],21:[function(r,n,a){var o=r("./ArrayReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var d=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},n.exports=l},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,a){var o=r("../utils"),l=r("../support"),i=r("./ArrayReader"),d=r("./StringReader"),u=r("./NodeBufferReader"),p=r("./Uint8ArrayReader");n.exports=function(f){var 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 d(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,n,a){a.LOCAL_FILE_HEADER="PK",a.CENTRAL_FILE_HEADER="PK",a.CENTRAL_DIRECTORY_END="PK",a.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",a.ZIP64_CENTRAL_DIRECTORY_END="PK",a.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,n,a){var o=r("./GenericWorker"),l=r("../utils");function i(d){o.call(this,"ConvertWorker to "+d),this.destType=d}l.inherits(i,o),i.prototype.processChunk=function(d){this.push({data:l.transformTo(this.destType,d.data),meta:d.meta})},n.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(r,n,a){var o=r("./GenericWorker"),l=r("../crc32");function i(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(i,o),i.prototype.processChunk=function(d){this.streamInfo.crc32=l(d.data,this.streamInfo.crc32||0),this.push(d)},n.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(d){l.call(this,"DataLengthProbe for "+d),this.propName=d,this.withStreamInfo(d,0)}o.inherits(i,l),i.prototype.processChunk=function(d){if(d){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+d.data.length}l.prototype.processChunk.call(this,d)},n.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(d){l.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,d.then(function(p){u.dataIsReady=!0,u.data=p,u.max=p&&p.length||0,u.type=o.getTypeOf(p),u.isPaused||u._tickAndRepeat()},function(p){u.error(p)})}o.inherits(i,l),i.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var d=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":d=this.data.substring(this.index,u);break;case"uint8array":d=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":d=this.data.slice(this.index,u)}return this.index=u,this.push({data:d,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(r,n,a){function o(l){this.name=l||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(l){this.emit("data",l)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(l){this.emit("error",l)}return!0},error:function(l){return!this.isFinished&&(this.isPaused?this.generatedError=l:(this.isFinished=!0,this.emit("error",l),this.previous&&this.previous.error(l),this.cleanUp()),!0)},on:function(l,i){return this._listeners[l].push(i),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(l,i){if(this._listeners[l])for(var d=0;d "+l:l}},n.exports=o},{}],29:[function(r,n,a){var o=r("../utils"),l=r("./ConvertWorker"),i=r("./GenericWorker"),d=r("../base64"),u=r("../support"),p=r("../external"),f=null;if(u.nodestream)try{f=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function y(b,N){return new p.Promise(function(w,S){var C=[],A=b._internalType,I=b._outputType,L=b._mimeType;b.on("data",function(O,U){C.push(O),N&&N(U)}).on("error",function(O){C=[],S(O)}).on("end",function(){try{var O=function(U,q,$){switch(U){case"blob":return o.newBlob(o.transformTo("arraybuffer",q),$);case"base64":return d.encode(q);default:return o.transformTo(U,q)}}(I,function(U,q){var $,V=0,ee=null,Z=0;for($=0;$"u")a.blob=!1;else{var o=new ArrayBuffer(0);try{a.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var l=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);l.append(o),a.blob=l.getBlob("application/zip").size===0}catch{a.blob=!1}}}try{a.nodestream=!!r("readable-stream").Readable}catch{a.nodestream=!1}},{"readable-stream":16}],31:[function(r,n,a){for(var o=r("./utils"),l=r("./support"),i=r("./nodejsUtils"),d=r("./stream/GenericWorker"),u=new Array(256),p=0;p<256;p++)u[p]=252<=p?6:248<=p?5:240<=p?4:224<=p?3:192<=p?2:1;u[254]=u[254]=1;function f(){d.call(this,"utf-8 decode"),this.leftOver=null}function y(){d.call(this,"utf-8 encode")}a.utf8encode=function(_){return l.nodebuffer?i.newBufferFrom(_,"utf-8"):function(b){var N,w,S,C,A,I=b.length,L=0;for(C=0;C>>6:(w<65536?N[A++]=224|w>>>12:(N[A++]=240|w>>>18,N[A++]=128|w>>>12&63),N[A++]=128|w>>>6&63),N[A++]=128|63&w);return N}(_)},a.utf8decode=function(_){return l.nodebuffer?o.transformTo("nodebuffer",_).toString("utf-8"):function(b){var N,w,S,C,A=b.length,I=new Array(2*A);for(N=w=0;N>10&1023,I[w++]=56320|1023&S)}return I.length!==w&&(I.subarray?I=I.subarray(0,w):I.length=w),o.applyFromCharCode(I)}(_=o.transformTo(l.uint8array?"uint8array":"array",_))},o.inherits(f,d),f.prototype.processChunk=function(_){var b=o.transformTo(l.uint8array?"uint8array":"array",_.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var N=b;(b=new Uint8Array(N.length+this.leftOver.length)).set(this.leftOver,0),b.set(N,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var w=function(C,A){var I;for((A=A||C.length)>C.length&&(A=C.length),I=A-1;0<=I&&(192&C[I])==128;)I--;return I<0||I===0?A:I+u[C[I]]>A?I:A}(b),S=b;w!==b.length&&(l.uint8array?(S=b.subarray(0,w),this.leftOver=b.subarray(w,b.length)):(S=b.slice(0,w),this.leftOver=b.slice(w,b.length))),this.push({data:a.utf8decode(S),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,d),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"),d=r("./external");function u(N){return N}function p(N,w){for(var S=0;S>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,N,w,S=_.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});_.index+4>>6:(_<65536?y[w++]=224|_>>>12:(y[w++]=240|_>>>18,y[w++]=128|_>>>12&63),y[w++]=128|_>>>6&63),y[w++]=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,C[b++]=56320|1023&N)}return p(C,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:_+d[f[_]]>y?_:y}},{"./common":41}],43:[function(r,n,a){n.exports=function(o,l,i,d){for(var u=65535&o|0,p=o>>>16&65535|0,f=0;i!==0;){for(i-=f=2e3>>1:l>>>1;i[d]=l}return i}();n.exports=function(l,i,d,u){var p=o,f=u+d;l^=-1;for(var 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"),d=r("./adler32"),u=r("./crc32"),p=r("./messages"),f=0,y=4,_=0,b=-2,N=-1,w=4,S=2,C=8,A=9,I=286,L=30,O=19,U=2*I+1,q=15,$=3,V=258,ee=V+$+1,Z=42,J=113,Y=1,ce=2,ae=3,ie=4;function le(pe,Ge){return pe.msg=p[Ge],Ge}function fe(pe){return(pe<<1)-(4pe.avail_out&&(tt=pe.avail_out),tt!==0&&(l.arraySet(pe.output,Ge.pending_buf,Ge.pending_out,tt,pe.next_out),pe.next_out+=tt,Ge.pending_out+=tt,pe.total_out+=tt,pe.avail_out-=tt,Ge.pending-=tt,Ge.pending===0&&(Ge.pending_out=0))}function we(pe,Ge){i._tr_flush_block(pe,0<=pe.block_start?pe.block_start:-1,pe.strstart-pe.block_start,Ge),pe.block_start=pe.strstart,he(pe.strm)}function Ne(pe,Ge){pe.pending_buf[pe.pending++]=Ge}function Ve(pe,Ge){pe.pending_buf[pe.pending++]=Ge>>>8&255,pe.pending_buf[pe.pending++]=255&Ge}function Te(pe,Ge){var tt,st,Ce=pe.max_chain_length,et=pe.strstart,Ct=pe.prev_length,Ot=pe.nice_match,ut=pe.strstart>pe.w_size-ee?pe.strstart-(pe.w_size-ee):0,Oe=pe.window,Xe=pe.w_mask,at=pe.prev,Ke=pe.strstart+V,He=Oe[et+Ct-1],gt=Oe[et+Ct];pe.prev_length>=pe.good_match&&(Ce>>=2),Ot>pe.lookahead&&(Ot=pe.lookahead);do if(Oe[(tt=Ge)+Ct]===gt&&Oe[tt+Ct-1]===He&&Oe[tt]===Oe[et]&&Oe[++tt]===Oe[et+1]){et+=2,tt++;do;while(Oe[++et]===Oe[++tt]&&Oe[++et]===Oe[++tt]&&Oe[++et]===Oe[++tt]&&Oe[++et]===Oe[++tt]&&Oe[++et]===Oe[++tt]&&Oe[++et]===Oe[++tt]&&Oe[++et]===Oe[++tt]&&Oe[++et]===Oe[++tt]&&etut&&--Ce!=0);return Ct<=pe.lookahead?Ct:pe.lookahead}function Ae(pe){var Ge,tt,st,Ce,et,Ct,Ot,ut,Oe,Xe,at=pe.w_size;do{if(Ce=pe.window_size-pe.lookahead-pe.strstart,pe.strstart>=at+(at-ee)){for(l.arraySet(pe.window,pe.window,at,at,0),pe.match_start-=at,pe.strstart-=at,pe.block_start-=at,Ge=tt=pe.hash_size;st=pe.head[--Ge],pe.head[Ge]=at<=st?st-at:0,--tt;);for(Ge=tt=at;st=pe.prev[--Ge],pe.prev[Ge]=at<=st?st-at:0,--tt;);Ce+=at}if(pe.strm.avail_in===0)break;if(Ct=pe.strm,Ot=pe.window,ut=pe.strstart+pe.lookahead,Oe=Ce,Xe=void 0,Xe=Ct.avail_in,Oe=$)for(et=pe.strstart-pe.insert,pe.ins_h=pe.window[et],pe.ins_h=(pe.ins_h<=$&&(pe.ins_h=(pe.ins_h<=$)if(st=i._tr_tally(pe,pe.strstart-pe.match_start,pe.match_length-$),pe.lookahead-=pe.match_length,pe.match_length<=pe.max_lazy_match&&pe.lookahead>=$){for(pe.match_length--;pe.strstart++,pe.ins_h=(pe.ins_h<=$&&(pe.ins_h=(pe.ins_h<=$&&pe.match_length<=pe.prev_length){for(Ce=pe.strstart+pe.lookahead-$,st=i._tr_tally(pe,pe.strstart-1-pe.prev_match,pe.prev_length-$),pe.lookahead-=pe.prev_length-1,pe.prev_length-=2;++pe.strstart<=Ce&&(pe.ins_h=(pe.ins_h<pe.pending_buf_size-5&&(tt=pe.pending_buf_size-5);;){if(pe.lookahead<=1){if(Ae(pe),pe.lookahead===0&&Ge===f)return Y;if(pe.lookahead===0)break}pe.strstart+=pe.lookahead,pe.lookahead=0;var st=pe.block_start+tt;if((pe.strstart===0||pe.strstart>=st)&&(pe.lookahead=pe.strstart-st,pe.strstart=st,we(pe,!1),pe.strm.avail_out===0)||pe.strstart-pe.block_start>=pe.w_size-ee&&(we(pe,!1),pe.strm.avail_out===0))return Y}return pe.insert=0,Ge===y?(we(pe,!0),pe.strm.avail_out===0?ae:ie):(pe.strstart>pe.block_start&&(we(pe,!1),pe.strm.avail_out),Y)}),new ve(4,4,8,4,ze),new ve(4,5,16,8,ze),new ve(4,6,32,32,ze),new ve(4,4,16,16,Ee),new ve(8,16,32,32,Ee),new ve(8,16,128,128,Ee),new ve(8,32,128,256,Ee),new ve(32,128,258,1024,Ee),new ve(32,258,258,4096,Ee)],a.deflateInit=function(pe,Ge){return ct(pe,Ge,C,15,8,0)},a.deflateInit2=ct,a.deflateReset=ye,a.deflateResetKeep=Ue,a.deflateSetHeader=function(pe,Ge){return pe&&pe.state?pe.state.wrap!==2?b:(pe.state.gzhead=Ge,_):b},a.deflate=function(pe,Ge){var tt,st,Ce,et;if(!pe||!pe.state||5>8&255),Ne(st,st.gzhead.time>>16&255),Ne(st,st.gzhead.time>>24&255),Ne(st,st.level===9?2:2<=st.strategy||st.level<2?4:0),Ne(st,255&st.gzhead.os),st.gzhead.extra&&st.gzhead.extra.length&&(Ne(st,255&st.gzhead.extra.length),Ne(st,st.gzhead.extra.length>>8&255)),st.gzhead.hcrc&&(pe.adler=u(pe.adler,st.pending_buf,st.pending,0)),st.gzindex=0,st.status=69):(Ne(st,0),Ne(st,0),Ne(st,0),Ne(st,0),Ne(st,0),Ne(st,st.level===9?2:2<=st.strategy||st.level<2?4:0),Ne(st,3),st.status=J);else{var Ct=C+(st.w_bits-8<<4)<<8;Ct|=(2<=st.strategy||st.level<2?0:st.level<6?1:st.level===6?2:3)<<6,st.strstart!==0&&(Ct|=32),Ct+=31-Ct%31,st.status=J,Ve(st,Ct),st.strstart!==0&&(Ve(st,pe.adler>>>16),Ve(st,65535&pe.adler)),pe.adler=1}if(st.status===69)if(st.gzhead.extra){for(Ce=st.pending;st.gzindex<(65535&st.gzhead.extra.length)&&(st.pending!==st.pending_buf_size||(st.gzhead.hcrc&&st.pending>Ce&&(pe.adler=u(pe.adler,st.pending_buf,st.pending-Ce,Ce)),he(pe),Ce=st.pending,st.pending!==st.pending_buf_size));)Ne(st,255&st.gzhead.extra[st.gzindex]),st.gzindex++;st.gzhead.hcrc&&st.pending>Ce&&(pe.adler=u(pe.adler,st.pending_buf,st.pending-Ce,Ce)),st.gzindex===st.gzhead.extra.length&&(st.gzindex=0,st.status=73)}else st.status=73;if(st.status===73)if(st.gzhead.name){Ce=st.pending;do{if(st.pending===st.pending_buf_size&&(st.gzhead.hcrc&&st.pending>Ce&&(pe.adler=u(pe.adler,st.pending_buf,st.pending-Ce,Ce)),he(pe),Ce=st.pending,st.pending===st.pending_buf_size)){et=1;break}et=st.gzindexCe&&(pe.adler=u(pe.adler,st.pending_buf,st.pending-Ce,Ce)),et===0&&(st.gzindex=0,st.status=91)}else st.status=91;if(st.status===91)if(st.gzhead.comment){Ce=st.pending;do{if(st.pending===st.pending_buf_size&&(st.gzhead.hcrc&&st.pending>Ce&&(pe.adler=u(pe.adler,st.pending_buf,st.pending-Ce,Ce)),he(pe),Ce=st.pending,st.pending===st.pending_buf_size)){et=1;break}et=st.gzindexCe&&(pe.adler=u(pe.adler,st.pending_buf,st.pending-Ce,Ce)),et===0&&(st.status=103)}else st.status=103;if(st.status===103&&(st.gzhead.hcrc?(st.pending+2>st.pending_buf_size&&he(pe),st.pending+2<=st.pending_buf_size&&(Ne(st,255&pe.adler),Ne(st,pe.adler>>8&255),pe.adler=0,st.status=J)):st.status=J),st.pending!==0){if(he(pe),pe.avail_out===0)return st.last_flush=-1,_}else if(pe.avail_in===0&&fe(Ge)<=fe(tt)&&Ge!==y)return le(pe,-5);if(st.status===666&&pe.avail_in!==0)return le(pe,-5);if(pe.avail_in!==0||st.lookahead!==0||Ge!==f&&st.status!==666){var Ot=st.strategy===2?function(ut,Oe){for(var Xe;;){if(ut.lookahead===0&&(Ae(ut),ut.lookahead===0)){if(Oe===f)return Y;break}if(ut.match_length=0,Xe=i._tr_tally(ut,0,ut.window[ut.strstart]),ut.lookahead--,ut.strstart++,Xe&&(we(ut,!1),ut.strm.avail_out===0))return Y}return ut.insert=0,Oe===y?(we(ut,!0),ut.strm.avail_out===0?ae:ie):ut.last_lit&&(we(ut,!1),ut.strm.avail_out===0)?Y:ce}(st,Ge):st.strategy===3?function(ut,Oe){for(var Xe,at,Ke,He,gt=ut.window;;){if(ut.lookahead<=V){if(Ae(ut),ut.lookahead<=V&&Oe===f)return Y;if(ut.lookahead===0)break}if(ut.match_length=0,ut.lookahead>=$&&0ut.lookahead&&(ut.match_length=ut.lookahead)}if(ut.match_length>=$?(Xe=i._tr_tally(ut,1,ut.match_length-$),ut.lookahead-=ut.match_length,ut.strstart+=ut.match_length,ut.match_length=0):(Xe=i._tr_tally(ut,0,ut.window[ut.strstart]),ut.lookahead--,ut.strstart++),Xe&&(we(ut,!1),ut.strm.avail_out===0))return Y}return ut.insert=0,Oe===y?(we(ut,!0),ut.strm.avail_out===0?ae:ie):ut.last_lit&&(we(ut,!1),ut.strm.avail_out===0)?Y:ce}(st,Ge):o[st.level].func(st,Ge);if(Ot!==ae&&Ot!==ie||(st.status=666),Ot===Y||Ot===ae)return pe.avail_out===0&&(st.last_flush=-1),_;if(Ot===ce&&(Ge===1?i._tr_align(st):Ge!==5&&(i._tr_stored_block(st,0,0,!1),Ge===3&&(xe(st.head),st.lookahead===0&&(st.strstart=0,st.block_start=0,st.insert=0))),he(pe),pe.avail_out===0))return st.last_flush=-1,_}return Ge!==y?_:st.wrap<=0?1:(st.wrap===2?(Ne(st,255&pe.adler),Ne(st,pe.adler>>8&255),Ne(st,pe.adler>>16&255),Ne(st,pe.adler>>24&255),Ne(st,255&pe.total_in),Ne(st,pe.total_in>>8&255),Ne(st,pe.total_in>>16&255),Ne(st,pe.total_in>>24&255)):(Ve(st,pe.adler>>>16),Ve(st,65535&pe.adler)),he(pe),0=tt.w_size&&(et===0&&(xe(tt.head),tt.strstart=0,tt.block_start=0,tt.insert=0),Oe=new l.Buf8(tt.w_size),l.arraySet(Oe,Ge,Xe-tt.w_size,tt.w_size,0),Ge=Oe,Xe=tt.w_size),Ct=pe.avail_in,Ot=pe.next_in,ut=pe.input,pe.avail_in=Xe,pe.next_in=0,pe.input=Ge,Ae(tt);tt.lookahead>=$;){for(st=tt.strstart,Ce=tt.lookahead-($-1);tt.ins_h=(tt.ins_h<>>=$=q>>>24,A-=$,($=q>>>16&255)===0)ce[p++]=65535&q;else{if(!(16&$)){if(!(64&$)){q=I[(65535&q)+(C&(1<<$)-1)];continue t}if(32&$){i.mode=12;break e}o.msg="invalid literal/length code",i.mode=30;break e}V=65535&q,($&=15)&&(A<$&&(C+=Y[d++]<>>=$,A-=$),A<15&&(C+=Y[d++]<>>=$=q>>>24,A-=$,!(16&($=q>>>16&255))){if(!(64&$)){q=L[(65535&q)+(C&(1<<$)-1)];continue s}o.msg="invalid distance code",i.mode=30;break e}if(ee=65535&q,A<($&=15)&&(C+=Y[d++]<>>=$,A-=$,($=p-f)>3,C&=(1<<(A-=V<<3))-1,o.next_in=d,o.next_out=p,o.avail_in=d>>24&255)+(Z>>>8&65280)+((65280&Z)<<8)+((255&Z)<<24)}function C(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function A(Z){var J;return Z&&Z.state?(J=Z.state,Z.total_in=Z.total_out=J.total=0,Z.msg="",J.wrap&&(Z.adler=1&J.wrap),J.mode=b,J.last=0,J.havedict=0,J.dmax=32768,J.head=null,J.hold=0,J.bits=0,J.lencode=J.lendyn=new o.Buf32(N),J.distcode=J.distdyn=new o.Buf32(w),J.sane=1,J.back=-1,y):_}function I(Z){var J;return Z&&Z.state?((J=Z.state).wsize=0,J.whave=0,J.wnext=0,A(Z)):_}function L(Z,J){var Y,ce;return Z&&Z.state?(ce=Z.state,J<0?(Y=0,J=-J):(Y=1+(J>>4),J<48&&(J&=15)),J&&(J<8||15=ie.wsize?(o.arraySet(ie.window,J,Y-ie.wsize,ie.wsize,0),ie.wnext=0,ie.whave=ie.wsize):(ce<(ae=ie.wsize-ie.wnext)&&(ae=ce),o.arraySet(ie.window,J,Y-ce,ae,ie.wnext),(ce-=ae)?(o.arraySet(ie.window,J,Y-ce,ce,0),ie.wnext=ce,ie.whave=ie.wsize):(ie.wnext+=ae,ie.wnext===ie.wsize&&(ie.wnext=0),ie.whave>>8&255,Y.check=i(Y.check,et,2,0),we=he=0,Y.mode=2;break}if(Y.flags=0,Y.head&&(Y.head.done=!1),!(1&Y.wrap)||(((255&he)<<8)+(he>>8))%31){Z.msg="incorrect header check",Y.mode=30;break}if((15&he)!=8){Z.msg="unknown compression method",Y.mode=30;break}if(we-=4,pe=8+(15&(he>>>=4)),Y.wbits===0)Y.wbits=pe;else if(pe>Y.wbits){Z.msg="invalid window size",Y.mode=30;break}Y.dmax=1<>8&1),512&Y.flags&&(et[0]=255&he,et[1]=he>>>8&255,Y.check=i(Y.check,et,2,0)),we=he=0,Y.mode=3;case 3:for(;we<32;){if(fe===0)break e;fe--,he+=ce[ie++]<>>8&255,et[2]=he>>>16&255,et[3]=he>>>24&255,Y.check=i(Y.check,et,4,0)),we=he=0,Y.mode=4;case 4:for(;we<16;){if(fe===0)break e;fe--,he+=ce[ie++]<>8),512&Y.flags&&(et[0]=255&he,et[1]=he>>>8&255,Y.check=i(Y.check,et,2,0)),we=he=0,Y.mode=5;case 5:if(1024&Y.flags){for(;we<16;){if(fe===0)break e;fe--,he+=ce[ie++]<>>8&255,Y.check=i(Y.check,et,2,0)),we=he=0}else Y.head&&(Y.head.extra=null);Y.mode=6;case 6:if(1024&Y.flags&&(fe<(Te=Y.length)&&(Te=fe),Te&&(Y.head&&(pe=Y.head.extra_len-Y.length,Y.head.extra||(Y.head.extra=new Array(Y.head.extra_len)),o.arraySet(Y.head.extra,ce,ie,Te,pe)),512&Y.flags&&(Y.check=i(Y.check,ce,Te,ie)),fe-=Te,ie+=Te,Y.length-=Te),Y.length))break e;Y.length=0,Y.mode=7;case 7:if(2048&Y.flags){if(fe===0)break e;for(Te=0;pe=ce[ie+Te++],Y.head&&pe&&Y.length<65536&&(Y.head.name+=String.fromCharCode(pe)),pe&&Te>9&1,Y.head.done=!0),Z.adler=Y.check=0,Y.mode=12;break;case 10:for(;we<32;){if(fe===0)break e;fe--,he+=ce[ie++]<>>=7&we,we-=7&we,Y.mode=27;break}for(;we<3;){if(fe===0)break e;fe--,he+=ce[ie++]<>>=1)){case 0:Y.mode=14;break;case 1:if(V(Y),Y.mode=20,J!==6)break;he>>>=2,we-=2;break e;case 2:Y.mode=17;break;case 3:Z.msg="invalid block type",Y.mode=30}he>>>=2,we-=2;break;case 14:for(he>>>=7&we,we-=7&we;we<32;){if(fe===0)break e;fe--,he+=ce[ie++]<>>16^65535)){Z.msg="invalid stored block lengths",Y.mode=30;break}if(Y.length=65535&he,we=he=0,Y.mode=15,J===6)break e;case 15:Y.mode=16;case 16:if(Te=Y.length){if(fe>>=5,we-=5,Y.ndist=1+(31&he),he>>>=5,we-=5,Y.ncode=4+(15&he),he>>>=4,we-=4,286>>=3,we-=3}for(;Y.have<19;)Y.lens[Ct[Y.have++]]=0;if(Y.lencode=Y.lendyn,Y.lenbits=7,tt={bits:Y.lenbits},Ge=u(0,Y.lens,0,19,Y.lencode,0,Y.work,tt),Y.lenbits=tt.bits,Ge){Z.msg="invalid code lengths set",Y.mode=30;break}Y.have=0,Y.mode=19;case 19:for(;Y.have>>16&255,Re=65535&Ce,!((Ee=Ce>>>24)<=we);){if(fe===0)break e;fe--,he+=ce[ie++]<>>=Ee,we-=Ee,Y.lens[Y.have++]=Re;else{if(Re===16){for(st=Ee+2;we>>=Ee,we-=Ee,Y.have===0){Z.msg="invalid bit length repeat",Y.mode=30;break}pe=Y.lens[Y.have-1],Te=3+(3&he),he>>>=2,we-=2}else if(Re===17){for(st=Ee+3;we>>=Ee)),he>>>=3,we-=3}else{for(st=Ee+7;we>>=Ee)),he>>>=7,we-=7}if(Y.have+Te>Y.nlen+Y.ndist){Z.msg="invalid bit length repeat",Y.mode=30;break}for(;Te--;)Y.lens[Y.have++]=pe}}if(Y.mode===30)break;if(Y.lens[256]===0){Z.msg="invalid code -- missing end-of-block",Y.mode=30;break}if(Y.lenbits=9,tt={bits:Y.lenbits},Ge=u(p,Y.lens,0,Y.nlen,Y.lencode,0,Y.work,tt),Y.lenbits=tt.bits,Ge){Z.msg="invalid literal/lengths set",Y.mode=30;break}if(Y.distbits=6,Y.distcode=Y.distdyn,tt={bits:Y.distbits},Ge=u(f,Y.lens,Y.nlen,Y.ndist,Y.distcode,0,Y.work,tt),Y.distbits=tt.bits,Ge){Z.msg="invalid distances set",Y.mode=30;break}if(Y.mode=20,J===6)break e;case 20:Y.mode=21;case 21:if(6<=fe&&258<=xe){Z.next_out=le,Z.avail_out=xe,Z.next_in=ie,Z.avail_in=fe,Y.hold=he,Y.bits=we,d(Z,Ve),le=Z.next_out,ae=Z.output,xe=Z.avail_out,ie=Z.next_in,ce=Z.input,fe=Z.avail_in,he=Y.hold,we=Y.bits,Y.mode===12&&(Y.back=-1);break}for(Y.back=0;ve=(Ce=Y.lencode[he&(1<>>16&255,Re=65535&Ce,!((Ee=Ce>>>24)<=we);){if(fe===0)break e;fe--,he+=ce[ie++]<>Ue)])>>>16&255,Re=65535&Ce,!(Ue+(Ee=Ce>>>24)<=we);){if(fe===0)break e;fe--,he+=ce[ie++]<>>=Ue,we-=Ue,Y.back+=Ue}if(he>>>=Ee,we-=Ee,Y.back+=Ee,Y.length=Re,ve===0){Y.mode=26;break}if(32&ve){Y.back=-1,Y.mode=12;break}if(64&ve){Z.msg="invalid literal/length code",Y.mode=30;break}Y.extra=15&ve,Y.mode=22;case 22:if(Y.extra){for(st=Y.extra;we>>=Y.extra,we-=Y.extra,Y.back+=Y.extra}Y.was=Y.length,Y.mode=23;case 23:for(;ve=(Ce=Y.distcode[he&(1<>>16&255,Re=65535&Ce,!((Ee=Ce>>>24)<=we);){if(fe===0)break e;fe--,he+=ce[ie++]<>Ue)])>>>16&255,Re=65535&Ce,!(Ue+(Ee=Ce>>>24)<=we);){if(fe===0)break e;fe--,he+=ce[ie++]<>>=Ue,we-=Ue,Y.back+=Ue}if(he>>>=Ee,we-=Ee,Y.back+=Ee,64&ve){Z.msg="invalid distance code",Y.mode=30;break}Y.offset=Re,Y.extra=15&ve,Y.mode=24;case 24:if(Y.extra){for(st=Y.extra;we>>=Y.extra,we-=Y.extra,Y.back+=Y.extra}if(Y.offset>Y.dmax){Z.msg="invalid distance too far back",Y.mode=30;break}Y.mode=25;case 25:if(xe===0)break e;if(Te=Ve-xe,Y.offset>Te){if((Te=Y.offset-Te)>Y.whave&&Y.sane){Z.msg="invalid distance too far back",Y.mode=30;break}Ae=Te>Y.wnext?(Te-=Y.wnext,Y.wsize-Te):Y.wnext-Te,Te>Y.length&&(Te=Y.length),ze=Y.window}else ze=ae,Ae=le-Y.offset,Te=Y.length;for(xeU?($=Ae[ze+w[J]],we[Ne+w[J]]):($=96,0),C=1<>le)+(A-=C)]=q<<24|$<<16|V|0,A!==0;);for(C=1<>=1;if(C!==0?(he&=C-1,he+=C):he=0,J++,--Ve[Z]==0){if(Z===ce)break;Z=f[y+w[J]]}if(ae>>7)]}function Ne(Ce,et){Ce.pending_buf[Ce.pending++]=255&et,Ce.pending_buf[Ce.pending++]=et>>>8&255}function Ve(Ce,et,Ct){Ce.bi_valid>S-Ct?(Ce.bi_buf|=et<>S-Ce.bi_valid,Ce.bi_valid+=Ct-S):(Ce.bi_buf|=et<>>=1,Ct<<=1,0<--et;);return Ct>>>1}function ze(Ce,et,Ct){var Ot,ut,Oe=new Array(w+1),Xe=0;for(Ot=1;Ot<=w;Ot++)Oe[Ot]=Xe=Xe+Ct[Ot-1]<<1;for(ut=0;ut<=et;ut++){var at=Ce[2*ut+1];at!==0&&(Ce[2*ut]=Ae(Oe[at]++,at))}}function Ee(Ce){var et;for(et=0;et>1;1<=Ct;Ct--)Ue(Ce,Oe,Ct);for(ut=Ke;Ct=Ce.heap[1],Ce.heap[1]=Ce.heap[Ce.heap_len--],Ue(Ce,Oe,1),Ot=Ce.heap[1],Ce.heap[--Ce.heap_max]=Ct,Ce.heap[--Ce.heap_max]=Ot,Oe[2*ut]=Oe[2*Ct]+Oe[2*Ot],Ce.depth[ut]=(Ce.depth[Ct]>=Ce.depth[Ot]?Ce.depth[Ct]:Ce.depth[Ot])+1,Oe[2*Ct+1]=Oe[2*Ot+1]=ut,Ce.heap[1]=ut++,Ue(Ce,Oe,1),2<=Ce.heap_len;);Ce.heap[--Ce.heap_max]=Ce.heap[1],function(gt,Mt){var Wt,xs,Cs,Us,Ar,Bt,Xs=Mt.dyn_tree,Nr=Mt.max_code,Vs=Mt.stat_desc.static_tree,ar=Mt.stat_desc.has_stree,Or=Mt.stat_desc.extra_bits,Rn=Mt.stat_desc.extra_base,bn=Mt.stat_desc.max_length,ir=0;for(Us=0;Us<=w;Us++)gt.bl_count[Us]=0;for(Xs[2*gt.heap[gt.heap_max]+1]=0,Wt=gt.heap_max+1;Wt>=7;ut<_;ut++)for(fe[ut]=Oe<<7,et=0;et<1<>>=1)if(1&He&&at.dyn_ltree[2*Ke]!==0)return l;if(at.dyn_ltree[18]!==0||at.dyn_ltree[20]!==0||at.dyn_ltree[26]!==0)return i;for(Ke=32;Ke>>3,(Oe=Ce.static_len+3+7>>>3)<=ut&&(ut=Oe)):ut=Oe=Ct+5,Ct+4<=ut&&et!==-1?st(Ce,et,Ct,Ot):Ce.strategy===4||Oe===ut?(Ve(Ce,2+(Ot?1:0),3),ye(Ce,ee,Z)):(Ve(Ce,4+(Ot?1:0),3),function(at,Ke,He,gt){var Mt;for(Ve(at,Ke-257,5),Ve(at,He-1,5),Ve(at,gt-4,4),Mt=0;Mt>>8&255,Ce.pending_buf[Ce.d_buf+2*Ce.last_lit+1]=255&et,Ce.pending_buf[Ce.l_buf+Ce.last_lit]=255&Ct,Ce.last_lit++,et===0?Ce.dyn_ltree[2*Ct]++:(Ce.matches++,et--,Ce.dyn_ltree[2*(Y[Ct]+f+1)]++,Ce.dyn_dtree[2*we(et)]++),Ce.last_lit===Ce.lit_bufsize-1},a._tr_align=function(Ce){Ve(Ce,2,3),Te(Ce,A,ee),function(et){et.bi_valid===16?(Ne(et,et.bi_buf),et.bi_buf=0,et.bi_valid=0):8<=et.bi_valid&&(et.pending_buf[et.pending++]=255&et.bi_buf,et.bi_buf>>=8,et.bi_valid-=8)}(Ce)}},{"../utils/common":41}],53:[function(r,n,a){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,n,a){(function(o){(function(l,i){if(!l.setImmediate){var d,u,p,f,y=1,_={},b=!1,N=l.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(l);w=w&&w.setTimeout?w:l,d={}.toString.call(l.process)==="[object process]"?function(I){process.nextTick(function(){C(I)})}:function(){if(l.postMessage&&!l.importScripts){var I=!0,L=l.onmessage;return l.onmessage=function(){I=!1},l.postMessage("","*"),l.onmessage=L,I}}()?(f="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",A,!1):l.attachEvent("onmessage",A),function(I){l.postMessage(f+I,"*")}):l.MessageChannel?((p=new MessageChannel).port1.onmessage=function(I){C(I.data)},function(I){p.port2.postMessage(I)}):N&&"onreadystatechange"in N.createElement("script")?(u=N.documentElement,function(I){var L=N.createElement("script");L.onreadystatechange=function(){C(I),L.onreadystatechange=null,u.removeChild(L),L=null},u.appendChild(L)}):function(I){setTimeout(C,0,I)},w.setImmediate=function(I){typeof I!="function"&&(I=new Function(""+I));for(var L=new Array(arguments.length-1),O=0;O"u"?o===void 0?this:o:self)}).call(this,typeof hd<"u"?hd:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(_tt);var QVt=_tt.exports;const JVt=ro(QVt);function Nye(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 eHt=()=>{const{isAdmin:t}=$s(),[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState("all"),[i,d]=k.useState(new Set),[u,p]=k.useState(!1),[f,y]=k.useState(!1),[_,b]=k.useState("images"),[N,w]=k.useState(null),{data:S=[],isLoading:C}=ft({queryKey:["social-swag-2"],queryFn:async()=>{const{data:fe,error:xe}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(xe)throw xe;return fe}}),{data:A=[]}=ft({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:fe,error:xe}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(xe)throw xe;return fe}}),{data:I=[]}=ft({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:fe,error:xe}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(xe)throw xe;return fe}}),{data:L=[]}=ft({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:fe,error:xe}=await G.from("social_accounts").select("id, platform").eq("is_active",!0);if(xe)throw xe;return fe||[]}}),O=L.length>0,U=k.useMemo(()=>o==="all"?null:I.find(fe=>fe.month===o)||null,[o,I]),q=k.useMemo(()=>[...new Set(S.map(xe=>xe.month))].sort((xe,he)=>he.localeCompare(xe)),[S]);k.useEffect(()=>{q.length>0&&o==="all"&&l(q[0])},[q,o]);const $=fe=>{try{const xe=lNe(fe,"yyyy-MM",new Date);return gs(xe,"MMMM yyyy")}catch{return fe}},V=k.useMemo(()=>o==="all"?S:S.filter(fe=>fe.month===o),[o,S]),ee=k.useMemo(()=>{var fe;return o==="all"?null:((fe=A.find(xe=>xe.month===o))==null?void 0:fe.canva_link)||null},[o,A]),Z=async fe=>{try{await navigator.clipboard.writeText(fe),me.success("Caption copied to clipboard!")}catch{me.error("Failed to copy caption")}},J=async(fe,xe)=>{try{const we=await(await fetch(fe)).blob(),Ne=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),Ve=navigator.canShare&&navigator.canShare({files:[new File([we],"test.jpg",{type:"image/jpeg"})]});if(Ne&&Ve){const Te=new File([we],`social-swag-${xe}.jpg`,{type:"image/jpeg"});await navigator.share({files:[Te],title:"Social Swag Image"}),me.success("Image ready to save!")}else{const Te=window.URL.createObjectURL(we),Ae=document.createElement("a");Ae.href=Te,Ae.download=`social-swag-${xe}.jpg`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),window.URL.revokeObjectURL(Te),me.success("Image downloaded!")}}catch(he){he.name!=="AbortError"&&me.error("Failed to download image")}},Y=fe=>{d(xe=>{const he=new Set(xe);return he.has(fe)?he.delete(fe):he.add(fe),he})},ce=()=>{d(new Set(V.map(fe=>fe.id)))},ae=()=>{d(new Set),p(!1)},ie=async()=>{const fe=V.filter(xe=>i.has(xe.id));if(fe.length===0){me.error("No images selected");return}y(!0),me.info(`Preparing ${fe.length} images for download...`);try{const xe=new JVt,he=[...fe].sort((Ae,ze)=>Ae.sort_order-ze.sort_order);for(let Ae=0;Ae{u?Y(fe.id):r(fe)};return e.jsx(Ls,{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(Ye,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(qr,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(Ye,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(Uo,{className:"h-3 w-3 mr-1"}),S.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(ta,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(Qn,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(ls,{value:"gallery",className:"gap-2",children:[e.jsx(Uo,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(ls,{value:"scheduled",className:"gap-2",children:[e.jsx(xd,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs(js,{value:"gallery",className:"space-y-6",children:[t?O?e.jsx(Ie,{className:"border rounded-xl",children:e.jsx(Be,{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(da,{to:"/social-connections",children:"Manage Accounts"})})]})})}):e.jsx(Ie,{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(Be,{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(du,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(hu,{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(da,{to:"/social-connections",children:[e.jsx(Do,{className:"h-4 w-4"}),"Connect Accounts"]})})]})})}):e.jsx(Ie,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Be,{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(rn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(du,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(hu,{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(Ye,{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(fe=>e.jsx("button",{onClick:()=>l(fe),className:Rt("px-4 py-2 rounded-full text-sm font-medium transition-all",o===fe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:$(fe)},fe))}),o!=="all"&&(ee?e.jsxs("a",{href:ee,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 ",$(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 ",$(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"),ae()},className:Rt("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(Uo,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),ae()},className:Rt("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(Ld,{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:ce,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ae,className:"gap-2",children:[e.jsx(Sr,{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:ie,disabled:f,className:"gap-2",children:[e.jsx(Xa,{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(ea,{className:"h-4 w-4"}),"Select Images"]})})]}),C&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!C&&_==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(fe=>{const xe=i.has(fe.id);return e.jsx(Ie,{className:Rt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&xe&&"ring-2 ring-primary ring-offset-2"),onClick:()=>le(fe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:Nye(fe.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"}),fe.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:gs(new Date(fe.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:Rt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",xe?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:xe&&e.jsx(ea,{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"})})]})},fe.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Uo,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!C&&_==="reels"&&e.jsx(e.Fragment,{children:U?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(Ie,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a(U),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:Nye(U.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(Ye,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(Ld,{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(Ld,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No reel available for this month yet."})]})})]}),e.jsx(fs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(ms,{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:Nye(s.image_url,900,85),alt:"Social swag",className:"w-full h-full object-cover",decoding:"async"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground mb-4",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(nn,{className:"h-4 w-4"}),gs(new Date(s.created_at),"MMMM d, yyyy")]}),s.post_date&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium rounded-full px-3 py-1 text-xs text-white",style:{background:"#406E71"},children:[e.jsx(nn,{className:"h-3.5 w-3.5"}),"Post on ",gs(new Date(s.post_date+"T00:00:00"),"MMMM d, yyyy")]})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col gap-3 mt-6",children:[t&&e.jsxs(K,{onClick:()=>{w({imageUrl:s.image_url,imageId:s.id,caption:s.caption})},className:"w-full gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600 text-white",children:[e.jsx(Nn,{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:()=>Z(s.caption),className:"flex-1 gap-2",children:[e.jsx(Ya,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>J(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(Xa,{className:"h-4 w-4"}),"Download"]})]})]})]})]})})})}),e.jsx(fs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(ms,{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(Ld,{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:()=>Z(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(Ya,{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(Kr,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(YVt,{open:!!N,onOpenChange:fe=>!fe&&w(null),imageUrl:(N==null?void 0:N.imageUrl)||"",imageId:(N==null?void 0:N.imageId)||"",defaultCaption:(N==null?void 0:N.caption)||"",swagItemId:N==null?void 0:N.imageId})]}),e.jsx(js,{value:"scheduled",children:e.jsx(XVt,{})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ie,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Be,{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(rn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(du,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(hu,{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(Ye,{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(fe=>e.jsx("button",{onClick:()=>l(fe),className:Rt("px-4 py-2 rounded-full text-sm font-medium transition-all",o===fe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:$(fe)},fe))}),o!=="all"&&(ee?e.jsxs("a",{href:ee,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 ",$(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 ",$(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"),ae()},className:Rt("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(Uo,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),ae()},className:Rt("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(Ld,{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:ce,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ae,className:"gap-2",children:[e.jsx(Sr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(K,{size:"sm",onClick:ie,disabled:f,className:"gap-2",children:[e.jsx(Xa,{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(ea,{className:"h-4 w-4"}),"Select Images"]})})]}),C&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!C&&_==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(fe=>{const xe=i.has(fe.id);return e.jsx(Ie,{className:Rt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&xe&&"ring-2 ring-primary ring-offset-2"),onClick:()=>le(fe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:fe.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:Rt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",xe?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:xe&&e.jsx(ea,{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"})})]})},fe.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Uo,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!C&&_==="reels"&&e.jsx(e.Fragment,{children:U?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(Ie,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a(U),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:U.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(Ye,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(Ld,{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(Ld,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No reel available for this month yet."})]})})]}),e.jsx(fs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(ms,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:s&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-muted",children:e.jsx("div",{className:"aspect-[4/5]",children:e.jsx("img",{src:s.image_url,alt:"Social swag",className:"w-full h-full object-cover"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(nn,{className:"h-4 w-4"}),gs(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:()=>Z(s.caption),className:"flex-1 gap-2",children:[e.jsx(Ya,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>J(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(Xa,{className:"h-4 w-4"}),"Download"]})]})]})]})})})}),e.jsx(fs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(ms,{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(Ld,{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:()=>Z(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(Ya,{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(Kr,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},tHt=()=>{const{swagId:t}=ho(),{user:s}=$s(),{toast:r}=va(),n=es(),{trackEngagement:a}=JA(),[o,l]=k.useState(""),{data:i,isLoading:d}=ft({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:S,error:C}=await G.from("social_swag").select("*").eq("id",t).single();if(C)throw C;const{data:A}=await G.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...S,links:A||[]}},enabled:!!t});k.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:u=[]}=ft({queryKey:["social-swag-likes",t],queryFn:async()=>{const{data:S,error:C}=await G.from("social_swag_likes").select("*").eq("swag_id",t);if(C)throw C;return S},enabled:!!t}),{data:p=[]}=ft({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:S,error:C}=await G.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(C)throw C;const A=[...new Set(S.map(O=>O.user_id))],{data:I}=await G.from("profiles").select("id, name").in("id",A),L=new Map((I==null?void 0:I.map(O=>[O.id,O.name]))||[]);return S.map(O=>({...O,user_name:L.get(O.user_id)||"Unknown User"}))},enabled:!!t}),f=Et({mutationFn:async S=>{const{error:C}=await G.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:S});if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:S=>{r({title:"Error adding comment",description:S.message,variant:"destructive"})}}),y=Et({mutationFn:async S=>{const{error:C}=await G.from("social_swag_comments").delete().eq("id",S);if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),_=Et({mutationFn:async()=>{const S=u.find(C=>C.user_id===(s==null?void 0:s.id));if(S){const{error:C}=await G.from("social_swag_likes").delete().eq("id",S.id);if(C)throw C}else{const{error:C}=await G.from("social_swag_likes").insert({swag_id:t,user_id:s.id});if(C)throw C}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",t]})}}),b=u.some(S=>S.user_id===(s==null?void 0:s.id)),N=S=>S.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),w=S=>{S.preventDefault(),!(!o.trim()||!s)&&f.mutate(o.trim())};return d?e.jsx(Ls,{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(Ls,{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(da,{to:"/social-swag",children:[e.jsx(Ra,{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(rE,{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(Ou,{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(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(go,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(S=>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(S.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:S.title}),e.jsx(Kr,{className:"h-4 w-4 text-muted-foreground"})]},S.id))})]})}),e.jsx(jo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(bc,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),s?e.jsxs("form",{onSubmit:w,className:"flex gap-2",children:[e.jsx(_r,{placeholder:"Add a comment...",value:o,onChange:S=>l(S.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(Nn,{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(Ie,{children:e.jsx(Be,{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(S=>e.jsx(Ie,{children:e.jsx(Be,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(vn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(_n,{className:"text-sm",children:N(S.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:S.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:jl(new Date(S.created_at),{addSuffix:!0})}),S.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(S.id),children:e.jsx(yr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:S.content})]})]})})},S.id))})]})]})}):e.jsx(Ls,{title:"Social Swag",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(go,{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(da,{to:"/social-swag",children:"Back to Social Swag"})})]})})},sHt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=k.useState(!0),[i,d]=k.useState(!0),[u,p]=k.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(rS,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(uf,{open:o,onOpenChange:l,children:[e.jsx(hf,{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(Fi,{className:"h-4 w-4"}):e.jsx(ja,{className:"h-4 w-4"})]})}),e.jsx(mf,{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(uf,{open:i,onOpenChange:d,children:[e.jsx(hf,{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(yd,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(Fi,{className:"h-4 w-4"}):e.jsx(ja,{className:"h-4 w-4"})]})}),e.jsx(mf,{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(uf,{open:u,onOpenChange:p,children:[e.jsx(hf,{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(cr,{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(Fi,{className:"h-4 w-4"}):e.jsx(ja,{className:"h-4 w-4"})]})}),e.jsx(mf,{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(vn,{className:"h-7 w-7",children:[e.jsx(Ca,{src:y.avatarUrl}),e.jsx(_n,{className:"text-xs",children:f(y.name)})]}),e.jsx(sd,{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))})]})]})})})},rHt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=k.useState(!1),i=u=>u.split(" ").map(p=>p[0]).join("").toUpperCase().slice(0,2),d=()=>{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(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:d()}),e.jsx(Fi,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(jd,{className:"w-56 bg-background border",children:[e.jsxs(xa,{onClick:()=>n("all"),children:[e.jsx(rS,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(Jb,{}),e.jsx(x1e,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(xa,{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(Jb,{}),e.jsxs(x1e,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(yd,{className:"h-3 w-3"}),"Your Groups"]}),s.map(u=>e.jsxs(xa,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(ZA,{open:o,onOpenChange:l,children:[e.jsx(GNe,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(cr,{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(CC,{children:[e.jsx(YA,{children:e.jsxs(XA,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(di,{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(vn,{className:"h-10 w-10",children:[e.jsx(Ca,{src:u.avatarUrl}),e.jsx(_n,{children:i(u.name)})]}),e.jsx(sd,{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 kye,Che="HoverCard",[btt]=bd(Che,[_0]),Mhe=_0(),[nHt,j4e]=btt(Che),wtt=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,d=Mhe(s),u=k.useRef(0),p=k.useRef(0),f=k.useRef(!1),y=k.useRef(!1),[_,b]=Bu({prop:n,defaultProp:a??!1,onChange:o,caller:Che}),N=k.useCallback(()=>{clearTimeout(p.current),u.current=window.setTimeout(()=>b(!0),l)},[l,b]),w=k.useCallback(()=>{clearTimeout(u.current),!f.current&&!y.current&&(p.current=window.setTimeout(()=>b(!1),i))},[i,b]),S=k.useCallback(()=>b(!1),[b]);return k.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(p.current)},[]),e.jsx(nHt,{scope:s,open:_,onOpenChange:b,onOpen:N,onClose:w,onDismiss:S,hasSelectionRef:f,isPointerDownOnContentRef:y,children:e.jsx(CR,{...d,children:r})})};wtt.displayName=Che;var jtt="HoverCardTrigger",Ntt=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=j4e(jtt,r),o=Mhe(r);return e.jsx(RA,{asChild:!0,...o,children:e.jsx(dn.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Tr(t.onPointerEnter,hce(a.onOpen)),onPointerLeave:Tr(t.onPointerLeave,hce(a.onClose)),onFocus:Tr(t.onFocus,a.onOpen),onBlur:Tr(t.onBlur,a.onClose),onTouchStart:Tr(t.onTouchStart,l=>l.preventDefault())})})});Ntt.displayName=jtt;var aHt="HoverCardPortal",[bEs,iHt]=btt(aHt,{forceMount:void 0}),uce="HoverCardContent",ktt=k.forwardRef((t,s)=>{const r=iHt(uce,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=j4e(uce,t.__scopeHoverCard);return e.jsx(wd,{present:n||o.open,children:e.jsx(oHt,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Tr(t.onPointerEnter,hce(o.onOpen)),onPointerLeave:Tr(t.onPointerLeave,hce(o.onClose)),ref:s})})});ktt.displayName=uce;var oHt=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,d=j4e(uce,r),u=Mhe(r),p=k.useRef(null),f=Ma(s,p),[y,_]=k.useState(!1);return k.useEffect(()=>{if(y){const b=document.body;return kye=b.style.userSelect||b.style.webkitUserSelect,b.style.userSelect="none",b.style.webkitUserSelect="none",()=>{b.style.userSelect=kye,b.style.webkitUserSelect=kye}}},[y]),k.useEffect(()=>{if(p.current){const b=()=>{_(!1),d.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var w;((w=document.getSelection())==null?void 0:w.toString())!==""&&(d.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",b),()=>{document.removeEventListener("pointerup",b),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!1}}},[d.isPointerDownOnContentRef,d.hasSelectionRef]),k.useEffect(()=>{p.current&&dHt(p.current).forEach(N=>N.setAttribute("tabindex","-1"))}),e.jsx(mw,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Tr(o,b=>{b.preventDefault()}),onDismiss:d.onDismiss,children:e.jsx(MR,{...u,...i,onPointerDown:Tr(i.onPointerDown,b=>{b.currentTarget.contains(b.target)&&_(!0),d.hasSelectionRef.current=!1,d.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)"}})})}),lHt="HoverCardArrow",cHt=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Mhe(r);return e.jsx(TR,{...a,...n,ref:s})});cHt.displayName=lHt;function hce(t){return s=>s.pointerType==="touch"?void 0:t()}function dHt(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 uHt=wtt,hHt=Ntt,Stt=ktt;const mHt=uHt,pHt=hHt,Ctt=k.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(Stt,{ref:a,align:s,sideOffset:r,className:Rt("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}));Ctt.displayName=Stt.displayName;const fHt=[{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"}],xHt=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),Mtt=({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(mHt,{openDelay:200,closeDelay:100,children:[e.jsx(pHt,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(Ctt,{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=fHt.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(vn,{className:"h-6 w-6",children:[e.jsx(Ca,{src:l.user_avatar||void 0}),e.jsx(_n,{className:"text-[10px]",children:xHt(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 gHt({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=k.useState(s),[l,i]=k.useState(!1);k.useEffect(()=>{r&&(o(s),i(!1))},[r,s]);const d=()=>{o(y=>y>0?y-1:t.length-1),i(!1)},u=()=>{o(y=>y{r&&(y.key==="ArrowLeft"&&d(),y.key==="ArrowRight"&&u(),y.key==="Escape"&&n(!1))},[r,t.length]);k.useEffect(()=>(window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)),[p]);const f=t[a];return e.jsx(fs,{open:r,onOpenChange:n,children:e.jsxs(ms,{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(Sr,{className:"h-6 w-6"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:d,children:e.jsx(wl,{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(ja,{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($M,{className:"h-5 w-5"}):e.jsx(Ob,{className:"h-5 w-5"})}),e.jsx("div",{className:Rt("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:Rt("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:Rt("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 Qz=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],yHt=({commentId:t,reactions:s,currentUserId:r})=>{var u,p;const n=es(),[a,o]=k.useState(!1),l=s.find(f=>f.user_id===r),i=Et({mutationFn:async f=>{l?l.reaction_type===f?await G.from("community_comment_reactions").delete().eq("id",l.id):await G.from("community_comment_reactions").update({reaction_type:f}).eq("id",l.id):await G.from("community_comment_reactions").insert({comment_id:t,user_id:r,reaction_type:f})},onSuccess:()=>{n.invalidateQueries({queryKey:["community-posts"]}),o(!1)}}),d={};return s.forEach(f=>{d[f.reaction_type]=(d[f.reaction_type]||0)+1}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.length>0&&e.jsx(Mtt,{reactions:s,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("div",{className:"flex -space-x-0.5",children:Object.keys(d).slice(0,2).map(f=>{var y;return e.jsx("span",{className:"text-sm",children:(y=Qz.find(_=>_.type===f))==null?void 0:y.emoji},f)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs(yo,{open:a,onOpenChange:o,children:[e.jsx(vo,{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=Qz.find(f=>f.type===l.reaction_type))==null?void 0:u.emoji," ",(p=Qz.find(f=>f.type===l.reaction_type))==null?void 0:p.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Za,{className:"h-3 w-3"}),"Like"]})})}),e.jsx(uo,{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:Qz.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 N4e({content:t,className:s}){const r=/([@#])\[([^\]]+)\]\(([^)]+)\)|(https?:\/\/[^\s<>]+)/g,n=[];let a=0,o,l=0;for(;(o=r.exec(t))!==null;){if(o.index>a&&n.push(t.substring(a,o.index)),o[1]){const i=o[1],d=o[2],u=o[3],p=i==="#";n.push(e.jsx(da,{to:p?`/templates/${u}`:`/profile?user=${u}`,className:Rt("font-medium hover:underline",p?"text-white bg-[#2a4c64] px-1.5 py-0.5 rounded":"text-primary"),onClick:f=>f.stopPropagation(),children:p?d:`@${d}`},`mention-${l++}`))}else if(o[4]){const i=o[4],d=i.replace(/[.,;:!?)]+$/,""),u=i.slice(d.length);let p;try{const f=new URL(d);p=f.hostname+(f.pathname!=="/"?f.pathname.slice(0,20)+(f.pathname.length>20?"...":""):"")}catch{p=d.length>40?d.slice(0,40)+"...":d}n.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline break-all",onClick:f=>f.stopPropagation(),children:p},`url-${l++}`)),u&&n.push(u)}a=o.index+o[0].length}return ae.jsx(k.Fragment,{children:i},d))})}function mce({value:t,onChange:s,placeholder:r="What's on your mind? Use @ to mention someone",className:n,minHeight:a="80px",onMentionsChange:o,onTemplatesChange:l,onKeyDown:i,mentionFormat:d="encoded",enableTemplateMentions:u=!1}){const p=k.useRef(null),f=k.useRef(null),[y,_]=k.useState(!1),[b,N]=k.useState("user"),[w,S]=k.useState(""),[C,A]=k.useState(null),[I,L]=k.useState(0),[O,U]=k.useState({top:0,left:0,width:0}),q=k.useRef(new Map),$=k.useRef(new Map),V=we=>{if(d==="plain"){const Ae=[];return q.current.forEach((Ee,ve)=>{we.includes(`@${ve}`)&&Ae.push(Ee)}),[...new Set(Ae)]}const Ne=/@\[([^\]]+)\]\(([^)]+)\)/g,Ve=[];let Te;for(;(Te=Ne.exec(we))!==null;)Ve.push(Te[2]);return[...new Set(Ve)]},ee=we=>{if(d==="plain"){const Ae=[];return $.current.forEach((Ee,ve)=>{we.includes(`#${ve}`)&&Ae.push(Ee)}),[...new Set(Ae)]}const Ne=/#\[([^\]]+)\]\(([^)]+)\)/g,Ve=[];let Te;for(;(Te=Ne.exec(we))!==null;)Ve.push(Te[2]);return[...new Set(Ve)]};k.useEffect(()=>{if(o){const we=V(t);o(we)}if(l){const we=ee(t);l(we)}},[t,o,l,d]);const{data:Z=[],isLoading:J}=ft({queryKey:["mention-users",w],queryFn:async()=>{const we=G.from("profiles").select("id, name").limit(8),Ne=w.length>=1?we.ilike("name",`%${w}%`):we.order("name"),{data:Ve,error:Te}=await Ne;if(Te)throw Te;const Ae=Ve.map(Ee=>Ee.id),ze=await uYe(Ae);return Ve.map(Ee=>({id:Ee.id,name:Ee.name||"Unknown",avatar_url:ze.get(Ee.id)}))},enabled:y&&b==="user",staleTime:3e4}),{data:Y=[],isLoading:ce}=ft({queryKey:["mention-templates",w],queryFn:async()=>{let we=G.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);w.length>=1&&(we=we.ilike("name",`%${w}%`));const{data:Ne,error:Ve}=await we;if(Ve)throw Ve;return Ne||[]},enabled:y&&b==="template"&&u,staleTime:3e4}),ae=b==="user"?J:ce,ie=b==="user"?Z:Y,le=we=>we.split(" ").map(Ne=>Ne[0]).join("").toUpperCase().slice(0,2),fe=we=>{const Ne=we.target.value,Ve=we.target.selectionStart;s(Ne);const Te=Ne.substring(0,Ve),Ae=Te.lastIndexOf("@"),ze=u?Te.lastIndexOf("#"):-1;let Ee=-1,ve="user";if(Ae>ze?(Ee=Ae,ve="user"):ze>Ae&&u&&(Ee=ze,ve="template"),Ee!==-1){const Re=Te.substring(Ee+1),Ue=Re.includes(" "),ye=Re.includes(` `);if(!Ue&&!ye&&Re.length<=30){A(Ee),S(Re),N(ve),_(!0),L(0);return}}_(!1),A(null)},xe=we=>{if(C===null)return;const Ne=t.substring(0,C),Ve=t.substring(C+w.length+1),Te=b==="user"?"@":"#",Ae=d==="plain"?`${Te}${we.name} `:`${Te}[${we.name}](${we.id}) `;d==="plain"&&(b==="user"?q.current.set(we.name,we.id):$.current.set(we.name,we.id));const ze=Ne+Ae+Ve;s(ze),_(!1),A(null),S(""),setTimeout(()=>{if(p.current){const Ee=Ne.length+Ae.length;p.current.focus(),p.current.setSelectionRange(Ee,Ee)}},0)},he=we=>{if(!(!y||ie.length===0))switch(we.key){case"ArrowDown":we.preventDefault(),L(Ne=>(Ne+1)%ie.length);break;case"ArrowUp":we.preventDefault(),L(Ne=>(Ne-1+ie.length)%ie.length);break;case"Enter":ie[I]&&(we.preventDefault(),xe(ie[I]));break;case"Escape":we.preventDefault(),_(!1);break;case"Tab":ie[I]&&(we.preventDefault(),xe(ie[I]));break}};return k.useEffect(()=>{const we=Ne=>{f.current&&!f.current.contains(Ne.target)&&p.current&&!p.current.contains(Ne.target)&&_(!1)};return document.addEventListener("mousedown",we),()=>document.removeEventListener("mousedown",we)},[]),k.useEffect(()=>{if(!y)return;const we=()=>{const Ne=p.current;if(!Ne)return;const Ve=Ne.getBoundingClientRect();U({top:Ve.bottom+4,left:Ve.left,width:Ve.width})};return we(),window.addEventListener("resize",we),window.addEventListener("scroll",we,!0),()=>{window.removeEventListener("resize",we),window.removeEventListener("scroll",we,!0)}},[y,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(_r,{ref:p,value:t,onChange:fe,onKeyDown:we=>{he(we),we.defaultPrevented||i==null||i(we)},placeholder:r,className:Rt("resize-none",n),style:{minHeight:a}}),y&&ap.createPortal(e.jsxs("div",{ref:f,className:"fixed z-[1000] max-h-[220px] overflow-hidden rounded-lg border bg-popover shadow-lg",style:{top:O.top,left:O.left,width:O.width,maxWidth:"320px"},children:[e.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground border-b bg-muted/30",children:b==="user"?"👤 Mention a person":"📋 Link a template"}),ae?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):ie.length===0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:w.length<1?`Type to search ${b==="user"?"people":"templates"}...`:`No ${b==="user"?"users":"templates"} found`}):e.jsx("ul",{className:"py-1 max-h-[180px] overflow-y-auto",children:ie.map((we,Ne)=>e.jsx("li",{className:Rt("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",Ne===I?"bg-accent":"hover:bg-accent/50"),onClick:()=>xe(we),onMouseEnter:()=>L(Ne),children:b==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(vn,{className:"h-6 w-6",children:[e.jsx(Ca,{src:we.avatar_url}),e.jsx(_n,{className:"text-xs",children:le(we.name)})]}),e.jsx("span",{className:"text-sm font-medium truncate",children:we.name})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center overflow-hidden flex-shrink-0",children:we.preview_image_url?e.jsx("img",{src:we.preview_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(Rl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:we.name})]})},we.id))})]}),document.body)]})}function vHt(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const gDe=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function Ttt({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=es(),[d,u]=k.useState(!1),[p,f]=k.useState(""),[y,_]=k.useState([]),b=Et({mutationFn:async({content:C,parentCommentId:A})=>{const{data:I,error:L}=await G.from("community_comments").insert({post_id:s,user_id:r,content:C,parent_comment_id:A}).select("id").single();if(L)throw L;const O=y;if(O.length>0&&I){const U=O.filter(q=>q!==r).map(q=>({comment_id:I.id,mentioned_user_id:q,mentioned_by_user_id:r}));U.length>0&&await G.from("community_comment_mentions").insert(U)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),f(""),_([]),u(!1)}}),N=Et({mutationFn:async C=>{const{error:A}=await G.from("community_comments").delete().eq("id",C);if(A)throw A},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),w=()=>{p.trim()&&b.mutate({content:p,parentCommentId:t.id})};return e.jsxs("div",{className:l>0?"ml-8 border-l-2 border-muted pl-3":"",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(vn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ca,{src:t.user_avatar||void 0}),e.jsx(_n,{className:"text-xs",children:gDe(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(N4e,{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:jl(new Date(t.created_at),{addSuffix:!0})}),e.jsx(yHt,{commentId:t.id,reactions:t.reactions,currentUserId:r}),r&&l<2&&e.jsxs("button",{onClick:()=>u(!d),className:"hover:text-primary flex items-center gap-1",children:[e.jsx(IL,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>N.mutate(t.id),className:"hover:text-destructive",children:t.user_id!==r?"Remove":"Delete"})]}),d&&r&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(vn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx(Ca,{src:n||void 0}),e.jsx(_n,{className:"text-xs",children:gDe((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(mce,{placeholder:`Reply to ${t.user_name}...`,value:p,onChange:f,onMentionsChange:_,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:w,disabled:!p.trim()||b.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(Nn,{className:"h-3 w-3"})})]})]})]})]}),t.replies&&t.replies.length>0&&e.jsx("div",{className:"mt-2 space-y-2",children:t.replies.map(C=>e.jsx(Ttt,{comment:C,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},C.id))})]})}const Jz=[{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"}],_Ht=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=$s(),{avatarUrl:a}=dYe(t==null?void 0:t.id),{onlineUsers:o}=hXe(),{toast:l}=va(),i=es(),d=k.useRef(null),[u,p]=k.useState("all"),[f,y]=k.useState(""),[_,b]=k.useState(""),[N,w]=k.useState(""),[S,C]=k.useState([]),[A,I]=k.useState([]),[L,O]=k.useState(""),[U,q]=k.useState(!1),[$,V]=k.useState(null),[ee,Z]=k.useState(""),[J,Y]=k.useState(new Set),[ce,ae]=k.useState({}),[ie,le]=k.useState({}),[fe,xe]=k.useState([]),[he,we]=k.useState([]),[Ne,Ve]=k.useState({open:!1,images:[],index:0});k.useEffect(()=>{if(u.startsWith("group:")){const He=u.replace("group:","");w(He),b("")}else u!=="all"?(b(u),w("")):(b(""),w(""))},[u]);const{data:Te=[]}=ft({queryKey:["community-categories"],queryFn:async()=>{const{data:He,error:gt}=await G.from("community_categories").select("*").order("sort_order");if(gt)throw gt;return He}}),{data:Ae=[]}=ft({queryKey:["community-private-groups"],queryFn:async()=>{const{data:He,error:gt}=await G.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(gt)throw gt;return He}}),ze=20,{data:Ee,isLoading:ve,hasNextPage:Re,fetchNextPage:Ue,isFetchingNextPage:ye}=x1t({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:He})=>{var De;const gt=He*ze,Mt=gt+ze;let Wt=G.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(gt,Mt);if(u.startsWith("group:")){const Ze=u.replace("group:","");Wt=Wt.eq("private_group_id",Ze)}else u==="all"||(Wt=Wt.eq("category_id",u).is("private_group_id",null));const{data:xs,error:Cs}=await Wt;if(Cs)throw Cs;const Us=((xs==null?void 0:xs.length)||0)>ze,Ar=(xs||[]).slice(0,ze);if(Ar.length===0)return{posts:[],hasMore:!1,nextPage:He+1};const Bt=Ar.map(Ze=>Ze.id),Xs=[...new Set(Ar.filter(Ze=>Ze.category_id).map(Ze=>Ze.category_id))].filter(Boolean),[Nr,Vs,ar,Or,Rn]=await Promise.all([Xs.length?G.from("community_categories").select("*").in("id",Xs):Promise.resolve({data:[]}),G.from("community_post_media").select("*").in("post_id",Bt).order("sort_order"),G.from("community_reactions").select("*").in("post_id",Bt),G.from("community_comments").select("*").in("post_id",Bt).order("created_at",{ascending:!0}),G.from("community_post_resources").select("*").in("post_id",Bt)]),bn=Nr==null?void 0:Nr.data,ir=Vs==null?void 0:Vs.data,or=ar==null?void 0:ar.data,hr=Or==null?void 0:Or.data,an=Rn==null?void 0:Rn.data,Gr=(hr||[]).map(Ze=>Ze.id),[Va,$a]=await Promise.all([Gr.length?G.from("community_comment_reactions").select("*").in("comment_id",Gr):Promise.resolve({data:[]}),(()=>{const Ze=(an||[]).filter(xt=>xt.resource_type==="template").map(xt=>xt.resource_id);return Ze.length===0?Promise.resolve({data:[]}):G.from("canva_templates").select("id, name, preview_image_url").in("id",Ze)})()]),Xt=(Va==null?void 0:Va.data)||[],Qa=($a==null?void 0:$a.data)||[],Cr=new Map(Qa.map(Ze=>[Ze.id,{name:Ze.name,preview_image_url:Ze.preview_image_url}])),Fn=Array.from(new Set([...Ar.map(Ze=>Ze.user_id),...(or||[]).map(Ze=>Ze.user_id),...(hr||[]).map(Ze=>Ze.user_id),...Xt.map(Ze=>Ze.user_id)])),[Kt,Mr]=await Promise.all([Fn.length?G.from("profiles").select("id, name").in("id",Fn):Promise.resolve({data:[]}),uYe(Fn)]),On=new Map(((De=Kt==null?void 0:Kt.data)==null?void 0:De.map(Ze=>[Ze.id,Ze.name]))||[]),ua=new Map((bn||[]).map(Ze=>[Ze.id,Ze])),$t=Ze=>{const xt=new Map,_t=[];return Ze.forEach(Pt=>{xt.set(Pt.id,{...Pt,user_name:On.get(Pt.user_id)||"Unknown User",user_avatar:Mr.get(Pt.user_id),reactions:Xt.filter(Yt=>Yt.comment_id===Pt.id).map(Yt=>({...Yt,user_name:On.get(Yt.user_id)||"Unknown User",user_avatar:Mr.get(Yt.user_id)})),replies:[]})}),Ze.forEach(Pt=>{const Yt=xt.get(Pt.id);if(Pt.parent_comment_id&&xt.has(Pt.parent_comment_id)){const Vt=xt.get(Pt.parent_comment_id);Vt.replies=Vt.replies||[],Vt.replies.push(Yt)}else _t.push(Yt)}),_t};return{posts:Ar.map(Ze=>{const xt=(an||[]).filter(_t=>_t.post_id===Ze.id).map(_t=>{let Pt="",Yt=null;if(_t.resource_type==="template"){const Vt=Cr.get(_t.resource_id);Pt=(Vt==null?void 0:Vt.name)||"Unknown Template",Yt=(Vt==null?void 0:Vt.preview_image_url)||null}return{id:_t.id,resource_type:_t.resource_type,resource_id:_t.resource_id,resource_name:Pt,resource_preview_url:Yt}});return{...Ze,user_name:On.get(Ze.user_id)||"Unknown User",user_avatar:Mr.get(Ze.user_id),category:Ze.category_id?ua.get(Ze.category_id):null,media:(ir||[]).filter(_t=>_t.post_id===Ze.id),reactions:((or||[]).filter(_t=>_t.post_id===Ze.id)||[]).map(_t=>({..._t,user_name:On.get(_t.user_id)||"Unknown User",user_avatar:Mr.get(_t.user_id)})),comments:$t((hr||[]).filter(_t=>_t.post_id===Ze.id)),resources:xt}}),hasMore:Us,nextPage:He+1}},getNextPageParam:He=>He.hasMore?He.nextPage:void 0}),ct=k.useMemo(()=>(Ee==null?void 0:Ee.pages.flatMap(He=>He.posts))??[],[Ee]),pe=Et({mutationFn:async()=>{q(!0);const{data:He,error:gt}=await G.from("community_posts").insert({user_id:t.id,category_id:N?null:_||null,private_group_id:N||null,content:f,link_url:L||null}).select().single();if(gt)throw gt;for(let Wt=0;Wt0){const Wt=fe.filter(xs=>xs!==t.id).map(xs=>({post_id:He.id,mentioned_user_id:xs,mentioned_by_user_id:t.id}));Wt.length>0&&await G.from("community_post_mentions").insert(Wt)}const Mt=vHt(f);if(Mt.length>0){const Wt=Mt.map(xs=>({post_id:He.id,resource_type:"template",resource_id:xs}));await G.from("community_post_resources").insert(Wt)}return He},onSuccess:async He=>{var gt;i.invalidateQueries({queryKey:["community-posts"]}),y(""),xe([]),we([]),b(""),w(""),C([]),I([]),O(""),l({title:"Post created!"});try{const Mt=((gt=t==null?void 0:t.user_metadata)==null?void 0:gt.name)||"Someone",Wt=f.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),xs=Wt.length>50?Wt.substring(0,50)+"...":Wt;await G.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${Mt}: ${xs}`,url:"/community"}})}catch(Mt){console.error("Failed to send push notification:",Mt)}},onError:He=>{l({title:"Error creating post",description:He.message,variant:"destructive"})},onSettled:()=>q(!1)}),Ge=Et({mutationFn:async({postId:He,content:gt})=>{const{error:Mt}=await G.from("community_posts").update({content:gt}).eq("id",He);if(Mt)throw Mt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),V(null),Z(""),l({title:"Post updated!"})}}),tt=Et({mutationFn:async He=>{const{error:gt}=await G.from("community_posts").delete().eq("id",He);if(gt)throw gt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),st=Et({mutationFn:async({postId:He,isPinned:gt})=>{const{error:Mt}=await G.from("community_posts").update({is_pinned:!gt,pinned_at:gt?null:new Date().toISOString(),pinned_by:gt?null:t==null?void 0:t.id}).eq("id",He);if(Mt)throw Mt},onSuccess:(He,{isPinned:gt})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:gt?"Post unpinned":"Post pinned to top"})}}),Ce=Et({mutationFn:async({postId:He,reactionType:gt})=>{var Wt;const Mt=(Wt=ct.find(xs=>xs.id===He))==null?void 0:Wt.reactions.find(xs=>xs.user_id===(t==null?void 0:t.id));Mt?Mt.reaction_type===gt?await G.from("community_reactions").delete().eq("id",Mt.id):await G.from("community_reactions").update({reaction_type:gt}).eq("id",Mt.id):await G.from("community_reactions").insert({post_id:He,user_id:t.id,reaction_type:gt})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),et=Et({mutationFn:async({postId:He,content:gt})=>{const{data:Mt,error:Wt}=await G.from("community_comments").insert({post_id:He,user_id:t.id,content:gt}).select("id").single();if(Wt)throw Wt;const xs=ie[He]||[];if(xs.length>0&&Mt){const Cs=xs.filter(Us=>Us!==t.id).map(Us=>({comment_id:Mt.id,mentioned_user_id:Us,mentioned_by_user_id:t.id}));Cs.length>0&&await G.from("community_comment_mentions").insert(Cs)}},onSuccess:(He,{postId:gt})=>{i.invalidateQueries({queryKey:["community-posts"]}),ae(Mt=>({...Mt,[gt]:""})),le(Mt=>({...Mt,[gt]:[]}))}});Et({mutationFn:async He=>{const{error:gt}=await G.from("community_comments").delete().eq("id",He);if(gt)throw gt},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const Ct=He=>{const gt=Array.from(He.target.files||[]);if(gt.length+S.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}C(Mt=>[...Mt,...gt]),gt.forEach(Mt=>{const Wt=new FileReader;Wt.onloadend=()=>{I(xs=>[...xs,Wt.result])},Wt.readAsDataURL(Mt)})},Ot=He=>{C(gt=>gt.filter((Mt,Wt)=>Wt!==He)),I(gt=>gt.filter((Mt,Wt)=>Wt!==He))},ut=He=>He.split(" ").map(gt=>gt[0]).join("").toUpperCase().slice(0,2),Oe=He=>{const gt={};return He.forEach(Mt=>{gt[Mt.reaction_type]=(gt[Mt.reaction_type]||0)+1}),gt},Xe=He=>{var gt;return(gt=He.find(Mt=>Mt.user_id===(t==null?void 0:t.id)))==null?void 0:gt.reaction_type},at=He=>He.reduce((gt,Mt)=>gt+1+(Mt.replies?at(Mt.replies):0),0),Ke=He=>{if(n)return!0;if(!s||!He.private_group_id)return!1;const gt=Ae.find(Mt=>Mt.id===He.private_group_id);return gt!=null&>.brokerage_id?r.some(Mt=>Mt.id===gt.brokerage_id):!1};return e.jsx(Ls,{title:"Community",children:e.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[e.jsx(sHt,{categories:Te,privateGroups:Ae,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsxs("div",{className:"flex-1 min-w-0 max-w-2xl mx-auto lg:mx-0 space-y-6",children:[e.jsxs("div",{className:"px-1",children:[e.jsx("h1",{className:"text-4xl lg:text-5xl font-bold text-foreground",children:"Community"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Connect and share with fellow agents"})]}),e.jsx(rHt,{categories:Te,privateGroups:Ae,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsx(Ie,{children:e.jsx(Be,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(vn,{className:"h-10 w-10",children:[e.jsx(Ca,{src:a||void 0}),e.jsx(_n,{children:t!=null&&t.email?ut(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(mce,{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:xe,onTemplatesChange:we,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),A.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:A.map((He,gt)=>{var Mt;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(Mt=S[gt])!=null&&Mt.type.startsWith("video/")?e.jsx("video",{src:He,className:"w-full h-full object-cover"}):e.jsx("img",{src:He,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(gt),children:e.jsx(Sr,{className:"h-3 w-3"})})]},gt)})}),L&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(go,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{value:L,onChange:He=>O(He.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>O(""),children:e.jsx(Sr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx("input",{type:"file",ref:d,onChange:Ct,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var He;return(He=d.current)==null?void 0:He.click()},children:[e.jsx(Uo,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var He;return(He=d.current)==null?void 0:He.click()},children:[e.jsx(hn,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>O("https://"),children:[e.jsx(go,{className:"h-4 w-4 mr-1"}),"Link"]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end",children:[Ae.length>0?e.jsxs(zs,{value:N||_||"none",onValueChange:He=>{He==="none"?(b(""),w("")):He.startsWith("group:")?(w(He.replace("group:","")),b("")):(b(He),w(""))},children:[e.jsx(Os,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(qs,{placeholder:"Select..."})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"No category"}),Te.map(He=>e.jsxs(yt,{value:He.id,children:[He.icon," ",He.name]},He.id)),Ae.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-muted-foreground border-t mt-1 pt-1",children:"🔒 Private Groups"}),Ae.map(He=>e.jsxs(yt,{value:`group:${He.id}`,children:[He.icon||"🔒"," ",He.name]},He.id))]})]})]}):e.jsxs(zs,{value:_,onValueChange:b,children:[e.jsx(Os,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(qs,{placeholder:"Category"})}),e.jsx(Fs,{children:Te.map(He=>e.jsxs(yt,{value:He.id,children:[He.icon," ",He.name]},He.id))})]}),e.jsxs(K,{size:"sm",onClick:()=>pe.mutate(),disabled:!f.trim()||U,children:[e.jsx(Nn,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),ve?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((He,gt)=>e.jsx(Ie,{children:e.jsx(Be,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Ss,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Ss,{className:"h-4 w-32"}),e.jsx(Ss,{className:"h-4 w-full"}),e.jsx(Ss,{className:"h-4 w-3/4"})]})]})})},gt))}):ct.length===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"py-12 text-center",children:[e.jsx(bc,{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:[ct.map(He=>{var gt,Mt,Wt,xs;return e.jsx(Ie,{children:e.jsxs(Be,{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(vn,{className:"h-10 w-10",children:[e.jsx(Ca,{src:He.user_avatar||void 0}),e.jsx(_n,{children:ut(He.user_name||"U")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold break-words",children:He.user_name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:jl(new Date(He.created_at),{addSuffix:!0})}),He.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:[He.category.icon," ",He.category.name]})]})]})]})]}),(He.user_id===(t==null?void 0:t.id)||Ke(He))&&e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(dx,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",children:[Ke(He)&&He.private_group_id&&e.jsx(xa,{onClick:()=>st.mutate({postId:He.id,isPinned:He.is_pinned}),children:He.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(ML,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ib,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),He.user_id===(t==null?void 0:t.id)&&e.jsxs(xa,{onClick:()=>{V(He),Z(He.content)},children:[e.jsx(pa,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(xa,{className:"text-destructive",onClick:()=>tt.mutate(He.id),children:[e.jsx(yr,{className:"h-4 w-4 mr-2"}),He.user_id!==(t==null?void 0:t.id)?"Remove (Moderate)":"Delete"]})]})]})]}),He.is_pinned&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-primary",children:[e.jsx(Ib,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(N4e,{content:He.content})}),He.media.length>0&&e.jsx("div",{className:`grid gap-2 mb-3 ${He.media.length===1?"grid-cols-1":He.media.length===2?"grid-cols-2":He.media.length===3?"grid-cols-3":"grid-cols-2"}`,children:He.media.slice(0,4).map((Cs,Us)=>{const Ar=Us===3&&He.media.length>4,Bt=He.media.length-4;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden bg-muted cursor-pointer group ${He.media.length===1?"max-h-[500px]":He.media.length===2?"aspect-[4/3]":"aspect-square"}`,onClick:()=>Ve({open:!0,images:He.media.map(Xs=>({url:Xs.media_url,type:Xs.media_type==="video"?"video":"image"})),index:Us}),children:[Cs.media_type==="video"?e.jsx("video",{src:Cs.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:Cs.media_url,alt:"",className:"w-full h-full object-cover transition-transform group-hover:scale-105"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-white",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})})})}),Ar&&e.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:e.jsxs("span",{className:"text-white text-2xl font-bold",children:["+",Bt]})})]},Cs.id)})}),He.link_url&&e.jsxs("a",{href:He.link_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg border hover:bg-muted transition-colors mb-3 overflow-hidden",children:[He.link_image&&e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:He.link_image,alt:He.link_title||"Link preview",className:"w-full h-full object-cover",onError:Cs=>{Cs.currentTarget.style.display="none"}})}),e.jsx("div",{className:"p-3",children:He.link_title?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:He.link_title}),He.link_description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:He.link_description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 truncate",children:new URL(He.link_url).hostname})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[e.jsx(go,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:He.link_url})]})})]}),He.reactions.length>0&&e.jsx(Mtt,{reactions:He.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(Oe(He.reactions)).slice(0,3).map(([Cs])=>{var Us;return e.jsx("span",{className:"text-base",children:(Us=Jz.find(Ar=>Ar.type===Cs))==null?void 0:Us.emoji},Cs)})}),e.jsx("span",{children:He.reactions.length})]})}),e.jsxs("div",{className:"flex items-center gap-1 border-t border-b py-1 my-2",children:[e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",children:[Xe(He.reactions)?e.jsx("span",{className:"mr-1",children:(gt=Jz.find(Cs=>Cs.type===Xe(He.reactions)))==null?void 0:gt.emoji}):e.jsx(Ou,{className:"h-4 w-4 mr-1"}),Xe(He.reactions)?(Mt=Jz.find(Cs=>Cs.type===Xe(He.reactions)))==null?void 0:Mt.label:"Like"]})}),e.jsx(uo,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:Jz.map(Cs=>e.jsx("button",{onClick:()=>Ce.mutate({postId:He.id,reactionType:Cs.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:Cs.label,children:Cs.emoji},Cs.type))})})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>Y(Cs=>{const Us=new Set(Cs);return Us.has(He.id)?Us.delete(He.id):Us.add(He.id),Us}),children:[e.jsx(bc,{className:"h-4 w-4 mr-1"}),(()=>{const Cs=at(He.comments);return Cs>0?`Comment (${Cs})`:"Comment"})()]})]}),J.has(He.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[He.comments.map(Cs=>e.jsx(Ttt,{comment:Cs,postId:He.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:Ke(He)},Cs.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ca,{src:a||void 0}),e.jsx(_n,{className:"text-xs",children:ut(((Wt=t.email)==null?void 0:Wt.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(mce,{placeholder:"Write a comment... (use @ to mention)",value:ce[He.id]||"",onChange:Cs=>ae(Us=>({...Us,[He.id]:Cs})),onMentionsChange:Cs=>le(Us=>({...Us,[He.id]:Cs})),mentionFormat:"plain",onKeyDown:Cs=>{var Us;Cs.defaultPrevented||Cs.key==="Enter"&&!Cs.shiftKey&&((Us=ce[He.id])!=null&&Us.trim())&&(Cs.preventDefault(),et.mutate({postId:He.id,content:ce[He.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{var Cs;(Cs=ce[He.id])!=null&&Cs.trim()&&et.mutate({postId:He.id,content:ce[He.id]})},disabled:!((xs=ce[He.id])!=null&&xs.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(Nn,{className:"h-4 w-4"})})]})]})]})]})},He.id)}),Re&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(K,{variant:"outline",onClick:()=>Ue(),disabled:ye,children:ye?"Loading…":"Load more posts"})})]}),e.jsx(fs,{open:!!$,onOpenChange:()=>V(null),children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Edit Post"})}),e.jsx(_r,{value:ee,onChange:He=>Z(He.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:()=>{$&&Ge.mutate({postId:$.id,content:ee})},disabled:!ee.trim(),children:"Save Changes"})]})]})}),e.jsx(gHt,{images:Ne.images,initialIndex:Ne.index,open:Ne.open,onOpenChange:He=>Ve(gt=>({...gt,open:He}))})]})]})})},N5={open:{label:"Open",icon:rn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:bc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:si,color:"bg-green-500"},closed:{label:"Closed",icon:Ql,color:"bg-muted-foreground"}},yDe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function bHt(){const{user:t}=$s(),s=es(),[r,n]=k.useState(null),[a,o]=k.useState(""),{data:l=[],isLoading:i}=ft({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:d=[]}=ft({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=Et({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=N5[r.status].icon;return e.jsx(Ls,{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(Ra,{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(Ye,{variant:"secondary",children:yDe[r.category]}),e.jsxs(Ye,{className:N5[r.status].color,children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),N5[r.status].label]})]})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(mr,{children:["Created on ",gs(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Be,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Conversation"})}),e.jsxs(Be,{children:[e.jsx(di,{className:"h-[300px] pr-4",children:d.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:d.map(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:gs(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(jo,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_r,{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(Nn,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Ls,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ie,{className:"bg-gradient-to-br from-primary/10 via-primary/5 to-background border-primary/20",children:e.jsx(Be,{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(Sv,{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(o_e,{trigger:e.jsxs(K,{size:"lg",className:"gap-2",children:[e.jsx(Bs,{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(Tn,{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(o_e,{trigger:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(Bs,{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(Ie,{className:"border-dashed",children:e.jsxs(Be,{className:"text-center py-12",children:[e.jsx(bc,{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=N5[f.status].icon;return e.jsx(Ie,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(f),children:e.jsx(Be,{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(Ye,{variant:"outline",className:"text-xs",children:yDe[f.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:gs(new Date(f.created_at),"MMM d, yyyy")})]})]}),e.jsxs(Ye,{className:N5[f.status].color,children:[e.jsx(y,{className:"h-3 w-3 mr-1"}),N5[f.status].label]})]})})},f.id)})})]})})}function wHt({open:t,onOpenChange:s}){return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(ks,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(nn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(bs,{children:"Schedule Agent Onboarding"}),e.jsx(Rr,{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 jHt({open:t,onOpenChange:s}){const{brokerageId:r}=$s(),[n,a]=k.useState(""),[o,l]=k.useState([]),[i,d]=k.useState(!1),{data:u,isLoading:p}=ft({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:N,error:w}=await G.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(w)throw w;return N},enabled:t&&!!r}),f=u==null?void 0:u.filter(N=>N.name.toLowerCase().includes(n.toLowerCase())||N.email.toLowerCase().includes(n.toLowerCase())),y=N=>{l(w=>w.includes(N)?w.filter(S=>S!==N):[...w,N])},_=async()=>{if(o.length===0){me.error("Please select at least one agent");return}d(!0);try{const{data:N,error:w}=await G.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(w)throw w;me.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(N){console.error("Error sending onboarding link:",N),me.error(N.message||"Failed to send onboarding link")}finally{d(!1)}},b=N=>{N||(l([]),a("")),s(N)};return e.jsx(fs,{open:t,onOpenChange:b,children:e.jsxs(ms,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Nn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(bs,{children:"Send Onboarding Link"}),e.jsx(Rr,{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(tn,{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:N=>a(N.target.value),className:"pl-10"})]}),p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ps,{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(cr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(di,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:f==null?void 0:f.map(N=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>y(N.id),children:[e.jsx(Gi,{checked:o.includes(N.id),onCheckedChange:()=>y(N.id)}),e.jsx(vn,{className:"h-8 w-8",children:e.jsx(_n,{className:"text-xs",children:N.name.split(" ").map(w=>w[0]).join("").toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:N.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:N.email})]})]},N.id))})}),o.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),e.jsxs(gn,{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(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function NHt(){const[t,s]=k.useState(!1),[r,n]=k.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{className:"mb-8",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(cr,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ft,{children:"Agent Onboarding"}),e.jsx(mr,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(Be,{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(nn,{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(Nn,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(wHt,{open:t,onOpenChange:s}),e.jsx(jHt,{open:r,onOpenChange:n})]})}function kHt({open:t,onOpenChange:s}){return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(ks,{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(Jy,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(bs,{children:"Schedule Launch Meeting"}),e.jsx(Rr,{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 SHt(){const[t,s]=k.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{className:"mb-8",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Jy,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ft,{children:"Launch or ReLaunch Meeting"}),e.jsx(mr,{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(Be,{children:e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(Jy,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(kHt,{open:t,onOpenChange:s})]})}function CHt(){const t=br(),[s,r]=k.useState(""),[n,a]=k.useState(null),{data:o,isLoading:l}=ft({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:N,error:w}=await G.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(w)throw w;return N}}),{data:i}=ft({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:N,error:w}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(w)throw w;return N}}),{data:d}=ft({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:N,error:w}=await G.from("brokerage_resource_pdfs").select("resource_id");if(w)throw w;return N}}),{data:u}=ft({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:N,error:w}=await G.from("brokerage_resource_videos").select("resource_id");if(w)throw w;return N}}),{data:p}=ft({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:N,error:w}=await G.from("brokerage_resource_links").select("resource_id");if(w)throw w;return N}}),f=o==null?void 0:o.filter(N=>{var C;const w=N.title.toLowerCase().includes(s.toLowerCase())||((C=N.description)==null?void 0:C.toLowerCase().includes(s.toLowerCase())),S=!n||N.category_id===n;return w&&S}),y=i==null?void 0:i.filter(N=>o==null?void 0:o.some(w=>w.category_id===N.id)),_=N=>{const w=(d==null?void 0:d.filter(A=>A.resource_id===N).length)||0,S=(u==null?void 0:u.filter(A=>A.resource_id===N).length)||0,C=(p==null?void 0:p.filter(A=>A.resource_id===N).length)||0;return{pdfCount:w,videoCount:S,linkCount:C}},b=N=>{t(`/brokerage-resources/${N}`)};return e.jsx(Ls,{title:"Brokerage Resources",description:"Access exclusive resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(NHt,{}),e.jsx(SHt,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(tn,{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:N=>r(N.target.value),className:"pl-10"})]}),y&&y.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Ye,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),y.map(N=>e.jsx(Ye,{variant:n===N.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(N.id),children:N.name},N.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((N,w)=>e.jsxs(Ie,{children:[e.jsx(Ss,{className:"h-40 w-full"}),e.jsx(Lt,{children:e.jsx(Ss,{className:"h-5 w-3/4"})}),e.jsxs(Be,{children:[e.jsx(Ss,{className:"h-4 w-full mb-2"}),e.jsx(Ss,{className:"h-4 w-2/3"})]})]},w))}):(f==null?void 0:f.length)===0?e.jsxs(Ie,{className:"p-12 text-center",children:[e.jsx(Lh,{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(N=>{const{pdfCount:w,videoCount:S,linkCount:C}=_(N.id),A=i==null?void 0:i.find(I=>I.id===N.category_id);return e.jsxs(Ie,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>b(N.id),children:[N.preview_image_url?e.jsx("img",{src:N.preview_image_url,alt:N.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(Lh,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Ft,{className:"text-lg line-clamp-1",children:N.title}),A&&e.jsx(Ye,{variant:"secondary",className:"shrink-0 text-xs",children:A.name})]})}),e.jsxs(Be,{children:[N.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:N.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[w>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mn,{className:"h-4 w-4"}),w]}),S>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-4 w-4"}),S]}),C>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(go,{className:"h-4 w-4"}),C]})]})]})]},N.id)})})]})})}const MHt=()=>{const{resourceId:t}=ho(),{data:s,isLoading:r}=ft({queryKey:["brokerage-resource-detail",t],queryFn:async()=>{const{data:a,error:o}=await G.from("brokerage_resources").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;const{data:l}=await G.from("brokerage_resource_pdfs").select("*").eq("resource_id",t).order("sort_order"),{data:i}=await G.from("brokerage_resource_videos").select("*").eq("resource_id",t).order("sort_order"),{data:d}=await G.from("brokerage_resource_links").select("*").eq("resource_id",t).order("sort_order");return{...a,pdfs:l||[],videos:i||[],links:d||[]}},enabled:!!t}),n=a=>a?a<1024?a+" B":a<1024*1024?(a/1024).toFixed(1)+" KB":(a/(1024*1024)).toFixed(1)+" MB":"";return r?e.jsx(Ls,{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(Ls,{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(da,{to:"/brokerage-resources",children:[e.jsx(Ra,{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(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(hn,{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(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(mn,{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(mn,{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(Xa,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})}),s.links&&s.links.length>0&&e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Kr,{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(Kr,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(Kr,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})})]})}):e.jsx(Ls,{title:"Brokerage Resources",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Lh,{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(da,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function THt(){const{onlineUsers:t,totalOnline:s}=hXe();return e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(Ye,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(sd,{className:"h-2 w-2 fill-green-500 text-green-500 mr-1"}),s," online"]})]})}),e.jsx(Be,{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(di,{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(vn,{className:"h-9 w-9",children:[e.jsx(Ca,{src:r.avatarUrl,alt:r.name}),e.jsx(_n,{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 ",jl(new Date(r.onlineSince),{addSuffix:!1})]})]})]},r.id)})})})})]})}const vDe={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:cr,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:$L,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:jx,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:hL,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:hh,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:vd,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:cr,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:Oh,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:il,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:Rl,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:Dh,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:Og,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:qr,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:qr,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:Jv,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:xd,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:Lh,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:Lh,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:tr,path:"/admin/agent-email-templates",color:"bg-rose-500/10 text-rose-600"},{title:"Mass Email Templates",description:"Create and manage shared campaign templates",icon:dh,path:"/admin/email-campaigns/templates",color:"bg-teal-500/10 text-teal-600"}]},platform:{label:"Platform",sections:[{title:"Dashboard Management",description:"Configure banners and dashboard modules",icon:oS,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:tx,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:tr,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:dh,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:NM,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:t0,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:Vi,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:Hi,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:Do,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:cr,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:dh,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:Si,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:EM,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:Eb,path:"/admin/wishlist",color:"bg-yellow-500/10 text-yellow-600"},{title:"Membership Reviews",description:"View member feedback and ratings",icon:Gn,path:"/admin/membership-reviews",color:"bg-amber-500/10 text-amber-600"},{title:"Weekly Digest",description:"Configure automated weekly email digests",icon:tr,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:so,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:oh,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:Dh,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:Za,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:Mn,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:Rg,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:oh,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:Uo,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:tr,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:Ab,path:"/admin/beta/homereel",color:"bg-gradient-to-br from-violet-500/20 to-indigo-500/10 text-violet-600"}]},"lead-sites":{label:"Lead Sites",sections:[{title:"All Sites",description:"Overview of all agent websites with status and quick actions",icon:gd,path:"/admin/lead-sites",color:"bg-gradient-to-br from-sky-500/20 to-blue-500/10 text-sky-600"},{title:"MLS Feeds",description:"Manage MLS data feed connections, API keys, and coverage areas",icon:mL,path:"/admin/mls-feeds",color:"bg-gradient-to-br from-emerald-500/20 to-green-500/10 text-emerald-600"},{title:"Lead Analytics",description:"Cross-site lead capture stats, conversions, and top-performing sites",icon:Yo,path:"/admin/lead-site-analytics",color:"bg-gradient-to-br from-amber-500/20 to-orange-500/10 text-amber-600"},{title:"Website Interests",description:"Track interest form submissions from TheLocalMove.com",icon:mn,path:"/admin/website-interests",color:"bg-gradient-to-br from-rose-500/20 to-pink-500/10 text-rose-600"},{title:"Website Order Tracker",description:"Full setup requests with all build details from /get-started",icon:mn,path:"/admin/website-orders",color:"bg-gradient-to-br from-emerald-500/20 to-teal-500/10 text-emerald-600"},{title:"MLS Fee Tracker",description:"Track MLS providers, setup fees, and monthly costs",icon:_c,path:"/admin/mls-fee-tracker",color:"bg-gradient-to-br from-teal-500/20 to-cyan-500/10 text-teal-600"}]}};function _De(){const t=br();return console.log("[AdminDashboard] render"),e.jsx(Ls,{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(THt,{})})]}),e.jsxs(ta,{defaultValue:"users",className:"w-full",children:[e.jsx(Qn,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(vDe).map(([s,r])=>e.jsx(ls,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(vDe).map(([s,r])=>e.jsx(js,{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(Ie,{className:"cursor-pointer hover:shadow-md transition-all hover:border-primary/50 group",onClick:()=>t(n.path),children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${n.color} mb-2 group-hover:scale-110 transition-transform`,children:e.jsx(n.icon,{className:"h-5 w-5"})}),e.jsx(Ft,{className:"text-base",children:n.title})]}),e.jsx(Be,{className:"pt-0",children:e.jsx(mr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const An=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:Rt("w-full caption-bottom text-sm",t),...s})}));An.displayName="Table";const En=k.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:Rt("[&_tr]:border-b",t),...s}));En.displayName="TableHeader";const Pn=k.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:Rt("[&_tr:last-child]:border-0",t),...s}));Pn.displayName="TableBody";const AHt=k.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:Rt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));AHt.displayName="TableFooter";const As=k.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:Rt("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));As.displayName="TableRow";const Nt=k.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:Rt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));Nt.displayName="TableHead";const dt=k.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:Rt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));dt.displayName="TableCell";const EHt=k.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:Rt("mt-4 text-sm text-muted-foreground",t),...s}));EHt.displayName="TableCaption";const PHt=()=>{const{isAdmin:t}=$s(),s=br(),[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(!1),[d,u]=k.useState(null);k.useEffect(()=>{if(!t){s("/dashboard");return}p()},[t]);const p=async()=>{try{const{data:N,error:w}=await G.from("app_tiles").select("*").order("name");if(w)throw w;n(N||[])}catch(N){console.error("Error loading apps:",N),me.error("Failed to load apps")}finally{o(!1)}},f=async N=>{N.preventDefault();const w=new FormData(N.currentTarget),S={name:w.get("name"),description:w.get("description"),icon:w.get("icon"),app_id:w.get("app_id"),target_url:w.get("target_url"),required_tags:w.get("required_tags").split(",").map(C=>C.trim()).filter(Boolean)};try{if(d){const{error:C}=await G.from("app_tiles").update(S).eq("id",d.id);if(C)throw C;me.success("App updated successfully")}else{const{error:C}=await G.from("app_tiles").insert([S]);if(C)throw C;me.success("App created successfully")}i(!1),u(null),p()}catch(C){console.error("Error saving app:",C),me.error("Failed to save app")}},y=async N=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:w}=await G.from("app_tiles").delete().eq("id",N);if(w)throw w;me.success("App deleted successfully"),p()}catch(w){console.error("Error deleting app:",w),me.error("Failed to delete app")}},_=N=>{u(N),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(Ra,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Manage Apps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create and configure application tiles"})]})]}),e.jsxs(fs,{open:l,onOpenChange:i,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{onClick:b,children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(ms,{className:"max-w-2xl",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:d?"Edit App":"Create New App"}),e.jsx(Rr,{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(ge,{htmlFor:"name",children:"App Name"}),e.jsx(Fe,{id:"name",name:"name",defaultValue:d==null?void 0:d.name,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"app_id",children:"App ID"}),e.jsx(Fe,{id:"app_id",name:"app_id",defaultValue:d==null?void 0:d.app_id,placeholder:"agent_connect",required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",name:"description",defaultValue:d==null?void 0:d.description})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"icon",children:"Icon (emoji)"}),e.jsx(Fe,{id:"icon",name:"icon",defaultValue:d==null?void 0:d.icon,placeholder:"🚀",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"target_url",children:"Target URL"}),e.jsx(Fe,{id:"target_url",name:"target_url",type:"url",defaultValue:d==null?void 0:d.target_url,required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"required_tags",children:"Required Tags (comma-separated)"}),e.jsx(Fe,{id:"required_tags",name:"required_tags",defaultValue:d==null?void 0:d.required_tags.join(", "),placeholder:"levelup-member, agent-connect"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{type:"submit",children:d?"Update":"Create"})]})]})]})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Application Tiles"}),e.jsx(mr,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(Be,{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(Bs,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Icon"}),e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"App ID"}),e.jsx(Nt,{children:"Target URL"}),e.jsx(Nt,{children:"Tags"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:r.map(N=>e.jsxs(As,{children:[e.jsx(dt,{className:"text-2xl",children:N.icon}),e.jsx(dt,{className:"font-medium",children:N.name}),e.jsx(dt,{className:"font-mono text-sm",children:N.app_id}),e.jsx(dt,{className:"text-sm text-muted-foreground max-w-xs truncate",children:N.target_url}),e.jsx(dt,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:N.required_tags.map(w=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:w},w))})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>_(N),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>y(N.id),children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},N.id))})]})})]})})]})};function qu({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(da,{to:"/admin",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(Ra,{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 bDe=({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(Ye,{variant:"destructive",className:Rt("gap-1",s),children:[e.jsx(Qc,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(Ye,{variant:"destructive",className:Rt("gap-1",s),children:[e.jsx(rn,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(Ye,{className:Rt("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(rn,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(Ye,{variant:"secondary",className:Rt("gap-1",s),children:[e.jsx(rn,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},Att=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=va(),l=k.useRef(null),[i,d]=k.useState([]),[u,p]=k.useState(""),[f,y]=k.useState(!1),[_,b]=k.useState("upload"),[N,w]=k.useState(null),S=()=>{d([]),p(""),b("upload"),w(null),l.current&&(l.current.value="")},C=()=>{S(),s(!1)},A=q=>{const $=q.split(` `).map(Y=>Y.trim()).filter(Y=>Y);if($.length===0)return[];const V=$[0].toLowerCase(),Z=V.includes("first")||V.includes("last")||V.includes("email")||V.includes("name")||V.includes("phone")||V.includes("sms")||V.includes("consent")?$.slice(1):$,J=[];for(const Y of Z){const ae=(Y.includes(" ")?Y.split(" "):Y.split(",")).map(ie=>ie.trim().replace(/^["']|["']$/g,""));if(ae.length>=2){let ie="",le="",fe="",xe="",he;if(ae.length===2){const Ve=ae[0].split(" ");ie=Ve[0]||"",le=Ve.slice(1).join(" ")||"",fe=ae[1]}else if(ae.length===3)ie=ae[0],le=ae[1],fe=ae[2];else if(ae.length===4)ie=ae[0],le=ae[1],fe=ae[2],xe=ae[3];else if(ae.length>=5){ie=ae[0],le=ae[1],fe=ae[2],xe=ae[3];const Ve=ae[4].toLowerCase();he=Ve==="true"||Ve==="yes"||Ve==="1"||Ve==="y"}const Ne=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(fe);J.push({firstName:ie.trim(),lastName:le.trim(),email:fe.trim().toLowerCase(),phone:xe.trim()||void 0,smsConsent:he,isValid:Ne&&ie.trim().length>0,error:Ne?ie.trim()?void 0:"Missing name":"Invalid email"})}}return J},I=q=>{var ee;const $=(ee=q.target.files)==null?void 0:ee[0];if(!$)return;const V=new FileReader;V.onload=Z=>{var ce;const J=(ce=Z.target)==null?void 0:ce.result,Y=A(J);if(Y.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}d(Y),b("preview")},V.readAsText($)},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 $=n||u||null;y(!0);try{const{data:{session:V}}=await G.auth.getSession(),ee=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(J=>({firstName:J.firstName,lastName:J.lastName,email:J.email,phone:J.phone,smsConsent:J.smsConsent})),brokerageId:$})}),Z=await ee.json();if(!ee.ok)throw new Error(Z.error||"Failed to import users");w(Z),b("result"),Z.created>0&&a(),o({title:"Import Complete",description:`${Z.created} user(s) created successfully.${Z.failed>0?` ${Z.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)}},O=i.filter(q=>q.isValid).length,U=i.filter(q=>!q.isValid).length;return e.jsx(fs,{open:t,onOpenChange:C,children:e.jsxs(ms,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Zv,{className:"h-5 w-5"}),"Import Agents from CSV"]}),e.jsx(Rr,{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(Da,{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(ge,{children:"Assign to Brokerage (optional)"}),e.jsxs(zs,{value:u||"none",onValueChange:q=>p(q==="none"?"":q),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select a brokerage..."})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"No brokerage"}),r.map(q=>e.jsx(yt,{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(Hn,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[O," valid"]})]}),U>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(co,{className:"h-4 w-4"}),e.jsxs("span",{children:[U," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{className:"bg-muted/30",children:[e.jsx(Nt,{children:"First Name"}),e.jsx(Nt,{children:"Last Name"}),e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{children:"Phone"}),e.jsx(Nt,{children:"SMS"}),e.jsx(Nt,{children:"Status"})]})}),e.jsx(Pn,{children:i.slice(0,100).map((q,$)=>e.jsxs(As,{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(Ye,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(Ye,{variant:"destructive",children:q.error||"Invalid"})})]},$))})]}),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"&&N&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(Hn,{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:[N.created," agent(s) created and invited"]}),N.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[N.failed," failed to create"]})]}),N.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:[N.errors.slice(0,10).map((q,$)=>e.jsxs("li",{children:["• ",q]},$)),N.errors.length>10&&e.jsxs("li",{children:["...and ",N.errors.length-10," more"]})]})]})]}),e.jsxs(gn,{children:[_==="upload"&&e.jsx(K,{variant:"outline",onClick:C,children:"Cancel"}),_==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:S,children:"Back"}),e.jsx(K,{onClick:L,disabled:f||O===0,children:f?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${O} Agent${O!==1?"s":""}`})]}),_==="result"&&e.jsx(K,{onClick:C,children:"Done"})]})]})})};function Ko({sortKey:t,currentSortKey:s,currentDirection:r,onSort:n,children:a,className:o,...l}){const i=s===t;return e.jsx(Nt,{className:Rt("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(cu,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Ih,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(td,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function rO(t=null,s=null){const[r,n]=k.useState(t),[a,o]=k.useState(s),l=k.useCallback(d=>{r===d?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(d),o("asc"))},[r,a]),i=k.useCallback((d,u)=>{if(!r||!a||!u[r])return d;const p=u[r];return[...d].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 N;return typeof _=="string"&&typeof b=="string"?N=_.localeCompare(b,void 0,{sensitivity:"base"}):N=_-b,a==="asc"?N:-N})},[r,a]);return{sortKey:r,sortDirection:a,handleSort:l,sortData:i}}const IHt=[{type:"custom",title:"Great job!",message:"Keep up the amazing work!",icon:Gn},{type:"custom",title:"You're on fire!",message:"Your dedication is inspiring!",icon:Hi},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:Bd}];function Ett({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=k.useState("custom"),[l,i]=k.useState(""),[d,u]=k.useState(""),p=dkt(),f=_=>{o(_.type),i(_.title),u(_.message)},y=async _=>{if(_.preventDefault(),!l.trim()){cn({title:"Title required",description:"Please enter a celebration title",variant:"destructive"});return}try{await p.mutateAsync({user_id:r,celebration_type:a,title:l.trim(),message:d.trim()||void 0}),cn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{cn({title:"Error",description:"Failed to send celebration",variant:"destructive"})}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Bd,{className:"h-5 w-5 text-primary"}),"Send Celebration to ",n]}),e.jsx(Rr,{children:"They'll see confetti and this message next time they log in!"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(ge,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:IHt.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(ge,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(zs,{value:a,onValueChange:_=>o(_),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"custom",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gn,{className:"h-4 w-4"})," Custom"]})}),e.jsx(yt,{value:"points_earned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hi,{className:"h-4 w-4"})," Points Earned"]})}),e.jsx(yt,{value:"listing_created",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-4 w-4"})," Listing Created"]})}),e.jsx(yt,{value:"deal_closed",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_c,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{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(ge,{htmlFor:"message",children:"Message (optional)"}),e.jsx(_r,{id:"message",value:d,onChange:_=>u(_.target.value),placeholder:"Add a personal message...",rows:3,maxLength:500})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[e.jsx(Bd,{className:"h-4 w-4 mr-2"}),p.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const Sye={points_earned:{label:"Points Earned",icon:Hi,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:Mn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:_c,color:"bg-green-500"},custom:{label:"Custom",icon:qr,color:"bg-purple-500"}};function LHt(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState("all"),{data:l=[],isLoading:i}=ft({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(N=>N.user_id),...p.map(N=>N.created_by).filter(Boolean)])],{data:_}=await G.from("profiles").select("id, name, email").in("id",y),b=new Map((_==null?void 0:_.map(N=>[N.id,N]))||[]);return p.map(N=>{var w,S,C;return{...N,user_name:((w=b.get(N.user_id))==null?void 0:w.name)||"Unknown",user_email:((S=b.get(N.user_id))==null?void 0:S.email)||"",creator_name:N.created_by?((C=b.get(N.created_by))==null?void 0:C.name)||"System":"Auto-triggered"}})}}),d=l.filter(p=>{var b,N;const f=((b=p.user_name)==null?void 0:b.toLowerCase().includes(t.toLowerCase()))||((N=p.user_email)==null?void 0:N.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(Sye).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(ps,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Bd,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(mr,{children:"View all celebrations awarded to agents"})]}),e.jsxs(Be,{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(tn,{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(zs,{value:r,onValueChange:n,children:[e.jsx(Os,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"Filter by type"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Types"}),Object.entries(Sye).map(([p,f])=>e.jsx(yt,{value:p,children:f.label},p))]})]}),e.jsxs(zs,{value:a,onValueChange:o,children:[e.jsx(Os,{className:"w-[140px]",children:e.jsx(qs,{placeholder:"Status"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Status"}),e.jsx(yt,{value:"seen",children:"Seen"}),e.jsx(yt,{value:"unseen",children:"Pending"})]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Type"}),e.jsx(Nt,{children:"Agent"}),e.jsx(Nt,{children:"Title"}),e.jsx(Nt,{children:"Points"}),e.jsx(Nt,{children:"Created By"}),e.jsx(Nt,{children:"Created"}),e.jsx(Nt,{children:"Status"})]})}),e.jsx(Pn,{children:d.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):d.map(p=>{const f=Sye[p.celebration_type],y=f.icon;return e.jsxs(As,{children:[e.jsx(dt,{children:e.jsxs(Ye,{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(Ye,{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:gs(new Date(p.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(dt,{children:p.seen_at?e.jsx(Ye,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(Ye,{variant:"outline",className:"bg-orange-50 text-orange-700 border-orange-200",children:"Pending"})})]},p.id)})})]})}),d.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-right",children:["Showing ",d.length," of ",l.length," celebrations"]})]})]})]})}const DHt=()=>{const{user:t}=$s(),{toast:s}=va(),[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(!1),[d,u]=k.useState("all"),[p,f]=k.useState("all"),[y,_]=k.useState("new"),[b,N]=k.useState(new Set),w=k.useCallback(async()=>{try{o(!0);const{data:J,error:Y}=await G.from("profiles").select("id, name, email, phone, is_trial, trial_started_at, trial_expires_at, subscription_status, subscription_end_date, converted_from_trial_at, created_at").or("is_trial.eq.true,subscription_status.eq.trialing,converted_from_trial_at.not.is.null");if(Y)throw Y;const{data:ce,error:ae}=await G.from("trial_email_exports").select("user_id");if(ae)throw ae;const ie=new Set((ce||[]).map(fe=>fe.user_id)),le=(J||[]).map(fe=>({...fe,converted_from_trial_at:fe.converted_from_trial_at??null,already_exported:ie.has(fe.id)}));le.sort((fe,xe)=>new Date(xe.created_at).getTime()-new Date(fe.created_at).getTime()),n(le)}catch(J){console.error("Error loading trial users:",J),s({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[s]);k.useEffect(()=>{w()},[w]);const S=J=>J.trial_started_at?"ghl":"stripe",C=J=>J.trial_expires_at?J.trial_expires_at:J.subscription_end_date?J.subscription_end_date:null,A=J=>J.converted_from_trial_at!==null,I=J=>{if(A(J))return!1;const Y=C(J);return Y?new Date(Y).getTime()<=Date.now():!1},L=r.filter(J=>!(d!=="all"&&S(J)!==d||p==="active"&&(I(J)||A(J))||p==="expired"&&!I(J)||p==="converted"&&!A(J)||y==="new"&&J.already_exported||y==="exported"&&!J.already_exported)),O=()=>{b.size===L.length?N(new Set):N(new Set(L.map(J=>J.id)))},U=J=>{const Y=new Set(b);Y.has(J)?Y.delete(J):Y.add(J),N(Y)},q=async()=>{if(b.size===0){s({title:"No users selected",description:"Select users to export",variant:"destructive"});return}i(!0);try{const J=r.filter(he=>b.has(he.id)),Y="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",ce=J.map(he=>{const we=(he.name||"").split(" "),Ne=we[0]||"",Ve=we.slice(1).join(" ")||"",Te=S(he)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Ae=A(he)?"Converted":I(he)?"Expired":"Active",ze=he.created_at?new Date(he.created_at).toLocaleDateString():"",Ee=C(he)?new Date(C(he)).toLocaleDateString():"";return`"${Ne}","${Ve}","${he.email}","${he.phone||""}","${Te}","${Ae}","${ze}","${Ee}"`}),ae=[Y,...ce].join(` `),ie=new Blob([ae],{type:"text/csv"}),le=URL.createObjectURL(ie),fe=document.createElement("a");fe.href=le,fe.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,fe.click(),URL.revokeObjectURL(le);const xe=J.filter(he=>!he.already_exported).map(he=>({user_id:he.id,exported_by:t.id}));if(xe.length>0){const{error:he}=await G.from("trial_email_exports").upsert(xe,{onConflict:"user_id"});he&&console.error("Error marking exports:",he)}s({title:"Export complete",description:`Downloaded ${J.length} trial user(s). ${xe.length} newly marked as exported.`}),N(new Set),w()}catch(J){console.error("Export error:",J),s({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},$=r.filter(J=>!J.already_exported).length,V=r.filter(J=>J.already_exported).length,ee=r.filter(J=>A(J)).length,Z=r.filter(J=>!I(J)&&!A(J)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ps,{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(Ie,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(mr,{children:"Total"}),e.jsx(Ft,{className:"text-2xl",children:r.length})]})}),e.jsx(Ie,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(mr,{children:"New (Not Exported)"}),e.jsx(Ft,{className:"text-2xl text-green-600",children:$})]})}),e.jsx(Ie,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(mr,{children:"Active Trials"}),e.jsx(Ft,{className:"text-2xl",children:Z})]})}),e.jsx(Ie,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(mr,{children:"Converted 🎉"}),e.jsx(Ft,{className:"text-2xl text-primary",children:ee})]})}),e.jsx(Ie,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(mr,{children:"Already Exported"}),e.jsx(Ft,{className:"text-2xl text-muted-foreground",children:V})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(zs,{value:y,onValueChange:J=>_(J),children:[e.jsx(Os,{className:"w-[160px]",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Users"}),e.jsx(yt,{value:"new",children:"New Only"}),e.jsx(yt,{value:"exported",children:"Already Exported"})]})]}),e.jsxs(zs,{value:d,onValueChange:J=>u(J),children:[e.jsx(Os,{className:"w-[180px]",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Trial Types"}),e.jsx(yt,{value:"stripe",children:"Credit Card Trial"}),e.jsx(yt,{value:"ghl",children:"Free Trial (No CC)"})]})]}),e.jsxs(zs,{value:p,onValueChange:J=>f(J),children:[e.jsx(Os,{className:"w-[160px]",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Statuses"}),e.jsx(yt,{value:"active",children:"Active Trial"}),e.jsx(yt,{value:"expired",children:"Expired"}),e.jsx(yt,{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(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Xa,{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(As,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(Nt,{className:"w-[40px]",children:e.jsx(Gi,{checked:L.length>0&&b.size===L.length,onCheckedChange:O})}),e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{children:"Trial Type"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{children:"Signup Date"}),e.jsx(Nt,{children:"Expires / Renews"}),e.jsx(Nt,{children:"Exported"})]})}),e.jsx(Pn,{children:L.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):L.map(J=>{const Y=S(J),ce=A(J),ae=I(J),ie=C(J);return e.jsxs(As,{className:`hover:bg-muted/30 ${ce?"bg-primary/5":""}`,children:[e.jsx(dt,{children:e.jsx(Gi,{checked:b.has(J.id),onCheckedChange:()=>U(J.id)})}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[J.name,ce&&e.jsx(Yo,{className:"h-3.5 w-3.5 text-primary"})]})}),e.jsx(dt,{className:"text-muted-foreground",children:J.email}),e.jsx(dt,{children:Y==="stripe"?e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(jx,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(tr,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(dt,{children:ce?e.jsxs(Ye,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(Yo,{className:"h-3 w-3"}),"Converted"]}):ae?e.jsx(Ye,{variant:"destructive",children:"Expired"}):e.jsx(Ye,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(dt,{className:"text-sm",children:J.created_at?new Date(J.created_at).toLocaleDateString():"—"}),e.jsx(dt,{className:"text-sm",children:ce&&ie?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(ie).toLocaleDateString()]}):ie?new Date(ie).toLocaleDateString():"—"}),e.jsx(dt,{children:J.already_exported?e.jsx(Hn,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Ye,{variant:"outline",className:"text-green-600 border-green-300",children:"New"})})]},J.id)})})]})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",L.length," of ",r.length," trial users · ",ee," converted to paid"]})]})},RHt=()=>{const[t,s]=k.useState([]),[r,n]=k.useState(!0);return k.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(ps,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(yr,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{children:"No deletion records yet"})]})}):e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"User Deletion History"})}),e.jsx(Be,{children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Date"}),e.jsx(Nt,{children:"User"}),e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{children:"Brokerage"}),e.jsx(Nt,{children:"Type"}),e.jsx(Nt,{children:"Deleted By"})]})}),e.jsx(Pn,{children:t.map(a=>e.jsxs(As,{children:[e.jsx(dt,{className:"whitespace-nowrap text-sm",children:gs(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(Ye,{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))})]})})]})},TC=t=>{const{user:s}=$s(),r=es(),n=ft({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=>ft({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(S=>S.user_id),{data:N}=await G.from("profiles").select("id, name, email, avatar_url").in("id",b),w=new Map((N||[]).map(S=>[S.id,S]));return(y||[]).map(S=>({...S,profile:w.get(S.user_id)||null}))},enabled:!!f}),o=Et({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=Et({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=Et({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)}}),d=Et({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=Et({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=Et({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:d,removeMember:u,updateMemberRole:p,useTeamMembers:a}},OHt=()=>{const{user:t}=$s();return ft({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})},Ptt=t=>{const{user:s}=$s(),r=es(),n=ft({queryKey:["lead-pond",t],queryFn:async()=>{const{data:i,error:d}=await G.from("team_lead_pond").select("*").eq("team_id",t).order("created_at",{ascending:!1});if(d)throw d;if(!i||i.length===0)return[];const u=i.map(S=>S.contact_id),p=[...new Set(i.map(S=>S.added_by))],f=i.filter(S=>S.claimed_by).map(S=>S.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)]),N=new Map((_.data||[]).map(S=>[S.id,S])),w=new Map((b.data||[]).map(S=>[S.id,S]));return i.map(S=>({...S,status:S.claimed_by?"claimed":"available",contact:N.get(S.contact_id)||null,contributor:w.get(S.added_by)||null,claimer:S.claimed_by&&w.get(S.claimed_by)||null}))},enabled:!!t&&!!s}),a=Et({mutationFn:async i=>{const{data:d,error:u}=await G.rpc("add_to_lead_pond",{_contact_id:i.contact_id,_team_id:i.team_id,_notes:i.notes||null});if(u)throw u;return d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),me.success("Contact added to Lead Pond")},onError:i=>{me.error(i.message)}}),o=Et({mutationFn:async i=>{const{error:d}=await G.rpc("claim_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),me.success("Lead claimed!")},onError:i=>{me.error(i.message)}}),l=Et({mutationFn:async i=>{const{error:d}=await G.rpc("return_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),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}},FHt=()=>{const t=es();return Et({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 Itt({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var L;const{user:o}=$s(),{data:l}=Rx(),{useTeamMembers:i}=TC(),{data:d=[]}=i((l==null?void 0:l.teamId)||""),u=FHt(),[p,f]=k.useState(null),[y,_]=k.useState(""),[b,N]=k.useState(!1),w=d.filter(O=>O.user_id!==(o==null?void 0:o.id)),S=async()=>{if(p){N(!0);try{for(const O of r)await u.mutateAsync({contactId:O,toUserId:p,notes:y||void 0});s(!1),f(null),_(""),a==null||a()}catch{}finally{N(!1)}}},C=w.find(O=>O.user_id===p),A=r.length>1,I=n.length>0?A?`${n.length} contacts`:n[0]:A?`${r.length} contacts`:"this contact";return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Gv,{className:"h-5 w-5"}),"Transfer ",I]}),e.jsxs(Rr,{children:["Select a team member to transfer ",A?"these contacts":"this contact"," to. The contact will be removed from the current owner's CRM and added to the selected member's."]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm font-medium mb-2 block",children:"Transfer to:"}),e.jsx("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:w.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):w.map(O=>{var U,q,$;return e.jsxs("button",{onClick:()=>f(O.user_id),className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${p===O.user_id?"bg-primary/10 border border-primary/30":"hover:bg-accent border border-transparent"}`,children:[e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ca,{src:((U=O.profile)==null?void 0:U.avatar_url)||""}),e.jsx(_n,{className:"text-xs",children:(((q=O.profile)==null?void 0:q.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:(($=O.profile)==null?void 0:$.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:O.role.replace("_"," ")})]})]},O.user_id)})})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(_r,{id:"transfer-notes",value:y,onChange:O=>_(O.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:S,disabled:!p||b,children:[b?e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Gv,{className:"h-4 w-4 mr-2"}),"Transfer",C?` to ${(L=C.profile)==null?void 0:L.name}`:""]})]})]})})}const k4e=()=>{const t=br(),{data:s,isLoading:r}=OHt(),{data:n}=Rx(),[a,o]=k.useState(""),[l,i]=k.useState("all"),[d,u]=k.useState(null),[p,f]=k.useState(""),y=(n==null?void 0:n.role)==="team_leader",_=k.useMemo(()=>{if(!s)return[];const N=new Map;return s.forEach(w=>{N.has(w.owner_user_id)||N.set(w.owner_user_id,{id:w.owner_user_id,name:w.owner_name||"Unknown",avatar:w.owner_avatar_url})}),Array.from(N.values())},[s]),b=k.useMemo(()=>{if(!s)return[];let N=s;if(l!=="all"&&(N=N.filter(w=>w.owner_user_id===l)),a.trim()){const w=a.toLowerCase();N=N.filter(S=>{var C,A,I;return(S.first_name+" "+(S.last_name||"")).toLowerCase().includes(w)||((C=S.email)==null?void 0:C.toLowerCase().includes(w))||((A=S.phone)==null?void 0:A.includes(w))||((I=S.owner_name)==null?void 0:I.toLowerCase().includes(w))})}return N},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ss,{className:"h-10 w-full"}),e.jsx(Ss,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(cr,{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(Ie,{children:e.jsx(Be,{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(tn,{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:N=>o(N.target.value),className:"pl-9"})]}),e.jsxs(zs,{value:l,onValueChange:i,children:[e.jsx(Os,{className:"w-[200px]",children:e.jsx(qs,{placeholder:"Filter by agent"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Team Members"}),_.map(N=>e.jsx(yt,{value:N.id,children:N.name},N.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(Ie,{children:e.jsx(Be,{className:"p-0 overflow-x-auto",children:e.jsxs(An,{className:"min-w-[800px]",children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Agent"}),e.jsx(Nt,{children:"Contact Info"}),e.jsx(Nt,{children:"Address"}),e.jsx(Nt,{children:"Lead Source"}),e.jsx(Nt,{children:"Date Added"}),y&&e.jsx(Nt,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(Pn,{children:b.length===0?e.jsx(As,{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(N=>e.jsxs(As,{className:`hover:bg-accent/50 ${y?"cursor-pointer":""}`,onClick:y?()=>t(`/mission-control/contacts/${N.id}`):void 0,children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("span",{className:y?"hover:text-primary hover:underline transition-colors":"",children:[N.first_name," ",N.last_name||""]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(vn,{className:"h-6 w-6",children:[e.jsx(Ca,{src:N.owner_avatar_url||""}),e.jsx(_n,{className:"text-[10px]",children:(N.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:N.owner_name||"Unknown"})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[N.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(tr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:N.email})]}),N.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:N.phone})]}),!N.email&&!N.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(dt,{children:N.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(La,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:N.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(dt,{children:N.lead_source?e.jsx(Ye,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:N.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:gs(new Date(N.created_at),"MMM d, yyyy")})}),y&&e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:w=>{w.stopPropagation(),u(N.id),f(`${N.first_name} ${N.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(Gv,{className:"h-4 w-4"})})})]},N.id))})]})})}),e.jsx(Itt,{open:!!d,onOpenChange:N=>{N||u(null)},contactIds:d?[d]:[],contactNames:p?[p]:[],onComplete:()=>u(null)})]})},S4e=({teamId:t})=>{const{user:s}=$s(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=Ptt(t);if(console.log("[LeadPondView] render — teamId:",t,"itemCount:",r.length,"loading:",n),n)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(d=>e.jsx(Ss,{className:"h-20 w-full"},d))});if(r.length===0)return e.jsx(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Lg,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Lead Pond is Empty"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Team members can contribute contacts here for others to claim and follow up with."})]})});const l=r.filter(d=>d.status==="available"),i=r.filter(d=>d.status==="claimed");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Available (",l.length,")"]}),l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No leads available right now."}):e.jsx("div",{className:"space-y-2",children:l.map(d=>{var u,p,f,y,_,b,N;return e.jsx(Ie,{children:e.jsxs(Be,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=d.contact)==null?void 0:u.first_name," ",((p=d.contact)==null?void 0:p.last_name)||""]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 mt-1",children:[((f=d.contact)==null?void 0:f.email)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(tr,{className:"h-3 w-3"})," ",d.contact.email]}),((y=d.contact)==null?void 0:y.phone)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"})," ",d.contact.phone]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs(vn,{className:"h-4 w-4",children:[e.jsx(Ca,{src:((_=d.contributor)==null?void 0:_.avatar_url)||""}),e.jsx(_n,{className:"text-[8px]",children:(((b=d.contributor)==null?void 0:b.name)||"?").charAt(0)})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["from ",((N=d.contributor)==null?void 0:N.name)||"Unknown"]})]})]}),e.jsxs(K,{size:"sm",onClick:()=>a.mutate(d.id),disabled:a.isPending,children:[e.jsx(xL,{className:"mr-1 h-3 w-3"}),"Claim"]})]})},d.id)})})]}),i.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Claimed (",i.length,")"]}),e.jsx("div",{className:"space-y-2",children:i.map(d=>{var u,p,f;return e.jsx(Ie,{className:"opacity-75",children:e.jsxs(Be,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=d.contact)==null?void 0:u.first_name," ",((p=d.contact)==null?void 0:p.last_name)||""]}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:["Claimed by ",((f=d.claimer)==null?void 0:f.name)||"Unknown"]})})]}),d.claimed_by===(s==null?void 0:s.id)&&e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>o.mutate(d.id),disabled:o.isPending,children:[e.jsx(e0,{className:"mr-1 h-3 w-3"}),"Return"]})]})},d.id)})})]})]})},Ltt=({teamId:t})=>{const{useTeamMembers:s}=TC(),{data:r=[]}=s(t),n=r.map(_=>_.user_id),a=new Map(r.map(_=>[_.user_id,_.profile])),{data:o=[],isLoading:l}=ft({queryKey:["team-shared-presentations",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.from("smart_presentations").select("id, owner_user_id, title, client_name, status, view_count, cta_clicked_count, share_token, created_at, published_at").in("owner_user_id",n).neq("status","archived").order("created_at",{ascending:!1});if(b)throw b;return _||[]},enabled:n.length>0}),{data:i=[],isLoading:d}=ft({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}=ft({queryKey:["team-shared-videos",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.from("agent_videos").select("id, owner_user_id, title, recipient_name, status, view_count, touch_type, share_token, created_at").in("owner_user_id",n).eq("is_deleted",!1).order("created_at",{ascending:!1}).limit(50);if(b)throw b;return _||[]},enabled:n.length>0});if(l||d||p)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(_=>e.jsx(Ss,{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(Ie,{children:e.jsxs(Be,{className:"flex items-center gap-3 p-4",children:[e.jsx(Rg,{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(Ie,{children:e.jsxs(Be,{className:"flex items-center gap-3 p-4",children:[e.jsx(Mn,{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(Ie,{children:e.jsxs(Be,{className:"flex items-center gap-3 p-4",children:[e.jsx(hn,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:u.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]}),e.jsxs(ta,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(Qn,{children:[e.jsxs(ls,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(ls,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(ls,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx(js,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(Cye,{icon:e.jsx(Rg,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(_=>{const b=y(_.owner_user_id);return e.jsx(Ie,{children:e.jsxs(Be,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(vn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ca,{src:b.avatar}),e.jsx(_n,{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," · ",gs(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(Ye,{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(jn,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})}),e.jsx(js,{value:"guest-books",className:"space-y-2",children:i.length===0?e.jsx(Cye,{icon:e.jsx(Mn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(_=>{const b=y(_.agent_id);return e.jsx(Ie,{children:e.jsxs(Be,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(vn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ca,{src:b.avatar}),e.jsx(_n,{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," · ",gs(new Date(_.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[_.is_active?e.jsx(Ye,{className:"text-xs",children:"Active"}):e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(cr,{className:"h-3 w-3"}),_.visitor_count||0]})]})]})},_.id)})}),e.jsx(js,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(Cye,{icon:e.jsx(hn,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(_=>{const b=y(_.owner_user_id);return e.jsx(Ie,{children:e.jsxs(Be,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(vn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ca,{src:b.avatar}),e.jsx(_n,{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," · ",gs(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(Ye,{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(jn,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})})]})]})},Cye=({icon:t,label:s})=>e.jsx(Ie,{children:e.jsxs(Be,{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})]})}),Dtt=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:d,isAddingMember:u})=>{var U,q;const{useTeamMembers:p}=TC(),{data:f=[],isLoading:y}=p(t.id),[_,b]=k.useState(!1),[N,w]=k.useState(""),[S,C]=k.useState("team_member"),{data:A}=ft({queryKey:["agents-on-other-teams",t.id],queryFn:async()=>{const{data:$}=await G.from("team_members").select("user_id, team_id, teams:team_id(name)").neq("team_id",t.id),V=new Map;return($||[]).forEach(ee=>{var Z;V.set(ee.user_id,((Z=ee.teams)==null?void 0:Z.name)||"another team")}),V}}),I=new Set(f.map($=>$.user_id)),L=s.filter($=>!I.has($.id)),O=async()=>{N&&(await a(N,S),w(""),C("team_member"),b(!1))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(K,{variant:"ghost",onClick:r,className:"mb-2",children:"← Back to Teams"}),e.jsxs(ta,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"members",children:"Members"}),e.jsxs(ls,{value:"contacts",children:[e.jsx(eS,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(ls,{value:"lead-pond",children:[e.jsx(Lg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(ls,{value:"shared-assets",children:[e.jsx(Sm,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(ls,{value:"settings",children:"Settings"})]}),e.jsxs(js,{value:"members",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold",children:[t.name," — Members"]}),e.jsxs(fs,{open:_,onOpenChange:b,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(il,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Add Team Member"}),e.jsxs(Rr,{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(ge,{children:"Agent"}),e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[N&&(((U=L.find($=>$.id===N))==null?void 0:U.name)||((q=L.find($=>$.id===N))==null?void 0:q.email))||"Select an agent",e.jsx(wx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(uo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Ax,{children:[e.jsx(Ex,{placeholder:"Search agents..."}),e.jsxs(Px,{children:[e.jsx(Ix,{children:"No agents found."}),e.jsx(Lx,{children:L.map($=>{const V=A==null?void 0:A.get($.id);return e.jsxs(op,{value:$.name||$.email||$.id,disabled:!!V,onSelect:()=>w($.id),children:[e.jsx(ea,{className:Rt("mr-2 h-4 w-4",N===$.id?"opacity-100":"opacity-0")}),$.name||$.email,V&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",V,")"]})]},$.id)})})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Role"}),e.jsxs(zs,{value:S,onValueChange:C,children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"team_leader",children:"Team Leader"}),e.jsx(yt,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{onClick:O,disabled:!N||u,children:u?"Adding...":"Add to Team"})]})]})]})]}),y?e.jsx("div",{className:"space-y-3",children:[1,2,3].map($=>e.jsx(Ss,{className:"h-16 w-full"},$))}):f.length===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(cr,{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($=>{var V,ee,Z,J,Y;return e.jsx(Ie,{children:e.jsxs(Be,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(vn,{className:"h-10 w-10",children:[e.jsx(Ca,{src:((V=$.profile)==null?void 0:V.avatar_url)||""}),e.jsx(_n,{children:(((ee=$.profile)==null?void 0:ee.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Z=$.profile)==null?void 0:Z.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(J=$.profile)==null?void 0:J.email})]}),$.role==="team_leader"?e.jsxs(Ye,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(km,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(Ye,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(zs,{value:$.role,onValueChange:ce=>l($.id,ce),children:[e.jsx(Os,{className:"w-[140px]",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"team_leader",children:"Team Leader"}),e.jsx(yt,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(HL,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Remove Member?"}),e.jsxs(vl,{children:["Remove ",((Y=$.profile)==null?void 0:Y.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:()=>o($.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},$.id)})})]}),e.jsx(js,{value:"contacts",className:"space-y-4",children:e.jsx(k4e,{})}),t.lead_pond_enabled&&e.jsx(js,{value:"lead-pond",className:"space-y-4",children:e.jsx(S4e,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(js,{value:"shared-assets",className:"space-y-4",children:e.jsx(Ltt,{teamId:t.id})}),e.jsxs(js,{value:"settings",className:"space-y-4",children:[e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{className:"text-lg",children:"Team Settings"}),e.jsx(mr,{children:"Configure how this team operates."})]}),e.jsxs(Be,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Team Name"}),e.jsx(Fe,{defaultValue:t.name,onBlur:$=>{$.target.value!==t.name&&n({name:$.target.value})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Description"}),e.jsx(_r,{defaultValue:t.description||"",onBlur:$=>{$.target.value!==(t.description||"")&&n({description:$.target.value||null})},rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Contact Visibility"}),e.jsxs(zs,{defaultValue:t.contact_visibility,onValueChange:$=>n({contact_visibility:$}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"private",children:"Private — Members keep their contacts private"}),e.jsx(yt,{value:"leader_only",children:"Leader Only — Only team leaders can see member contacts"}),e.jsx(yt,{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(ge,{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(Lr,{checked:t.lead_pond_enabled,onCheckedChange:$=>n({lead_pond_enabled:$})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ge,{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(Lr,{checked:t.shared_assets_enabled,onCheckedChange:$=>n({shared_assets_enabled:$})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ge,{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(Lr,{checked:t.shared_videos_enabled??!1,onCheckedChange:$=>n({shared_videos_enabled:$})})]})]})]}),e.jsxs(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsxs(K,{variant:"destructive",size:"sm",children:[e.jsx(yr,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Delete Team?"}),e.jsxs(vl,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},Rtt=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[d,u]=k.useState(1),[p,f]=k.useState(""),[y,_]=k.useState(""),[b,N]=k.useState(""),[w,S]=k.useState(""),[C,A]=k.useState([]),I=()=>{u(1),f(""),_(""),N(""),S(""),A([])},L=$=>{$||I(),s($)},O=async()=>{const $=b&&b!=="none"?b:i||null;await r({name:p.trim(),description:y.trim()||void 0,brokerage_id:$,leaderId:w||void 0,memberIds:C.length>0?C:void 0}),I()},U=$=>{$!==w&&A(V=>V.includes($)?V.filter(ee=>ee!==$):[...V,$])},q=a.filter($=>$.id!==w);return e.jsx(fs,{open:t,onOpenChange:L,children:e.jsxs(ms,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:d===1?"Create New Team":"Assign Team Members"}),e.jsx(Rr,{children:d===1?"Name your team and add a description.":"Pick a leader and optionally add initial members."}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("div",{className:Rt("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:Rt("h-1.5 flex-1 rounded-full transition-colors",d===2?"bg-primary":"bg-muted")})]})]}),e.jsx("div",{className:"overflow-y-auto flex-1 pr-1",children:d===1?e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"team-name",children:"Team Name *"}),e.jsx(Fe,{id:"team-name",value:p,onChange:$=>f($.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"team-desc",children:"Description"}),e.jsx(_r,{id:"team-desc",value:y,onChange:$=>_($.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(ge,{children:"Brokerage"}),e.jsxs(zs,{value:b,onValueChange:N,children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"No brokerage (independent team)"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"No brokerage (independent)"}),l.map($=>e.jsx(yt,{value:$.id,children:$.name},$.id))]})]})]})]}):e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ge,{className:"flex items-center gap-1.5",children:[e.jsx(km,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(zs,{value:w,onValueChange:$=>{S($),A(V=>V.filter(ee=>ee!==$))},children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select a team leader (optional)"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"No leader for now"}),a.map($=>e.jsx(yt,{value:$.id,children:$.name||$.email||"Unknown"},$.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ge,{className:"flex items-center gap-1.5",children:[e.jsx(il,{className:"h-3.5 w-3.5"}),"Initial Members",C.length>0&&e.jsxs(Ye,{variant:"secondary",className:"ml-1 text-xs",children:[C.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click agents to add them. You can always add more later."}),e.jsx("div",{className:"border rounded-lg max-h-[240px] overflow-y-auto divide-y",children:q.length===0?e.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:[e.jsx(cr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):q.map($=>{const V=C.includes($.id);return e.jsxs("button",{type:"button",className:Rt("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(vn,{className:"h-8 w-8",children:[e.jsx(Ca,{src:$.avatar_url||""}),e.jsx(_n,{className:"text-xs",children:($.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:$.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:$.email})]}),e.jsx("div",{className:Rt("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(ea,{className:"h-3 w-3"})})]},$.id)})})]})]})}),e.jsx(gn,{className:"gap-2 sm:gap-0",children:d===1?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>u(2),disabled:!p.trim(),children:["Next",e.jsx(ti,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>u(1),children:[e.jsx(Ra,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(K,{onClick:O,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},zHt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=TC(),[d,u]=k.useState(!1),[p,f]=k.useState(null),[y,_]=k.useState(""),{data:b}=ft({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:L,error:O}=await G.from("brokerages").select("id, name").order("name");if(O)throw O;return L||[]}}),{data:N}=ft({queryKey:["admin-team-member-info",t.map(L=>L.id).join(",")],queryFn:async()=>{var $;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 O=L.filter(V=>V.role==="team_leader").map(V=>V.user_id);let U={};if(O.length>0){const{data:V}=await G.from("profiles").select("id, name").in("id",O);V&&(U=Object.fromEntries(V.map(ee=>[ee.id,{name:ee.name}])))}const q={};for(const V of t){const ee=L.filter(J=>J.team_id===V.id),Z=ee.find(J=>J.role==="team_leader");q[V.id]={count:ee.length,leaderName:Z&&(($=U[Z.user_id])==null?void 0:$.name)||null}}return q},enabled:t.length>0}),w=(p==null?void 0:p.brokerage_id)||null,{data:S}=ft({queryKey:["brokerage-agents-for-teams",w],queryFn:async()=>{let L=G.from("profiles").select("id, name, email, avatar_url").order("name");w&&(L=L.eq("brokerage_id",w));const{data:O,error:U}=await L;if(U)throw U;return O||[]},enabled:!!p}),C=Object.fromEntries((b||[]).map(L=>[L.id,L.name])),A=async L=>{const O=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:O.id,user_id:L.leaderId,role:"team_leader"}),L.memberIds)for(const U of L.memberIds)await o.mutateAsync({team_id:O.id,user_id:U,role:"team_member"});u(!1)};if(p)return e.jsx(Dtt,{team:p,brokerageAgents:S||[],onBack:()=>f(null),onUpdate:L=>n.mutateAsync({id:p.id,...L}).then(O=>f(O)),onAddMember:(L,O)=>o.mutateAsync({team_id:p.id,user_id:L,role:O}),onRemoveMember:L=>l.mutateAsync({team_id:p.id,member_id:L}),onUpdateRole:(L,O)=>i.mutateAsync({team_id:p.id,member_id:L,role:O}),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(tn,{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(Bs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(Rtt,{open:d,onOpenChange:u,onCreateTeam:A,isCreating:r.isPending,brokerageAgents:[],isAdmin:!0,allBrokerages:b,activeBrokerageId:null}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(Nt,{className:"font-semibold",children:"Team Name"}),e.jsx(Nt,{className:"font-semibold",children:"Brokerage"}),e.jsx(Nt,{className:"font-semibold",children:"Leader"}),e.jsx(Nt,{className:"font-semibold",children:"Members"}),e.jsx(Nt,{className:"font-semibold",children:"Visibility"}),e.jsx(Nt,{className:"w-[100px]"})]})}),e.jsx(Pn,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(L=>e.jsxs(As,{children:[e.jsx(dt,{children:e.jsx(Ss,{className:"h-4 w-32"})}),e.jsx(dt,{children:e.jsx(Ss,{className:"h-4 w-24"})}),e.jsx(dt,{children:e.jsx(Ss,{className:"h-4 w-28"})}),e.jsx(dt,{children:e.jsx(Ss,{className:"h-4 w-12"})}),e.jsx(dt,{children:e.jsx(Ss,{className:"h-4 w-20"})}),e.jsx(dt,{children:e.jsx(Ss,{className:"h-4 w-16"})})]},L))}):I.length===0?e.jsx(As,{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 O=N==null?void 0:N[L.id];return e.jsxs(As,{className:"hover:bg-muted/30",children:[e.jsxs(dt,{children:[e.jsx("button",{onClick:()=>f(L),className:"text-primary hover:underline font-medium",children:L.name}),L.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:L.description})]}),e.jsx(dt,{children:L.brokerage_id?e.jsx("span",{className:"text-sm",children:C[L.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(dt,{children:O!=null&&O.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(km,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),O.leaderName]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No leader"})}),e.jsx(dt,{children:e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:[e.jsx(cr,{className:"h-3 w-3 mr-1"}),(O==null?void 0:O.count)??0]})}),e.jsx(dt,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(Ru,{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(pa,{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(yr,{className:"h-3.5 w-3.5"})})]})})]},L.id)})})]})})]})},BHt=()=>{const t=br(),{user:s,isAdmin:r}=$s(),{startImpersonation:n,isLoading:a}=fue(),{toast:o}=va(),[l,i]=k.useState([]),[d,u]=k.useState([]),[p,f]=k.useState([]),[y,_]=k.useState({}),[b,N]=k.useState(!0),[w,S]=k.useState({}),[C,A]=k.useState(!1),[I,L]=k.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[O,U]=k.useState(!1),[q,$]=k.useState(""),[V,ee]=k.useState(1),[Z,J]=k.useState(50),[Y,ce]=k.useState("all"),[ae,ie]=k.useState("all"),[le,fe]=k.useState("all"),[xe,he]=k.useState("all"),[we,Ne]=k.useState(!1),[Ve,Te]=k.useState(!1),[Ae,ze]=k.useState(null),[Ee,ve]=k.useState(null),[Re,Ue]=k.useState(!1),[ye,ct]=k.useState({name:"",email:"",brokerage_id:"",phone:""}),[pe,Ge]=k.useState(null),[tt,st]=k.useState(!1),[Ce,et]=k.useState(""),[Ct,Ot]=k.useState(!1),[ut,Oe]=k.useState(!1),[Xe,at]=k.useState(null),[Ke,He]=k.useState(""),[gt,Mt]=k.useState(!1),[Wt,xs]=k.useState(!1),[Cs,Us]=k.useState(null),[Ar,Bt]=k.useState(!1),[Xs,Nr]=k.useState(!1),[Vs,ar]=k.useState(null),[Or,Rn]=k.useState(""),[bn,ir]=k.useState(!1),[or,hr]=k.useState({email:"",name:"",password:"",phone:""}),[an,Gr]=k.useState(!1),[Va,$a]=k.useState(!1),[Xt,Qa]=k.useState(""),[Cr,Fn]=k.useState(!1),[Kt,Mr]=k.useState(!1),[On,ua]=k.useState(""),[$t,Se]=k.useState(new Set),[De,Ze]=k.useState(!1),[xt,_t]=k.useState(!1),[Pt,Yt]=k.useState(null),[Vt,Qt]=k.useState(!1),[Es,ys]=k.useState(null),[lr,Fr]=k.useState([]),[Br,zr]=k.useState([]),[un,Vn]=k.useState(!1),[Zn,vi]=k.useState({});k.useEffect(()=>{!s||!r||(Ha(),no())},[s,r]);const To=async()=>{try{const{data:jt,error:Ps}=await G.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(Ps)throw Ps;const nr={};for(const Yr of jt??[])nr[Yr.brokerage_id]||(nr[Yr.brokerage_id]=[]),nr[Yr.brokerage_id].push(Yr.user_id);_(nr)}catch(jt){console.error("Error loading brokerage manager assignments:",jt)}},Ha=async()=>{try{N(!0);const{data:jt,error:Ps}=await G.functions.invoke("get-user-details");if(Ps)throw Ps;const nr=jt.users||[];i(nr),f(jt.brokerages||[]),await To();const Yr=nr.filter(pn=>pn.roles.includes("assistant"));if(Yr.length>0){const pn=Yr.map(Bn=>Bn.id),{data:Na}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",pn);if(Na&&Na.length>0){const Bn=[...new Set(Na.map(zm=>zm.agent_id))],{data:Ri}=await G.from("profiles").select("id, name, email").in("id",Bn),Mp={};for(const zm of Na){const la=Ri==null?void 0:Ri.find(R0=>R0.id===zm.agent_id);la&&(Mp[zm.assistant_id]={agent_name:la.name||"",agent_email:la.email||""})}vi(Mp)}}}catch(jt){console.error("Error loading members:",jt),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{N(!1)}},no=async()=>{try{const{data:jt,error:Ps}=await G.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(Ps)throw Ps;u(jt||[])}catch(jt){console.error("Error loading apps:",jt),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},ai=async jt=>{if(!ye.name.trim()||!ye.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(ye.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:nr}=await G.from("profiles").update({name:ye.name.trim(),email:ye.email.trim(),brokerage_id:ye.brokerage_id||null,phone:ye.phone.trim()||null}).eq("id",jt);if(nr)throw nr;o({title:"Success",description:"Member details updated successfully"}),ze(null),Ha()}catch(nr){console.error("Error updating member:",nr),o({title:"Error",description:nr.message||"Failed to update member",variant:"destructive"})}},zi=async jt=>{try{const{data:{session:Ps}}=await G.auth.getSession(),nr=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ps==null?void 0:Ps.access_token}`},body:JSON.stringify({userId:jt})}),Yr=await nr.json();if(!nr.ok)throw new Error(Yr.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(Ps){console.error("Error resending welcome email:",Ps),o({title:"Error",description:Ps.message||"Failed to resend welcome email",variant:"destructive"})}},Qo=async(jt,Ps)=>{try{const{error:nr}=await G.functions.invoke("send-password-reset",{body:{email:jt,redirectTo:window.location.origin}});if(nr)throw nr;o({title:"Password Reset Sent",description:`Password reset email sent to ${Ps}`})}catch(nr){console.error("Error sending password reset:",nr),o({title:"Error",description:nr.message||"Failed to send password reset email",variant:"destructive"})}},fi=async(jt,Ps)=>{if(confirm(`Are you sure you want to delete ${Ps}? This action cannot be undone.`))try{const{data:{session:nr}}=await G.auth.getSession(),Yr=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${nr==null?void 0:nr.access_token}`},body:JSON.stringify({userId:jt})}),pn=await Yr.json();if(!Yr.ok)throw new Error(pn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),Ha()}catch(nr){console.error("Error deleting user:",nr),o({title:"Error",description:nr.message||"Failed to delete user",variant:"destructive"})}},Ki=async()=>{if(!I.email||!I.name||!I.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}if(I.role==="brokerage_manager"&&!I.brokerage_id){o({title:"Error",description:"Please select a brokerage for this manager",variant:"destructive"});return}A(!0);try{const{data:{session:jt}}=await G.auth.getSession(),Ps=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${jt==null?void 0:jt.access_token}`},body:JSON.stringify(I)}),nr=await Ps.json();if(!Ps.ok)throw new Error(nr.error||"Failed to create user");if(I.role&&I.role!=="user"&&nr.userId){const Yr=I.role==="brokerage_manager"?I.brokerage_id:void 0;await Bi(nr.userId,I.role,"add",Yr)}o({title:"Success",description:`User ${I.email} created successfully`}),L({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),U(!1),Ha()}catch(jt){console.error("Error creating user:",jt),o({title:"Error",description:jt.message||"Failed to create user",variant:"destructive"})}finally{A(!1)}},Bi=async(jt,Ps,nr,Yr)=>{try{const{data:{session:pn}}=await G.auth.getSession(),Na={userId:jt,role:Ps,action:nr};if(Ps==="brokerage_manager"){if(!Yr){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}Na.brokerageId=Yr}const Bn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${pn==null?void 0:pn.access_token}`},body:JSON.stringify(Na)}),Ri=await Bn.json();if(!Bn.ok)throw new Error(Ri.error||"Failed to manage user role");o({title:"Success",description:`Role ${nr==="add"?"added":"removed"} successfully`}),Ha()}catch(pn){console.error("Error managing user role:",pn),o({title:"Error",description:pn.message||"Failed to manage user role",variant:"destructive"})}},oa=(jt,Ps)=>Ps.length===0?!0:Ps.some(nr=>jt.includes(nr)),Jo=async(jt,Ps,nr)=>{const Yr=`${jt}-${Ps.id}`;Ge(Yr);try{if(nr){const pn=l.find(Bn=>Bn.id===jt),Na=Ps.required_tags.filter(Bn=>pn==null?void 0:pn.tags.includes(Bn));for(const Bn of Na){const{error:Ri}=await G.from("user_tags").delete().eq("user_id",jt).eq("tag",Bn);if(Ri)throw Ri}o({title:"Access Removed",description:`Removed access to ${Ps.name}`})}else if(Ps.required_tags.length>0){const{error:pn}=await G.from("user_tags").insert({user_id:jt,tag:Ps.required_tags[0]});if(pn)throw pn;o({title:"Access Granted",description:`Granted access to ${Ps.name}`})}await Ha()}catch(pn){console.error("Error toggling access:",pn),o({title:"Error",description:pn.message||"Failed to update access",variant:"destructive"})}finally{Ge(null)}},Cc=async()=>{const jt=Ce.trim();if(!jt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(jt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(p.find(nr=>nr.name.toLowerCase()===jt.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}Ot(!0);try{const{error:nr}=await G.from("brokerages").insert({name:jt});if(nr)throw nr;o({title:"Success",description:`Brokerage "${jt}" created successfully`}),et(""),st(!1),Ha()}catch(nr){console.error("Error creating brokerage:",nr),o({title:"Error",description:nr.message||"Failed to create brokerage",variant:"destructive"})}finally{Ot(!1)}},Bl=jt=>{at(jt),He(jt.name),Oe(!0)},Hd=()=>{at(null),He(""),Oe(!1)},vu=async()=>{if(!Xe)return;const jt=Ke.trim();if(!jt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(jt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}Mt(!0);try{const{error:Ps}=await G.from("brokerages").update({name:jt}).eq("id",Xe.id);if(Ps)throw Ps;o({title:"Success",description:"Brokerage updated successfully"}),Hd(),Ha()}catch(Ps){console.error("Error updating brokerage:",Ps),o({title:"Error",description:Ps.message||"Failed to update brokerage",variant:"destructive"})}finally{Mt(!1)}},Rm=async(jt,Ps)=>{var nr;if(!Ps||typeof Ps!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const Yr={userId:jt,role:"brokerage_manager",action:"add",brokerageId:Ps};console.debug("[assignManagerToBrokerage] payload",Yr);const{data:{session:pn}}=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 ${pn==null?void 0:pn.access_token}`},body:JSON.stringify(Yr)}),Bn=await Na.json();if(!Na.ok&&!((nr=Bn.error)!=null&&nr.includes("duplicate")))throw new Error(Bn.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await Ha()}catch(Yr){console.error("Error assigning manager:",Yr),o({title:"Error",description:Yr.message||"Failed to assign manager",variant:"destructive"})}},Nd=jt=>{Us(jt),xs(!0)},_u=async()=>{if(Cs){Bt(!0);try{const jt=l.filter(Yr=>Yr.brokerage_id===Cs.id),{data:{session:Ps}}=await G.auth.getSession();for(const Yr of jt){const pn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ps==null?void 0:Ps.access_token}`},body:JSON.stringify({userId:Yr.id})});if(!pn.ok){const Na=await pn.json();console.error(`Failed to delete user ${Yr.email}:`,Na.error)}}const{error:nr}=await G.from("brokerages").delete().eq("id",Cs.id);if(nr)throw nr;o({title:"Success",description:`Brokerage "${Cs.name}" and ${jt.length} member(s) deleted`}),xs(!1),Us(null),Ha()}catch(jt){console.error("Error deleting brokerage:",jt),o({title:"Error",description:jt.message||"Failed to delete brokerage",variant:"destructive"})}finally{Bt(!1)}}},Om=jt=>{ar(jt),Rn(""),Nr(!0)},Vu=()=>{ar(null),Rn(""),Nr(!1)},Fm=async jt=>{try{const{error:Ps}=await G.from("profiles").update({brokerage_id:null}).eq("id",jt);if(Ps)throw Ps;o({title:"Success",description:"User removed from brokerage"}),Ha()}catch(Ps){console.error("Error removing user from brokerage:",Ps),o({title:"Error",description:Ps.message||"Failed to remove user",variant:"destructive"})}},xh=async(jt,Ps)=>{try{const{error:nr}=await G.from("profiles").update({brokerage_id:Ps}).eq("id",jt);if(nr)throw nr;o({title:"Success",description:"User added to brokerage"}),Ha()}catch(nr){console.error("Error adding user to brokerage:",nr),o({title:"Error",description:nr.message||"Failed to add user",variant:"destructive"})}},Gd=async()=>{if(!Vs||!or.email||!or.name||!or.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Gr(!0);try{const{data:{session:jt}}=await G.auth.getSession(),Ps=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${jt==null?void 0:jt.access_token}`},body:JSON.stringify({...or,brokerage_id:Vs.id,role:"user"})}),nr=await Ps.json();if(!Ps.ok)throw new Error(nr.error||"Failed to create agent");o({title:"Success",description:`Agent ${or.email} created successfully`}),hr({email:"",name:"",password:"",phone:""}),ir(!1),Ha()}catch(jt){console.error("Error creating agent:",jt),o({title:"Error",description:jt.message||"Failed to create agent",variant:"destructive"})}finally{Gr(!1)}},jp=jt=>l.filter(Ps=>Ps.brokerage_id===jt),P1=jt=>{const Ps=jp(jt);if(!Or)return Ps;const nr=Or.toLowerCase();return Ps.filter(Yr=>Yr.name.toLowerCase().includes(nr)||Yr.email.toLowerCase().includes(nr))},Ux=jt=>l.filter(Ps=>Ps.brokerage_id!==jt),I1=l.filter(jt=>{var nr;if(q){const Yr=q.toLowerCase();if(!(jt.name.toLowerCase().includes(Yr)||jt.email.toLowerCase().includes(Yr)||((nr=jt.brokerage_name)==null?void 0:nr.toLowerCase().includes(Yr))))return!1}if(Y==="claimed"&&!jt.claimed||Y==="unclaimed"&&jt.claimed||ae!=="all"&&!jt.roles.includes(ae))return!1;const Ps=jt.is_trial||jt.subscription_status==="trialing";return!(le==="trial"&&!Ps||le==="non-trial"&&Ps||xe==="none"&&jt.brokerage_id||xe!=="all"&&xe!=="none"&&jt.brokerage_id!==xe)}),{sortKey:Np,sortDirection:Ef,handleSort:Wd,sortData:FC}=rO("created_at","desc"),P0=FC(I1,{name:jt=>{var Ps;return((Ps=jt.name)==null?void 0:Ps.toLowerCase())||""},brokerage:jt=>{var Ps;return((Ps=jt.brokerage_name)==null?void 0:Ps.toLowerCase())||""},status:jt=>jt.claimed?"active":"pending",role:jt=>jt.roles[0]||"",last_login:jt=>jt.last_sign_in_at?new Date(jt.last_sign_in_at).getTime():null,created_at:jt=>jt.created_at?new Date(jt.created_at).getTime():null}),kp=P0.length,Vx=Z===0,nc=Vx?1:Math.ceil(kp/Z),Sp=Vx?0:(V-1)*Z,I0=Vx?kp:Sp+Z,$l=P0.slice(Sp,I0),Iw=jt=>{$(jt),ee(1)},ty=jt=>{J(jt),ee(1)},Pf=(jt,Ps)=>{jt(Ps),ee(1)},L0=async(jt,Ps)=>{Ne(!0);try{const nr=l.find(Bn=>Bn.id===jt);if(!nr)return;const Yr=nr.trial_expires_at?new Date(nr.trial_expires_at):new Date,pn=new Date(Yr.getTime()+Ps*24*60*60*1e3),{error:Na}=await G.from("profiles").update({trial_expires_at:pn.toISOString()}).eq("id",jt);if(Na)throw Na;o({title:"Trial Extended",description:`Trial extended by ${Ps} days`}),Ha()}catch(nr){console.error("Error extending trial:",nr),o({title:"Error",description:nr.message||"Failed to extend trial",variant:"destructive"})}finally{Ne(!1)}},Lw=async jt=>{Te(!0);try{const{error:Ps}=await G.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",jt);if(Ps)throw Ps;o({title:"Account Converted",description:"User has been converted to a full account"}),Ha(),If()}catch(Ps){console.error("Error converting trial:",Ps),o({title:"Error",description:Ps.message||"Failed to convert account",variant:"destructive"})}finally{Te(!1)}},Pa=async jt=>{Vn(!0);try{const{data:Ps}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",jt);if(Ps&&Ps.length>0){const Yr=Ps.map(Na=>Na.assistant_id),{data:pn}=await G.from("profiles").select("id, name, email").in("id",Yr);Fr(Ps.map(Na=>{const Bn=pn==null?void 0:pn.find(Ri=>Ri.id===Na.assistant_id);return{id:Na.id,assistant_id:Na.assistant_id,assistant_name:(Bn==null?void 0:Bn.name)||"Unknown",assistant_email:(Bn==null?void 0:Bn.email)||"",permissions:Na.permissions||{}}}))}else Fr([]);const{data:nr}=await G.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",jt);if(nr&&nr.length>0){const Yr=nr.map(Na=>Na.agent_id),{data:pn}=await G.from("profiles").select("id, name, email").in("id",Yr);zr(nr.map(Na=>{const Bn=pn==null?void 0:pn.find(Ri=>Ri.id===Na.agent_id);return{id:Na.id,agent_id:Na.agent_id,agent_name:(Bn==null?void 0:Bn.name)||"Unknown",agent_email:(Bn==null?void 0:Bn.email)||"",permissions:Na.permissions||{}}}))}else zr([])}catch(Ps){console.error("Error loading assistant data:",Ps)}finally{Vn(!1)}},Hx=jt=>{ve(jt),ct({name:jt.name,email:jt.email,brokerage_id:jt.brokerage_id||"",phone:jt.phone||""}),Ue(!0),Pa(jt.id)},If=()=>{ve(null),Ue(!1),ct({name:"",email:"",brokerage_id:"",phone:""})},OE=async()=>{Ee&&(await ai(Ee.id),If())},L1=jt=>{Se(Ps=>{const nr=new Set(Ps);return nr.has(jt)?nr.delete(jt):nr.add(jt),nr})},Lf=()=>{if($t.size===$l.length&&$l.every(jt=>$t.has(jt.id))){const jt=new Set($t);$l.forEach(Ps=>jt.delete(Ps.id)),Se(jt)}else{const jt=new Set($t);$l.forEach(Ps=>jt.add(Ps.id)),Se(jt)}},Cp=()=>{Se(new Set)},D0=async()=>{if($t.size===0)return;Ze(!0);let jt=0,Ps=0;try{const{data:{session:nr}}=await G.auth.getSession();for(const Yr of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${nr==null?void 0:nr.access_token}`},body:JSON.stringify({userId:Yr})})).ok?jt++:Ps++}catch{Ps++}o({title:"Bulk Email Complete",description:`Sent ${jt} emails${Ps>0?`, ${Ps} failed`:""}`}),Cp()}catch(nr){o({title:"Error",description:nr.message||"Failed to send emails",variant:"destructive"})}finally{Ze(!1)}},D1=async()=>{if($t.size===0)return;Ze(!0);let jt=0,Ps=0;try{const{data:{session:nr}}=await G.auth.getSession();for(const Yr of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${nr==null?void 0:nr.access_token}`},body:JSON.stringify({userId:Yr})})).ok?jt++:Ps++}catch{Ps++}o({title:"Bulk Password Reset Complete",description:`Sent ${jt} reset emails${Ps>0?`, ${Ps} failed`:""}`}),Cp()}catch(nr){o({title:"Error",description:nr.message||"Failed to send password reset emails",variant:"destructive"})}finally{Ze(!1)}},zC=async()=>{if($t.size===0)return;const jt=l.filter(pn=>$t.has(pn.id)).map(pn=>pn.name).slice(0,5).join(", "),Ps=$t.size>5?` and ${$t.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${$t.size} users (${jt}${Ps})? This action cannot be undone.`))return;Ze(!0);let nr=0,Yr=0;try{const{data:{session:pn}}=await G.auth.getSession();for(const Na of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${pn==null?void 0:pn.access_token}`},body:JSON.stringify({userId:Na})})).ok?nr++:Yr++}catch{Yr++}o({title:"Bulk Delete Complete",description:`Deleted ${nr} users${Yr>0?`, ${Yr} failed`:""}`}),Cp(),Ha()}catch(pn){o({title:"Error",description:pn.message||"Failed to delete users",variant:"destructive"})}finally{Ze(!1)}},Gx=async()=>{_t(!0);try{const{data:{session:jt}}=await G.auth.getSession(),Ps=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${jt==null?void 0:jt.access_token}`}});if(!Ps.ok){const Yr=await Ps.json();throw new Error(Yr.error||"Failed to sync phones")}const nr=await Ps.json();o({title:"Phone Sync Complete",description:`Pulled ${nr.summary.pulledFromGHL} from GHL, pushed ${nr.summary.pushedToGHL} to GHL, ${nr.summary.alreadySynced} already synced`}),Ha()}catch(jt){o({title:"Error",description:jt.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{_t(!1)}},BC=async(jt,Ps)=>{Yt(jt);try{const{data:{session:nr}}=await G.auth.getSession(),{data:Yr}=await G.from("profiles").select("phone").eq("id",jt).single(),pn=(Yr==null?void 0:Yr.phone)||"",Na=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${nr==null?void 0:nr.access_token}`},body:JSON.stringify({email:Ps,action:"update",phone:pn||void 0})});if(!Na.ok){const Ri=await Na.json();throw new Error(Ri.error||"Failed to sync with GHL")}const Bn=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(Ps)}`,{method:"GET",headers:{"Content-Type":"application/json"}});o({title:"Phone Synced",description:pn?`Phone ${pn} synced to GHL`:"Sync attempted - run bulk sync to pull phone from GHL"}),Ha()}catch(nr){o({title:"Error",description:nr.message||"Failed to sync phone",variant:"destructive"})}finally{Yt(null)}},R1=async jt=>{await n(jt)},FE=()=>{if($t.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const jt=l.filter(Ri=>$t.has(Ri.id)),Ps=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],nr=jt.map(Ri=>[Ri.name,Ri.email,Ri.phone||"",Ri.brokerage_name||"",Ri.roles.join("; "),Ri.claimed?"Claimed":"Unclaimed",new Date(Ri.created_at).toLocaleDateString()]),Yr=[Ps.join(","),...nr.map(Ri=>Ri.map(Mp=>`"${(Mp||"").replace(/"/g,'""')}"`).join(","))].join(` `),pn=new Blob([Yr],{type:"text/csv"}),Na=URL.createObjectURL(pn),Bn=document.createElement("a");Bn.href=Na,Bn.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,Bn.click(),URL.revokeObjectURL(Na),o({title:"Export complete",description:`Exported ${jt.length} member(s)`})};return b?e.jsx(Ls,{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(Ls,{title:"Members",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{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:Gx,disabled:xt,children:[xt?e.jsx(ps,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Tn,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:xt?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:xt?"Syncing...":"Sync GHL"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>$a(!0),children:[e.jsx(Zv,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Import CSV"}),e.jsx("span",{className:"sm:hidden",children:"Import"})]}),e.jsxs(fs,{open:O,onOpenChange:U,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(il,{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(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Create New User"}),e.jsx(Rr,{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(ge,{htmlFor:"name",children:"Name"}),e.jsx(Fe,{id:"name",placeholder:"John Doe",value:I.name,onChange:jt=>L({...I,name:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"email",children:"Email"}),e.jsx(Fe,{id:"email",type:"email",placeholder:"john@example.com",value:I.email,onChange:jt=>L({...I,email:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"password",children:"Password"}),e.jsx(Fe,{id:"password",type:"password",placeholder:"Min 6 characters",value:I.password,onChange:jt=>L({...I,password:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Fe,{id:"phone",type:"tel",placeholder:"555-123-4567",value:I.phone,onChange:jt=>L({...I,phone:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ge,{htmlFor:"brokerage",children:["Brokerage",I.role==="brokerage_manager"?" (required)":""]}),e.jsxs(zs,{value:I.brokerage_id||"none",onValueChange:jt=>L({...I,brokerage_id:jt==="none"?"":jt}),children:[e.jsx(Os,{id:"brokerage",children:e.jsx(qs,{placeholder:I.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"None"}),p.map(jt=>e.jsx(yt,{value:jt.id,children:jt.name},jt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"role",children:"Role"}),e.jsxs(zs,{value:I.role,onValueChange:jt=>L({...I,role:jt}),children:[e.jsx(Os,{id:"role",children:e.jsx(qs,{placeholder:"Select role"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"user",children:"User"}),e.jsx(yt,{value:"moderator",children:"Moderator"}),e.jsx(yt,{value:"brokerage_manager",children:"Brokerage Manager"}),e.jsx(yt,{value:"admin",children:"Admin"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"trial_days",children:"Trial Period (optional)"}),e.jsxs(zs,{value:I.trial_days||"none",onValueChange:jt=>L({...I,trial_days:jt==="none"?"":jt}),children:[e.jsx(Os,{id:"trial_days",children:e.jsx(qs,{placeholder:"No trial (full access)"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"No trial (full access)"}),e.jsx(yt,{value:"7",children:"7-day trial"}),e.jsx(yt,{value:"30",children:"30-day trial"}),e.jsx(yt,{value:"60",children:"60-day trial"}),e.jsx(yt,{value:"90",children:"90-day trial"}),e.jsx(yt,{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(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>U(!1),children:"Cancel"}),e.jsx(K,{onClick:Ki,disabled:C,children:C?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(ta,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"members",children:"Members"}),e.jsx(ls,{value:"brokerages",children:"Brokerages"}),e.jsx(ls,{value:"teams",children:"Teams"}),e.jsx(ls,{value:"trials",children:"Trial Users"}),e.jsx(ls,{value:"access",children:"Access Matrix"}),e.jsx(ls,{value:"celebrations",children:"Celebrations"}),e.jsx(ls,{value:"deletions",children:"Deletion Log"})]}),e.jsxs(js,{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(tn,{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:jt=>Iw(jt.target.value),className:"pl-10 h-9"})]}),e.jsxs(zs,{value:Y,onValueChange:jt=>Pf(ce,jt),children:[e.jsx(Os,{className:"w-[130px] h-9",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Status"}),e.jsx(yt,{value:"claimed",children:"Active"}),e.jsx(yt,{value:"unclaimed",children:"Pending"})]})]}),e.jsxs(zs,{value:ae,onValueChange:jt=>Pf(ie,jt),children:[e.jsx(Os,{className:"w-[130px] h-9",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Roles"}),e.jsx(yt,{value:"admin",children:"Admin"}),e.jsx(yt,{value:"brokerage_manager",children:"Manager"}),e.jsx(yt,{value:"assistant",children:"Assistant"}),e.jsx(yt,{value:"user",children:"User"})]})]}),e.jsxs(zs,{value:le,onValueChange:jt=>Pf(fe,jt),children:[e.jsx(Os,{className:"w-[130px] h-9",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Users"}),e.jsx(yt,{value:"trial",children:"Trial Only"}),e.jsx(yt,{value:"non-trial",children:"Full Only"})]})]}),e.jsxs(zs,{value:xe,onValueChange:jt=>Pf(he,jt),children:[e.jsx(Os,{className:"w-[150px] h-9",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Brokerages"}),e.jsx(yt,{value:"none",children:"No Brokerage"}),p.map(jt=>e.jsx(yt,{value:jt.id,children:jt.name},jt.id))]})]}),(q||Y!=="all"||ae!=="all"||le!=="all"||xe!=="all")&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{$(""),ce("all"),ie("all"),fe("all"),he("all"),ee(1)},children:[e.jsx(Sr,{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:Vx?`Showing all ${kp} members`:`Showing ${Sp+1}-${Math.min(I0,kp)} of ${kp} members`}),e.jsxs(zs,{value:Z.toString(),onValueChange:jt=>ty(Number(jt)),children:[e.jsx(Os,{className:"h-9 w-[110px]",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"50",children:"50 / page"}),e.jsx(yt,{value:"100",children:"100 / page"}),e.jsx(yt,{value:"250",children:"250 / page"}),e.jsx(yt,{value:"0",children:"All"})]})]})]})]}),$t.size>0&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/10 border border-primary/20 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Av,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[$t.size," selected"]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:D0,disabled:De,children:[De?e.jsx(ps,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(tr,{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:D1,disabled:De,children:[De?e.jsx(ps,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(mp,{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:FE,children:[e.jsx(Xa,{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:zC,disabled:De,children:[De?e.jsx(ps,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(yr,{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:Cp,disabled:De,children:e.jsx(Sr,{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(As,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(Nt,{className:"w-[50px]",children:e.jsx(Gi,{checked:$l.length>0&&$l.every(jt=>$t.has(jt.id)),onCheckedChange:Lf,"aria-label":"Select all on page"})}),e.jsx(Ko,{sortKey:"name",currentSortKey:Np,currentDirection:Ef,onSort:Wd,children:"Name"}),e.jsx(Ko,{sortKey:"brokerage",currentSortKey:Np,currentDirection:Ef,onSort:Wd,children:"Brokerage"}),e.jsx(Ko,{sortKey:"status",currentSortKey:Np,currentDirection:Ef,onSort:Wd,children:"Status"}),e.jsx(Ko,{sortKey:"role",currentSortKey:Np,currentDirection:Ef,onSort:Wd,children:"Role"}),e.jsx(Ko,{sortKey:"last_login",currentSortKey:Np,currentDirection:Ef,onSort:Wd,children:"Last Login"}),e.jsx(Ko,{sortKey:"created_at",currentSortKey:Np,currentDirection:Ef,onSort:Wd,children:"Member Since"}),e.jsx(Nt,{className:"w-[100px]"})]})}),e.jsx(Pn,{children:$l.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):$l.map(jt=>e.jsxs(As,{className:`hover:bg-muted/30 ${$t.has(jt.id)?"bg-primary/5":""}`,children:[e.jsx(dt,{children:e.jsx(Gi,{checked:$t.has(jt.id),onCheckedChange:()=>L1(jt.id),"aria-label":`Select ${jt.name}`})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>Hx(jt),className:"text-primary hover:underline font-medium text-left",children:jt.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:jt.email})]})}),e.jsx(dt,{className:"text-muted-foreground",children:jt.brokerage_name||"—"}),e.jsx(dt,{children:e.jsx("div",{className:"flex flex-col",children:(()=>{const Ps=jt.is_trial&&jt.trial_expires_at||!jt.is_trial&&jt.subscription_status==="trialing"&&jt.subscription_end_date,nr=jt.trial_expires_at||jt.subscription_end_date;if(Ps&&nr){const Yr=Math.ceil((new Date(nr).getTime()-Date.now())/864e5),pn=Yr<=0,Na=Yr<=3;return e.jsx(Ye,{variant:"outline",className:Rt("w-fit",pn?"border-destructive text-destructive":Na?"border-amber-500 text-amber-600":"border-violet-300 text-violet-700 bg-violet-50"),children:pn?"Trial Expired":`Trial · ${Yr}d left`})}return e.jsx(Ye,{variant:jt.claimed?"default":"secondary",className:jt.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:jt.claimed?"Active":"Pending"})})()})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col",children:[jt.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:jt.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),jt.roles.includes("assistant")&&Zn[jt.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",Zn[jt.id].agent_name||Zn[jt.id].agent_email]})]})}),e.jsx(dt,{className:"text-muted-foreground",children:jt.last_sign_in_at?new Date(jt.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(dt,{className:"text-muted-foreground",children:jt.created_at?new Date(jt.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",onClick:()=>{ys(jt),Qt(!0)},title:"Send celebration",children:e.jsx(Bd,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Hx(jt),title:"Edit member",children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>BC(jt.id,jt.email),disabled:Pt===jt.id,title:"Sync phone with GHL",children:Pt===jt.id?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(Tn,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>zi(jt.id),title:"Resend welcome email",children:e.jsx(tr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Qo(jt.email,jt.name),title:"Send password reset",children:e.jsx(iS,{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:()=>R1(jt.id),disabled:a||jt.id===(s==null?void 0:s.id),title:jt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${jt.name}`,children:a?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(dS,{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:()=>fi(jt.id,jt.name),title:"Delete user",children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},jt.id))})]})}),nc>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 ",nc]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>ee(1),disabled:V===1,children:"First"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>ee(jt=>Math.max(1,jt-1)),disabled:V===1,children:e.jsx(wl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,nc)},(jt,Ps)=>{let nr;return nc<=5||V<=3?nr=Ps+1:V>=nc-2?nr=nc-4+Ps:nr=V-2+Ps,e.jsx(K,{variant:V===nr?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>ee(nr),children:nr},nr)})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>ee(jt=>Math.min(nc,jt+1)),disabled:V===nc,children:e.jsx(ja,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>ee(nc),disabled:V===nc,children:"Last"})]})]})]}),e.jsx(fs,{open:Re,onOpenChange:Ue,children:e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Edit Member"}),e.jsx(Rr,{children:"Update member details, roles, and app access"})]}),Ee&&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(ge,{htmlFor:"edit-name",children:"Name"}),e.jsx(Fe,{id:"edit-name",value:ye.name,onChange:jt=>ct({...ye,name:jt.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"edit-email",children:"Email"}),e.jsx(Fe,{id:"edit-email",type:"email",value:ye.email,onChange:jt=>ct({...ye,email:jt.target.value}),maxLength:255})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Fe,{id:"edit-phone",type:"tel",value:ye.phone,onChange:jt=>ct({...ye,phone:jt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(zs,{value:ye.brokerage_id||"none",onValueChange:jt=>ct({...ye,brokerage_id:jt==="none"?"":jt}),children:[e.jsx(Os,{id:"edit-brokerage",children:e.jsx(qs,{placeholder:"Select brokerage"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"None"}),p.map(jt=>e.jsx(yt,{value:jt.id,children:jt.name},jt.id))]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Roles"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Ee.roles.map(jt=>e.jsxs(Ye,{variant:"default",className:"gap-1",children:[e.jsx(Ru,{className:"h-3 w-3"}),jt,jt==="brokerage_manager"?e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):e.jsx("button",{onClick:()=>Bi(Ee.id,jt,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Sr,{className:"h-3 w-3"})})]},jt)),Ee.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(zs,{onValueChange:jt=>Bi(Ee.id,jt,"add"),children:[e.jsx(Os,{className:"w-[200px]",children:e.jsx(qs,{placeholder:"Add role..."})}),e.jsxs(Fs,{children:[!Ee.roles.includes("admin")&&e.jsx(yt,{value:"admin",children:"Admin"}),!Ee.roles.includes("user")&&e.jsx(yt,{value:"user",children:"User"})]})]}),!Ee.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"})]}),(lr.length>0||Br.length>0||Ee.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(cr,{className:"h-4 w-4"}),"Assistant Relationships"]}),un?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ps,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[lr.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:"}),lr.map(jt=>e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/30 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:jt.assistant_name}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:jt.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(jt.permissions).filter(([,Ps])=>Ps).map(([Ps])=>e.jsx(Ye,{variant:"secondary",className:"text-[10px] capitalize",children:Ps},Ps))})]},jt.id))]}),Br.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:"}),Br.map(jt=>e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/30 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:jt.agent_name}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:jt.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(jt.permissions).filter(([,Ps])=>Ps).map(([Ps])=>e.jsx(Ye,{variant:"secondary",className:"text-[10px] capitalize",children:Ps},Ps))})]},jt.id))]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"App Access"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Toggle which apps this member can access"}),e.jsx("div",{className:"grid gap-3",children:d.map(jt=>{const Ps=oa(Ee.tags,jt.required_tags),nr=`${Ee.id}-${jt.id}`,Yr=pe===nr,pn=jt.required_tags.length===0;return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xl",children:jt.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:jt.name}),pn&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:Yr?e.jsx(ps,{className:"h-4 w-4 animate-spin text-muted-foreground"}):pn?e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(Lr,{checked:Ps,onCheckedChange:()=>Jo(Ee.id,jt,Ps)})})]},jt.id)})})]}),(Ee.is_trial||Ee.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(rn,{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:[Ee.trial_expires_at&&e.jsx(bDe,{expiresAt:Ee.trial_expires_at}),!Ee.trial_expires_at&&Ee.subscription_status==="trialing"&&Ee.subscription_end_date&&e.jsx(bDe,{expiresAt:Ee.subscription_end_date})]}),(Ee.trial_expires_at||Ee.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(Ee.trial_expires_at||Ee.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>L0(Ee.id,7),disabled:we,children:[e.jsx(Cb,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>L0(Ee.id,14),disabled:we,children:[e.jsx(Cb,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>L0(Ee.id,30),disabled:we,children:[e.jsx(Cb,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(K,{size:"sm",variant:"default",onClick:()=>Lw(Ee.id),disabled:Ve,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Rb,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),Ee.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(Ee.trial_started_at).toLocaleDateString(),Ee.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(Ee.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:[Ee.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(Ee.email_confirmed_at).toLocaleString()]}),Ee.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(Ee.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(Ee.created_at).toLocaleString()]})]})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:If,children:"Cancel"}),e.jsx(K,{onClick:OE,children:"Save Changes"})]})]})}),e.jsxs(js,{value:"access",children:[d.length===0?e.jsx(Ie,{children:e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Member Access Matrix"}),e.jsx(mr,{children:"Toggle switches to grant or revoke app access for each member"})]}),e.jsxs("div",{className:"relative w-full sm:w-72",children:[e.jsx(tn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search agents by name or email...",value:q,onChange:jt=>{$(jt.target.value),ee(1)},className:"pl-9"})]})]}),e.jsxs(Be,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left p-4 font-semibold sticky left-0 bg-card z-10",children:"Member"}),d.map(jt=>e.jsx("th",{className:"text-center p-4 font-semibold min-w-[120px]",children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("span",{className:"text-2xl",children:jt.icon}),e.jsx("span",{className:"text-sm",children:jt.name})]})},jt.id))]})}),e.jsxs("tbody",{children:[$l.map(jt=>e.jsxs("tr",{className:"border-b hover:bg-muted/50",children:[e.jsx("td",{className:"p-4 sticky left-0 bg-card z-10",children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:jt.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:jt.email})]})}),d.map(Ps=>{const nr=oa(jt.tags,Ps.required_tags),Yr=`${jt.id}-${Ps.id}`,pn=pe===Yr;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:pn?e.jsx(ps,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(Lr,{checked:nr,onCheckedChange:()=>Jo(jt.id,Ps,nr),disabled:Ps.required_tags.length===0})})},Ps.id)})]},jt.id)),$l.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:d.length+1,className:"p-8 text-center text-muted-foreground",children:"No members found"})})]})]})}),nc>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 ",Sp+1,"-",Math.min(I0,kp)," of ",kp," • Page ",V," of ",nc]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>ee(jt=>Math.max(1,jt-1)),disabled:V===1,children:e.jsx(wl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>ee(jt=>Math.min(nc,jt+1)),disabled:V===nc,children:e.jsx(ja,{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(js,{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(tn,{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:Xt,onChange:jt=>Qa(jt.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[p.filter(jt=>jt.name.toLowerCase().includes(Xt.toLowerCase())).length," of ",p.length," brokerages"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{const jt=[];for(const Bn of p){const Ri=y[Bn.id]??[];for(const Mp of Ri){const zm=l.find(la=>la.id===Mp);if(zm){const la=(zm.name||"").trim().split(/\s+/),R0=la[0]||"",O1=la.slice(1).join(" ")||"";jt.push({firstName:R0,lastName:O1,email:zm.email,brokerageName:Bn.name})}}}if(jt.length===0){o({title:"No managers found to export"});return}const nr=[["First Name","Last Name","Email","Brokerage Name"].join(","),...jt.map(Bn=>[Bn.firstName,Bn.lastName,Bn.email,Bn.brokerageName].map(Ri=>`"${(Ri||"").replace(/"/g,'""')}"`).join(","))].join(` `),Yr=new Blob([nr],{type:"text/csv"}),pn=URL.createObjectURL(Yr),Na=document.createElement("a");Na.href=pn,Na.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,Na.click(),URL.revokeObjectURL(pn),o({title:`Exported ${jt.length} managers`})},children:[e.jsx(Xa,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(fs,{open:tt,onOpenChange:st,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(ma,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Create New Brokerage"}),e.jsx(Rr,{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(ge,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Fe,{id:"brokerage-name",placeholder:"Enter brokerage name",value:Ce,onChange:jt=>et(jt.target.value),maxLength:100})]})}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>st(!1),children:"Cancel"}),e.jsx(K,{onClick:Cc,disabled:Ct,children:Ct?"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(As,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(Nt,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(Nt,{className:"font-semibold",children:"Manager(s)"}),e.jsx(Nt,{className:"font-semibold",children:"Agents"}),e.jsx(Nt,{className:"w-[150px]"})]})}),e.jsx(Pn,{children:(()=>{const jt=p.filter(Ps=>Ps.name.toLowerCase().includes(Xt.toLowerCase()));return jt.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:Xt?"No brokerages match your search":"No brokerages found"})}):jt.map(Ps=>{const nr=l.filter(Bn=>Bn.brokerage_id===Ps.id),pn=(y[Ps.id]??[]).map(Bn=>l.find(Ri=>Ri.id===Bn)).filter(Boolean),Na=nr.length;return e.jsxs(As,{className:"hover:bg-muted/30",children:[e.jsx(dt,{children:e.jsx("button",{onClick:()=>Bl(Ps),className:"text-primary hover:underline font-medium",children:Ps.name})}),e.jsx(dt,{children:pn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:pn.map(Bn=>e.jsx(Ye,{variant:"secondary",className:"text-xs",children:Bn.name},Bn.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:()=>Om(Ps),children:[e.jsx(cr,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Bl(Ps),title:"Edit brokerage",children:e.jsx(pa,{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:()=>Nd(Ps),title:"Delete brokerage",children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},Ps.id)})})()})]})}),e.jsx(fs,{open:ut,onOpenChange:Oe,children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Edit Brokerage"}),e.jsx(Rr,{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(ge,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),e.jsx(Fe,{id:"edit-brokerage-name",value:Ke,onChange:jt=>He(jt.target.value),maxLength:100})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ge,{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 Ps=(y[Xe.id]??[]).map(nr=>l.find(Yr=>Yr.id===nr)).filter(Boolean);return Ps.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):Ps.map(nr=>e.jsxs(Ye,{variant:"default",className:"gap-1",children:[e.jsx(Ru,{className:"h-3 w-3"}),nr.name,e.jsx("button",{onClick:()=>Bi(nr.id,"brokerage_manager","remove",Xe.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(Sr,{className:"h-3 w-3"})})]},nr.id))})()}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),e.jsxs(yo,{open:Cr,onOpenChange:Fn,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Cr,className:"w-full justify-between",children:["Search for a member...",e.jsx(tn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(uo,{className:"w-full p-0",align:"start",children:e.jsxs(Ax,{children:[e.jsx(Ex,{placeholder:"Search by name or email..."}),e.jsxs(Px,{className:"max-h-[200px]",children:[e.jsx(Ix,{children:"No members found."}),e.jsx(Lx,{children:(()=>{const jt=new Set(y[Xe.id]??[]);return l.filter(Ps=>!jt.has(Ps.id)&&(r||Ps.brokerage_id===Xe.id)).map(Ps=>e.jsxs(op,{value:`${Ps.name} ${Ps.email}`,onSelect:()=>{Rm(Ps.id,Xe.id),Fn(!1)},children:[Ps.name," (",Ps.email,")"]},Ps.id))})()})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Members in this Brokerage"}),e.jsx("div",{className:"max-h-32 overflow-y-auto border rounded p-2",children:l.filter(jt=>jt.brokerage_id===Xe.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(jt=>jt.brokerage_id===Xe.id).map(jt=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:jt.name}),jt.roles.includes("brokerage_manager")&&e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Manager"})]},jt.id))})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:Hd,children:"Cancel"}),e.jsx(K,{onClick:vu,disabled:gt,children:gt?"Saving...":"Save Changes"})]})]})}),e.jsx(fs,{open:Wt,onOpenChange:xs,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Rr,{children:['Are you sure you want to delete "',Cs==null?void 0:Cs.name,'"?']})]}),e.jsx("div",{className:"py-4",children:e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:"Warning: This action cannot be undone!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This will permanently delete:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground list-disc list-inside",children:[e.jsxs("li",{children:['The brokerage "',Cs==null?void 0:Cs.name,'"']}),e.jsxs("li",{children:["All ",l.filter(jt=>jt.brokerage_id===(Cs==null?void 0:Cs.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>xs(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:_u,disabled:Ar,children:Ar?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(fs,{open:Xs,onOpenChange:Nr,children:e.jsxs(ms,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(ma,{className:"h-5 w-5"}),"Manage ",Vs==null?void 0:Vs.name]}),e.jsx(Rr,{children:"Add, remove, or manage users in this brokerage"})]}),Vs&&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(tn,{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:Or,onChange:jt=>Rn(jt.target.value),className:"pl-10 h-9"})]}),e.jsxs(fs,{open:bn,onOpenChange:ir,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(il,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Add New Agent"}),e.jsxs(Rr,{children:["Create a new agent for ",Vs.name]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"agent-name",children:"Name"}),e.jsx(Fe,{id:"agent-name",placeholder:"John Doe",value:or.name,onChange:jt=>hr({...or,name:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"agent-email",children:"Email"}),e.jsx(Fe,{id:"agent-email",type:"email",placeholder:"john@example.com",value:or.email,onChange:jt=>hr({...or,email:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"agent-password",children:"Password"}),e.jsx(Fe,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:or.password,onChange:jt=>hr({...or,password:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(Fe,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:or.phone,onChange:jt=>hr({...or,phone:jt.target.value})})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>ir(!1),children:"Cancel"}),e.jsx(K,{onClick:Gd,disabled:an,children:an?"Creating...":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),e.jsxs(yo,{open:Kt,onOpenChange:Mr,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Kt,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(tn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(uo,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Ax,{children:[e.jsx(Ex,{placeholder:"Search users...",value:On,onValueChange:ua}),e.jsxs(Px,{children:[e.jsx(Ix,{children:"No users found."}),e.jsx(Lx,{children:Ux(Vs.id).filter(jt=>On===""||jt.name.toLowerCase().includes(On.toLowerCase())||jt.email.toLowerCase().includes(On.toLowerCase())).map(jt=>e.jsxs(op,{value:`${jt.name} ${jt.email}`,onSelect:()=>{xh(jt.id,Vs.id),Mr(!1),ua("")},children:[jt.name," (",jt.email,")"]},jt.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(Nt,{className:"font-semibold",children:"Name"}),e.jsx(Nt,{className:"font-semibold",children:"Email"}),e.jsx(Nt,{className:"font-semibold",children:"Status"}),e.jsx(Nt,{className:"font-semibold",children:"Role"}),e.jsx(Nt,{className:"w-[120px]"})]})}),e.jsx(Pn,{children:P1(Vs.id).length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:Or?"No matching members found":"No members in this brokerage"})}):P1(Vs.id).map(jt=>e.jsxs(As,{className:"hover:bg-muted/30",children:[e.jsx(dt,{className:"font-medium",children:jt.name}),e.jsx(dt,{className:"text-muted-foreground",children:jt.email}),e.jsx(dt,{children:jt.claimed?e.jsx(Ye,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(Ye,{variant:"secondary",children:"Pending"})}),e.jsx(dt,{children:jt.roles.includes("brokerage_manager")?e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(Ru,{className:"h-3 w-3"}),"Manager"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Agent"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[!jt.claimed&&e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>zi(jt.id),title:"Resend welcome email",children:e.jsx(tr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Fm(jt.id),title:"Remove from brokerage",children:e.jsx(Sr,{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:()=>R1(jt.id),disabled:a||jt.id===(s==null?void 0:s.id),title:jt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${jt.name}`,children:a?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(dS,{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:()=>fi(jt.id,jt.name),title:"Delete user",children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},jt.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[jp(Vs.id).length," total member",jp(Vs.id).length!==1?"s":""," •",jp(Vs.id).filter(jt=>jt.roles.includes("brokerage_manager")).length," manager",jp(Vs.id).filter(jt=>jt.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(gn,{children:e.jsx(K,{variant:"outline",onClick:Vu,children:"Close"})})]})})]}),e.jsx(js,{value:"teams",children:e.jsx(zHt,{})}),e.jsx(js,{value:"trials",children:e.jsx(DHt,{})}),e.jsx(js,{value:"celebrations",children:e.jsx(LHt,{})}),e.jsx(js,{value:"deletions",children:e.jsx(RHt,{})})]})]}),e.jsx(Att,{open:Va,onOpenChange:$a,brokerages:p,onSuccess:Ha}),Es&&e.jsx(Ett,{open:Vt,onOpenChange:jt=>{Qt(jt),jt||ys(null)},userId:Es.id,userName:Es.name})]})},$Ht=()=>{const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(""),[d,u]=k.useState(""),[p,f]=k.useState(""),[y,_]=k.useState("");k.useEffect(()=>{b()},[]);const b=async()=>{const{data:L,error:O}=await G.from("invite_codes").select("*").order("created_at",{ascending:!1});O?(me.error("Failed to load invite codes"),console.error(O)):s(L||[]),n(!1)},N=async L=>{if(L.preventDefault(),!l.trim()){me.error("Please enter a code");return}o(!0);const{error:O}=await G.from("invite_codes").insert({code:l.trim().toUpperCase(),description:d.trim()||null,max_uses:p?parseInt(p):null,trial_days:y?parseInt(y):null});O?O.code==="23505"?me.error("This code already exists"):(me.error("Failed to create invite code"),console.error(O)):(me.success("Invite code created"),i(""),u(""),f(""),_(""),b()),o(!1)},w=async(L,O)=>{const{error:U}=await G.from("invite_codes").update({is_active:!O}).eq("id",L);U?me.error("Failed to update code"):s(t.map(q=>q.id===L?{...q,is_active:!O}:q))},S=async L=>{const{error:O}=await G.from("invite_codes").delete().eq("id",L);O?me.error("Failed to delete code"):(me.success("Code deleted"),s(t.filter(U=>U.id!==L)))},C="https://dashboard.relevelup.com",A=L=>{const O=`${C}/join?code=${L}`;navigator.clipboard.writeText(O),me.success("Link copied to clipboard")},I=`${C}/join`;return e.jsx(Ls,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Create New Code"}),e.jsxs(mr,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:I})]})]}),e.jsx(Be,{children:e.jsxs("form",{onSubmit:N,className:"flex flex-wrap gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(ge,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Fe,{id:"description",placeholder:"For marketing campaign",value:d,onChange:L=>u(L.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(ge,{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(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Active Codes"})}),e.jsx(Be,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ps,{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(As,{children:[e.jsx(Nt,{children:"Code"}),e.jsx(Nt,{children:"Description"}),e.jsx(Nt,{children:"Uses"}),e.jsx(Nt,{children:"Trial"}),e.jsx(Nt,{children:"Created"}),e.jsx(Nt,{children:"Active"}),e.jsx(Nt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(L=>e.jsxs(As,{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:gs(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx(Lr,{checked:L.is_active,onCheckedChange:()=>w(L.id,L.is_active)})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>A(L.code),title:"Copy invite link",children:e.jsx(Ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(L.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},L.id))})]})})]})]})})},nO=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}},nE=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}}},qHt=async(t,s)=>await nO("new_templates")?nE({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}),UHt=async(t,s)=>nE({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),VHt=async(t,s)=>await nO("new_events")?nE({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),HHt=async(t,s)=>await nO("new_toolbox")?nE({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),Q_e=async(t,s)=>await nO("new_social_swag")?nE({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}),GHt=async(t,s)=>await nO("new_newsletters")?nE({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),e9={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 WHt(){const t=br(),s=es(),[r,n]=k.useState(!1),[a,o]=k.useState(null),[l,i]=k.useState(e9),[d,u]=k.useState(null),[p,f]=k.useState(null),[y,_]=k.useState(!1),b=k.useRef(null),[N,w]=k.useState(!1),[S,C]=k.useState(null),[A,I]=k.useState(!1),[L,O]=k.useState(null),[U,q]=k.useState(null),[$,V]=k.useState(!0),[ee,Z]=k.useState(""),{data:J,isLoading:Y}=ft({queryKey:["admin-events"],queryFn:async()=>{const{data:Ce,error:et}=await G.from("events").select("*").order("event_date",{ascending:!0});if(et)throw et;return Ce}}),{data:ce}=ft({queryKey:["event-registrations-count"],queryFn:async()=>{let Ce=[],et=0;const Ct=1e3;for(;;){const{data:ut,error:Oe}=await G.from("event_registrations").select("event_id").range(et,et+Ct-1);if(Oe)throw Oe;if(!ut||ut.length===0||(Ce=Ce.concat(ut),ut.length{Ot[ut.event_id]=(Ot[ut.event_id]||0)+1}),Ot}}),{data:ae,isLoading:ie}=ft({queryKey:["event-registrations-details",S==null?void 0:S.id],queryFn:async()=>{if(!S)return[];const{data:Ce,error:et}=await G.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",S.id).order("registered_at",{ascending:!1});if(et)throw et;if(!Ce||Ce.length===0)return[];const Ct=Ce.map(Oe=>Oe.user_id).filter(Boolean);let Ot=[];if(Ct.length>0){const{data:Oe,error:Xe}=await G.from("profiles").select("id, name, email").in("id",Ct);if(Xe)throw Xe;Ot=Oe||[]}const ut=new Map((Ot==null?void 0:Ot.map(Oe=>[Oe.id,Oe]))||[]);return Ce.map(Oe=>({...Oe,profiles:Oe.user_id&&ut.get(Oe.user_id)||null}))},enabled:!!S}),{data:le,isLoading:fe}=ft({queryKey:["event-attendees-details",S==null?void 0:S.id],queryFn:async()=>{if(!S)return[];const{data:Ce,error:et}=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",S.id).order("created_at",{ascending:!1});if(et)throw et;if(!Ce||Ce.length===0)return[];const Ct=Ce.map(at=>at.user_id).filter(Boolean);let Ot=[];if(Ct.length>0){const{data:at,error:Ke}=await G.from("profiles").select("id, name, email").in("id",Ct);if(Ke)throw Ke;Ot=at||[]}const{data:ut}=await G.from("agent_points").select("user_id").eq("event_id",S.id),Oe=new Set((ut==null?void 0:ut.map(at=>at.user_id))||[]),Xe=new Map((Ot==null?void 0:Ot.map(at=>[at.id,at]))||[]);return Ce.map(at=>({...at,profiles:at.user_id&&Xe.get(at.user_id)||null,points_awarded:at.user_id?Oe.has(at.user_id):!1}))},enabled:!!S}),xe=Ce=>{C(Ce),w(!0)},he=Et({mutationFn:async Ce=>{const{data:{session:et}}=await G.auth.getSession();if(!et)throw new Error("Not authenticated");const Ct=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${et.access_token}`},body:JSON.stringify({event_id:Ce})}),Ot=await Ct.json();if(!Ct.ok)throw new Error(Ot.error||"Failed to sync");return Ot},onSuccess:Ce=>{s.invalidateQueries({queryKey:["event-registrations-details",S==null?void 0:S.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),me.success(Ce.message)},onError:Ce=>{me.error("Failed to sync: "+Ce.message)}}),we=Et({mutationFn:async Ce=>{const{data:{session:et}}=await G.auth.getSession();if(!et)throw new Error("Not authenticated");const Ct=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${et.access_token}`},body:JSON.stringify({event_id:Ce})}),Ot=await Ct.json();if(!Ct.ok)throw new Error(Ot.error||"Failed to sync attendees");return Ot},onSuccess:Ce=>{s.invalidateQueries({queryKey:["event-attendees-details",S==null?void 0:S.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),Ce!=null&&Ce.message?me.success(Ce.message):me.success(`Synced ${Ce.synced||0} attendees. ${Ce.points_awarded||0} points awarded!`)},onError:Ce=>{me.error("Failed to sync attendees: "+Ce.message)}}),Ne=Et({mutationFn:async({eventId:Ce,testMode:et})=>{const{data:{session:Ct}}=await G.auth.getSession();if(!Ct)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 ${Ct.access_token}`},body:JSON.stringify({event_id:Ce,test_mode:et})}),ut=await Ot.json();if(!Ot.ok)throw new Error(ut.error||"Failed to send reminders");return ut},onSuccess:Ce=>{Ce.test?me.success(Ce.message||"Test email sent!"):me.success(Ce.message||`Reminder emails sent to ${Ce.sent} registrants!`)},onError:Ce=>{me.error("Failed to send reminders: "+Ce.message)}}),{data:Ve}=ft({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let Ce=[],et=0;const Ct=1e3;for(;;){const{data:Ot,error:ut}=await G.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(et,et+Ct-1);if(ut)throw ut;if(!Ot||Ot.length===0||(Ce=[...Ce,...Ot],Ot.length{const{error:ut}=await G.from("event_attendees").update({user_id:et}).eq("id",Ce);if(ut)throw ut;if(Ot&&Ct){const{error:Xe}=await G.from("zoom_email_aliases").upsert({user_id:et,zoom_email:Ct.toLowerCase()},{onConflict:"zoom_email"});Xe&&console.error("Failed to save alias:",Xe)}const Oe=S==null?void 0:S.id;if(Oe){const{data:Xe}=await G.from("user_roles").select("id").eq("user_id",et).eq("role","admin").single();if(!Xe){const{data:at}=await G.from("agent_points").select("id").eq("user_id",et).eq("event_id",Oe).single();at||(await G.rpc("award_attendance_points",{p_user_id:et,p_event_id:Oe,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await G.rpc("check_and_award_badges",{p_user_id:et}))}}return{userId:et,zoomEmail:Ct,shouldSaveAlias:Ot}},onSuccess:Ce=>{s.invalidateQueries({queryKey:["event-attendees-details",S==null?void 0:S.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let et="Attendee linked and points awarded!";Ce.shouldSaveAlias&&Ce.zoomEmail&&(et+=` Email "${Ce.zoomEmail}" will be auto-matched in the future.`),me.success(et),I(!1),O(null),q(null),Z("")},onError:Ce=>{me.error("Failed to link attendee: "+Ce.message)}}),Ae=Ce=>{O(Ce),q(null),V(!0),Z(""),I(!0)},ze=()=>{!L||!U||Te.mutate({attendeeId:L.id,userId:U,zoomEmail:L.zoom_email,shouldSaveAlias:$})},Ee=(Ve==null?void 0:Ve.filter(Ce=>{var Ct,Ot;if(!ee)return!0;const et=ee.toLowerCase();return((Ct=Ce.name)==null?void 0:Ct.toLowerCase().includes(et))||((Ot=Ce.email)==null?void 0:Ot.toLowerCase().includes(et))}))||[],ve=async Ce=>{const et=Ce.name.split(".").pop(),Ot=`${`${crypto.randomUUID()}.${et}`}`,{error:ut}=await G.storage.from("event-images").upload(Ot,Ce);if(ut)throw ut;const{data:{publicUrl:Oe}}=G.storage.from("event-images").getPublicUrl(Ot);return Oe},Re=Ce=>{var Ct;const et=(Ct=Ce.target.files)==null?void 0:Ct[0];if(et){if(et.size>5*1024*1024){me.error("Image must be less than 5MB");return}u(et),f(URL.createObjectURL(et))}},Ue=()=>{u(null),f(null),i({...l,image_url:""}),b.current&&(b.current.value="")},ye=Et({mutationFn:async Ce=>{_(!0);let et=Ce.image_url;d&&(et=await ve(d)||"");const Ct=new Date(Ce.event_date),[Ot,ut]=Ce.event_time.split(":");Ct.setHours(parseInt(Ot),parseInt(ut));const Oe=[new Date(Ct)];if(Ce.is_recurring&&Ce.recurrence_end_date){let He=new Date(Ct);for(;Ce.recurrence_pattern==="weekly"?He=y4(He,1):Ce.recurrence_pattern==="biweekly"?He=y4(He,2):He=Tm(He,1),!(He>Ce.recurrence_end_date);)Oe.push(new Date(He))}const Xe=Oe.map(He=>({title:Ce.title,description:Ce.description||null,image_url:et||null,video_url:Ce.video_url||null,event_date:He.toISOString(),zoom_link:Ce.zoom_link,zoom_meeting_id:Ce.zoom_meeting_id||null,capacity:Ce.capacity?parseInt(Ce.capacity):null,is_published:Ce.is_published})),{data:at,error:Ke}=await G.from("events").insert(Xe).select();if(Ke)throw Ke;return at&&at.length>0&&VHt(Ce.title,at[0].id),Oe.length},onSuccess:Ce=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success(Ce>1?`${Ce} recurring events created successfully`:"Event created successfully"),n(!1),i(e9),u(null),f(null),_(!1)},onError:Ce=>{me.error("Failed to create event: "+Ce.message),_(!1)}}),ct=Et({mutationFn:async({id:Ce,data:et})=>{_(!0);let Ct=et.image_url;d&&(Ct=await ve(d)||"");const Ot=new Date(et.event_date),[ut,Oe]=et.event_time.split(":");Ot.setHours(parseInt(ut),parseInt(Oe));const{error:Xe}=await G.from("events").update({title:et.title,description:et.description||null,image_url:Ct||null,video_url:et.video_url||null,event_date:Ot.toISOString(),zoom_link:et.zoom_link,zoom_meeting_id:et.zoom_meeting_id||null,capacity:et.capacity?parseInt(et.capacity):null,is_published:et.is_published}).eq("id",Ce);if(Xe)throw Xe},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event updated successfully"),n(!1),o(null),i(e9),u(null),f(null),_(!1)},onError:Ce=>{me.error("Failed to update event: "+Ce.message),_(!1)}}),pe=Et({mutationFn:async Ce=>{const{error:et}=await G.from("events").delete().eq("id",Ce);if(et)throw et},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event deleted successfully")},onError:Ce=>{me.error("Failed to delete event: "+Ce.message)}}),Ge=Ce=>{var Ct;const et=new Date(Ce.event_date);o(Ce),i({title:Ce.title,description:Ce.description||"",image_url:Ce.image_url||"",video_url:Ce.video_url||"",event_date:et,event_time:gs(et,"HH:mm"),zoom_link:Ce.zoom_link,zoom_meeting_id:Ce.zoom_meeting_id||"",capacity:((Ct=Ce.capacity)==null?void 0:Ct.toString())||"",is_published:Ce.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),f(Ce.image_url||null),u(null),n(!0)},tt=Ce=>{if(Ce.preventDefault(),!l.event_date){me.error("Please select a date");return}if(l.is_recurring&&!l.recurrence_end_date){me.error("Please select an end date for recurring events");return}a?ct.mutate({id:a.id,data:l}):ye.mutate(l)},st=()=>{n(!1),o(null),i(e9),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(Ra,{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(Ie,{className:"mb-6",children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{children:"All Events"}),e.jsxs(fs,{open:r,onOpenChange:Ce=>!Ce&&st(),children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),e.jsxs(ms,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:tt,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"title",children:"Title *"}),e.jsx(Fe,{id:"title",value:l.title,onChange:Ce=>i({...l,title:Ce.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Description"}),e.jsx(Yg,{content:l.description,onChange:Ce=>i({...l,description:Ce}),placeholder:"Event description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Event Image"}),e.jsx("input",{type:"file",ref:b,accept:"image/*",onChange:Re,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:Ue,children:e.jsx(Sr,{className:"h-4 w-4"})})]}):e.jsxs(K,{type:"button",variant:"outline",className:"w-full h-32 border-dashed flex flex-col gap-2",onClick:()=>{var Ce;return(Ce=b.current)==null?void 0:Ce.click()},children:[e.jsx(Da,{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(ge,{children:"Date *"}),e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Rt("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),l.event_date?gs(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(ff,{mode:"single",selected:l.event_date,onSelect:Ce=>i({...l,event_date:Ce}),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"time",children:"Time *"}),e.jsx(Fe,{id:"time",type:"time",value:l.event_time,onChange:Ce=>i({...l,event_time:Ce.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(Fe,{id:"zoom_link",value:l.zoom_link,onChange:Ce=>i({...l,zoom_link:Ce.target.value}),placeholder:"https://zoom.us/j/...",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),e.jsx(Fe,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:Ce=>i({...l,zoom_meeting_id:Ce.target.value}),placeholder:"e.g., 1234567890 (find in Zoom dashboard)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional: Enter the numeric meeting ID for automatic Zoom registration"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),e.jsx(Fe,{id:"video_url",value:l.video_url,onChange:Ce=>i({...l,video_url:Ce.target.value}),placeholder:"YouTube, Vimeo, or Bunny.net embed URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a preview/promo video for this event"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"capacity",children:"Capacity (optional)"}),e.jsx(Fe,{id:"capacity",type:"number",value:l.capacity,onChange:Ce=>i({...l,capacity:Ce.target.value}),placeholder:"Leave empty for unlimited",min:"1"})]}),!a&&e.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(PL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ge,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx(Lr,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:Ce=>i({...l,is_recurring:Ce})})]}),l.is_recurring&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Frequency"}),e.jsxs(zs,{value:l.recurrence_pattern,onValueChange:Ce=>i({...l,recurrence_pattern:Ce}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"weekly",children:"Weekly"}),e.jsx(yt,{value:"biweekly",children:"Every 2 Weeks"}),e.jsx(yt,{value:"monthly",children:"Monthly"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Repeat Until"}),e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Rt("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?gs(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(ff,{mode:"single",selected:l.recurrence_end_date,onSelect:Ce=>i({...l,recurrence_end_date:Ce}),disabled:Ce=>Ce<(l.event_date||new Date),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),l.event_date&&l.recurrence_end_date&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will create ",(()=>{let Ce=1,et=new Date(l.event_date);for(;et=l.recurrence_pattern==="weekly"?y4(et,1):l.recurrence_pattern==="biweekly"?y4(et,2):Tm(et,1),!(et>l.recurrence_end_date);)Ce++;return Ce})()," events with the same Zoom link"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{htmlFor:"is_published",children:"Published"}),e.jsx(Lr,{id:"is_published",checked:l.is_published,onCheckedChange:Ce=>i({...l,is_published:Ce})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:st,className:"flex-1",children:"Cancel"}),e.jsx(K,{type:"submit",className:"flex-1",disabled:ye.isPending||ct.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(Be,{children:Y?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading events..."}):(J==null?void 0:J.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(As,{children:[e.jsx(Nt,{children:"Title"}),e.jsx(Nt,{children:"Date & Time"}),e.jsx(Nt,{children:"Registrations"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:J==null?void 0:J.map(Ce=>e.jsxs(As,{children:[e.jsx(dt,{className:"font-medium",children:Ce.title}),e.jsx(dt,{children:gs(new Date(Ce.event_date),"PPP p")}),e.jsx(dt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>xe(Ce),children:[e.jsx(cr,{className:"h-4 w-4"}),(ce==null?void 0:ce[Ce.id])||0,Ce.capacity&&` / ${Ce.capacity}`]})}),e.jsx(dt,{children:e.jsx("span",{className:Rt("px-2 py-1 rounded-full text-xs font-medium",Ce.is_published?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200"),children:Ce.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(Ce.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(Kr,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ge(Ce),children:e.jsx(pa,{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(Ce.id)},children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})})]},Ce.id))})]})})]}),e.jsx(fs,{open:N,onOpenChange:w,children:e.jsxs(ms,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),S==null?void 0:S.title]}),e.jsx(Rr,{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:()=>Ne.mutate({eventId:S.id,testMode:!0}),disabled:Ne.isPending,children:[e.jsx(tr,{className:Rt("h-4 w-4 mr-2",Ne.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Ne.mutate({eventId:S.id}),disabled:Ne.isPending||!(ae!=null&&ae.length),children:[e.jsx(tr,{className:Rt("h-4 w-4 mr-2",Ne.isPending&&"animate-spin")}),Ne.isPending?"Sending...":"Send Reminder to All"]}),(S==null?void 0:S.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>he.mutate(S.id),disabled:he.isPending,children:[e.jsx(to,{className:Rt("h-4 w-4 mr-2",he.isPending&&"animate-spin")}),he.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>we.mutate(S.id),disabled:we.isPending,children:[e.jsx(Hi,{className:Rt("h-4 w-4 mr-2",we.isPending&&"animate-spin")}),we.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(ta,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(Qn,{className:"grid w-full grid-cols-2",children:[e.jsxs(ls,{value:"registrations",className:"gap-2",children:[e.jsx(cr,{className:"h-4 w-4"}),"Registrations (",(ae==null?void 0:ae.length)||0,")"]}),e.jsxs(ls,{value:"attendees",className:"gap-2",children:[e.jsx(Hn,{className:"h-4 w-4"}),"Attendees (",(le==null?void 0:le.length)||0,")"]})]}),e.jsx(js,{value:"registrations",className:"mt-4",children:ie?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(ae==null?void 0:ae.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No registrations yet for this event."}),(S==null?void 0:S.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(As,{children:[e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{children:"Registered"}),e.jsx(Nt,{children:"Status"})]})}),e.jsx(Pn,{children:ae==null?void 0:ae.map(Ce=>{var ut,Oe;const et=((ut=Ce.profiles)==null?void 0:ut.name)||Ce.zoom_name||"Unknown",Ct=((Oe=Ce.profiles)==null?void 0:Oe.email)||Ce.zoom_email||null,Ot=!Ce.user_id;return e.jsxs(As,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[et,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:Ct?e.jsxs("a",{href:`mailto:${Ct}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(tr,{className:"h-3 w-3"}),Ct]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(dt,{className:"text-muted-foreground text-sm",children:gs(new Date(Ce.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{children:Ce.zoom_join_url?e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:"Registered"}):e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},Ce.id)})})]})}),e.jsx(js,{value:"attendees",className:"mt-4",children:fe?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."}),(S==null?void 0:S.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(Ce=>!Ce.user_id).length)>0&&e.jsxs("div",{className:"mb-6 p-4 border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(co,{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(Ce=>!Ce.user_id).length,")"]})]}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300 mb-3",children:"These attendees couldn't be matched to a profile. Link them to award points."}),e.jsx("div",{className:"space-y-2",children:le==null?void 0:le.filter(Ce=>!Ce.user_id).map(Ce=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-background rounded border",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-sm",children:Ce.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Ce.zoom_email||"No email"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Ae(Ce),className:"gap-1",children:[e.jsx(Do,{className:"h-3 w-3"}),"Link to Profile"]})]},Ce.id))})]}),e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{children:"Duration"}),e.jsx(Nt,{children:"Points"})]})}),e.jsx(Pn,{children:le==null?void 0:le.filter(Ce=>Ce.user_id).map(Ce=>{var Ot,ut;const et=((Ot=Ce.profiles)==null?void 0:Ot.name)||Ce.zoom_name||"Unknown",Ct=((ut=Ce.profiles)==null?void 0:ut.email)||Ce.zoom_email||null;return e.jsxs(As,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[et,Ce.manually_added&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:"Manual"})]})}),e.jsx(dt,{children:Ct?e.jsxs("a",{href:`mailto:${Ct}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(tr,{className:"h-3 w-3"}),Ct]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(dt,{children:Ce.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(rn,{className:"h-3 w-3"}),Ce.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:Ce.points_awarded?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:[e.jsx(Hi,{className:"h-3 w-3"}),"+10 pts"]}):e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},Ce.id)})})]})]})})]})]})}),e.jsx(fs,{open:A,onOpenChange:I,children:e.jsxs(ms,{className:"max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Do,{className:"h-5 w-5"}),"Link Attendee to Profile"]}),e.jsx(Rr,{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(ge,{children:"Search for a profile"}),e.jsxs("div",{className:"relative",children:[e.jsx(tn,{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:ee,onChange:Ce=>Z(Ce.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:Ee.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:Ee.slice(0,20).map(Ce=>e.jsxs("button",{type:"button",onClick:()=>q(Ce.id),className:Rt("w-full p-3 text-left hover:bg-muted/50 transition-colors",U===Ce.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:Ce.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ce.email})]},Ce.id))})}),L.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Gi,{id:"save-alias",checked:$,onCheckedChange:Ce=>V(Ce)}),e.jsx("label",{htmlFor:"save-alias",className:"text-sm text-muted-foreground cursor-pointer",children:"Remember this email for future auto-matching"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsx(K,{onClick:ze,disabled:!U||Te.isPending,children:Te.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function KHt({selectedKitIds:t,onChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l=[]}=ft({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)),d=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(ge,{className:"flex items-center gap-2",children:[e.jsx(al,{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(Ye,{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(Sr,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(yo,{open:a,onOpenChange:o,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(al,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(uo,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(tn,{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:d.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No toolkits found":"All toolkits selected"}):d.map(f=>e.jsxs("button",{type:"button",onClick:()=>{u(f.id),n("")},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[f.featured_image_url?e.jsx("img",{src:f.featured_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(al,{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 ZHt=()=>{const{user:t}=$s(),{toast:s}=va(),r=es(),[n,a]=Sc(),[o,l]=k.useState(!1),[i,d]=k.useState(null),[u,p]=k.useState({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),[f,y]=k.useState(null),[_,b]=k.useState(0),[N,w]=k.useState(!1),[S,C]=k.useState(null),[A,I]=k.useState(""),[L,O]=k.useState([]),[U,q]=k.useState(""),[$,V]=k.useState(""),[ee,Z]=k.useState(!1),[J,Y]=k.useState(!1),{data:ce=[]}=ft({queryKey:["template-categories"],queryFn:async()=>{const{data:Ge,error:tt}=await G.from("template_categories").select("*").order("name");if(tt)throw tt;return Ge}}),{data:ae=[]}=ft({queryKey:["template-types"],queryFn:async()=>{const{data:Ge,error:tt}=await G.from("template_types").select("*").order("name");if(tt)throw tt;return Ge}}),{data:ie=[],isLoading:le}=ft({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:Ge,error:tt}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(tt)throw tt;const{data:st,error:Ce}=await G.from("template_links").select("*").order("sort_order");if(Ce)throw Ce;const{data:et,error:Ct}=await G.from("template_guides").select("*").order("sort_order");if(Ct)throw Ct;return Ge.map(ut=>({...ut,links:(st==null?void 0:st.filter(Oe=>Oe.template_id===ut.id))||[],guides:(et==null?void 0:et.filter(Oe=>Oe.template_id===ut.id))||[]}))}});k.useEffect(()=>{const Ge=n.get("edit");if(Ge&&ie.length>0){const tt=ie.find(st=>st.id===Ge);tt&&(Ve(tt),a({},{replace:!0}))}},[ie,n]);const fe=Et({mutationFn:async Ge=>{const{data:tt,error:st}=await G.from("template_categories").insert({name:Ge}).select().single();if(st)throw st;return tt},onSuccess:Ge=>{r.invalidateQueries({queryKey:["template-categories"]}),p({...u,category_id:Ge.id}),q(""),Z(!1),s({title:"Category added"})},onError:Ge=>{s({title:"Error adding category",description:Ge.message,variant:"destructive"})}}),xe=Et({mutationFn:async Ge=>{const{data:tt,error:st}=await G.from("template_types").insert({name:Ge}).select().single();if(st)throw st;return tt},onSuccess:Ge=>{r.invalidateQueries({queryKey:["template-types"]}),p({...u,type_id:Ge.id}),V(""),Y(!1),s({title:"Type added"})},onError:Ge=>{s({title:"Error adding type",description:Ge.message,variant:"destructive"})}}),he=Et({mutationFn:async Ge=>{var Ct;let tt=Ge.existingImageUrl;if(Ge.image){const Ot=Ge.image.name.split(".").pop(),ut=`${Date.now()}-${Math.random().toString(36).substring(7)}.${Ot}`,{error:Oe}=await G.storage.from("template-previews").upload(ut,Ge.image);if(Oe)throw Oe;const{data:Xe}=G.storage.from("template-previews").getPublicUrl(ut);tt=Xe.publicUrl}const st={name:Ge.template.name,description:Ge.template.description||null,category_id:Ge.template.category_id||null,type_id:Ge.template.type_id||null,preview_image_url:tt,video_url:Ge.videoUrl||null,publish_date:Ge.template.publish_date?new Date(Ge.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let Ce=Ge.templateId;if(Ce){const{error:Ot}=await G.from("canva_templates").update(st).eq("id",Ce);if(Ot)throw Ot;const{error:ut}=await G.from("template_links").delete().eq("template_id",Ce);if(ut)throw ut;const Oe=((Ct=Ge.existingGuides)==null?void 0:Ct.map(Ke=>Ke.id).filter(Boolean))||[],Xe=Ge.template.guides.map(Ke=>Ke.id).filter(Boolean),at=Oe.filter(Ke=>!Xe.includes(Ke));at.length>0&&await G.from("template_guides").delete().in("id",at)}else{const{data:Ot,error:ut}=await G.from("canva_templates").insert(st).select().single();if(ut)throw ut;Ce=Ot.id,qHt(Ge.template.name,Ot.id)}const et=Ge.template.links.filter(Ot=>Ot.title.trim()&&Ot.canva_share_link.trim());if(et.length>0){const Ot=et.map((Oe,Xe)=>({template_id:Ce,title:Oe.title.trim(),canva_share_link:Oe.canva_share_link.trim(),sort_order:Xe})),{error:ut}=await G.from("template_links").insert(Ot);if(ut)throw ut}for(let Ot=0;Ot0)){const{error:Ot}=await G.from("resource_kit_templates").insert(Ge.linkedKitIds.map(ut=>({template_id:Ce,kit_id:ut})));if(Ot)throw Ot}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),Ne(),l(!1),s({title:i?"Template updated":"Template created"})},onError:Ge=>{s({title:"Error saving template",description:Ge.message,variant:"destructive"})}}),we=Et({mutationFn:async Ge=>{const{error:tt}=await G.from("canva_templates").delete().eq("id",Ge);if(tt)throw tt},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:Ge=>{s({title:"Error deleting template",description:Ge.message,variant:"destructive"})}}),Ne=()=>{p({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),C(null),I(""),d(null),Z(!1),Y(!1),q(""),V(""),y(null),b(0),w(!1),O([])},Ve=async Ge=>{var st;d(Ge),p({name:Ge.name,description:Ge.description||"",category_id:Ge.category_id||"",type_id:Ge.type_id||"",publish_date:Ge.publish_date?new Date(Ge.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:Ge.links&&Ge.links.length>0?Ge.links.map(Ce=>({id:Ce.id,title:Ce.title,canva_share_link:Ce.canva_share_link,sort_order:Ce.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((st=Ge.guides)==null?void 0:st.map(Ce=>({id:Ce.id,name:Ce.name,file_url:Ce.file_url,file_type:Ce.file_type,file_size:Ce.file_size,sort_order:Ce.sort_order})))||[],video_url:Ge.video_url||""}),I(Ge.preview_image_url||""),y(null);const{data:tt}=await G.from("resource_kit_templates").select("kit_id").eq("template_id",Ge.id);O((tt||[]).map(Ce=>Ce.kit_id)),l(!0)},Te=Ge=>{var st;const tt=(st=Ge.target.files)==null?void 0:st[0];tt&&(C(tt),I(URL.createObjectURL(tt)))},Ae=()=>{p({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},ze=Ge=>{if(u.links.length<=1)return;const tt=u.links.filter((st,Ce)=>Ce!==Ge);p({...u,links:tt})},Ee=(Ge,tt,st)=>{const Ce=[...u.links];Ce[Ge]={...Ce[Ge],[tt]:st},p({...u,links:Ce})},ve=Ge=>{const tt=Ge.target.files;if(!tt)return;const st=Array.from(tt).map((Ce,et)=>({name:Ce.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:Ce.type,file_size:Ce.size,sort_order:u.guides.length+et,file:Ce}));p({...u,guides:[...u.guides,...st]}),Ge.target.value=""},Re=Ge=>{const tt=u.guides.filter((st,Ce)=>Ce!==Ge);p({...u,guides:tt})},Ue=(Ge,tt)=>{const st=[...u.guides];st[Ge]={...st[Ge],name:tt},p({...u,guides:st})},ye=async()=>{if(!f)return null;w(!0),b(0);try{const{data:Ge,error:tt}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||f.name}});if(tt)throw new Error(tt.message);const{videoId:st,libraryId:Ce}=Ge,{data:et,error:Ct}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:st}});if(Ct)throw new Error(Ct.message);const Ot=new XMLHttpRequest;return await new Promise((Oe,Xe)=>{Ot.upload.addEventListener("progress",at=>{if(at.lengthComputable){const Ke=Math.round(at.loaded/at.total*100);b(Ke)}}),Ot.addEventListener("load",()=>{Ot.status>=200&&Ot.status<300?Oe():Xe(new Error(`Upload failed with status ${Ot.status}`))}),Ot.addEventListener("error",()=>Xe(new Error("Upload failed"))),Ot.open("PUT",et.uploadUrl),Ot.setRequestHeader("AccessKey",et.apiKey),Ot.send(f)}),`https://player.mediadelivery.net/embed/${Ce}/${st}`}catch(Ge){return console.error("Bunny upload error:",Ge),s({title:"Video upload failed",description:Ge instanceof Error?Ge.message:"Unknown error",variant:"destructive"}),null}finally{w(!1)}},ct=Ge=>{var st;const tt=(st=Ge.target.files)==null?void 0:st[0];tt&&y(tt),Ge.target.value=""},pe=async Ge=>{if(Ge.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(Ce=>Ce.title.trim()&&Ce.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let st=u.video_url;if(f){const Ce=await ye();if(!Ce)return;st=Ce}he.mutate({template:u,image:S,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:st,linkedKitIds:L})};return e.jsx(Ls,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:ie.length})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:ce.length})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:ae.length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:Ge=>{l(Ge),Ge||Ne()},children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add Template"]})}),e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{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(ge,{htmlFor:"name",children:"Name *"}),e.jsx(Fe,{id:"name",value:u.name,onChange:Ge=>p({...u,name:Ge.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Description"}),e.jsx(Yg,{content:u.description,onChange:Ge=>p({...u,description:Ge}),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(ge,{children:"Canva Links *"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Ae,className:"gap-1",children:[e.jsx(Bs,{className:"h-3 w-3"}),"Add Link"]})]}),e.jsx("div",{className:"space-y-3",children:u.links.map((Ge,tt)=>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:Ge.title,onChange:st=>Ee(tt,"title",st.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(Fe,{value:Ge.canva_share_link,onChange:st=>Ee(tt,"canva_share_link",st.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:()=>ze(tt),children:e.jsx(Sr,{className:"h-4 w-4"})})]},tt))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Category"}),ee?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:U,onChange:Ge=>q(Ge.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>U.trim()&&fe.mutate(U.trim()),disabled:fe.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Z(!1),q("")},children:e.jsx(Sr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(zs,{value:u.category_id,onValueChange:Ge=>p({...u,category_id:Ge}),children:[e.jsx(Os,{className:"flex-1",children:e.jsx(qs,{placeholder:"Select category"})}),e.jsx(Fs,{children:ce.map(Ge=>e.jsx(yt,{value:Ge.id,children:Ge.name},Ge.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>Z(!0),children:e.jsx(Bs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Template Type"}),J?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:$,onChange:Ge=>V(Ge.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>$.trim()&&xe.mutate($.trim()),disabled:xe.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Y(!1),V("")},children:e.jsx(Sr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(zs,{value:u.type_id,onValueChange:Ge=>p({...u,type_id:Ge}),children:[e.jsx(Os,{className:"flex-1",children:e.jsx(qs,{placeholder:"Select type"})}),e.jsx(Fs,{children:ae.map(Ge=>e.jsx(yt,{value:Ge.id,children:Ge.name},Ge.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>Y(!0),children:e.jsx(Bs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Fe,{id:"publish_date",type:"date",value:u.publish_date,onChange:Ge=>p({...u,publish_date:Ge.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(ge,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[A?e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border bg-muted",children:[e.jsx("img",{src:A,alt:"Preview",className:"w-full h-full object-cover"}),e.jsx(K,{type:"button",size:"icon",variant:"destructive",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>{C(null),I("")},children:e.jsx(Sr,{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(Uo,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Fe,{type:"file",accept:"image/*",onChange:Te,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(ge,{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(hn,{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})})]}):N?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(ps,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",_,"%"]})]}),e.jsx(pi,{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(hn,{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(Sr,{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:ct,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(hn,{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(ge,{children:"Guide Files (PDFs)"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Fe,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:ve,className:"hidden"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx(Da,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map((Ge,tt)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(mn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(Fe,{value:Ge.name,onChange:st=>Ue(tt,st.target.value),placeholder:"Guide name",className:"flex-1"}),Ge.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(Ge.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:()=>Re(tt),children:e.jsx(Sr,{className:"h-4 w-4"})})]},Ge.id||tt))}):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(KHt,{selectedKitIds:L,onChange:O}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{l(!1),Ne()},children:"Cancel"}),e.jsx(K,{type:"submit",disabled:he.isPending,children:he.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Ie,{children:e.jsx(Be,{className:"p-0",children:le?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):ie.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(As,{children:[e.jsx(Nt,{children:"Preview"}),e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Links"}),e.jsx(Nt,{children:"Category"}),e.jsx(Nt,{children:"Type"}),e.jsx(Nt,{children:"Publish Date"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:ie.map(Ge=>{var tt,st,Ce,et,Ct;return e.jsxs(As,{children:[e.jsx(dt,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:Ge.preview_image_url?e.jsx("img",{src:Ge.preview_image_url,alt:Ge.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Uo,{className:"h-4 w-4 text-muted-foreground"})})})}),e.jsx(dt,{className:"font-medium",children:Ge.name}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(Ye,{variant:"secondary",children:[((tt=Ge.links)==null?void 0:tt.length)||0," link",(((st=Ge.links)==null?void 0:st.length)||0)!==1?"s":""]}),(((Ce=Ge.guides)==null?void 0:Ce.length)||0)>0&&e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),(et=Ge.guides)==null?void 0:et.length," guide",(((Ct=Ge.guides)==null?void 0:Ct.length)||0)!==1?"s":""]})]})}),e.jsx(dt,{children:Ge.category?e.jsx(Ye,{variant:"secondary",children:Ge.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{children:Ge.type?e.jsx(Ye,{variant:"outline",children:Ge.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{className:"text-muted-foreground",children:new Date(Ge.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:()=>Ve(Ge),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&we.mutate(Ge.id)},children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},Ge.id)})})]})})})]})})};function Ott({selectedTemplateIds:t,onChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l=[]}=ft({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)),d=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(ge,{className:"flex items-center gap-2",children:[e.jsx(lS,{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(Ye,{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(Sr,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(yo,{open:a,onOpenChange:o,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(lS,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(uo,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(tn,{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:d.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No templates found":"All templates selected"}):d.map(f=>e.jsxs("button",{type:"button",onClick:()=>{u(f.id),n("")},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[f.preview_image_url?e.jsx("img",{src:f.preview_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(lS,{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 YHt=[{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"}],XHt=()=>{const{user:t}=$s(),[s,r]=Sc(),{toast:n}=va(),a=es(),[o,l]=k.useState(!1),[i,d]=k.useState(null),[u,p]=k.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[f,y]=k.useState(null),[_,b]=k.useState(""),[N,w]=k.useState([]),[S,C]=k.useState([]),[A,I]=k.useState([]),[L,O]=k.useState([]),[U,q]=k.useState(""),[$,V]=k.useState(!1),[ee,Z]=k.useState(null),[J,Y]=k.useState(0),[ce,ae]=k.useState(!1),[ie,le]=k.useState(null),{data:fe=[]}=ft({queryKey:["academy-categories"],queryFn:async()=>{const{data:pe,error:Ge}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(Ge)throw Ge;return pe}}),{data:xe=[],isLoading:he}=ft({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:pe,error:Ge}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(Ge)throw Ge;const{data:tt,error:st}=await G.from("academy_resources").select("*").order("sort_order");if(st)throw st;return pe.map(et=>({...et,resources:(tt==null?void 0:tt.filter(Ct=>Ct.video_id===et.id))||[]}))}});k.useEffect(()=>{const pe=s.get("edit");if(pe&&xe.length>0){const Ge=xe.find(tt=>tt.id===pe);Ge&&(ze(Ge),r({},{replace:!0}))}},[xe,s]);const we=Et({mutationFn:async pe=>{const{data:Ge,error:tt}=await G.from("academy_categories").insert({name:pe,sort_order:fe.length}).select().single();if(tt)throw tt;return Ge},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"})}}),Ne=Et({mutationFn:async pe=>{let Ge=pe.existingThumbnailUrl;if(pe.thumbnail){const Ce=pe.thumbnail.name.split(".").pop(),et=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${Ce}`,{error:Ct}=await G.storage.from("academy-resources").upload(et,pe.thumbnail);if(Ct)throw Ct;const{data:Ot}=G.storage.from("academy-resources").getPublicUrl(et);Ge=Ot.publicUrl}const tt={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:Ge,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 st=pe.videoId;if(st){const{error:Ce}=await G.from("academy_videos").update(tt).eq("id",st);if(Ce)throw Ce}else{const{data:Ce,error:et}=await G.from("academy_videos").insert(tt).select().single();if(et)throw et;st=Ce.id,UHt(pe.video.title,Ce.id)}if(pe.resourcesToDelete.length>0){const{error:Ce}=await G.from("academy_resources").delete().in("id",pe.resourcesToDelete);if(Ce)throw Ce}for(let Ce=0;Ce0){const{error:Ce}=await G.from("academy_video_templates").insert(L.map(et=>({video_id:st,template_id:et})));if(Ce)throw Ce}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Ae(),l(!1),n({title:i?"Video updated":"Video created"})},onError:pe=>{n({title:"Error saving video",description:pe.message,variant:"destructive"})}}),Ve=Et({mutationFn:async pe=>{const{error:Ge}=await G.from("academy_videos").delete().eq("id",pe);if(Ge)throw Ge},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"})}}),Te=Et({mutationFn:async({id:pe,is_published:Ge})=>{const{error:tt}=await G.from("academy_videos").update({is_published:Ge}).eq("id",pe);if(tt)throw tt},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:pe=>{n({title:"Error updating video",description:pe.message,variant:"destructive"})}}),Ae=()=>{p({title:"",description:"",video_url:"",video_type:"bunny_stream",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),y(null),b(""),w([]),C([]),I([]),d(null),O([]),q(""),Z(null),Y(0),ae(!1),le(null)},ze=async pe=>{d(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||""),C(pe.resources||[]),w([]),I([]);const{data:Ge}=await G.from("academy_video_templates").select("template_id").eq("video_id",pe.id);O((Ge||[]).map(tt=>tt.template_id)),l(!0)},Ee=pe=>{var tt;const Ge=(tt=pe.target.files)==null?void 0:tt[0];Ge&&(y(Ge),b(URL.createObjectURL(Ge)))},ve=pe=>{const Ge=pe.target.files;if(Ge){const tt=Array.from(Ge).map(st=>({file:st,title:st.name.replace(/\.[^/.]+$/,"")}));w([...N,...tt])}pe.target.value=""},Re=pe=>{w(N.filter((Ge,tt)=>tt!==pe))},Ue=pe=>{I([...A,pe]),C(S.filter(Ge=>Ge.id!==pe))},ye=async()=>{if(!ee)return null;ae(!0),Y(0);try{const{data:pe,error:Ge}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||ee.name}});if(Ge)throw new Error(Ge.message);const{videoId:tt,libraryId:st}=pe;le(tt);const{data:Ce,error:et}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:tt}});if(et)throw new Error(et.message);const Ct=new XMLHttpRequest;return await new Promise((ut,Oe)=>{Ct.upload.addEventListener("progress",Xe=>{if(Xe.lengthComputable){const at=Math.round(Xe.loaded/Xe.total*100);Y(at)}}),Ct.addEventListener("load",()=>{Ct.status>=200&&Ct.status<300?ut():Oe(new Error(`Upload failed with status ${Ct.status}`))}),Ct.addEventListener("error",()=>Oe(new Error("Upload failed"))),Ct.open("PUT",Ce.uploadUrl),Ct.setRequestHeader("AccessKey",Ce.apiKey),Ct.send(ee)}),`https://player.mediadelivery.net/embed/${st}/${tt}`}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{ae(!1)}},ct=async pe=>{if(pe.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let Ge=u.video_url;if(u.video_type==="bunny_stream"&&ee&&!i){const tt=await ye();if(!tt)return;Ge=tt}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"&&!ee&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}Ne.mutate({video:{...u,video_url:Ge},thumbnail:f,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:N,resourcesToDelete:A})};return e.jsx(Ls,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:xe.length})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:xe.filter(pe=>pe.is_published).length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:pe=>{l(pe),pe||Ae()},children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add Video"]})}),e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:ct,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(ge,{children:"Description"}),e.jsx(Yg,{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(ge,{children:"Video Type"}),e.jsxs(zs,{value:u.video_type,onValueChange:pe=>{p({...u,video_type:pe,video_url:""}),Z(null)},disabled:ce,children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:YHt.map(pe=>e.jsx(yt,{value:pe.value,children:pe.label},pe.value))})]})]}),u.video_type==="bunny_stream"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs(ge,{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 tt;const Ge=(tt=pe.target.files)==null?void 0:tt[0];Ge&&Z(Ge)},disabled:ce}),ee&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(hn,{className:"h-4 w-4"}),ee.name," (",(ee.size/(1024*1024)).toFixed(1)," MB)"]}),ce&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(pi,{value:J,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[J,"%"]})]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(ge,{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(ge,{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(ge,{children:"Category"}),$?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:U,onChange:pe=>q(pe.target.value),placeholder:"New category 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:()=>{V(!1),q("")},children:e.jsx(Sr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(zs,{value:u.category_id,onValueChange:pe=>p({...u,category_id:pe}),children:[e.jsx(Os,{className:"flex-1",children:e.jsx(qs,{placeholder:"Select category"})}),e.jsx(Fs,{children:fe.map(pe=>e.jsx(yt,{value:pe.id,children:pe.name},pe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>V(!0),children:e.jsx(Bs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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:Ee,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(ge,{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(Da,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:ve,className:"hidden"})]})})]}),(S.length>0||N.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[S.map(pe=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(mn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:pe.title}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:pe.file_type}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>Ue(pe.id),className:"text-destructive hover:text-destructive",children:e.jsx(Sr,{className:"h-4 w-4"})})]},pe.id)),N.map((pe,Ge)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(mn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{value:pe.title,onChange:tt=>{const st=[...N];st[Ge].title=tt.target.value,w(st)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>Re(Ge),className:"text-destructive hover:text-destructive",children:e.jsx(Sr,{className:"h-4 w-4"})})]},Ge))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(Ott,{selectedTemplateIds:L,onChange:O}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{id:"is_published",checked:u.is_published,onCheckedChange:pe=>p({...u,is_published:pe})}),e.jsx(ge,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(gn,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:ce,children:"Cancel"}),e.jsx(K,{type:"submit",disabled:Ne.isPending||ce,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):Ne.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Ie,{children:e.jsx(Be,{className:"p-0",children:he?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):xe.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(hn,{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(As,{children:[e.jsx(Nt,{children:"Title"}),e.jsx(Nt,{children:"Category"}),e.jsx(Nt,{children:"Duration"}),e.jsx(Nt,{children:"Resources"}),e.jsx(Nt,{children:"Publish Date"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(Pn,{children:xe.map(pe=>e.jsxs(As,{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(hn,{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(Ye,{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(Ye,{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(Lr,{checked:pe.is_published,onCheckedChange:Ge=>Te.mutate({id:pe.id,is_published:Ge})})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ze(pe),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Ve.mutate(pe.id),className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},pe.id))})]})})})]})})};function QHt(){var Ne,Ve,Te;const t=es(),[s,r]=Sc(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,d]=k.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=k.useState(null),[f,y]=k.useState(""),[_,b]=k.useState([]),[N,w]=k.useState([]),[S,C]=k.useState([]),[A,I]=k.useState(null),{data:L,isLoading:O}=ft({queryKey:["resource-kits"],queryFn:async()=>{const{data:Ae,error:ze}=await G.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(ze)throw ze;return Ae}}),{data:U}=ft({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Ae,error:ze}=await G.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(ze)throw ze;return Ae}}),{data:q}=ft({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Ae,error:ze}=await G.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(ze)throw ze;return Ae}});k.useEffect(()=>{const Ae=s.get("edit");if(Ae&&L&&L.length>0&&U&&q){const ze=L.find(Ee=>Ee.id===Ae);ze&&(V(ze),r({},{replace:!0}))}},[L,U,q,s]);const $=()=>{d({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),y(""),b([]),w([]),C([]),l(null)},V=async Ae=>{l(Ae),d({name:Ae.name,description:Ae.description||"",publish_date:Ae.publish_date.split("T")[0],is_published:Ae.is_published}),y(Ae.featured_image_url||"");const ze=(U==null?void 0:U.filter(Re=>Re.kit_id===Ae.id))||[];b(ze.map(Re=>({id:Re.id,name:Re.name,file_url:Re.file_url,file_type:Re.file_type,file_size:Re.file_size,sort_order:Re.sort_order})));const Ee=(q==null?void 0:q.filter(Re=>Re.kit_id===Ae.id))||[];w(Ee.map(Re=>({id:Re.id,title:Re.title,canva_share_link:Re.canva_share_link,sort_order:Re.sort_order})));const{data:ve}=await G.from("resource_kit_templates").select("template_id").eq("kit_id",Ae.id);C((ve||[]).map(Re=>Re.template_id)),a(!0)},ee=Ae=>{var Ee;const ze=(Ee=Ae.target.files)==null?void 0:Ee[0];ze&&(p(ze),y(URL.createObjectURL(ze)))},Z=()=>{b([..._,{name:"",file_url:"",sort_order:_.length}])},J=Ae=>{b(_.filter((ze,Ee)=>Ee!==Ae))},Y=(Ae,ze,Ee)=>{const ve=[..._];ve[Ae]={...ve[Ae],[ze]:Ee},b(ve)},ce=()=>{w([...N,{title:"",canva_share_link:"",sort_order:N.length}])},ae=Ae=>{w(N.filter((ze,Ee)=>Ee!==Ae))},ie=(Ae,ze,Ee)=>{const ve=[...N];ve[Ae]={...ve[Ae],[ze]:Ee},w(ve)},le=(Ae,ze)=>{var ve;const Ee=(ve=ze.target.files)==null?void 0:ve[0];if(Ee){const Re=[..._],Ue=Ee.name.replace(/\.[^/.]+$/,"");Re[Ae]={...Re[Ae],file:Ee,file_type:Ee.type,file_size:Ee.size,name:Re[Ae].name||Ue},b(Re)}},fe=Et({mutationFn:async()=>{let Ae=(o==null?void 0:o.featured_image_url)||null;if(u){const Ue=u.name.split(".").pop(),ye=`${Date.now()}.${Ue}`,{error:ct}=await G.storage.from("resource-kits").upload(`featured/${ye}`,u);if(ct)throw ct;const{data:pe}=G.storage.from("resource-kits").getPublicUrl(`featured/${ye}`);Ae=pe.publicUrl}const ze={name:i.name,description:i.description||null,featured_image_url:Ae,publish_date:i.publish_date,is_published:i.is_published};let Ee;const ve=!o,Re=(o==null?void 0:o.is_published)||!1;if(o){const{error:Ue}=await G.from("resource_kits").update(ze).eq("id",o.id);if(Ue)throw Ue;Ee=o.id;const ye=(U==null?void 0:U.filter(Ce=>Ce.kit_id===o.id).map(Ce=>Ce.id))||[],ct=_.filter(Ce=>Ce.id).map(Ce=>Ce.id),pe=ye.filter(Ce=>!ct.includes(Ce));pe.length>0&&await G.from("resource_kit_files").delete().in("id",pe);const Ge=(q==null?void 0:q.filter(Ce=>Ce.kit_id===o.id).map(Ce=>Ce.id))||[],tt=N.filter(Ce=>Ce.id).map(Ce=>Ce.id),st=Ge.filter(Ce=>!tt.includes(Ce));st.length>0&&await G.from("resource_kit_links").delete().in("id",st)}else{const{data:Ue,error:ye}=await G.from("resource_kits").insert(ze).select().single();if(ye)throw ye;Ee=Ue.id}for(let Ue=0;Ue<_.length;Ue++){const ye=_[Ue];let ct=ye.file_url;if(ye.file){const pe=ye.file.name.split(".").pop(),Ge=`${Date.now()}-${Ue}.${pe}`,{error:tt}=await G.storage.from("resource-kits").upload(`files/${Ge}`,ye.file);if(tt)throw tt;const{data:st}=G.storage.from("resource-kits").getPublicUrl(`files/${Ge}`);ct=st.publicUrl}ye.id?await G.from("resource_kit_files").update({name:ye.name,file_url:ct,file_type:ye.file_type,file_size:ye.file_size,sort_order:Ue}).eq("id",ye.id):ct&&ye.name&&await G.from("resource_kit_files").insert({kit_id:Ee,name:ye.name,file_url:ct,file_type:ye.file_type,file_size:ye.file_size,sort_order:Ue})}for(let Ue=0;Ue0){const{error:Ue}=await G.from("resource_kit_templates").insert(S.map(ye=>({kit_id:Ee,template_id:ye})));if(Ue)throw Ue}return{kitId:Ee,kitName:i.name,isNewKit:ve,wasPublished:Re,isPublished:i.is_published}},onSuccess:Ae=>{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"),Ae.isPublished&&(Ae.isNewKit||!Ae.wasPublished)&&HHt(Ae.kitName,Ae.kitId),a(!1),$()},onError:Ae=>{me.error("Failed to save resource kit: "+Ae.message)}}),xe=Et({mutationFn:async Ae=>{const{error:ze}=await G.from("resource_kits").delete().eq("id",Ae);if(ze)throw ze},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),me.success("Resource kit deleted")},onError:Ae=>{me.error("Failed to delete: "+Ae.message)}}),he=Ae=>{if(Ae.preventDefault(),!i.name){me.error("Please enter a name");return}fe.mutate()},we=Ae=>(U==null?void 0:U.filter(ze=>ze.kit_id===Ae).length)||0;return e.jsx(Ls,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.length)||0})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.filter(Ae=>Ae.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{$(),a(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(Ie,{children:e.jsx(Be,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Files"}),e.jsx(Nt,{children:"Publish Date"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:O?e.jsx(As,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(L==null?void 0:L.length)===0?e.jsx(As,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No resource kits yet. Create your first one!"})}):L==null?void 0:L.map(Ae=>e.jsxs(As,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ae.featured_image_url?e.jsx("img",{src:Ae.featured_image_url,alt:Ae.name,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(al,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ae.name}),Ae.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ae.description})]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(mn,{className:"h-4 w-4 text-muted-foreground"}),we(Ae.id)]})}),e.jsx(dt,{children:gs(new Date(Ae.publish_date),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Ae.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Ae.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const ze=(U==null?void 0:U.filter(ve=>ve.kit_id===Ae.id))||[],Ee=(q==null?void 0:q.filter(ve=>ve.kit_id===Ae.id))||[];I({...Ae,files:ze,links:Ee})},children:e.jsx(jn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>V(Ae),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&xe.mutate(Ae.id)},children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})})]},Ae.id))})]})})}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:o?"Edit Resource Kit":"Add Resource Kit"})}),e.jsxs("form",{onSubmit:he,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(al,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Fe,{type:"file",accept:"image/*",onChange:ee})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"name",children:"Name *"}),e.jsx(Fe,{id:"name",value:i.name,onChange:Ae=>d({...i,name:Ae.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Description"}),e.jsx(Yg,{content:i.description,onChange:Ae=>d({...i,description:Ae}),placeholder:"Brief description of this resource kit",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Fe,{id:"publish_date",type:"date",value:i.publish_date,onChange:Ae=>d({...i,publish_date:Ae.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(Lr,{checked:i.is_published,onCheckedChange:Ae=>d({...i,is_published:Ae})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:i.is_published?"Visible to agents":"Hidden from agents"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ge,{children:"Resource Files"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Z,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add File"]})]}),_.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No files added yet. Click "Add File" to include resources.'}):e.jsx("div",{className:"space-y-3",children:_.map((Ae,ze)=>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 ",ze+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>J(ze),children:e.jsx(Sr,{className:"h-4 w-4"})})]}),e.jsx(Fe,{placeholder:"File name (e.g., Getting Started Guide)",value:Ae.name,onChange:Ee=>Y(ze,"name",Ee.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{type:"file",onChange:Ee=>le(ze,Ee),className:"flex-1"}),Ae.file_url&&!Ae.file&&e.jsx("a",{href:Ae.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Ae.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},ze))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ge,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ce,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Canva Link"]})]}),N.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:N.map((Ae,ze)=>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 ",ze+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ae(ze),children:e.jsx(Sr,{className:"h-4 w-4"})})]}),e.jsx(Fe,{placeholder:"Link title (e.g., Social Media Post Template)",value:Ae.title,onChange:Ee=>ie(ze,"title",Ee.target.value)}),e.jsx(Fe,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Ae.canva_share_link,onChange:Ee=>ie(ze,"canva_share_link",Ee.target.value)})]},ze))})]}),e.jsx(Ott,{selectedTemplateIds:S,onChange:C}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:fe.isPending,children:fe.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsx(ks,{children:e.jsx(bs,{children:A==null?void 0:A.name})}),e.jsxs("div",{className:"space-y-4",children:[(A==null?void 0:A.featured_image_url)&&e.jsx("img",{src:A.featured_image_url,alt:A.name,className:"w-full h-48 object-cover rounded-lg"}),(A==null?void 0:A.description)&&e.jsx("p",{className:"text-muted-foreground",children:A.description}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Resource Files (",((Ne=A==null?void 0:A.files)==null?void 0:Ne.length)||0,")"]}),((Ve=A==null?void 0:A.files)==null?void 0:Ve.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:(Te=A==null?void 0:A.files)==null?void 0:Te.map(Ae=>e.jsxs("a",{href:Ae.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(mn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ae.name})]},Ae.id))})]}),(A==null?void 0:A.links)&&A.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Canva Links (",A.links.length,")"]}),e.jsx("div",{className:"space-y-2",children:A.links.map(Ae=>e.jsxs("a",{href:Ae.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(go,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ae.title})]},Ae.id))})]})]})]})})]})})}const JHt=()=>{const{user:t}=$s(),{toast:s}=va(),r=es(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,d]=k.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,p]=k.useState(null),[f,y]=k.useState(""),{data:_=[],isLoading:b}=ft({queryKey:["social-swag-admin"],queryFn:async()=>{const{data:q,error:$}=await G.from("social_swag").select("*").order("publish_date",{ascending:!1});if($)throw $;const{data:V,error:ee}=await G.from("social_swag_links").select("*").order("sort_order");if(ee)throw ee;return q.map(J=>({...J,links:(V==null?void 0:V.filter(Y=>Y.swag_id===J.id))||[]}))}}),N=Et({mutationFn:async q=>{let $=q.existingImageUrl;if(q.image){const ce=q.image.name.split(".").pop(),ae=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ce}`,{error:ie}=await G.storage.from("template-previews").upload(ae,q.image);if(ie)throw ie;const{data:le}=G.storage.from("template-previews").getPublicUrl(ae);$=le.publicUrl}const V={title:q.item.title,description:q.item.description||null,preview_image_url:$,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 ee=q.itemId;const Z=!ee,J=(o==null?void 0:o.is_published)||!1;if(ee){const{error:ce}=await G.from("social_swag").update(V).eq("id",ee);if(ce)throw ce;await G.from("social_swag_links").delete().eq("swag_id",ee)}else{const{data:ce,error:ae}=await G.from("social_swag").insert(V).select().single();if(ae)throw ae;ee=ce.id}const Y=q.item.links.filter(ce=>ce.title.trim()&&ce.canva_share_link.trim());if(Y.length>0){const ce=Y.map((ie,le)=>({swag_id:ee,title:ie.title.trim(),canva_share_link:ie.canva_share_link.trim(),sort_order:le})),{error:ae}=await G.from("social_swag_links").insert(ce);if(ae)throw ae}return{itemId:ee,itemTitle:q.item.title,isNewItem:Z,wasPublished:J,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)&&Q_e(q.itemTitle,q.itemId),a(!1),S()},onError:q=>{s({title:"Error saving item",description:q.message,variant:"destructive"})}}),w=Et({mutationFn:async q=>{const{error:$}=await G.from("social_swag").delete().eq("id",q);if($)throw $},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"})}}),S=()=>{d({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)},C=q=>{l(q),d({title:q.title,description:q.description||"",publish_date:q.publish_date?new Date(q.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:q.is_published,links:q.links&&q.links.length>0?q.links.map($=>({id:$.id,title:$.title,canva_share_link:$.canva_share_link,sort_order:$.sort_order})):[{title:"",canva_share_link:"",sort_order:0}]}),y(q.preview_image_url||""),a(!0)},A=q=>{var V;const $=(V=q.target.files)==null?void 0:V[0];$&&(p($),y(URL.createObjectURL($)))},I=()=>{d({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},L=q=>{if(i.links.length<=1)return;const $=i.links.filter((V,ee)=>ee!==q);d({...i,links:$})},O=(q,$,V)=>{const ee=[...i.links];ee[q]={...ee[q],[$]:V},d({...i,links:ee})},U=q=>{if(q.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}N.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(Ls,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(q=>q.is_published).length})})]})]}),e.jsxs(fs,{open:n,onOpenChange:q=>{a(q),q||S()},children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add Item"]})}),e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:o?"Edit Item":"Add New Item"})}),e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"title",children:"Title *"}),e.jsx(Fe,{id:"title",value:i.title,onChange:q=>d({...i,title:q.target.value}),placeholder:"Enter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Description"}),e.jsx(Yg,{content:i.description,onChange:q=>d({...i,description:q}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Fe,{id:"publish_date",type:"date",value:i.publish_date,onChange:q=>d({...i,publish_date:q.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Lr,{id:"is_published",checked:i.is_published,onCheckedChange:q=>d({...i,is_published:q})}),e.jsx(ge,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(Sr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(Uo,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(Fe,{type:"file",accept:"image/*",onChange:A,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:I,children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((q,$)=>e.jsx(Ie,{children:e.jsxs(Be,{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 ",$+1]}),i.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>L($),children:e.jsx(Sr,{className:"h-3 w-3"})})]}),e.jsx(Fe,{placeholder:"Link title (e.g., Instagram Post)",value:q.title,onChange:V=>O($,"title",V.target.value)}),e.jsx(Fe,{placeholder:"Canva share link",value:q.canva_share_link,onChange:V=>O($,"canva_share_link",V.target.value)})]})},$))]}),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:N.isPending,children:N.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ie,{children:e.jsx(Be,{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(As,{children:[e.jsx(Nt,{className:"w-16",children:"Preview"}),e.jsx(Nt,{children:"Title"}),e.jsx(Nt,{children:"Links"}),e.jsx(Nt,{children:"Publish Date"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:_.map(q=>{var $;return e.jsxs(As,{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(Uo,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(dt,{className:"font-medium",children:q.title}),e.jsxs(dt,{children:[(($=q.links)==null?void 0:$.length)||0," links"]}),e.jsx(dt,{children:new Date(q.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(Ye,{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(jn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(q),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&w.mutate(q.id)},children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},q.id)})})]})})})]})})};function eGt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const The=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function aE(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function C4e(t){return"nodeType"in t}function vp(t){var s,r;return t?aE(t)?t:C4e(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function M4e(t){const{Document:s}=vp(t);return t instanceof s}function aO(t){return aE(t)?!1:t instanceof vp(t).HTMLElement}function Ftt(t){return t instanceof vp(t).SVGElement}function iE(t){return t?aE(t)?t.document:C4e(t)?M4e(t)?t:aO(t)||Ftt(t)?t.ownerDocument:document:document:document}const f0=The?k.useLayoutEffect:k.useEffect;function T4e(t){const s=k.useRef(t);return f0(()=>{s.current=t}),k.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=k.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function kD(t,s){s===void 0&&(s=[t]);const r=k.useRef(t);return f0(()=>{r.current!==t&&(r.current=t)},s),r}function iO(t,s){const r=k.useRef();return k.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function pce(t){const s=T4e(t),r=k.useRef(null),n=k.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function J_e(t){const s=k.useRef();return k.useEffect(()=>{s.current=t},[t]),s.current}let Mye={};function oO(t,s){return k.useMemo(()=>{if(s)return s;const r=Mye[t]==null?0:Mye[t]+1;return Mye[t]=r,t+"-"+r},[t,s])}function ztt(t){return function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a{const i=Object.entries(l);for(const[d,u]of i){const p=o[d];p!=null&&(o[d]=p+t*u)}return o},{...s})}}const JM=ztt(1),SD=ztt(-1);function sGt(t){return"clientX"in t&&"clientY"in t}function A4e(t){if(!t)return!1;const{KeyboardEvent:s}=vp(t.target);return s&&t instanceof s}function rGt(t){if(!t)return!1;const{TouchEvent:s}=vp(t.target);return s&&t instanceof s}function ebe(t){if(rGt(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 sGt(t)?{x:t.clientX,y:t.clientY}:null}const oC=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[oC.Translate.toString(t),oC.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),wDe="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function nGt(t){return t.matches(wDe)?t:t.querySelector(wDe)}const aGt={display:"none"};function iGt(t){let{id:s,value:r}=t;return ht.createElement("div",{id:s,style:aGt},r)}function oGt(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 lGt(){const[t,s]=k.useState("");return{announce:k.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const Btt=k.createContext(null);function cGt(t){const s=k.useContext(Btt);k.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function dGt(){const[t]=k.useState(()=>new Set),s=k.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[k.useCallback(n=>{let{type:a,event:o}=n;t.forEach(l=>{var i;return(i=l[a])==null?void 0:i.call(l,o)})},[t]),s]}const uGt={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. `},hGt={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 mGt(t){let{announcements:s=hGt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=uGt}=t;const{announce:o,announcement:l}=lGt(),i=oO("DndLiveRegion"),[d,u]=k.useState(!1);if(k.useEffect(()=>{u(!0)},[]),cGt(k.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])),!d)return null;const p=ht.createElement(ht.Fragment,null,ht.createElement(iGt,{id:n,value:a.draggable}),ht.createElement(oGt,{id:i,announcement:l}));return r?ap.createPortal(p,r):p}var su;(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"})(su||(su={}));function fce(){}function xce(t,s){return k.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function E4e(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const Wg=Object.freeze({x:0,y:0});function $tt(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function qtt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function pGt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function jDe(t){let{left:s,top:r,height:n,width:a}=t;return[{x:s,y:r},{x:s+a,y:r},{x:s,y:r+n},{x:s+a,y:r+n}]}function Utt(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function NDe(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 P4e=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=NDe(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=$tt(NDe(d),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(qtt)},fGt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=jDe(s),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=jDe(d),p=a.reduce((y,_,b)=>y+$tt(u[b],_),0),f=Number((p/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:f}})}}return o.sort(qtt)};function xGt(t,s){const r=Math.max(s.top,t.top),n=Math.max(s.left,t.left),a=Math.min(s.left+s.width,t.left+t.width),o=Math.min(s.top+s.height,t.top+t.height),l=a-n,i=o-r;if(n{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=[];for(const o of n){const{id:l}=o,i=r.get(l);if(i){const d=xGt(i,s);d>0&&a.push({id:l,data:{droppableContainer:o,value:d}})}}return a.sort(pGt)};function yGt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Vtt(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:Wg}function vGt(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 _Gt=vGt(1);function bGt(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 wGt(t,s,r){const n=bGt(s);if(!n)return t;const{scaleX:a,scaleY:o,x:l,y:i}=n,d=t.left-l-(1-a)*parseFloat(r),u=t.top-i-(1-o)*parseFloat(r.slice(r.indexOf(" ")+1)),p=a?t.width/a:t.width,f=o?t.height/o:t.height;return{width:p,height:f,top:u,right:d+p,bottom:u+f,left:d}}const jGt={ignoreTransform:!1};function oE(t,s){s===void 0&&(s=jGt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:p}=vp(t).getComputedStyle(t);u&&(r=wGt(r,u,p))}const{top:n,left:a,width:o,height:l,bottom:i,right:d}=r;return{top:n,left:a,width:o,height:l,bottom:i,right:d}}function kDe(t){return oE(t,{ignoreTransform:!0})}function NGt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function kGt(t,s){return s===void 0&&(s=vp(t).getComputedStyle(t)),s.position==="fixed"}function SGt(t,s){s===void 0&&(s=vp(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 Ahe(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(M4e(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!aO(a)||Ftt(a)||r.includes(a))return r;const o=vp(t).getComputedStyle(a);return a!==t&&SGt(a,o)&&r.push(a),kGt(a,o)?r:n(a.parentNode)}return t?n(t):r}function Htt(t){const[s]=Ahe(t,1);return s??null}function Tye(t){return!The||!t?null:aE(t)?t:C4e(t)?M4e(t)||t===iE(t).scrollingElement?window:aO(t)?t:null:null}function Gtt(t){return aE(t)?t.scrollX:t.scrollLeft}function Wtt(t){return aE(t)?t.scrollY:t.scrollTop}function tbe(t){return{x:Gtt(t),y:Wtt(t)}}var Pu;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Pu||(Pu={}));function Ktt(t){return!The||!t?!1:t===document.scrollingElement}function Ztt(t){const s={x:0,y:0},r=Ktt(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 CGt={x:.2,y:.2};function MGt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:d}=r;n===void 0&&(n=10),a===void 0&&(a=CGt);const{isTop:u,isBottom:p,isLeft:f,isRight:y}=Ztt(t),_={x:0,y:0},b={x:0,y:0},N={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+N.height?(_.y=Pu.Backward,b.y=n*Math.abs((s.top+N.height-o)/N.height)):!p&&d>=s.bottom-N.height&&(_.y=Pu.Forward,b.y=n*Math.abs((s.bottom-N.height-d)/N.height)),!y&&i>=s.right-N.width?(_.x=Pu.Forward,b.x=n*Math.abs((s.right-N.width-i)/N.width)):!f&&l<=s.left+N.width&&(_.x=Pu.Backward,b.x=n*Math.abs((s.left+N.width-l)/N.width)),{direction:_,speed:b}}function TGt(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:l}=window;return{top:0,left:0,right:o,bottom:l,width:o,height:l}}const{top:s,left:r,right:n,bottom:a}=t.getBoundingClientRect();return{top:s,left:r,right:n,bottom:a,width:t.clientWidth,height:t.clientHeight}}function Ytt(t){return t.reduce((s,r)=>JM(s,tbe(r)),Wg)}function AGt(t){return t.reduce((s,r)=>s+Gtt(r),0)}function EGt(t){return t.reduce((s,r)=>s+Wtt(r),0)}function PGt(t,s){if(s===void 0&&(s=oE),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);Htt(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const IGt=[["x",["left","right"],AGt],["y",["top","bottom"],EGt]];class I4e{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=Ahe(r),a=Ytt(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of IGt)for(const d of l)Object.defineProperty(this,d,{get:()=>{const u=i(n),p=a[o]-u;return this.rect[d]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class g8{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 LGt(t){const{EventTarget:s}=vp(t);return t instanceof s?t:iE(t)}function Aye(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 ix;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(ix||(ix={}));function SDe(t){t.preventDefault()}function DGt(t){t.stopPropagation()}var eo;(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"})(eo||(eo={}));const Xtt={start:[eo.Space,eo.Enter],cancel:[eo.Esc],end:[eo.Space,eo.Enter,eo.Tab]},RGt=(t,s)=>{let{currentCoordinates:r}=s;switch(t.code){case eo.Right:return{...r,x:r.x+25};case eo.Left:return{...r,x:r.x-25};case eo.Down:return{...r,y:r.y+25};case eo.Up:return{...r,y:r.y-25}}};class L4e{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 g8(iE(r)),this.windowListeners=new g8(vp(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ix.Resize,this.handleCancel),this.windowListeners.add(ix.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ix.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&PGt(n),r(Wg)}handleKeyDown(s){if(A4e(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=Xtt,coordinateGetter:l=RGt,scrollBehavior:i="smooth"}=a,{code:d}=s;if(o.end.includes(d)){this.handleEnd(s);return}if(o.cancel.includes(d)){this.handleCancel(s);return}const{collisionRect:u}=n.current,p=u?{x:u.left,y:u.top}:Wg;this.referenceCoordinates||(this.referenceCoordinates=p);const f=l(s,{active:r,context:n.current,currentCoordinates:p});if(f){const y=SD(f,p),_={x:0,y:0},{scrollableAncestors:b}=n.current;for(const N of b){const w=s.code,{isTop:S,isRight:C,isLeft:A,isBottom:I,maxScroll:L,minScroll:O}=Ztt(N),U=TGt(N),q={x:Math.min(w===eo.Right?U.right-U.width/2:U.right,Math.max(w===eo.Right?U.left:U.left+U.width/2,f.x)),y:Math.min(w===eo.Down?U.bottom-U.height/2:U.bottom,Math.max(w===eo.Down?U.top:U.top+U.height/2,f.y))},$=w===eo.Right&&!C||w===eo.Left&&!A,V=w===eo.Down&&!I||w===eo.Up&&!S;if($&&q.x!==f.x){const ee=N.scrollLeft+y.x,Z=w===eo.Right&&ee<=L.x||w===eo.Left&&ee>=O.x;if(Z&&!y.y){N.scrollTo({left:ee,behavior:i});return}Z?_.x=N.scrollLeft-ee:_.x=w===eo.Right?N.scrollLeft-L.x:N.scrollLeft-O.x,_.x&&N.scrollBy({left:-_.x,behavior:i});break}else if(V&&q.y!==f.y){const ee=N.scrollTop+y.y,Z=w===eo.Down&&ee<=L.y||w===eo.Up&&ee>=O.y;if(Z&&!y.x){N.scrollTo({top:ee,behavior:i});return}Z?_.y=N.scrollTop-ee:_.y=w===eo.Down?N.scrollTop-L.y:N.scrollTop-O.y,_.y&&N.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(s,JM(SD(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()}}L4e.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=Xtt,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 CDe(t){return!!(t&&"distance"in t)}function MDe(t){return!!(t&&"delay"in t)}class D4e{constructor(s,r,n){var a;n===void 0&&(n=LGt(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=iE(l),this.documentListeners=new g8(this.document),this.listeners=new g8(n),this.windowListeners=new g8(vp(l)),this.initialCoordinates=(a=ebe(o))!=null?a:Wg,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(ix.Resize,this.handleCancel),this.windowListeners.add(ix.DragStart,SDe),this.windowListeners.add(ix.VisibilityChange,this.handleCancel),this.windowListeners.add(ix.ContextMenu,SDe),this.documentListeners.add(ix.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(MDe(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(CDe(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(ix.Click,DGt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ix.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:n,initialCoordinates:a,props:o}=this,{onMove:l,options:{activationConstraint:i}}=o;if(!a)return;const d=(r=ebe(s))!=null?r:Wg,u=SD(a,d);if(!n&&i){if(CDe(i)){if(i.tolerance!=null&&Aye(u,i.tolerance))return this.handleCancel();if(Aye(u,i.distance))return this.handleStart()}if(MDe(i)&&Aye(u,i.tolerance))return this.handleCancel();this.handlePending(i,u);return}s.cancelable&&s.preventDefault(),l(d)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===eo.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const OGt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class lO extends D4e{constructor(s){const{event:r}=s,n=iE(r.target);super(s,OGt,n)}}lO.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 FGt={move:{name:"mousemove"},end:{name:"mouseup"}};var sbe;(function(t){t[t.RightClick=2]="RightClick"})(sbe||(sbe={}));class zGt extends D4e{constructor(s){super(s,FGt,iE(s.event.target))}}zGt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===sbe.RightClick?!1:(n==null||n({event:r}),!0)}}];const Eye={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class BGt extends D4e{constructor(s){super(s,Eye)}static setup(){return window.addEventListener(Eye.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Eye.move.name,s)};function s(){}}}BGt.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 y8;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(y8||(y8={}));var gce;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(gce||(gce={}));function $Gt(t){let{acceleration:s,activator:r=y8.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=gce.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:p,delta:f,threshold:y}=t;const _=UGt({delta:f,disabled:!o}),[b,N]=tGt(),w=k.useRef({x:0,y:0}),S=k.useRef({x:0,y:0}),C=k.useMemo(()=>{switch(r){case y8.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case y8.DraggableRect:return a}},[r,a,d]),A=k.useRef(null),I=k.useCallback(()=>{const O=A.current;if(!O)return;const U=w.current.x*S.current.x,q=w.current.y*S.current.y;O.scrollBy(U,q)},[]),L=k.useMemo(()=>i===gce.TreeOrder?[...u].reverse():u,[i,u]);k.useEffect(()=>{if(!o||!u.length||!C){N();return}for(const O of L){if((n==null?void 0:n(O))===!1)continue;const U=u.indexOf(O),q=p[U];if(!q)continue;const{direction:$,speed:V}=MGt(O,q,C,s,y);for(const ee of["x","y"])_[ee][$[ee]]||(V[ee]=0,$[ee]=0);if(V.x>0||V.y>0){N(),A.current=O,b(I,l),w.current=V,S.current=$;return}}w.current={x:0,y:0},S.current={x:0,y:0},N()},[s,I,n,N,o,l,JSON.stringify(C),JSON.stringify(_),b,u,L,p,JSON.stringify(y)])}const qGt={x:{[Pu.Backward]:!1,[Pu.Forward]:!1},y:{[Pu.Backward]:!1,[Pu.Forward]:!1}};function UGt(t){let{delta:s,disabled:r}=t;const n=J_e(s);return iO(a=>{if(r||!n||!a)return qGt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[Pu.Backward]:a.x[Pu.Backward]||o.x===-1,[Pu.Forward]:a.x[Pu.Forward]||o.x===1},y:{[Pu.Backward]:a.y[Pu.Backward]||o.y===-1,[Pu.Forward]:a.y[Pu.Forward]||o.y===1}}},[r,s,n])}function VGt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return iO(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function HGt(t,s){return k.useMemo(()=>t.reduce((r,n)=>{const{sensor:a}=n,o=a.activators.map(l=>({eventName:l.eventName,handler:s(l.handler,n)}));return[...r,...o]},[]),[t,s])}var CD;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(CD||(CD={}));var rbe;(function(t){t.Optimized="optimized"})(rbe||(rbe={}));const TDe=new Map;function GGt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=k.useState(null),{frequency:i,measure:d,strategy:u}=a,p=k.useRef(t),f=w(),y=kD(f),_=k.useCallback(function(S){S===void 0&&(S=[]),!y.current&&l(C=>C===null?S:C.concat(S.filter(A=>!C.includes(A))))},[y]),b=k.useRef(null),N=iO(S=>{if(f&&!r)return TDe;if(!S||S===TDe||p.current!==t||o!=null){const C=new Map;for(let A of t){if(!A)continue;if(o&&o.length>0&&!o.includes(A.id)&&A.rect.current){C.set(A.id,A.rect.current);continue}const I=A.node.current,L=I?new I4e(d(I),I):null;A.rect.current=L,L&&C.set(A.id,L)}return C}return S},[t,o,r,f,d]);return k.useEffect(()=>{p.current=t},[t]),k.useEffect(()=>{f||_()},[r,f]),k.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),k.useEffect(()=>{f||typeof i!="number"||b.current!==null||(b.current=setTimeout(()=>{_(),b.current=null},i))},[i,f,_,...n]),{droppableRects:N,measureDroppableContainers:_,measuringScheduled:o!=null};function w(){switch(u){case CD.Always:return!1;case CD.BeforeDragging:return r;default:return!r}}}function Qtt(t,s){return iO(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function WGt(t,s){return Qtt(t,s)}function KGt(t){let{callback:s,disabled:r}=t;const n=T4e(s),a=k.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return k.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function Ehe(t){let{callback:s,disabled:r}=t;const n=T4e(s),a=k.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return k.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function ZGt(t){return new I4e(oE(t),t)}function ADe(t,s,r){s===void 0&&(s=ZGt);const[n,a]=k.useState(null);function o(){a(d=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=d??r)!=null?u:null}const p=s(t);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const l=KGt({callback(d){if(t)for(const u of d){const{type:p,target:f}=u;if(p==="childList"&&f instanceof HTMLElement&&f.contains(t)){o();break}}}}),i=Ehe({callback:o});return f0(()=>{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 YGt(t){const s=Qtt(t);return Vtt(t,s)}const EDe=[];function XGt(t){const s=k.useRef(t),r=iO(n=>t?n&&n!==EDe&&t&&s.current&&t.parentNode===s.current.parentNode?n:Ahe(t):EDe,[t]);return k.useEffect(()=>{s.current=t},[t]),r}function QGt(t){const[s,r]=k.useState(null),n=k.useRef(t),a=k.useCallback(o=>{const l=Tye(o.target);l&&r(i=>i?(i.set(l,tbe(l)),new Map(i)):null)},[]);return k.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(d=>{const u=Tye(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,tbe(u)]):null}).filter(d=>d!=null);r(i.length?new Map(i):null),n.current=t}return()=>{l(t),l(o)};function l(i){i.forEach(d=>{const u=Tye(d);u==null||u.removeEventListener("scroll",a)})}},[a,t]),k.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>JM(o,l),Wg):Ytt(t):Wg,[t,s])}function PDe(t,s){s===void 0&&(s=[]);const r=k.useRef(null);return k.useEffect(()=>{r.current=null},s),k.useEffect(()=>{const n=t!==Wg;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?SD(t,r.current):Wg}function JGt(t){k.useEffect(()=>{if(!The)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 eWt(t,s){return k.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:o}=n;return r[a]=l=>{o(l,s)},r},{}),[t,s])}function Jtt(t){return k.useMemo(()=>t?NGt(t):null,[t])}const IDe=[];function tWt(t,s){s===void 0&&(s=oE);const[r]=t,n=Jtt(r?vp(r):null),[a,o]=k.useState(IDe);function l(){o(()=>t.length?t.map(d=>Ktt(d)?n:new I4e(s(d),d)):IDe)}const i=Ehe({callback:l});return f0(()=>{i==null||i.disconnect(),l(),t.forEach(d=>i==null?void 0:i.observe(d))},[t]),a}function sWt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return aO(s)?s:t}function rWt(t){let{measure:s}=t;const[r,n]=k.useState(null),a=k.useCallback(u=>{for(const{target:p}of u)if(aO(p)){n(f=>{const y=s(p);return f?{...f,width:y.width,height:y.height}:y});break}},[s]),o=Ehe({callback:a}),l=k.useCallback(u=>{const p=sWt(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?s(p):null)},[s,o]),[i,d]=pce(l);return k.useMemo(()=>({nodeRef:i,rect:r,setRef:d}),[r,i,d])}const nWt=[{sensor:lO,options:{}},{sensor:L4e,options:{}}],aWt={current:{}},ooe={draggable:{measure:kDe},droppable:{measure:kDe,strategy:CD.WhileDragging,frequency:rbe.Optimized},dragOverlay:{measure:oE}};class v8 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 iWt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new v8,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:fce},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ooe,measureDroppableContainers:fce,windowRect:null,measuringScheduled:!1},oWt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:fce,draggableNodes:new Map,over:null,measureDroppableContainers:fce},Phe=k.createContext(oWt),est=k.createContext(iWt);function lWt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new v8}}}function cWt(t,s){switch(s.type){case su.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case su.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 su.DragEnd:case su.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case su.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new v8(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case su.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 v8(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case su.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new v8(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function dWt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=k.useContext(Phe),o=J_e(n),l=J_e(r==null?void 0:r.id);return k.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!A4e(o)||document.activeElement===o.target)return;const i=a.get(l);if(!i)return;const{activatorNode:d,node:u}=i;if(!d.current&&!u.current)return;requestAnimationFrame(()=>{for(const p of[d.current,u.current]){if(!p)continue;const f=nGt(p);if(f){f.focus();break}}})}},[n,s,a,l,o]),null}function uWt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function hWt(t){return k.useMemo(()=>({draggable:{...ooe.draggable,...t==null?void 0:t.draggable},droppable:{...ooe.droppable,...t==null?void 0:t.droppable},dragOverlay:{...ooe.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 mWt(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=k.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;f0(()=>{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=Vtt(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=Htt(u);y&&y.scrollBy({top:f.y,left:f.x})}},[s,l,i,n,r])}const tst=k.createContext({...Wg,scaleX:1,scaleY:1});var V_;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(V_||(V_={}));const R4e=k.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:d=!0,children:u,sensors:p=nWt,collisionDetection:f=gGt,measuring:y,modifiers:_,...b}=s;const N=k.useReducer(cWt,void 0,lWt),[w,S]=N,[C,A]=dGt(),[I,L]=k.useState(V_.Uninitialized),O=I===V_.Initialized,{draggable:{active:U,nodes:q,translate:$},droppable:{containers:V}}=w,ee=U!=null?q.get(U):null,Z=k.useRef({initial:null,translated:null}),J=k.useMemo(()=>{var bn;return U!=null?{id:U,data:(bn=ee==null?void 0:ee.data)!=null?bn:aWt,rect:Z}:null},[U,ee]),Y=k.useRef(null),[ce,ae]=k.useState(null),[ie,le]=k.useState(null),fe=kD(b,Object.values(b)),xe=oO("DndDescribedBy",l),he=k.useMemo(()=>V.getEnabled(),[V]),we=hWt(y),{droppableRects:Ne,measureDroppableContainers:Ve,measuringScheduled:Te}=GGt(he,{dragging:O,dependencies:[$.x,$.y],config:we.droppable}),Ae=VGt(q,U),ze=k.useMemo(()=>ie?ebe(ie):null,[ie]),Ee=Rn(),ve=WGt(Ae,we.draggable.measure);mWt({activeNode:U!=null?q.get(U):null,config:Ee.layoutShiftCompensation,initialRect:ve,measure:we.draggable.measure});const Re=ADe(Ae,we.draggable.measure,ve),Ue=ADe(Ae?Ae.parentElement:null),ye=k.useRef({activatorEvent:null,active:null,activeNode:Ae,collisionRect:null,collisions:null,droppableRects:Ne,draggableNodes:q,draggingNode:null,draggingNodeRect:null,droppableContainers:V,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ct=V.getNodeFor((r=ye.current.over)==null?void 0:r.id),pe=rWt({measure:we.dragOverlay.measure}),Ge=(n=pe.nodeRef.current)!=null?n:Ae,tt=O?(a=pe.rect)!=null?a:Re:null,st=!!(pe.nodeRef.current&&pe.rect),Ce=YGt(st?null:Re),et=Jtt(Ge?vp(Ge):null),Ct=XGt(O?ct??Ae:null),Ot=tWt(Ct),ut=uWt(_,{transform:{x:$.x-Ce.x,y:$.y-Ce.y,scaleX:1,scaleY:1},activatorEvent:ie,active:J,activeNodeRect:Re,containerNodeRect:Ue,draggingNodeRect:tt,over:ye.current.over,overlayNodeRect:pe.rect,scrollableAncestors:Ct,scrollableAncestorRects:Ot,windowRect:et}),Oe=ze?JM(ze,$):null,Xe=QGt(Ct),at=PDe(Xe),Ke=PDe(Xe,[Re]),He=JM(ut,at),gt=tt?_Gt(tt,ut):null,Mt=J&>?f({active:J,collisionRect:gt,droppableRects:Ne,droppableContainers:he,pointerCoordinates:Oe}):null,Wt=Utt(Mt,"id"),[xs,Cs]=k.useState(null),Us=st?ut:JM(ut,Ke),Ar=yGt(Us,(o=xs==null?void 0:xs.rect)!=null?o:null,Re),Bt=k.useRef(null),Xs=k.useCallback((bn,ir)=>{let{sensor:or,options:hr}=ir;if(Y.current==null)return;const an=q.get(Y.current);if(!an)return;const Gr=bn.nativeEvent,Va=new or({active:Y.current,activeNode:an,event:Gr,options:hr,context:ye,onAbort(Xt){if(!q.get(Xt))return;const{onDragAbort:Cr}=fe.current,Fn={id:Xt};Cr==null||Cr(Fn),C({type:"onDragAbort",event:Fn})},onPending(Xt,Qa,Cr,Fn){if(!q.get(Xt))return;const{onDragPending:Mr}=fe.current,On={id:Xt,constraint:Qa,initialCoordinates:Cr,offset:Fn};Mr==null||Mr(On),C({type:"onDragPending",event:On})},onStart(Xt){const Qa=Y.current;if(Qa==null)return;const Cr=q.get(Qa);if(!Cr)return;const{onDragStart:Fn}=fe.current,Kt={activatorEvent:Gr,active:{id:Qa,data:Cr.data,rect:Z}};ap.unstable_batchedUpdates(()=>{Fn==null||Fn(Kt),L(V_.Initializing),S({type:su.DragStart,initialCoordinates:Xt,active:Qa}),C({type:"onDragStart",event:Kt}),ae(Bt.current),le(Gr)})},onMove(Xt){S({type:su.DragMove,coordinates:Xt})},onEnd:$a(su.DragEnd),onCancel:$a(su.DragCancel)});Bt.current=Va;function $a(Xt){return async function(){const{active:Cr,collisions:Fn,over:Kt,scrollAdjustedTranslate:Mr}=ye.current;let On=null;if(Cr&&Mr){const{cancelDrop:ua}=fe.current;On={activatorEvent:Gr,active:Cr,collisions:Fn,delta:Mr,over:Kt},Xt===su.DragEnd&&typeof ua=="function"&&await Promise.resolve(ua(On))&&(Xt=su.DragCancel)}Y.current=null,ap.unstable_batchedUpdates(()=>{S({type:Xt}),L(V_.Uninitialized),Cs(null),ae(null),le(null),Bt.current=null;const ua=Xt===su.DragEnd?"onDragEnd":"onDragCancel";if(On){const $t=fe.current[ua];$t==null||$t(On),C({type:ua,event:On})}})}}},[q]),Nr=k.useCallback((bn,ir)=>(or,hr)=>{const an=or.nativeEvent,Gr=q.get(hr);if(Y.current!==null||!Gr||an.dndKit||an.defaultPrevented)return;const Va={active:Gr};bn(or,ir.options,Va)===!0&&(an.dndKit={capturedBy:ir.sensor},Y.current=hr,Xs(or,ir))},[q,Xs]),Vs=HGt(p,Nr);JGt(p),f0(()=>{Re&&I===V_.Initializing&&L(V_.Initialized)},[Re,I]),k.useEffect(()=>{const{onDragMove:bn}=fe.current,{active:ir,activatorEvent:or,collisions:hr,over:an}=ye.current;if(!ir||!or)return;const Gr={active:ir,activatorEvent:or,collisions:hr,delta:{x:He.x,y:He.y},over:an};ap.unstable_batchedUpdates(()=>{bn==null||bn(Gr),C({type:"onDragMove",event:Gr})})},[He.x,He.y]),k.useEffect(()=>{const{active:bn,activatorEvent:ir,collisions:or,droppableContainers:hr,scrollAdjustedTranslate:an}=ye.current;if(!bn||Y.current==null||!ir||!an)return;const{onDragOver:Gr}=fe.current,Va=hr.get(Wt),$a=Va&&Va.rect.current?{id:Va.id,rect:Va.rect.current,data:Va.data,disabled:Va.disabled}:null,Xt={active:bn,activatorEvent:ir,collisions:or,delta:{x:an.x,y:an.y},over:$a};ap.unstable_batchedUpdates(()=>{Cs($a),Gr==null||Gr(Xt),C({type:"onDragOver",event:Xt})})},[Wt]),f0(()=>{ye.current={activatorEvent:ie,active:J,activeNode:Ae,collisionRect:gt,collisions:Mt,droppableRects:Ne,draggableNodes:q,draggingNode:Ge,draggingNodeRect:tt,droppableContainers:V,over:xs,scrollableAncestors:Ct,scrollAdjustedTranslate:He},Z.current={initial:tt,translated:gt}},[J,Ae,Mt,gt,q,Ge,tt,Ne,V,xs,Ct,He]),$Gt({...Ee,delta:$,draggingRect:gt,pointerCoordinates:Oe,scrollableAncestors:Ct,scrollableAncestorRects:Ot});const ar=k.useMemo(()=>({active:J,activeNode:Ae,activeNodeRect:Re,activatorEvent:ie,collisions:Mt,containerNodeRect:Ue,dragOverlay:pe,draggableNodes:q,droppableContainers:V,droppableRects:Ne,over:xs,measureDroppableContainers:Ve,scrollableAncestors:Ct,scrollableAncestorRects:Ot,measuringConfiguration:we,measuringScheduled:Te,windowRect:et}),[J,Ae,Re,ie,Mt,Ue,pe,q,V,Ne,xs,Ve,Ct,Ot,we,Te,et]),Or=k.useMemo(()=>({activatorEvent:ie,activators:Vs,active:J,activeNodeRect:Re,ariaDescribedById:{draggable:xe},dispatch:S,draggableNodes:q,over:xs,measureDroppableContainers:Ve}),[ie,Vs,J,Re,S,xe,q,xs,Ve]);return ht.createElement(Btt.Provider,{value:A},ht.createElement(Phe.Provider,{value:Or},ht.createElement(est.Provider,{value:ar},ht.createElement(tst.Provider,{value:Ar},u)),ht.createElement(dWt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),ht.createElement(mGt,{...i,hiddenTextDescribedById:xe}));function Rn(){const bn=(ce==null?void 0:ce.autoScrollEnabled)===!1,ir=typeof d=="object"?d.enabled===!1:d===!1,or=O&&!bn&&!ir;return typeof d=="object"?{...d,enabled:or}:{enabled:or}}}),pWt=k.createContext(null),LDe="button",fWt="Draggable";function xWt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=oO(fWt),{activators:l,activatorEvent:i,active:d,activeNodeRect:u,ariaDescribedById:p,draggableNodes:f,over:y}=k.useContext(Phe),{role:_=LDe,roleDescription:b="draggable",tabIndex:N=0}=a??{},w=(d==null?void 0:d.id)===s,S=k.useContext(w?tst:pWt),[C,A]=pce(),[I,L]=pce(),O=eWt(l,s),U=kD(r);f0(()=>(f.set(s,{id:s,key:o,node:C,activatorNode:I,data:U}),()=>{const $=f.get(s);$&&$.key===o&&f.delete(s)}),[f,s]);const q=k.useMemo(()=>({role:_,tabIndex:N,"aria-disabled":n,"aria-pressed":w&&_===LDe?!0:void 0,"aria-roledescription":b,"aria-describedby":p.draggable}),[n,_,N,w,b,p.draggable]);return{active:d,activatorEvent:i,activeNodeRect:u,attributes:q,isDragging:w,listeners:n?void 0:O,node:C,over:y,setNodeRef:A,setActivatorNodeRef:L,transform:S}}function gWt(){return k.useContext(est)}const yWt="Droppable",vWt={timeout:25};function _Wt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=oO(yWt),{active:l,dispatch:i,over:d,measureDroppableContainers:u}=k.useContext(Phe),p=k.useRef({disabled:r}),f=k.useRef(!1),y=k.useRef(null),_=k.useRef(null),{disabled:b,updateMeasurementsFor:N,timeout:w}={...vWt,...a},S=kD(N??n),C=k.useCallback(()=>{if(!f.current){f.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{u(Array.isArray(S.current)?S.current:[S.current]),_.current=null},w)},[w]),A=Ehe({callback:C,disabled:b||!l}),I=k.useCallback((q,$)=>{A&&($&&(A.unobserve($),f.current=!1),q&&A.observe(q))},[A]),[L,O]=pce(I),U=kD(s);return k.useEffect(()=>{!A||!L.current||(A.disconnect(),f.current=!1,A.observe(L.current))},[L,A]),k.useEffect(()=>(i({type:su.RegisterDroppable,element:{id:n,key:o,disabled:r,node:L,rect:y,data:U}}),()=>i({type:su.UnregisterDroppable,key:o,id:n})),[n]),k.useEffect(()=>{r!==p.current.disabled&&(i({type:su.SetDroppableDisabled,id:n,key:o,disabled:r}),p.current.disabled=r)},[n,o,r,i]),{active:l,rect:y,isOver:(d==null?void 0:d.id)===n,node:L,over:d,setNodeRef:O}}function O4e(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function bWt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function t9(t){return t!==null&&t>=0}function wWt(t,s){if(t===s)return!0;if(t.length!==s.length)return!1;for(let r=0;r{var s;let{rects:r,activeNodeRect:n,activeIndex:a,overIndex:o,index:l}=t;const i=(s=r[a])!=null?s:n;if(!i)return null;const d=NWt(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-d,y:0,...s9}:l=o?{x:i.width+d,y:0,...s9}:{x:0,y:0,...s9}};function NWt(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=O4e(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}},r9={scaleX:1,scaleY:1},jEs=t=>{var s;let{activeIndex:r,activeNodeRect:n,index:a,rects:o,overIndex:l}=t;const i=(s=o[r])!=null?s:n;if(!i)return null;if(a===r){const u=o[l];return u?{x:0,y:rr&&a<=l?{x:0,y:-i.height-d,...r9}:a=l?{x:0,y:i.height+d,...r9}:{x:0,y:0,...r9}};function kWt(t,s,r){const n=t[s],a=t[s-1],o=t[s+1];return n?rn.map(O=>typeof O=="object"&&"id"in O?O.id:O),[n]),b=l!=null,N=l?_.indexOf(l.id):-1,w=u?_.indexOf(u.id):-1,S=k.useRef(_),C=!wWt(_,S.current),A=w!==-1&&N===-1||C,I=jWt(o);f0(()=>{C&&b&&p(_)},[C,_,b,p]),k.useEffect(()=>{S.current=_},[_]);const L=k.useMemo(()=>({activeIndex:N,containerId:f,disabled:I,disableTransforms:A,items:_,overIndex:w,useDragOverlay:y,sortedRects:bWt(_,d),strategy:a}),[N,f,I.draggable,I.droppable,A,_,w,d,y,a]);return ht.createElement(rst.Provider,{value:L},s)}const SWt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return O4e(r,n,a).indexOf(s)},CWt=t=>{let{containerId:s,isSorting:r,wasDragging:n,index:a,items:o,newIndex:l,previousItems:i,previousContainerId:d,transition:u}=t;return!u||!n||i!==o&&a===l?!1:r?!0:l!==a&&s===d},MWt={duration:200,easing:"ease"},nst="transform",TWt=oC.Transition.toString({property:nst,duration:0,easing:"linear"}),AWt={roleDescription:"sortable"};function EWt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=k.useState(null),i=k.useRef(r);return f0(()=>{if(!s&&r!==i.current&&n.current){const d=a.current;if(d){const u=oE(n.current,{ignoreTransform:!0}),p={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(p.x||p.y)&&l(p)}}r!==i.current&&(i.current=r)},[s,r,n,a]),k.useEffect(()=>{o&&l(null)},[o]),o}function z4e(t){let{animateLayoutChanges:s=CWt,attributes:r,disabled:n,data:a,getNewIndex:o=SWt,id:l,strategy:i,resizeObserverConfig:d,transition:u=MWt}=t;const{items:p,containerId:f,activeIndex:y,disabled:_,disableTransforms:b,sortedRects:N,overIndex:w,useDragOverlay:S,strategy:C}=k.useContext(rst),A=PWt(n,_),I=p.indexOf(l),L=k.useMemo(()=>({sortable:{containerId:f,index:I,items:p},...a}),[f,a,I,p]),O=k.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:U,node:q,isOver:$,setNodeRef:V}=_Wt({id:l,data:L,disabled:A.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...d}}),{active:ee,activatorEvent:Z,activeNodeRect:J,attributes:Y,setNodeRef:ce,listeners:ae,isDragging:ie,over:le,setActivatorNodeRef:fe,transform:xe}=xWt({id:l,data:L,attributes:{...AWt,...r},disabled:A.draggable}),he=eGt(V,ce),we=!!ee,Ne=we&&!b&&t9(y)&&t9(w),Ve=!S&&ie,Te=Ve&&Ne?xe:null,ze=Ne?Te??(i??C)({rects:N,activeNodeRect:J,activeIndex:y,overIndex:w,index:I}):null,Ee=t9(y)&&t9(w)?o({id:l,items:p,activeIndex:y,overIndex:w}):I,ve=ee==null?void 0:ee.id,Re=k.useRef({activeId:ve,items:p,newIndex:Ee,containerId:f}),Ue=p!==Re.current.items,ye=s({active:ee,containerId:f,isDragging:ie,isSorting:we,id:l,index:I,items:p,newIndex:Re.current.newIndex,previousItems:Re.current.items,previousContainerId:Re.current.containerId,transition:u,wasDragging:Re.current.activeId!=null}),ct=EWt({disabled:!ye,index:I,node:q,rect:U});return k.useEffect(()=>{we&&Re.current.newIndex!==Ee&&(Re.current.newIndex=Ee),f!==Re.current.containerId&&(Re.current.containerId=f),p!==Re.current.items&&(Re.current.items=p)},[we,Ee,f,p]),k.useEffect(()=>{if(ve===Re.current.activeId)return;if(ve!=null&&Re.current.activeId==null){Re.current.activeId=ve;return}const Ge=setTimeout(()=>{Re.current.activeId=ve},50);return()=>clearTimeout(Ge)},[ve]),{active:ee,activeIndex:y,attributes:Y,data:L,rect:U,index:I,newIndex:Ee,items:p,isOver:$,isSorting:we,isDragging:ie,listeners:ae,node:q,overIndex:w,over:le,setNodeRef:he,setActivatorNodeRef:fe,setDroppableNodeRef:V,setDraggableNodeRef:ce,transform:ct??ze,transition:pe()};function pe(){if(ct||Ue&&Re.current.newIndex===I)return TWt;if(!(Ve&&!A4e(Z)||!u)&&(we||ye))return oC.Transition.toString({...u,property:nst})}}function PWt(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 yce(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 IWt=[eo.Down,eo.Right,eo.Up,eo.Left],LWt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(IWt.includes(t.code)){if(t.preventDefault(),!r||!n)return;const d=[];o.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const y=a.get(f.id);if(y)switch(t.code){case eo.Down:n.topy.top&&d.push(f);break;case eo.Left:n.left>y.left&&d.push(f);break;case eo.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 w=Ahe(b).some((O,U)=>i[U]!==O),S=ast(f,y),C=DWt(f,y),A=w||!S?{x:0,y:0}:{x:C?n.width-_.width:0,y:C?n.height-_.height:0},I={x:_.left,y:_.top};return A.x&&A.y?I:SD(I,A)}}}};function ast(t,s){return!yce(t)||!yce(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function DWt(t,s){return!yce(t)||!yce(s)||!ast(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(pa,{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(yr,{className:"h-3.5 w-3.5"})})]}),t.post_date&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(Ye,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(nn,{className:"h-2.5 w-2.5"}),gs(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs(Be,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:Rt("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(nn,{className:"h-3 w-3"}),t.post_date?gs(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(uo,{className:"w-auto p-0",align:"start",children:[e.jsx(ff,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:f=>n(t.id,f?gs(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 OWt=()=>{const t=es(),[s,r]=k.useState("all"),[n,a]=k.useState(!1),[o,l]=k.useState(gs(new Date,"yyyy-MM")),[i,d]=k.useState([]),[u,p]=k.useState(!1),[f,y]=k.useState(null),[_,b]=k.useState(null),[N,w]=k.useState(""),[S,C]=k.useState(null),[A,I]=k.useState(!1),[L,O]=k.useState(!1),[U,q]=k.useState(gs(new Date,"yyyy-MM")),[$,V]=k.useState(null),[ee,Z]=k.useState(""),[J,Y]=k.useState(""),[ce,ae]=k.useState(""),[ie,le]=k.useState(!1),fe=E4e(xce(lO,{activationConstraint:{distance:5}}),xce(L4e,{coordinateGetter:LWt})),{data:xe=[],isLoading:he}=ft({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:Oe,error:Xe}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(Xe)throw Xe;return Oe}}),{data:we=[]}=ft({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:Oe,error:Xe}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(Xe)throw Xe;return Oe}}),{data:Ne=[]}=ft({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:Oe,error:Xe}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(Xe)throw Xe;return Oe}}),Ve=[...new Set(xe.map(Oe=>Oe.month))].sort((Oe,Xe)=>Xe.localeCompare(Oe)),Te=s==="all"?xe:xe.filter(Oe=>Oe.month===s),Ae=Oe=>{const Xe=lNe(Oe,"yyyy-MM",new Date);return gs(Xe,"MMMM yyyy")},ze=Oe=>{b(Oe),w(Oe.caption),C(Oe.post_date)},Ee=async()=>{if(_){I(!0);try{const{error:Oe}=await G.from("social_swag_2").update({caption:N,post_date:S}).eq("id",_.id);if(Oe)throw Oe;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)}}},ve=async Oe=>{const{active:Xe,over:at}=Oe;if(!at||Xe.id===at.id)return;const Ke=Te,He=Ke.findIndex(Wt=>Wt.id===Xe.id),gt=Ke.findIndex(Wt=>Wt.id===at.id);if(He===-1||gt===-1)return;const Mt=O4e(Ke,He,gt);t.setQueryData(["admin-social-swag-2"],Wt=>{if(!Wt)return Wt;const xs={};return Mt.forEach((Cs,Us)=>{xs[Cs.id]=Us}),Wt.map(Cs=>xs[Cs.id]!==void 0?{...Cs,sort_order:xs[Cs.id]}:Cs).sort((Cs,Us)=>Cs.month!==Us.month?Us.month.localeCompare(Cs.month):Cs.sort_order-Us.sort_order)});try{await Promise.all(Mt.map((Wt,xs)=>G.from("social_swag_2").update({sort_order:xs}).eq("id",Wt.id)))}catch{me.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},Re=Oe=>{const at=Array.from(Oe.target.files||[]).sort((Ke,He)=>Ke.name.localeCompare(He.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(Ke=>({file:Ke,preview:URL.createObjectURL(Ke),caption:""}));d(Ke=>[...Ke,...at].slice(0,16))},Ue=Oe=>{d(Xe=>{const at=[...Xe];return URL.revokeObjectURL(at[Oe].preview),at.splice(Oe,1),at})},ye=(Oe,Xe)=>{d(at=>{const Ke=[...at];return Ke[Oe]={...Ke[Oe],caption:Xe},Ke})},ct=async()=>{var Xe;if(i.length===0){me.error("Please add at least one image");return}if(i.filter(at=>!at.caption.trim()).length>0){me.error("Please add captions to all images");return}p(!0);try{const{data:at}=await G.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),Ke=(((Xe=at==null?void 0:at[0])==null?void 0:Xe.sort_order)??-1)+1;for(let He=0;He{const Xe=Oe.image_url.split("/social-swag-2/");Xe[1]&&await G.storage.from("social-swag-2").remove([Xe[1]]);const{error:at}=await G.from("social_swag_2").delete().eq("id",Oe.id);if(at)throw at},onSuccess:()=>{me.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>me.error("Failed to delete image")}),Ge=Et({mutationFn:async({id:Oe,postDate:Xe})=>{const{error:at}=await G.from("social_swag_2").update({post_date:Xe}).eq("id",Oe);if(at)throw at},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")}),tt=Et({mutationFn:async({month:Oe,link:Xe})=>{const{error:at}=await G.from("social_swag_2_months").upsert({month:Oe,canva_link:Xe||null},{onConflict:"month"});if(at)throw at},onSuccess:()=>{me.success("Canva link updated"),y(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>me.error("Failed to update Canva link")}),st=Oe=>{var Xe;return((Xe=we.find(at=>at.month===Oe))==null?void 0:Xe.canva_link)||""},Ce=Oe=>Ne.find(Xe=>Xe.month===Oe)||null,et=Oe=>{var at;const Xe=(at=Oe.target.files)==null?void 0:at[0];Xe&&(V(Xe),Z(URL.createObjectURL(Xe)))},Ct=()=>{ee&&URL.revokeObjectURL(ee),V(null),Z(""),Y(""),ae("")},Ot=async()=>{if(!$){me.error("Please select an image");return}le(!0);try{const Oe=$.name.split(".").pop(),Xe=`reels/${U}-${Date.now()}.${Oe}`,{error:at}=await G.storage.from("social-swag-2").upload(Xe,$);if(at)throw at;const{data:{publicUrl:Ke}}=G.storage.from("social-swag-2").getPublicUrl(Xe),{error:He}=await G.from("social_swag_2_reels").upsert({month:U,image_url:Ke,canva_link:ce||null,caption:J||null},{onConflict:"month"});if(He)throw He;me.success("Reel uploaded successfully!"),Q_e(`${Ae(U)} Reel`,"social-swag-2"),Ct(),O(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(Oe){console.error("Reel upload error:",Oe),me.error("Failed to upload reel")}finally{le(!1)}},ut=Et({mutationFn:async Oe=>{const Xe=Oe.image_url.split("/social-swag-2/");Xe[1]&&await G.storage.from("social-swag-2").remove([Xe[1]]);const{error:at}=await G.from("social_swag_2_reels").delete().eq("id",Oe.id);if(at)throw at},onSuccess:()=>{me.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>me.error("Failed to delete reel")});return e.jsxs(Ls,{title:"Admin - Social Swag 2.0",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Social Swag 2.0"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage monthly social media images and captions"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(fs,{open:n,onOpenChange:a,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Upload Images"]})}),e.jsxs(ms,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Upload Social Swag Images"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Month"}),e.jsx(Fe,{type:"month",value:o,onChange:Oe=>l(Oe.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ge,{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:Re,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx(Da,{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((Oe,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:Oe.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:()=>Ue(Xe),children:e.jsx(Sr,{className:"h-3 w-3"})})]}),e.jsx(_r,{placeholder:"Caption...",value:Oe.caption,onChange:at=>ye(Xe,at.target.value),className:"text-xs h-20"})]},Xe))}),e.jsx(K,{onClick:ct,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Da,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(fs,{open:L,onOpenChange:Oe=>{O(Oe),Oe||Ct()},children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(Ld,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(ms,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Upload Monthly Reel"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Month"}),e.jsx(Fe,{type:"month",value:U,onChange:Oe=>q(Oe.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Reel Preview Image"}),ee?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:ee,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(ee),V(null),Z("")},children:e.jsx(Sr,{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:et,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(Ld,{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(ge,{children:"Canva Download Link"}),e.jsx(Fe,{value:ce,onChange:Oe=>ae(Oe.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Caption"}),e.jsx(_r,{value:J,onChange:Oe=>Y(Oe.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(K,{onClick:Ot,disabled:ie||!$,className:"w-full gap-2",children:ie?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Da,{className:"h-4 w-4"}),"Upload Reel"]})})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:xe.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:Ve.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ta,{value:s,onValueChange:r,children:e.jsxs(Qn,{children:[e.jsx(ls,{value:"all",children:"All"}),Ve.map(Oe=>e.jsx(ls,{value:Oe,children:Ae(Oe)},Oe))]})}),s!=="all"&&e.jsx(Ie,{children:e.jsx(Be,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(go,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(ge,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Ae(s)]}),(f==null?void 0:f.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(Fe,{value:f.link,onChange:Oe=>y({...f,link:Oe.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(K,{size:"sm",onClick:()=>tt.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:st(s)||"No link set"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>y({month:s,link:st(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Ie,{children:e.jsx(Be,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(Ld,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(ge,{className:"text-sm text-muted-foreground",children:["Reel for ",Ae(s)]}),(()=>{const Oe=Ce(s);return Oe?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:Oe.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:Oe.caption||"No caption"}),Oe.canva_link&&e.jsx("a",{href:Oe.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:()=>ut.mutate(Oe),children:e.jsx(yr,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"No reel uploaded for this month"})})()]})]})})})]}),he?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}):Te.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Uo,{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(R4e,{sensors:fe,collisionDetection:P4e,onDragEnd:ve,children:e.jsx(F4e,{items:Te.map(Oe=>Oe.id),strategy:cO,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:Te.map(Oe=>e.jsx(RWt,{item:Oe,onEdit:ze,onDelete:Xe=>pe.mutate(Xe),onDateChange:(Xe,at)=>Ge.mutate({id:Xe,postDate:at})},Oe.id))})})})]}),e.jsx(fs,{open:!!_,onOpenChange:Oe=>{Oe||b(null)},children:e.jsxs(ms,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(bs,{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(ge,{children:"Caption"}),e.jsx(_r,{value:N,onChange:Oe=>w(Oe.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Rt("flex-1 justify-start gap-2 font-normal",!S&&"text-muted-foreground"),children:[e.jsx(nn,{className:"h-4 w-4"}),S?gs(new Date(S+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(ff,{mode:"single",selected:S?new Date(S+"T00:00:00"):void 0,onSelect:Oe=>C(Oe?gs(Oe,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),S&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(null),children:e.jsx(Sr,{className:"h-4 w-4"})})]})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(null),children:"Cancel"}),e.jsx(K,{onClick:Ee,disabled:A,className:"gap-2",children:A?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},FWt=()=>{const{toast:t}=va(),s=es(),[r,n]=k.useState("categories"),[a,o]=k.useState(!1),[l,i]=k.useState(null),[d,u]=k.useState({name:"",description:"",icon:""}),[p,f]=k.useState(!1),[y,_]=k.useState(null),[b,N]=k.useState({name:"",description:"",icon:""}),[w,S]=k.useState(!1),[C,A]=k.useState(null),[I,L]=k.useState(""),{data:O=[],isLoading:U}=ft({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:ve,error:Re}=await G.from("community_categories").select("*").order("sort_order");if(Re)throw Re;return ve}}),{data:q=[],isLoading:$}=ft({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:ve,error:Re}=await G.from("community_private_groups").select("*").order("sort_order");if(Re)throw Re;return ve}}),{data:V=[]}=ft({queryKey:["admin-group-members",C==null?void 0:C.id],queryFn:async()=>{if(!C)return[];const{data:ve,error:Re}=await G.from("community_private_group_members").select("*").eq("group_id",C.id);if(Re)throw Re;return ve},enabled:!!C}),{data:ee=[]}=ft({queryKey:["admin-all-profiles"],queryFn:async()=>{let Re=[],Ue=0,ye=!0;for(;ye;){const{data:ct,error:pe}=await G.from("profiles").select("id, name, email, brokerage_id").order("name").range(Ue,Ue+1e3-1);if(pe)throw pe;ct&&ct.length>0?(Re=[...Re,...ct],Ue+=1e3,ye=ct.length===1e3):ye=!1}return Re}}),{data:Z=[]}=ft({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:ve,error:Re}=await G.from("brokerages").select("*").order("name");if(Re)throw Re;return ve}}),J=Et({mutationFn:async ve=>{if(ve.id){const{error:Re}=await G.from("community_categories").update({name:ve.name,description:ve.description||null,icon:ve.icon||null}).eq("id",ve.id);if(Re)throw Re}else{const Re=Math.max(...O.map(ye=>ye.sort_order),0),{error:Ue}=await G.from("community_categories").insert({name:ve.name,description:ve.description||null,icon:ve.icon||null,sort_order:Re+1});if(Ue)throw Ue}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:ve=>{t({title:"Error",description:ve.message,variant:"destructive"})}}),Y=Et({mutationFn:async ve=>{const{error:Re}=await G.from("community_categories").delete().eq("id",ve);if(Re)throw Re},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),ce=Et({mutationFn:async({id:ve,direction:Re})=>{const Ue=O.findIndex(ye=>ye.id===ve);if(Re==="up"&&Ue>0){const ye=O[Ue-1],ct=O[Ue];await G.from("community_categories").update({sort_order:ct.sort_order}).eq("id",ye.id),await G.from("community_categories").update({sort_order:ye.sort_order}).eq("id",ct.id)}else if(Re==="down"&&Ues.invalidateQueries({queryKey:["admin-community-categories"]})}),ae=Et({mutationFn:async ve=>{if(ve.id){const{error:Re}=await G.from("community_private_groups").update({name:ve.name,description:ve.description||null,icon:ve.icon||null}).eq("id",ve.id);if(Re)throw Re}else{const Re=Math.max(...q.map(ye=>ye.sort_order),0),{error:Ue}=await G.from("community_private_groups").insert({name:ve.name,description:ve.description||null,icon:ve.icon||null,sort_order:Re+1});if(Ue)throw Ue}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),f(!1),_(null),N({name:"",description:"",icon:""}),t({title:y?"Private group updated!":"Private group created!"})},onError:ve=>{t({title:"Error",description:ve.message,variant:"destructive"})}}),ie=Et({mutationFn:async ve=>{const{error:Re}=await G.from("community_private_groups").delete().eq("id",ve);if(Re)throw Re},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),le=Et({mutationFn:async({id:ve,direction:Re})=>{const Ue=q.findIndex(ye=>ye.id===ve);if(Re==="up"&&Ue>0){const ye=q[Ue-1],ct=q[Ue];await G.from("community_private_groups").update({sort_order:ct.sort_order}).eq("id",ye.id),await G.from("community_private_groups").update({sort_order:ye.sort_order}).eq("id",ct.id)}else if(Re==="down"&&Ues.invalidateQueries({queryKey:["admin-private-groups"]})}),fe=Et({mutationFn:async({groupId:ve,userId:Re,isMember:Ue})=>{if(Ue){const{error:ye}=await G.from("community_private_group_members").delete().eq("group_id",ve).eq("user_id",Re);if(ye)throw ye}else{const{error:ye}=await G.from("community_private_group_members").insert({group_id:ve,user_id:Re});if(ye)throw ye}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),xe=Et({mutationFn:async({groupId:ve,brokerageId:Re,isMember:Ue})=>{if(Ue){const{error:ye}=await G.from("community_private_group_members").delete().eq("group_id",ve).eq("brokerage_id",Re);if(ye)throw ye}else{const{error:ye}=await G.from("community_private_group_members").insert({group_id:ve,brokerage_id:Re});if(ye)throw ye}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),he=ve=>{i(ve),u({name:ve.name,description:ve.description||"",icon:ve.icon||""}),o(!0)},we=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},Ne=ve=>{_(ve),N({name:ve.name,description:ve.description||"",icon:ve.icon||""}),f(!0)},Ve=()=>{_(null),N({name:"",description:"",icon:""}),f(!0)},Te=ve=>{A(ve),L(""),S(!0)},Ae=ve=>V.some(Re=>Re.user_id===ve),ze=ve=>V.some(Re=>Re.brokerage_id===ve),Ee=ee.filter(ve=>ve.name.toLowerCase().includes(I.toLowerCase())||ve.email.toLowerCase().includes(I.toLowerCase()));return e.jsx(Ls,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(ta,{value:r,onValueChange:n,children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"categories",children:"Public Categories"}),e.jsxs(ls,{value:"private-groups",children:[e.jsx(yd,{className:"h-4 w-4 mr-1"}),"Private Groups"]})]}),e.jsxs(js,{value:"categories",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Categories visible to all community members"}),e.jsxs(K,{onClick:we,children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Ie,{children:e.jsx(Be,{className:"pt-6",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{className:"w-[50px]",children:"Order"}),e.jsx(Nt,{className:"w-[80px]",children:"Icon"}),e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Description"}),e.jsx(Nt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Pn,{children:U?e.jsx(As,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):O.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):O.map((ve,Re)=>e.jsxs(As,{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:Re===0,onClick:()=>ce.mutate({id:ve.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Re===O.length-1,onClick:()=>ce.mutate({id:ve.id,direction:"down"}),children:"↓"})]})}),e.jsx(dt,{className:"text-2xl",children:ve.icon||"📁"}),e.jsx(dt,{className:"font-medium",children:ve.name}),e.jsx(dt,{className:"text-muted-foreground",children:ve.description||"—"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>he(ve),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&Y.mutate(ve.id)},children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},ve.id))})]})})})]}),e.jsxs(js,{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(ma,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(K,{onClick:Ve,children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Ie,{children:e.jsx(Be,{className:"pt-6",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{className:"w-[50px]",children:"Order"}),e.jsx(Nt,{className:"w-[80px]",children:"Icon"}),e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Description"}),e.jsx(Nt,{className:"w-[120px]",children:"Members"}),e.jsx(Nt,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(Pn,{children:$?e.jsx(As,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):q.length===0?e.jsx(As,{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((ve,Re)=>e.jsxs(As,{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:Re===0,onClick:()=>le.mutate({id:ve.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Re===q.length-1,onClick:()=>le.mutate({id:ve.id,direction:"down"}),children:"↓"})]})}),e.jsx(dt,{className:"text-2xl",children:ve.icon||"🔒"}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ve.name,ve.brokerage_id?e.jsxs(Ye,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(ma,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:[e.jsx(yd,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(dt,{className:"text-muted-foreground",children:ve.description||"—"}),e.jsx(dt,{children:e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Te(ve),children:[e.jsx(cr,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[!ve.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ne(ve),children:e.jsx(pa,{className:"h-4 w-4"})}),!ve.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.")&&ie.mutate(ve.id)},children:e.jsx(yr,{className:"h-4 w-4"})}),ve.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},ve.id))})]})})})]})]}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:l?"Edit Category":"Create Category"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Icon (emoji)"}),e.jsx(Fe,{value:d.icon,onChange:ve=>u(Re=>({...Re,icon:ve.target.value})),placeholder:"💬",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Fe,{value:d.name,onChange:ve=>u(Re=>({...Re,name:ve.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(_r,{value:d.description,onChange:ve=>u(Re=>({...Re,description:ve.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:()=>J.mutate({...d,id:l==null?void 0:l.id}),disabled:!d.name.trim(),children:l?"Save Changes":"Create Category"})]})]})]})}),e.jsx(fs,{open:p,onOpenChange:f,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{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:ve=>N(Re=>({...Re,icon:ve.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:ve=>N(Re=>({...Re,name:ve.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(_r,{value:b.description,onChange:ve=>N(Re=>({...Re,description:ve.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:()=>ae.mutate({...b,id:y==null?void 0:y.id}),disabled:!b.name.trim(),children:y?"Save Changes":"Create Private Group"})]})]})]})}),e.jsx(fs,{open:w,onOpenChange:S,children:e.jsxs(ms,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsxs(bs,{children:["Manage Members: ",C==null?void 0:C.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ta,{defaultValue:"brokerages",children:[e.jsxs(Qn,{className:"w-full",children:[e.jsx(ls,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(ls,{value:"users",className:"flex-1",children:"Individual Users"})]}),e.jsxs(js,{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(di,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Z.map(ve=>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(Gi,{checked:ze(ve.id),onCheckedChange:()=>{C&&xe.mutate({groupId:C.id,brokerageId:ve.id,isMember:ze(ve.id)})}}),e.jsx("span",{className:"font-medium",children:ve.name})]}),e.jsxs(Ye,{variant:"secondary",children:[ee.filter(Re=>Re.brokerage_id===ve.id).length," agents"]})]},ve.id)),Z.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No brokerages found"})]})})]}),e.jsxs(js,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(tn,{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:ve=>L(ve.target.value),className:"pl-9"})]}),e.jsx(di,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Ee.map(ve=>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(Gi,{checked:Ae(ve.id),onCheckedChange:()=>{C&&fe.mutate({groupId:C.id,userId:ve.id,isMember:Ae(ve.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ve.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ve.email})]})]})},ve.id)),Ee.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:()=>S(!1),children:"Done"})})]})]})})]})})},DDe=t=>{switch(t){case"academy_video":return e.jsx(Co,{className:"h-3 w-3"});case"template":return e.jsx(mn,{className:"h-3 w-3"});case"toolbox":return e.jsx(al,{className:"h-3 w-3"});case"newsletter":return e.jsx(Jv,{className:"h-3 w-3"});case"social_swag":return e.jsx(qr,{className:"h-3 w-3"});default:return e.jsx(Kr,{className:"h-3 w-3"})}},zWt=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}},BWt=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}},$Wt=()=>{const{toast:t}=va(),[s,r]=k.useState([]),[n,a]=k.useState([]),[o,l]=k.useState([]),[i,d]=k.useState(!0),[u,p]=k.useState(""),[f,y]=k.useState(null),[_,b]=k.useState([]),[N,w]=k.useState([]);k.useEffect(()=>{S()},[]);const S=async()=>{try{d(!0);const{data:V,error:ee}=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(ee)throw ee;const{data:Z,error:J}=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(J)throw J;const Y=[...new Set((Z==null?void 0:Z.map(he=>he.user_id))||[])],{data:ce}=await G.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",Y),ae=new Map((ce==null?void 0:ce.map(he=>[he.id,he]))||[]),ie=(V==null?void 0:V.map(he=>{var we,Ne,Ve,Te;return{id:he.id,user_id:he.user_id,app_name:he.app_name,launched_at:he.launched_at,user_name:((we=he.profiles)==null?void 0:we.name)||"Unknown",user_email:((Ne=he.profiles)==null?void 0:Ne.email)||"Unknown",brokerage_name:((Te=(Ve=he.profiles)==null?void 0:Ve.brokerages)==null?void 0:Te.name)||null}}))||[],le=(Z==null?void 0:Z.map(he=>{var Ne;const we=ae.get(he.user_id);return{id:he.id,user_id:he.user_id,resource_type:he.resource_type,resource_id:he.resource_id,resource_title:he.resource_title,action_type:he.action_type,created_at:he.created_at,user_name:(we==null?void 0:we.name)||"Unknown",user_email:(we==null?void 0:we.email)||"Unknown",brokerage_name:((Ne=we==null?void 0:we.brokerages)==null?void 0:Ne.name)||null}}))||[];r(ie),a(le);const fe=new Map;ie.forEach(he=>{if(!fe.has(he.user_id))fe.set(he.user_id,{user_id:he.user_id,user_name:he.user_name,user_email:he.user_email,brokerage_name:he.brokerage_name,last_activity_type:"app",last_activity_name:he.app_name,last_activity_at:he.launched_at,total_app_launches:1,total_content_views:0});else{const we=fe.get(he.user_id);we.total_app_launches++,new Date(he.launched_at)>new Date(we.last_activity_at)&&(we.last_activity_type="app",we.last_activity_name=he.app_name,we.last_activity_at=he.launched_at)}}),le.forEach(he=>{if(!fe.has(he.user_id))fe.set(he.user_id,{user_id:he.user_id,user_name:he.user_name,user_email:he.user_email,brokerage_name:he.brokerage_name,last_activity_type:he.resource_type,last_activity_name:he.resource_title,last_activity_at:he.created_at,total_app_launches:0,total_content_views:1});else{const we=fe.get(he.user_id);we.total_content_views++,new Date(he.created_at)>new Date(we.last_activity_at)&&(we.last_activity_type=he.resource_type,we.last_activity_name=he.resource_title,we.last_activity_at=he.created_at)}});const xe=Array.from(fe.values()).sort((he,we)=>new Date(we.last_activity_at).getTime()-new Date(he.last_activity_at).getTime());l(xe)}catch(V){console.error("Error loading activity:",V),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{d(!1)}},C=V=>{y({id:V.user_id,name:V.user_name,email:V.user_email});const ee=s.filter(J=>J.user_id===V.user_id),Z=n.filter(J=>J.user_id===V.user_id);b(ee),w(Z)},A=()=>{y(null),b([]),w([])},{sortKey:I,sortDirection:L,handleSort:O,sortData:U}=rO("last_activity_at","desc"),q=o.filter(V=>{var Z;if(!u)return!0;const ee=u.toLowerCase();return V.user_name.toLowerCase().includes(ee)||V.user_email.toLowerCase().includes(ee)||((Z=V.brokerage_name)==null?void 0:Z.toLowerCase().includes(ee))}),$=U(q,{user:V=>{var ee;return((ee=V.user_name)==null?void 0:ee.toLowerCase())||""},brokerage:V=>{var ee;return((ee=V.brokerage_name)==null?void 0:ee.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(Ie,{children:e.jsx(Be,{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(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"User Activity"}),e.jsx(mr,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs(Be,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(tn,{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(As,{children:[e.jsx(Ko,{sortKey:"user",currentSortKey:I,currentDirection:L,onSort:O,children:"User"}),e.jsx(Ko,{sortKey:"brokerage",currentSortKey:I,currentDirection:L,onSort:O,children:"Brokerage"}),e.jsx(Nt,{children:"Last Activity"}),e.jsx(Ko,{sortKey:"last_activity_at",currentSortKey:I,currentDirection:L,onSort:O,children:"Last Active"}),e.jsx(Ko,{sortKey:"apps",currentSortKey:I,currentDirection:L,onSort:O,className:"text-right",children:"Apps"}),e.jsx(Ko,{sortKey:"content",currentSortKey:I,currentDirection:L,onSort:O,className:"text-right",children:"Content"})]})}),e.jsx(Pn,{children:$.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):$.map(V=>e.jsxs(As,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>C(V),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:V.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:V.user_email})]})}),e.jsx(dt,{children:V.brokerage_name?e.jsx(Ye,{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(Ye,{variant:"secondary",children:[e.jsx(Kr,{className:"h-3 w-3 mr-1"}),V.last_activity_name]}):e.jsxs(Ye,{variant:"outline",className:"flex items-center gap-1",children:[DDe(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:jl(new Date(V.last_activity_at),{addSuffix:!0})}),e.jsx(dt,{className:"text-right",children:e.jsx(Ye,{variant:"outline",children:V.total_app_launches})}),e.jsx(dt,{className:"text-right",children:e.jsx(Ye,{variant:"outline",children:V.total_content_views})})]},V.user_id))})]})})]})]}),e.jsx(fs,{open:!!f,onOpenChange:V=>!V&&A(),children:e.jsxs(ms,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(ks,{children:[e.jsxs(bs,{children:[f==null?void 0:f.name,"'s Activity"]}),e.jsx(Rr,{children:f==null?void 0:f.email})]}),e.jsxs(ta,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(Qn,{className:"grid w-full grid-cols-2",children:[e.jsxs(ls,{value:"content",children:["Content (",N.length,")"]}),e.jsxs(ls,{value:"apps",children:["App Launches (",_.length,")"]})]}),e.jsx(js,{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(As,{children:[e.jsx(Nt,{children:"Type"}),e.jsx(Nt,{children:"Resource"}),e.jsx(Nt,{children:"Action"}),e.jsx(Nt,{children:"Time"})]})}),e.jsx(Pn,{children:N.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):N.map(V=>e.jsxs(As,{children:[e.jsx(dt,{children:e.jsxs(Ye,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[DDe(V.resource_type),zWt(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(Ye,{variant:"secondary",children:BWt(V.action_type)})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:jl(new Date(V.created_at),{addSuffix:!0})})]},V.id))})]})})}),e.jsx(js,{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(As,{children:[e.jsx(Nt,{children:"App"}),e.jsx(Nt,{children:"Time"})]})}),e.jsx(Pn,{children:_.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):_.map(V=>e.jsxs(As,{children:[e.jsx(dt,{children:e.jsx(Ye,{variant:"secondary",children:V.app_name})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:jl(new Date(V.launched_at),{addSuffix:!0})})]},V.id))})]})})})]})]})})]})},qWt=()=>{const{toast:t}=va(),[s,r]=k.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=k.useState(!0);k.useEffect(()=>{o()},[]);const o=async()=>{try{a(!0);const{count:l}=await G.from("profiles").select("*",{count:"exact",head:!0}),{count:i}=await G.from("profiles").select("*",{count:"exact",head:!0}).not("last_login","is",null),d=(l||0)-(i||0),{count:u}=await G.from("brokerages").select("*",{count:"exact",head:!0}),{count:p}=await G.from("activity_logs").select("*",{count:"exact",head:!0}),f=new Date;f.setDate(f.getDate()-7);const{count: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:N}=await G.from("activity_logs").select("user_id").gte("launched_at",f.toISOString()),w=new Set(N==null?void 0:N.map(S=>S.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:d,totalBrokerages:u||0,totalLaunches:p||0,launchesThisWeek:y||0,launchesThisMonth:b||0,uniqueActiveThisWeek:w})}catch(l){console.error("Error loading analytics:",l),t({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{a(!1)}};return n?e.jsx(Ie,{children:e.jsx(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(cr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(si,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(ma,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(ih,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(ih,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(ih,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(Yo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},RDe={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},ODe={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 ist({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(""),[d,u]=k.useState("all");k.useEffect(()=>{p()},[s]);const p=async()=>{o(!0);try{let O=[];if(t&&s){const{data:Y}=await G.from("profiles").select("id").eq("brokerage_id",s);if(O=(Y==null?void 0:Y.map(ce=>ce.id))||[],O.length===0){n([]),o(!1);return}}let U=G.from("resource_shares").select("*").order("created_at",{ascending:!1});t&&O.length>0&&(U=U.or(`sender_id.in.(${O.join(",")}),recipient_id.in.(${O.join(",")})`));const{data:q,error:$}=await U;if($)throw $;const V=new Set;q==null||q.forEach(Y=>{V.add(Y.sender_id),V.add(Y.recipient_id)});const{data:ee}=await G.from("profiles").select("id, name, email").in("id",Array.from(V)),Z=new Map((ee==null?void 0:ee.map(Y=>[Y.id,Y]))||[]),J=(q==null?void 0:q.map(Y=>({...Y,sender:Z.get(Y.sender_id),recipient:Z.get(Y.recipient_id)})))||[];n(J)}catch(O){console.error("Error loading shares:",O)}finally{o(!1)}},{sortKey:f,sortDirection:y,handleSort:_,sortData:b}=rO("created_at","desc"),N=r.filter(O=>{var $,V;const U=l===""||O.resource_title.toLowerCase().includes(l.toLowerCase())||(($=O.sender)==null?void 0:$.name.toLowerCase().includes(l.toLowerCase()))||((V=O.recipient)==null?void 0:V.name.toLowerCase().includes(l.toLowerCase())),q=d==="all"||O.resource_type===d;return U&&q}),w=b(N,{resource:O=>{var U;return((U=O.resource_title)==null?void 0:U.toLowerCase())||""},type:O=>O.resource_type,sender:O=>{var U,q;return((q=(U=O.sender)==null?void 0:U.name)==null?void 0:q.toLowerCase())||""},recipient:O=>{var U,q;return((q=(U=O.recipient)==null?void 0:U.name)==null?void 0:q.toLowerCase())||""},status:O=>O.is_read?1:0,created_at:O=>new Date(O.created_at).getTime()}),S=r.length,C=new Set(r.map(O=>O.sender_id)).size,A=new Set(r.map(O=>O.recipient_id)).size,I=r.length>0?Math.round(r.filter(O=>O.is_read).length/r.length*100):0,L=r.reduce((O,U)=>(O[U.resource_type]=(O[U.resource_type]||0)+1,O),{});return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((O,U)=>e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ss,{className:"h-4 w-20"})}),e.jsx(Be,{children:e.jsx(Ss,{className:"h-8 w-16"})})]},U))}),e.jsx(Ie,{children:e.jsx(Be,{className:"p-6",children:e.jsx(Ss,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(vd,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:S})})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(cr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:C})})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(Yo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:A})})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(mn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Be,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[I,"%"]})})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx(Be,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(L).map(([O,U])=>e.jsxs(Ye,{variant:"secondary",className:ODe[O],children:[RDe[O],": ",U]},O)),Object.keys(L).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Share History"}),e.jsxs(mr,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs(Be,{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(tn,{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:O=>i(O.target.value),className:"pl-9"})]}),e.jsxs(zs,{value:d,onValueChange:u,children:[e.jsx(Os,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"Resource type"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Types"}),e.jsx(yt,{value:"event",children:"Events"}),e.jsx(yt,{value:"template",children:"Templates"}),e.jsx(yt,{value:"academy_video",children:"Academy Videos"}),e.jsx(yt,{value:"resource_kit",children:"Resource Kits"}),e.jsx(yt,{value:"newsletter",children:"Newsletters"}),e.jsx(yt,{value:"social_swag",children:"Social Swag"})]})]})]}),e.jsx(di,{className:"h-[400px]",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Ko,{sortKey:"resource",currentSortKey:f,currentDirection:y,onSort:_,children:"Resource"}),e.jsx(Ko,{sortKey:"type",currentSortKey:f,currentDirection:y,onSort:_,children:"Type"}),e.jsx(Ko,{sortKey:"sender",currentSortKey:f,currentDirection:y,onSort:_,children:"Sender"}),e.jsx(Ko,{sortKey:"recipient",currentSortKey:f,currentDirection:y,onSort:_,children:"Recipient"}),e.jsx(Ko,{sortKey:"status",currentSortKey:f,currentDirection:y,onSort:_,children:"Status"}),e.jsx(Ko,{sortKey:"created_at",currentSortKey:f,currentDirection:y,onSort:_,children:"Date"})]})}),e.jsx(Pn,{children:w.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):w.map(O=>{var U,q;return e.jsxs(As,{children:[e.jsx(dt,{className:"font-medium max-w-[200px] truncate",children:O.resource_title}),e.jsx(dt,{children:e.jsx(Ye,{variant:"secondary",className:ODe[O.resource_type],children:RDe[O.resource_type]})}),e.jsx(dt,{children:((U=O.sender)==null?void 0:U.name)||"Unknown"}),e.jsx(dt,{children:((q=O.recipient)==null?void 0:q.name)||"Unknown"}),e.jsx(dt,{children:e.jsx(Ye,{variant:O.is_read?"default":"outline",children:O.is_read?"Read":"Unread"})}),e.jsx(dt,{className:"text-muted-foreground",children:gs(new Date(O.created_at),"MMM d, yyyy")})]},O.id)})})]})})]})]})]})}const Pye={academy_video:{label:"Academy Videos",icon:hn,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:jn},template:{label:"Templates",icon:Mv,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:sh},toolbox:{label:"Toolkit",icon:Og,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:Xa},newsletter:{label:"Newsletters",icon:tr,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:sh},social_swag:{label:"Social Swag",icon:Rl,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:sh},event:{label:"Events",icon:nn,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:sh}};function FDe(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function UWt(t,s){return t==="toolbox"?s.downloads:s.clicks}function VWt(){var O;const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(null),l=k.useRef(null),{sortKey:i,sortDirection:d,handleSort:u,sortData:p}=rO("total_views","desc");k.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:U,error:q}=await G.rpc("get_admin_content_engagement");if(q)throw q;s(U||[])}catch(U){console.error("Error loading content engagement:",U)}finally{n(!1)}},y=U=>{o(q=>{const $=q===U?null:U;return requestAnimationFrame(()=>{var V;(V=l.current)==null||V.scrollIntoView({behavior:"smooth",block:"start"})}),$})};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((U,q)=>e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ss,{className:"h-4 w-20"})}),e.jsx(Be,{children:e.jsx(Ss,{className:"h-8 w-16"})})]},q))}),e.jsx(Ie,{children:e.jsx(Be,{className:"py-8",children:e.jsx(Ss,{className:"h-64 w-full"})})})]});const _=t.reduce((U,q)=>U+q.total_views,0),b=t.reduce((U,q)=>U+q.total_clicks,0),N=t.reduce((U,q)=>U+q.total_downloads,0),w=t.length,S=t.reduce((U,q)=>(U[q.resource_type]||(U[q.resource_type]={views:0,clicks:0,downloads:0,assets:0,uniqueUsers:0}),U[q.resource_type].views+=q.total_views,U[q.resource_type].clicks+=q.total_clicks,U[q.resource_type].downloads+=q.total_downloads,U[q.resource_type].assets+=1,U[q.resource_type].uniqueUsers+=q.unique_users,U),{}),C=a?t.filter(U=>U.resource_type===a):t,A=p(C,{asset:U=>{var q;return((q=U.resource_title)==null?void 0:q.toLowerCase())||""},type:U=>U.resource_type,views:U=>U.total_views,actions:U=>FDe(U),unique_users:U=>U.unique_users,last_activity:U=>U.last_engaged_at?new Date(U.last_engaged_at).getTime():0}),I=a?Pye[a]||{label:a,icon:jn,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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(jn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(sh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{children:[e.jsx("div",{className:"text-2xl font-bold",children:N.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF downloads"})]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(Yo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique content items"})]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(sh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[_>0?Math.round((b+N)/_*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Of views → actions"})]})]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(mr,{children:"Click a category to see individual asset performance"})]}),e.jsx(Be,{children:e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3",children:Object.entries(S).map(([U,q])=>{const $=Pye[U]||{label:U,icon:jn,color:"bg-muted text-muted-foreground",actionIcon:sh},V=$.icon,ee=a===U;return e.jsxs("button",{type:"button",onClick:()=>y(U),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors cursor-pointer ${ee?"ring-2 ring-primary border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsx("div",{className:`p-2 rounded-md ${$.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:$.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(jn,{className:"h-3 w-3"})," ",q.views]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($.actionIcon,{className:"h-3 w-3"})," ",UWt(U,q)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cr,{className:"h-3 w-3"})," ",q.uniqueUsers]})]})]}),e.jsxs(Ye,{variant:"secondary",className:"text-[10px]",children:[q.assets," items"]})]},U)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{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(mr,{children:a?`${C.length} ${((O=I==null?void 0:I.label)==null?void 0:O.toLowerCase())||"items"} ranked by total interactions`:"All tracked assets ranked by total interactions"})]}),a&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"gap-1",children:[e.jsx(Ra,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(Be,{children:C.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No engagement data yet. As users view and click content, stats will appear here."}):e.jsx(di,{className:"h-[400px]",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{className:"w-[40px]",children:"#"}),e.jsx(Ko,{sortKey:"asset",currentSortKey:i,currentDirection:d,onSort:u,children:"Asset"}),!a&&e.jsx(Ko,{sortKey:"type",currentSortKey:i,currentDirection:d,onSort:u,children:"Type"}),e.jsx(Ko,{sortKey:"views",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:"Views"}),e.jsx(Ko,{sortKey:"actions",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:I?I.actionLabel:"Actions"}),e.jsx(Ko,{sortKey:"unique_users",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:"Unique Users"}),e.jsx(Ko,{sortKey:"last_activity",currentSortKey:i,currentDirection:d,onSort:u,children:"Last Activity"})]})}),e.jsx(Pn,{children:A.map((U,q)=>{const $=Pye[U.resource_type]||{label:U.resource_type,color:"bg-muted text-muted-foreground"};return e.jsxs(As,{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:U.resource_title})}),!a&&e.jsx(dt,{children:e.jsx(Ye,{className:`text-[10px] ${$.color}`,children:$.label})}),e.jsx(dt,{className:"text-right font-medium",children:U.total_views}),e.jsx(dt,{className:"text-right font-medium",children:FDe(U)}),e.jsx(dt,{className:"text-right",children:U.unique_users}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:U.last_engaged_at?jl(new Date(U.last_engaged_at),{addSuffix:!0}):"—"})]},`${U.resource_type}-${U.resource_id}`)})})]})})})]})})]})}var HWt=Array.isArray,_p=HWt,GWt=typeof hd=="object"&&hd&&hd.Object===Object&&hd,ost=GWt,WWt=ost,KWt=typeof self=="object"&&self&&self.Object===Object&&self,ZWt=WWt||KWt||Function("return this")(),N0=ZWt,YWt=N0,XWt=YWt.Symbol,dO=XWt,zDe=dO,lst=Object.prototype,QWt=lst.hasOwnProperty,JWt=lst.toString,l6=zDe?zDe.toStringTag:void 0;function eKt(t){var s=QWt.call(t,l6),r=t[l6];try{t[l6]=void 0;var n=!0}catch{}var a=JWt.call(t);return n&&(s?t[l6]=r:delete t[l6]),a}var tKt=eKt,sKt=Object.prototype,rKt=sKt.toString;function nKt(t){return rKt.call(t)}var aKt=nKt,BDe=dO,iKt=tKt,oKt=aKt,lKt="[object Null]",cKt="[object Undefined]",$De=BDe?BDe.toStringTag:void 0;function dKt(t){return t==null?t===void 0?cKt:lKt:$De&&$De in Object(t)?iKt(t):oKt(t)}var M1=dKt;function uKt(t){return t!=null&&typeof t=="object"}var T1=uKt,hKt=M1,mKt=T1,pKt="[object Symbol]";function fKt(t){return typeof t=="symbol"||mKt(t)&&hKt(t)==pKt}var lE=fKt,xKt=_p,gKt=lE,yKt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,vKt=/^\w*$/;function _Kt(t,s){if(xKt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||gKt(t)?!0:vKt.test(t)||!yKt.test(t)||s!=null&&t in Object(s)}var B4e=_Kt;function bKt(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var Sw=bKt;const cE=ro(Sw);var wKt=M1,jKt=Sw,NKt="[object AsyncFunction]",kKt="[object Function]",SKt="[object GeneratorFunction]",CKt="[object Proxy]";function MKt(t){if(!jKt(t))return!1;var s=wKt(t);return s==kKt||s==SKt||s==NKt||s==CKt}var $4e=MKt;const ci=ro($4e);var TKt=N0,AKt=TKt["__core-js_shared__"],EKt=AKt,Iye=EKt,qDe=function(){var t=/[^.]+$/.exec(Iye&&Iye.keys&&Iye.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function PKt(t){return!!qDe&&qDe in t}var IKt=PKt,LKt=Function.prototype,DKt=LKt.toString;function RKt(t){if(t!=null){try{return DKt.call(t)}catch{}try{return t+""}catch{}}return""}var cst=RKt,OKt=$4e,FKt=IKt,zKt=Sw,BKt=cst,$Kt=/[\\^$.*+?()[\]{}|]/g,qKt=/^\[object .+?Constructor\]$/,UKt=Function.prototype,VKt=Object.prototype,HKt=UKt.toString,GKt=VKt.hasOwnProperty,WKt=RegExp("^"+HKt.call(GKt).replace($Kt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function KKt(t){if(!zKt(t)||FKt(t))return!1;var s=OKt(t)?WKt:qKt;return s.test(BKt(t))}var ZKt=KKt;function YKt(t,s){return t==null?void 0:t[s]}var XKt=YKt,QKt=ZKt,JKt=XKt;function eZt(t,s){var r=JKt(t,s);return QKt(r)?r:void 0}var AC=eZt,tZt=AC,sZt=tZt(Object,"create"),Ihe=sZt,UDe=Ihe;function rZt(){this.__data__=UDe?UDe(null):{},this.size=0}var nZt=rZt;function aZt(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var iZt=aZt,oZt=Ihe,lZt="__lodash_hash_undefined__",cZt=Object.prototype,dZt=cZt.hasOwnProperty;function uZt(t){var s=this.__data__;if(oZt){var r=s[t];return r===lZt?void 0:r}return dZt.call(s,t)?s[t]:void 0}var hZt=uZt,mZt=Ihe,pZt=Object.prototype,fZt=pZt.hasOwnProperty;function xZt(t){var s=this.__data__;return mZt?s[t]!==void 0:fZt.call(s,t)}var gZt=xZt,yZt=Ihe,vZt="__lodash_hash_undefined__";function _Zt(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=yZt&&s===void 0?vZt:s,this}var bZt=_Zt,wZt=nZt,jZt=iZt,NZt=hZt,kZt=gZt,SZt=bZt;function dE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var UZt=qZt,VZt=Lhe;function HZt(t,s){var r=this.__data__,n=VZt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var GZt=HZt,WZt=TZt,KZt=OZt,ZZt=BZt,YZt=UZt,XZt=GZt;function uE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},C4=function(s){return lC(s)&&s.indexOf("%")===s.length-1},Qr=function(s){return gXt(s)&&!uO(s)},bXt=function(s){return yi(s)},ou=function(s){return Qr(s)||lC(s)},wXt=0,mE=function(s){var r=++wXt;return"".concat(s||"").concat(r)},bm=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(!Qr(s)&&!lC(s))return n;var o;if(C4(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return uO(o)&&(o=n),a&&o>r&&(o=r),o},J_=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},jXt=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 AXt(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 abe(t){"@babel/helpers - typeof";return abe=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},abe(t)}var YDe={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"},n1=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},XDe=null,Dye=null,X4e=function t(s){if(s===XDe&&Array.isArray(Dye))return Dye;var r=[];return k.Children.forEach(s,function(n){yi(n)||(hXt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),Dye=r,XDe=s,r};function gf(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return n1(a)}):n=[n1(s)],X4e(t).forEach(function(a){var o=xf(a,"type.displayName")||xf(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function Kp(t,s){var r=gf(t,s);return r&&r[0]}var QDe=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!Qr(n)||n<=0||!Qr(a)||a<=0)},EXt=["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"],PXt=function(s){return s&&s.type&&lC(s.type)&&EXt.indexOf(s.type)>=0},IXt=function(s){return s&&abe(s)==="object"&&"clipDot"in s},LXt=function(s,r,n,a){var o,l=(o=Lye==null?void 0:Lye[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!ci(s)&&(a&&l.includes(r)||SXt.includes(r))||n&&Y4e.includes(r)},Ba=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(k.isValidElement(s)&&(a=s.props),!cE(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;LXt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},ibe=function t(s,r){if(s===r)return!0;var n=k.Children.count(s);if(n!==k.Children.count(r))return!1;if(n===0)return!0;if(n===1)return JDe(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 zXt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function lbe(t){var s=t.children,r=t.width,n=t.height,a=t.viewBox,o=t.className,l=t.style,i=t.title,d=t.desc,u=FXt(t,OXt),p=a||{width:r,height:n,x:0,y:0},f=bi("recharts-surface",o);return ht.createElement("svg",obe({},Ba(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,d),s)}var BXt=["children","className"];function cbe(){return cbe=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 qXt(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 No=ht.forwardRef(function(t,s){var r=t.children,n=t.className,a=$Xt(t,BXt),o=bi("recharts-layer",n);return ht.createElement("g",cbe({className:o},Ba(a,!0),{ref:s}),r)}),zg=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:HXt(t,s,r)}var WXt=GXt,KXt="\\ud800-\\udfff",ZXt="\\u0300-\\u036f",YXt="\\ufe20-\\ufe2f",XXt="\\u20d0-\\u20ff",QXt=ZXt+YXt+XXt,JXt="\\ufe0e\\ufe0f",eQt="\\u200d",tQt=RegExp("["+eQt+KXt+QXt+JXt+"]");function sQt(t){return tQt.test(t)}var vst=sQt;function rQt(t){return t.split("")}var nQt=rQt,_st="\\ud800-\\udfff",aQt="\\u0300-\\u036f",iQt="\\ufe20-\\ufe2f",oQt="\\u20d0-\\u20ff",lQt=aQt+iQt+oQt,cQt="\\ufe0e\\ufe0f",dQt="["+_st+"]",dbe="["+lQt+"]",ube="\\ud83c[\\udffb-\\udfff]",uQt="(?:"+dbe+"|"+ube+")",bst="[^"+_st+"]",wst="(?:\\ud83c[\\udde6-\\uddff]){2}",jst="[\\ud800-\\udbff][\\udc00-\\udfff]",hQt="\\u200d",Nst=uQt+"?",kst="["+cQt+"]?",mQt="(?:"+hQt+"(?:"+[bst,wst,jst].join("|")+")"+kst+Nst+")*",pQt=kst+Nst+mQt,fQt="(?:"+[bst+dbe+"?",dbe,wst,jst,dQt].join("|")+")",xQt=RegExp(ube+"(?="+ube+")|"+fQt+pQt,"g");function gQt(t){return t.match(xQt)||[]}var yQt=gQt,vQt=nQt,_Qt=vst,bQt=yQt;function wQt(t){return _Qt(t)?bQt(t):vQt(t)}var jQt=wQt,NQt=WXt,kQt=vst,SQt=jQt,CQt=mst;function MQt(t){return function(s){s=CQt(s);var r=kQt(s)?SQt(s):void 0,n=r?r[0]:s.charAt(0),a=r?NQt(r,1).join(""):s.slice(1);return n[t]()+a}}var TQt=MQt,AQt=TQt,EQt=AQt("toUpperCase"),PQt=EQt;const Khe=ro(PQt);function Al(t){return function(){return t}}const Sst=Math.cos,bce=Math.sin,Xg=Math.sqrt,wce=Math.PI,Zhe=2*wce,hbe=Math.PI,mbe=2*hbe,o4=1e-6,IQt=mbe-o4;function Cst(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return Cst;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;ao4)if(!(Math.abs(f*d-u*p)>o4)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let _=n-l,b=a-i,N=d*d+u*u,w=_*_+b*b,S=Math.sqrt(N),C=Math.sqrt(y),A=o*Math.tan((hbe-Math.acos((N+y-w)/(2*S*C)))/2),I=A/C,L=A/S;Math.abs(I-1)>o4&&this._append`L${s+I*p},${r+I*f}`,this._append`A${o},${o},0,0,${+(f*_>p*b)},${this._x1=s+L*d},${this._y1=r+L*u}`}}arc(s,r,n,a,o,l){if(s=+s,r=+r,n=+n,l=!!l,n<0)throw new Error(`negative radius: ${n}`);let i=n*Math.cos(a),d=n*Math.sin(a),u=s+i,p=r+d,f=1^l,y=l?a-o:o-a;this._x1===null?this._append`M${u},${p}`:(Math.abs(this._x1-u)>o4||Math.abs(this._y1-p)>o4)&&this._append`L${u},${p}`,n&&(y<0&&(y=y%mbe+mbe),y>IQt?this._append`A${n},${n},0,1,${f},${s-i},${r-d}A${n},${n},0,1,${f},${this._x1=u},${this._y1=p}`:y>o4&&this._append`A${n},${n},0,${+(y>=hbe)},${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 Q4e(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 DQt(s)}function J4e(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Mst(t){this._context=t}Mst.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 Yhe(t){return new Mst(t)}function Tst(t){return t[0]}function Ast(t){return t[1]}function Est(t,s){var r=Al(!0),n=null,a=Yhe,o=null,l=Q4e(i);t=typeof t=="function"?t:t===void 0?Tst:Al(t),s=typeof s=="function"?s:s===void 0?Ast:Al(s);function i(d){var u,p=(d=J4e(d)).length,f,y=!1,_;for(n==null&&(o=a(_=l())),u=0;u<=p;++u)!(u=_;--b)i.point(A[b],I[b]);i.lineEnd(),i.areaEnd()}S&&(A[y]=+t(w,y,f),I[y]=+s(w,y,f),i.point(n?+n(w,y,f):A[y],r?+r(w,y,f):I[y]))}if(C)return i=null,C+""||null}function p(){return Est().defined(a).curve(l).context(o)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Al(+f),n=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Al(+f),u):t},u.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Al(+f),u):n},u.y=function(f){return arguments.length?(s=typeof f=="function"?f:Al(+f),r=null,u):s},u.y0=function(f){return arguments.length?(s=typeof f=="function"?f:Al(+f),u):s},u.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Al(+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:Al(!!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 Pst{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 RQt(t){return new Pst(t,!0)}function OQt(t){return new Pst(t,!1)}const eSe={draw(t,s){const r=Xg(s/wce);t.moveTo(r,0),t.arc(0,0,r,0,Zhe)}},FQt={draw(t,s){const r=Xg(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()}},Ist=Xg(1/3),zQt=Ist*2,BQt={draw(t,s){const r=Xg(s/zQt),n=r*Ist;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},$Qt={draw(t,s){const r=Xg(s),n=-r/2;t.rect(n,n,r,r)}},qQt=.8908130915292852,Lst=bce(wce/10)/bce(7*wce/10),UQt=bce(Zhe/10)*Lst,VQt=-Sst(Zhe/10)*Lst,HQt={draw(t,s){const r=Xg(s*qQt),n=UQt*r,a=VQt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=Zhe*o/5,i=Sst(l),d=bce(l);t.lineTo(d*r,-i*r),t.lineTo(i*n-d*a,d*n+i*a)}t.closePath()}},Rye=Xg(3),GQt={draw(t,s){const r=-Xg(s/(Rye*3));t.moveTo(0,r*2),t.lineTo(-Rye*r,-r),t.lineTo(Rye*r,-r),t.closePath()}},Kf=-.5,Zf=Xg(3)/2,pbe=1/Xg(12),WQt=(pbe/2+1)*3,KQt={draw(t,s){const r=Xg(s/WQt),n=r/2,a=r*pbe,o=n,l=r*pbe+r,i=-o,d=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,d),t.lineTo(Kf*n-Zf*a,Zf*n+Kf*a),t.lineTo(Kf*o-Zf*l,Zf*o+Kf*l),t.lineTo(Kf*i-Zf*d,Zf*i+Kf*d),t.lineTo(Kf*n+Zf*a,Kf*a-Zf*n),t.lineTo(Kf*o+Zf*l,Kf*l-Zf*o),t.lineTo(Kf*i+Zf*d,Kf*d-Zf*i),t.closePath()}};function ZQt(t,s){let r=null,n=Q4e(a);t=typeof t=="function"?t:Al(t||eSe),s=typeof s=="function"?s:Al(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:Al(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Al(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function jce(){}function Nce(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 Dst(t){this._context=t}Dst.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:Nce(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:Nce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function YQt(t){return new Dst(t)}function Rst(t){this._context=t}Rst.prototype={areaStart:jce,areaEnd:jce,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:Nce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function XQt(t){return new Rst(t)}function Ost(t){this._context=t}Ost.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(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:Nce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function QQt(t){return new Ost(t)}function Fst(t){this._context=t}Fst.prototype={areaStart:jce,areaEnd:jce,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 JQt(t){return new Fst(t)}function tRe(t){return t<0?-1:1}function sRe(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(tRe(o)+tRe(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function rRe(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function Oye(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 kce(t){this._context=t}kce.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:Oye(this,this._t0,rRe(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,Oye(this,rRe(this,r=sRe(this,t,s)),r);break;default:Oye(this,this._t0,r=sRe(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function zst(t){this._context=new Bst(t)}(zst.prototype=Object.create(kce.prototype)).point=function(t,s){kce.prototype.point.call(this,s,t)};function Bst(t){this._context=t}Bst.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 eJt(t){return new kce(t)}function tJt(t){return new zst(t)}function $st(t){this._context=t}$st.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=nRe(t),a=nRe(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 rJt(t){return new Xhe(t,.5)}function nJt(t){return new Xhe(t,0)}function aJt(t){return new Xhe(t,1)}function GT(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 iJt(t,s){return t[s]}function oJt(t){const s=[];return s.key=t,s}function lJt(){var t=Al([]),s=fbe,r=GT,n=iJt;function a(o){var l=Array.from(t.apply(this,arguments),oJt),i,d=l.length,u=-1,p;for(const f of o)for(i=0,++u;i0){for(var r,n,a=0,o=t[0].length,l;a0){for(var r=0,n=t[s[0]],a,o=n.length;r0)||!((o=(a=t[s[0]]).length)>0))){for(var r=0,n=1,a,o,l;n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function gJt(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 qst={symbolCircle:eSe,symbolCross:FQt,symbolDiamond:BQt,symbolSquare:$Qt,symbolStar:HQt,symbolTriangle:GQt,symbolWye:KQt},yJt=Math.PI/180,vJt=function(s){var r="symbol".concat(Khe(s));return qst[r]||eSe},_Jt=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*yJt;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}},bJt=function(s,r){qst["symbol".concat(Khe(s))]=r},tSe=function(s){var r=s.type,n=r===void 0?"circle":r,a=s.size,o=a===void 0?64:a,l=s.sizeType,i=l===void 0?"area":l,d=xJt(s,hJt),u=iRe(iRe({},d),{},{type:n,size:o,sizeType:i}),p=function(){var w=vJt(n),S=ZQt().type(w).size(_Jt(o,i,n));return S()},f=u.className,y=u.cx,_=u.cy,b=Ba(u,!0);return y===+y&&_===+_&&o===+o?ht.createElement("path",xbe({},b,{className:bi("recharts-symbols",f),transform:"translate(".concat(y,", ").concat(_,")"),d:p()})):null};tSe.registerSymbol=bJt;function WT(t){"@babel/helpers - typeof";return WT=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},WT(t)}function gbe(){return gbe=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var C=_.inactive?u:_.color;return ht.createElement("li",gbe({className:w,style:f,key:"legend-item-".concat(b)},cC(n.props,_,b)),ht.createElement(lbe,{width:l,height:l,viewBox:p,style:y},n.renderIcon(_)),ht.createElement("span",{className:"recharts-legend-item-text",style:{color:C}},N?N(S,_,b):S))})}},{key:"render",value:function(){var n=this.props,a=n.payload,o=n.layout,l=n.align;if(!a||!a.length)return null;var i={padding:0,margin:0,textAlign:o==="horizontal"?l:"left"};return ht.createElement("ul",{className:"recharts-default-legend",style:i},this.renderItems())}}])}(k.PureComponent);TD(sSe,"displayName","Legend");TD(sSe,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var EJt=Dhe;function PJt(){this.__data__=new EJt,this.size=0}var IJt=PJt;function LJt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var DJt=LJt;function RJt(t){return this.__data__.get(t)}var OJt=RJt;function FJt(t){return this.__data__.has(t)}var zJt=FJt,BJt=Dhe,$Jt=U4e,qJt=V4e,UJt=200;function VJt(t,s){var r=this.__data__;if(r instanceof BJt){var n=r.__data__;if(!$Jt||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&hes?new les:void 0;for(o.set(t,s),o.set(s,t);++f-1&&t%1==0&&t-1&&t%1==0&&t<=xts}var iSe=gts,yts=M1,vts=iSe,_ts=T1,bts="[object Arguments]",wts="[object Array]",jts="[object Boolean]",Nts="[object Date]",kts="[object Error]",Sts="[object Function]",Cts="[object Map]",Mts="[object Number]",Tts="[object Object]",Ats="[object RegExp]",Ets="[object Set]",Pts="[object String]",Its="[object WeakMap]",Lts="[object ArrayBuffer]",Dts="[object DataView]",Rts="[object Float32Array]",Ots="[object Float64Array]",Fts="[object Int8Array]",zts="[object Int16Array]",Bts="[object Int32Array]",$ts="[object Uint8Array]",qts="[object Uint8ClampedArray]",Uts="[object Uint16Array]",Vts="[object Uint32Array]",Kl={};Kl[Rts]=Kl[Ots]=Kl[Fts]=Kl[zts]=Kl[Bts]=Kl[$ts]=Kl[qts]=Kl[Uts]=Kl[Vts]=!0;Kl[bts]=Kl[wts]=Kl[Lts]=Kl[jts]=Kl[Dts]=Kl[Nts]=Kl[kts]=Kl[Sts]=Kl[Cts]=Kl[Mts]=Kl[Tts]=Kl[Ats]=Kl[Ets]=Kl[Pts]=Kl[Its]=!1;function Hts(t){return _ts(t)&&vts(t.length)&&!!Kl[yts(t)]}var Gts=Hts;function Wts(t){return function(s){return t(s)}}var Jst=Wts,Tce={exports:{}};Tce.exports;(function(t,s){var r=ost,n=s&&!s.nodeType&&s,a=n&&!0&&t&&!t.nodeType&&t,o=a&&a.exports===n,l=o&&r.process,i=function(){try{var d=a&&a.require&&a.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}}();t.exports=i})(Tce,Tce.exports);var Kts=Tce.exports,Zts=Gts,Yts=Jst,mRe=Kts,pRe=mRe&&mRe.isTypedArray,Xts=pRe?Yts(pRe):Zts,ert=Xts,Qts=tts,Jts=nSe,ess=_p,tss=Qst,sss=aSe,rss=ert,nss=Object.prototype,ass=nss.hasOwnProperty;function iss(t,s){var r=ess(t),n=!r&&Jts(t),a=!r&&!n&&tss(t),o=!r&&!n&&!a&&rss(t),l=r||n||a||o,i=l?Qts(t.length,String):[],d=i.length;for(var u in t)(s||ass.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||sss(u,d)))&&i.push(u);return i}var oss=iss,lss=Object.prototype;function css(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||lss;return t===r}var dss=css;function uss(t,s){return function(r){return t(s(r))}}var trt=uss,hss=trt,mss=hss(Object.keys,Object),pss=mss,fss=dss,xss=pss,gss=Object.prototype,yss=gss.hasOwnProperty;function vss(t){if(!fss(t))return xss(t);var s=[];for(var r in Object(t))yss.call(t,r)&&r!="constructor"&&s.push(r);return s}var _ss=vss,bss=$4e,wss=iSe;function jss(t){return t!=null&&wss(t.length)&&!bss(t)}var hO=jss,Nss=oss,kss=_ss,Sss=hO;function Css(t){return Sss(t)?Nss(t):kss(t)}var Qhe=Css,Mss=Ues,Tss=Jes,Ass=Qhe;function Ess(t){return Mss(t,Ass,Tss)}var Pss=Ess,fRe=Pss,Iss=1,Lss=Object.prototype,Dss=Lss.hasOwnProperty;function Rss(t,s,r,n,a,o){var l=r&Iss,i=fRe(t),d=i.length,u=fRe(s),p=u.length;if(d!=p&&!l)return!1;for(var f=d;f--;){var y=i[f];if(!(l?y in s:Dss.call(s,y)))return!1}var _=o.get(t),b=o.get(s);if(_&&b)return _==s&&b==t;var N=!0;o.set(t,s),o.set(s,t);for(var w=l;++f-1}var Lns=Ins;function Dns(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=Yns){var u=s?null:Kns(t);if(u)return Zns(u);l=!1,a=Wns,d=new Vns}else d=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function has(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 mas(t){return t.value}function pas(t,s){if(ht.isValidElement(t))return ht.cloneElement(t,s);if(typeof t=="function")return ht.createElement(t,s);s.ref;var r=uas(s,ras);return ht.createElement(sSe,r)}var ERe=1,tT=function(t){function s(){var r;nas(this,s);for(var n=arguments.length,a=new Array(n),o=0;oERe||Math.abs(a.height-this.lastBoundingBox.height)>ERe)&&(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?xv({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var a=this.props,o=a.layout,l=a.align,i=a.verticalAlign,d=a.margin,u=a.chartWidth,p=a.chartHeight,f,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:d&&d.right||0}:{left:d&&d.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(i==="middle"){var b=this.getBBoxSnapshot();y={top:((p||0)-b.height)/2}}else y=i==="bottom"?{bottom:d&&d.bottom||0}:{top:d&&d.top||0};return xv(xv({},f),y)}},{key:"render",value:function(){var n=this,a=this.props,o=a.content,l=a.width,i=a.height,d=a.wrapperStyle,u=a.payloadUniqBy,p=a.payload,f=xv(xv({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(d)),d);return ht.createElement("div",{className:"recharts-legend-wrapper",style:f,ref:function(_){n.wrapperNode=_}},pas(o,xv(xv({},this.props),{},{payload:lrt(p,u,mas)})))}}],[{key:"getWithHeight",value:function(n,a){var o=xv(xv({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&Qr(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(k.PureComponent);Jhe(tT,"displayName","Legend");Jhe(tT,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var PRe=dO,fas=nSe,xas=_p,IRe=PRe?PRe.isConcatSpreadable:void 0;function gas(t){return xas(t)||fas(t)||!!(IRe&&t&&t[IRe])}var yas=gas,vas=Yst,_as=yas;function urt(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=_as),a||(a=[]);++o0&&r(i)?s>1?urt(i,s-1,r,n,a):vas(a,i):n||(a[a.length]=i)}return a}var hrt=urt;function bas(t){return function(s,r,n){for(var a=-1,o=Object(s),l=n(s),i=l.length;i--;){var d=l[t?i:++a];if(r(o[d],d,o)===!1)break}return s}}var was=bas,jas=was,Nas=jas(),kas=Nas,Sas=kas,Cas=Qhe;function Mas(t,s){return t&&Sas(t,s,Cas)}var mrt=Mas,Tas=hO;function Aas(t,s){return function(r,n){if(r==null)return r;if(!Tas(r))return t(r,n);for(var a=r.length,o=s?a:-1,l=Object(r);(s?o--:++os||o&&l&&d&&!i&&!u||n&&l&&d||!r&&d||!a)return 1;if(!n&&!o&&!u&&t=i)return d;var u=r[n];return d*(u=="desc"?-1:1)}}return t.index-s.index}var Vas=Uas,$ye=G4e,Has=W4e,Gas=k0,Was=prt,Kas=zas,Zas=Jst,Yas=Vas,Xas=xE,Qas=_p;function Jas(t,s,r){s.length?s=$ye(s,function(o){return Qas(o)?function(l){return Has(l,o.length===1?o[0]:o)}:o}):s=[Xas];var n=-1;s=$ye(s,Zas(Gas));var a=Was(t,function(o,l,i){var d=$ye(s,function(u){return u(o)});return{criteria:d,index:++n,value:o}});return Kas(a,function(o,l){return Yas(o,l,r)})}var eis=Jas;function tis(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 sis=tis,ris=sis,DRe=Math.max;function nis(t,s,r){return s=DRe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=DRe(n.length-s,0),l=Array(o);++a0){if(++s>=pis)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var yis=gis,vis=mis,_is=yis,bis=_is(vis),wis=bis,jis=xE,Nis=ais,kis=wis;function Sis(t,s){return kis(Nis(t,s,jis),t+"")}var Cis=Sis,Mis=q4e,Tis=hO,Ais=aSe,Eis=Sw;function Pis(t,s,r){if(!Eis(r))return!1;var n=typeof s;return(n=="number"?Tis(r)&&Ais(s,r.length):n=="string"&&s in r)?Mis(r[s],t):!1}var eme=Pis,Iis=hrt,Lis=eis,Dis=Cis,ORe=eme,Ris=Dis(function(t,s){if(t==null)return[];var r=s.length;return r>1&&ORe(t,s[0],s[1])?s=[]:r>2&&ORe(s[0],s[1],s[2])&&(s=[s[0]]),Lis(t,Iis(s,1),[])}),Ois=Ris;const cSe=ro(Ois);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 kbe(){return kbe=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(c6,"-left"),Qr(r)&&s&&Qr(s.x)&&r=s.y),"".concat(c6,"-top"),Qr(n)&&s&&Qr(s.y)&&nN?Math.max(p,d[n]):Math.max(f,d[n])}function Qis(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 Jis(t){var s=t.allowEscapeViewBox,r=t.coordinate,n=t.offsetTopLeft,a=t.position,o=t.reverseDirection,l=t.tooltipBox,i=t.useTranslate3d,d=t.viewBox,u,p,f;return l.height>0&&l.width>0&&r?(p=BRe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:d,viewBoxDimension:d.width}),f=BRe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:d,viewBoxDimension:d.height}),u=Qis({translateX:p,translateY:f,useTranslate3d:i})):u=Yis,{cssProperties:u,cssClasses:Xis({translateX:p,translateY:f,coordinate:r})}}function ZT(t){"@babel/helpers - typeof";return ZT=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},ZT(t)}function $Re(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 qRe(t){for(var s=1;sURe||Math.abs(n.height-this.state.lastBoundingBox.height)>URe)&&this.setState({lastBoundingBox:{width:n.width,height:n.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var n,a;this.props.active&&this.updateBBox(),this.state.dismissed&&(((n=this.props.coordinate)===null||n===void 0?void 0:n.x)!==this.state.dismissedAtCoordinate.x||((a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var n=this,a=this.props,o=a.active,l=a.allowEscapeViewBox,i=a.animationDuration,d=a.animationEasing,u=a.children,p=a.coordinate,f=a.hasPayload,y=a.isAnimationActive,_=a.offset,b=a.position,N=a.reverseDirection,w=a.useTranslate3d,S=a.viewBox,C=a.wrapperStyle,A=Jis({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:_,position:b,reverseDirection:N,tooltipBox:this.state.lastBoundingBox,useTranslate3d:w,viewBox:S}),I=A.cssClasses,L=A.cssProperties,O=qRe(qRe({transition:y&&o?"transform ".concat(i,"ms ").concat(d):void 0},L),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&f?"visible":"hidden",position:"absolute",top:0,left:0},C);return ht.createElement("div",{tabIndex:-1,className:I,style:O,ref:function(q){n.wrapperNode=q}},u)}}])}(k.PureComponent),cos=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},EC={isSsr:cos()};function YT(t){"@babel/helpers - typeof";return YT=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},YT(t)}function 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 HRe(t){for(var s=1;s0;return ht.createElement(los,{allowEscapeViewBox:l,animationDuration:i,animationEasing:d,isAnimationActive:y,active:o,coordinate:p,hasPayload:O,offset:_,position:w,reverseDirection:S,useTranslate3d:C,viewBox:A,wrapperStyle:I},vos(u,HRe(HRe({},this.props),{},{payload:L})))}}])}(k.PureComponent);dSe(Jm,"displayName","Tooltip");dSe(Jm,"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 _os=N0,bos=function(){return _os.Date.now()},wos=bos,jos=/\s/;function Nos(t){for(var s=t.length;s--&&jos.test(t.charAt(s)););return s}var kos=Nos,Sos=kos,Cos=/^\s+/;function Mos(t){return t&&t.slice(0,Sos(t)+1).replace(Cos,"")}var Tos=Mos,Aos=Tos,GRe=Sw,Eos=lE,WRe=NaN,Pos=/^[-+]0x[0-9a-f]+$/i,Ios=/^0b[01]+$/i,Los=/^0o[0-7]+$/i,Dos=parseInt;function Ros(t){if(typeof t=="number")return t;if(Eos(t))return WRe;if(GRe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=GRe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=Aos(t);var r=Ios.test(t);return r||Los.test(t)?Dos(t.slice(2),r?2:8):Pos.test(t)?WRe:+t}var _rt=Ros,Oos=Sw,Uye=wos,KRe=_rt,Fos="Expected a function",zos=Math.max,Bos=Math.min;function $os(t,s,r){var n,a,o,l,i,d,u=0,p=!1,f=!1,y=!0;if(typeof t!="function")throw new TypeError(Fos);s=KRe(s)||0,Oos(r)&&(p=!!r.leading,f="maxWait"in r,o=f?zos(KRe(r.maxWait)||0,s):o,y="trailing"in r?!!r.trailing:y);function _(O){var U=n,q=a;return n=a=void 0,u=O,l=t.apply(q,U),l}function b(O){return u=O,i=setTimeout(S,s),p?_(O):l}function N(O){var U=O-d,q=O-u,$=s-U;return f?Bos($,o-q):$}function w(O){var U=O-d,q=O-u;return d===void 0||U>=s||U<0||f&&q>=o}function S(){var O=Uye();if(w(O))return C(O);i=setTimeout(S,N(O))}function C(O){return i=void 0,y&&n?_(O):(n=a=void 0,l)}function A(){i!==void 0&&clearTimeout(i),u=0,n=d=a=i=void 0}function I(){return i===void 0?l:C(Uye())}function L(){var O=Uye(),U=w(O);if(n=arguments,a=this,d=O,U){if(i===void 0)return b(d);if(f)return clearTimeout(i),i=setTimeout(S,s),_(d)}return i===void 0&&(i=setTimeout(S,s)),l}return L.cancel=A,L.flush=I,L}var qos=$os,Uos=qos,Vos=Sw,Hos="Expected a function";function Gos(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(Hos);return Vos(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),Uos(t,s,{leading:n,maxWait:s,trailing:a})}var Wos=Gos;const brt=ro(Wos);function PD(t){"@babel/helpers - typeof";return PD=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},PD(t)}function ZRe(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 o9(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(J=brt(J,N,{trailing:!0,leading:!1}));var Y=new ResizeObserver(J),ce=L.current.getBoundingClientRect(),ae=ce.width,ie=ce.height;return ee(ae,ie),Y.observe(L.current),function(){Y.disconnect()}},[ee,N]);var Z=k.useMemo(function(){var J=$.containerWidth,Y=$.containerHeight;if(J<0||Y<0)return null;zg(C4(l)||C4(d),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,d),zg(!r||r>0,"The aspect(%s) must be greater than zero.",r);var ce=C4(l)?J:l,ae=C4(d)?Y:d;r&&r>0&&(ce?ae=ce/r:ae&&(ce=ae*r),y&&ae>y&&(ae=y)),zg(ce>0||ae>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the height and width.`,ce,ae,l,d,p,f,r);var ie=!Array.isArray(_)&&n1(_.type).endsWith("Chart");return ht.Children.map(_,function(le){return ht.isValidElement(le)?k.cloneElement(le,o9({width:ce,height:ae},ie?{style:o9({height:"100%",width:"100%",maxHeight:ae,maxWidth:ce},le.props.style)}:{})):le})},[r,_,d,y,f,p,$,l]);return ht.createElement("div",{id:w?"".concat(w):void 0,className:bi("recharts-responsive-container",S),style:o9(o9({},I),{},{width:l,height:d,minWidth:p,minHeight:f,maxHeight:y}),ref:L},Z)}),mO=function(s){return null};mO.displayName="Cell";function ID(t){"@babel/helpers - typeof";return ID=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},ID(t)}function XRe(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 Tbe(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||EC.isSsr)return{width:0,height:0};var n=ols(r),a=JSON.stringify({text:s,copyStyle:n});if(k5.widthCache[a])return k5.widthCache[a];try{var o=document.getElementById(QRe);o||(o=document.createElement("span"),o.setAttribute("id",QRe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=Tbe(Tbe({},ils),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),d={width:i.width,height:i.height};return k5.widthCache[a]=d,++k5.cacheCount>als&&(k5.cacheCount=0,k5.widthCache={}),d}catch{return{width:0,height:0}}},lls=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};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 Ice(t,s){return hls(t)||uls(t,s)||dls(t,s)||cls()}function cls(){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 dls(t,s){if(t){if(typeof t=="string")return JRe(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 JRe(t,s)}}function JRe(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 Sls(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 aOe(t,s){return Als(t)||Tls(t,s)||Mls(t,s)||Cls()}function Cls(){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 Mls(t,s){if(t){if(typeof t=="string")return iOe(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 iOe(t,s)}}function iOe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&arguments[0]!==void 0?arguments[0]:[];return ce.reduce(function(ae,ie){var le=ie.word,fe=ie.width,xe=ae[ae.length-1];if(xe&&(a==null||o||xe.width+fe+nie.width?ae:ie})};if(!p)return _;for(var N="…",w=function(ce){var ae=f.slice(0,ce),ie=krt({breakAll:u,style:d,children:ae+N}).wordsWithComputedWidth,le=y(ie),fe=le.length>l||b(le).width>Number(a);return[fe,le]},S=0,C=f.length-1,A=0,I;S<=C&&A<=f.length-1;){var L=Math.floor((S+C)/2),O=L-1,U=w(O),q=aOe(U,2),$=q[0],V=q[1],ee=w(L),Z=aOe(ee,1),J=Z[0];if(!$&&!J&&(S=L+1),$&&J&&(C=L-1),!$&&J){I=V;break}A++}return I||_},oOe=function(s){var r=yi(s)?[]:s.toString().split(Nrt);return[{words:r}]},Pls=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 d,u,p=krt({breakAll:l,children:a,style:o});if(p){var f=p.wordsWithComputedWidth,y=p.spaceWidth;d=f,u=y}else return oOe(a);return Els({breakAll:l,children:a,maxLines:i,style:o},d,u,r,n)}return oOe(a)},lOe="#808080",dC=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,o=a===void 0?0:a,l=s.lineHeight,i=l===void 0?"1em":l,d=s.capHeight,u=d===void 0?"0.71em":d,p=s.scaleToFit,f=p===void 0?!1:p,y=s.textAnchor,_=y===void 0?"start":y,b=s.verticalAnchor,N=b===void 0?"end":b,w=s.fill,S=w===void 0?lOe:w,C=nOe(s,Nls),A=k.useMemo(function(){return Pls({breakAll:C.breakAll,children:C.children,maxLines:C.maxLines,scaleToFit:f,style:C.style,width:C.width})},[C.breakAll,C.children,C.maxLines,f,C.style,C.width]),I=C.dx,L=C.dy,O=C.angle,U=C.className,q=C.breakAll,$=nOe(C,kls);if(!ou(n)||!ou(o))return null;var V=n+(Qr(I)?I:0),ee=o+(Qr(L)?L:0),Z;switch(N){case"start":Z=Vye("calc(".concat(u,")"));break;case"middle":Z=Vye("calc(".concat((A.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:Z=Vye("calc(".concat(A.length-1," * -").concat(i,")"));break}var J=[];if(f){var Y=A[0].width,ce=C.width;J.push("scale(".concat((Qr(ce)?ce/Y:1)/Y,")"))}return O&&J.push("rotate(".concat(O,", ").concat(V,", ").concat(ee,")")),J.length&&($.transform=J.join(" ")),ht.createElement("text",Abe({},Ba($,!0),{x:V,y:ee,className:bi("recharts-text",U),textAnchor:_,fill:S.includes("url")?lOe:S}),A.map(function(ae,ie){var le=ae.words.join(q?"":" ");return ht.createElement("tspan",{x:V,dy:ie===0?Z:i,key:"".concat(le,"-").concat(ie)},le)}))};function Gb(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function Ils(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function uSe(t){let s,r,n;t.length!==2?(s=Gb,r=(i,d)=>Gb(t(i),d),n=(i,d)=>t(i)-d):(s=t===Gb||t===Ils?t:Lls,r=t,n=t);function a(i,d,u=0,p=i.length){if(u>>1;r(i[f],d)<0?u=f+1:p=f}while(u>>1;r(i[f],d)<=0?u=f+1:p=f}while(uu&&n(i[f-1],d)>-n(i[f],d)?f-1:f}return{left:a,center:l,right:o}}function Lls(){return 0}function Srt(t){return t===null?NaN:+t}function*Dls(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const Rls=uSe(Gb),pO=Rls.right;uSe(Srt).center;class cOe extends Map{constructor(s,r=zls){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(dOe(this,s))}has(s){return super.has(dOe(this,s))}set(s,r){return super.set(Ols(this,s),r)}delete(s){return super.delete(Fls(this,s))}}function dOe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function Ols({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function Fls({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function zls(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Bls(t=Gb){if(t===Gb)return Crt;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 Crt(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const $ls=Math.sqrt(50),qls=Math.sqrt(10),Uls=Math.sqrt(2);function Lce(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>=$ls?10:o>=qls?5:o>=Uls?2:1;let i,d,u;return a<0?(u=Math.pow(10,-a)/l,i=Math.round(t*u),d=Math.round(s*u),i/us&&--d,u=-u):(u=Math.pow(10,a)*l,i=Math.round(t/u),d=Math.round(s/u),i*us&&--d),d0))return[];if(t===s)return[t];const n=s=a))return[];const i=o-a+1,d=new Array(i);if(n)if(l<0)for(let u=0;u=n)&&(r=n);return r}function hOe(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function Mrt(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?Crt:Bls(a);n>r;){if(n-r>600){const d=n-r+1,u=s-r+1,p=Math.log(d),f=.5*Math.exp(2*p/3),y=.5*Math.sqrt(p*f*(d-f)/d)*(u-d/2<0?-1:1),_=Math.max(r,Math.floor(s-u*f/d+y)),b=Math.min(n,Math.floor(s+(d-u)*f/d+y));Mrt(t,s,_,b,a)}const o=t[s];let l=r,i=n;for(d6(t,r,s),a(t[n],o)>0&&d6(t,r,n);l0;)--i}a(t[r],o)===0?d6(t,r,i):(++i,d6(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function d6(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function Vls(t,s,r){if(t=Float64Array.from(Dls(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return hOe(t);if(s>=1)return uOe(t);var n,a=(n-1)*s,o=Math.floor(a),l=uOe(Mrt(t,o).subarray(0,o+1)),i=hOe(t.subarray(o+1));return l+(i-l)*(a-o)}}function Hls(t,s,r=Srt){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 Gls(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?c9(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?c9(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=Kls.exec(t))?new lp(s[1],s[2],s[3],1):(s=Zls.exec(t))?new lp(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=Yls.exec(t))?c9(s[1],s[2],s[3],s[4]):(s=Xls.exec(t))?c9(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=Qls.exec(t))?vOe(s[1],s[2]/100,s[3]/100,1):(s=Jls.exec(t))?vOe(s[1],s[2]/100,s[3]/100,s[4]):mOe.hasOwnProperty(t)?xOe(mOe[t]):t==="transparent"?new lp(NaN,NaN,NaN,0):null}function xOe(t){return new lp(t>>16&255,t>>8&255,t&255,1)}function c9(t,s,r,n){return n<=0&&(t=s=r=NaN),new lp(t,s,r,n)}function scs(t){return t instanceof fO||(t=FD(t)),t?(t=t.rgb(),new lp(t.r,t.g,t.b,t.opacity)):new lp}function Dbe(t,s,r,n){return arguments.length===1?scs(t):new lp(t,s,r,n??1)}function lp(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}mSe(lp,Dbe,Art(fO,{brighter(t){return t=t==null?Dce:Math.pow(Dce,t),new lp(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?RD:Math.pow(RD,t),new lp(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new lp(IS(this.r),IS(this.g),IS(this.b),Rce(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:gOe,formatHex:gOe,formatHex8:rcs,formatRgb:yOe,toString:yOe}));function gOe(){return`#${M4(this.r)}${M4(this.g)}${M4(this.b)}`}function rcs(){return`#${M4(this.r)}${M4(this.g)}${M4(this.b)}${M4((isNaN(this.opacity)?1:this.opacity)*255)}`}function yOe(){const t=Rce(this.opacity);return`${t===1?"rgb(":"rgba("}${IS(this.r)}, ${IS(this.g)}, ${IS(this.b)}${t===1?")":`, ${t})`}`}function Rce(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function IS(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function M4(t){return t=IS(t),(t<16?"0":"")+t.toString(16)}function vOe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new Mg(t,s,r,n)}function Ert(t){if(t instanceof Mg)return new Mg(t.h,t.s,t.l,t.opacity);if(t instanceof fO||(t=FD(t)),!t)return new Mg;if(t instanceof Mg)return t;t=t.rgb();var s=t.r/255,r=t.g/255,n=t.b/255,a=Math.min(s,r,n),o=Math.max(s,r,n),l=NaN,i=o-a,d=(o+a)/2;return i?(s===o?l=(r-n)/i+(r0&&d<1?0:l,new Mg(l,i,d,t.opacity)}function ncs(t,s,r,n){return arguments.length===1?Ert(t):new Mg(t,s,r,n??1)}function Mg(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}mSe(Mg,ncs,Art(fO,{brighter(t){return t=t==null?Dce:Math.pow(Dce,t),new Mg(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?RD:Math.pow(RD,t),new Mg(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 lp(Hye(t>=240?t-240:t+120,a,n),Hye(t,a,n),Hye(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Mg(_Oe(this.h),d9(this.s),d9(this.l),Rce(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=Rce(this.opacity);return`${t===1?"hsl(":"hsla("}${_Oe(this.h)}, ${d9(this.s)*100}%, ${d9(this.l)*100}%${t===1?")":`, ${t})`}`}}));function _Oe(t){return t=(t||0)%360,t<0?t+360:t}function d9(t){return Math.max(0,Math.min(1,t||0))}function Hye(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 pSe=t=>()=>t;function acs(t,s){return function(r){return t+r*s}}function ics(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 ocs(t){return(t=+t)==1?Prt:function(s,r){return r-s?ics(s,r,t):pSe(isNaN(s)?r:s)}}function Prt(t,s){var r=s-t;return r?acs(t,r):pSe(isNaN(t)?s:t)}const bOe=function t(s){var r=ocs(s);function n(a,o){var l=r((a=Dbe(a)).r,(o=Dbe(o)).r),i=r(a.g,o.g),d=r(a.b,o.b),u=Prt(a.opacity,o.opacity);return function(p){return a.r=l(p),a.g=i(p),a.b=d(p),a.opacity=u(p),a+""}}return n.gamma=t,n}(1);function lcs(t,s){s||(s=[]);var r=t?Math.min(s.length,t.length):0,n=s.slice(),a;return function(o){for(a=0;ar&&(o=s.slice(r,o),i[l]?i[l]+=o:i[++l]=o),(n=n[0])===(a=a[0])?i[l]?i[l]+=a:i[++l]=a:(i[++l]=null,d.push({i:l,x:Oce(n,a)})),r=Gye.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function vcs(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?_cs:vcs,d=u=null,f}function f(y){return y==null||isNaN(y=+y)?o:(d||(d=i(t.map(n),s,r)))(n(l(y)))}return f.invert=function(y){return l(a((u||(u=i(s,t.map(n),Oce)))(y)))},f.domain=function(y){return arguments.length?(t=Array.from(y,Fce),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=fSe,p()},f.clamp=function(y){return arguments.length?(l=y?!0:wm,p()):l!==wm},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 xSe(){return tme()(wm,wm)}function bcs(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function zce(t,s){if(!isFinite(t)||t===0)return null;var r=(t=s?t.toExponential(s-1):t.toExponential()).indexOf("e"),n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function XT(t){return t=zce(Math.abs(t)),t?t[1]:NaN}function wcs(t,s){return function(r,n){for(var a=r.length,o=[],l=0,i=t[0],d=0;a>0&&i>0&&(d+i+1>n&&(i=Math.max(1,n-d)),o.push(r.substring(a-=i,a+i)),!((d+=i+1)>n));)i=t[l=(l+1)%t.length];return o.reverse().join(s)}}function jcs(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var Ncs=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function zD(t){if(!(s=Ncs.exec(t)))throw new Error("invalid format: "+t);var s;return new gSe({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]})}zD.prototype=gSe.prototype;function gSe(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+""}gSe.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 kcs(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 Bce;function Scs(t,s){var r=zce(t,s);if(!r)return Bce=void 0,t.toPrecision(s);var n=r[0],a=r[1],o=a-(Bce=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")+zce(t,Math.max(0,s+o-1))[0]}function jOe(t,s){var r=zce(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 NOe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:bcs,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)=>jOe(t*100,s),r:jOe,s:Scs,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function kOe(t){return t}var SOe=Array.prototype.map,COe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Ccs(t){var s=t.grouping===void 0||t.thousands===void 0?kOe:wcs(SOe.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?kOe:jcs(SOe.call(t.numerals,String)),l=t.percent===void 0?"%":t.percent+"",i=t.minus===void 0?"−":t.minus+"",d=t.nan===void 0?"NaN":t.nan+"";function u(f,y){f=zD(f);var _=f.fill,b=f.align,N=f.sign,w=f.symbol,S=f.zero,C=f.width,A=f.comma,I=f.precision,L=f.trim,O=f.type;O==="n"?(A=!0,O="g"):NOe[O]||(I===void 0&&(I=12),L=!0,O="g"),(S||_==="0"&&b==="=")&&(S=!0,_="0",b="=");var U=(y&&y.prefix!==void 0?y.prefix:"")+(w==="$"?r:w==="#"&&/[boxX]/.test(O)?"0"+O.toLowerCase():""),q=(w==="$"?n:/[%p]/.test(O)?l:"")+(y&&y.suffix!==void 0?y.suffix:""),$=NOe[O],V=/[defgprs%]/.test(O);I=I===void 0?6:/[gprs]/.test(O)?Math.max(1,Math.min(21,I)):Math.max(0,Math.min(20,I));function ee(Z){var J=U,Y=q,ce,ae,ie;if(O==="c")Y=$(Z)+Y,Z="";else{Z=+Z;var le=Z<0||1/Z<0;if(Z=isNaN(Z)?d:$(Math.abs(Z),I),L&&(Z=kcs(Z)),le&&+Z==0&&N!=="+"&&(le=!1),J=(le?N==="("?N:i:N==="-"||N==="("?"":N)+J,Y=(O==="s"&&!isNaN(Z)&&Bce!==void 0?COe[8+Bce/3]:"")+Y+(le&&N==="("?")":""),V){for(ce=-1,ae=Z.length;++ceie||ie>57){Y=(ie===46?a+Z.slice(ce+1):Z.slice(ce))+Y,Z=Z.slice(0,ce);break}}}A&&!S&&(Z=s(Z,1/0));var fe=J.length+Z.length+Y.length,xe=fe>1)+J+Z+Y+xe.slice(fe);break;default:Z=xe+J+Z+Y;break}return o(Z)}return ee.toString=function(){return f+""},ee}function p(f,y){var _=Math.max(-8,Math.min(8,Math.floor(XT(y)/3)))*3,b=Math.pow(10,-_),N=u((f=zD(f),f.type="f",f),{suffix:COe[8+_/3]});return function(w){return N(b*w)}}return{format:u,formatPrefix:p}}var u9,ySe,Irt;Mcs({thousands:",",grouping:[3],currency:["$",""]});function Mcs(t){return u9=Ccs(t),ySe=u9.format,Irt=u9.formatPrefix,u9}function Tcs(t){return Math.max(0,-XT(Math.abs(t)))}function Acs(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(XT(s)/3)))*3-XT(Math.abs(t)))}function Ecs(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,XT(s)-XT(t))+1}function Lrt(t,s,r,n){var a=Ibe(t,s,r),o;switch(n=zD(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=Acs(a,l))&&(n.precision=o),Irt(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=Ecs(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=Tcs(a))&&(n.precision=o-(n.type==="%")*2);break}}return ySe(n)}function Cw(t){var s=t.domain;return t.ticks=function(r){var n=s();return Ebe(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return Lrt(a[0],a[a.length-1],r??10,n)},t.nice=function(r){r==null&&(r=10);var n=s(),a=0,o=n.length-1,l=n[a],i=n[o],d,u,p=10;for(i0;){if(u=Pbe(l,i,r),u===d)return n[a]=l,n[o]=i,s(n);if(u>0)l=Math.floor(l/u)*u,i=Math.ceil(i/u)*u;else if(u<0)l=Math.ceil(l*u)/u,i=Math.floor(i*u)/u;else break;d=u}return t},t}function $ce(){var t=xSe();return t.copy=function(){return xO(t,$ce())},Bx.apply(t,arguments),Cw(t)}function Drt(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,Fce),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return Drt(t).unknown(s)},t=arguments.length?Array.from(t,Fce):[0,1],Cw(r)}function Rrt(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 Rcs(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 AOe(t){return(s,r)=>-t(-s,r)}function vSe(t){const s=t(MOe,TOe),r=s.domain;let n=10,a,o;function l(){return a=Rcs(n),o=Dcs(n),r()[0]<0?(a=AOe(a),o=AOe(o),t(Pcs,Ics)):t(MOe,TOe),s}return s.base=function(i){return arguments.length?(n=+i,l()):n},s.domain=function(i){return arguments.length?(r(i),l()):r()},s.ticks=i=>{const d=r();let u=d[0],p=d[d.length-1];const f=p0){for(;y<=_;++y)for(b=1;bp)break;S.push(N)}}else for(;y<=_;++y)for(b=n-1;b>=1;--b)if(N=y>0?b/o(-y):b*o(y),!(Np)break;S.push(N)}S.length*2{if(i==null&&(i=10),d==null&&(d=n===10?"s":","),typeof d!="function"&&(!(n%1)&&(d=zD(d)).precision==null&&(d.trim=!0),d=ySe(d)),i===1/0)return d;const u=Math.max(1,n*i/s.ticks().length);return p=>{let f=p/o(Math.round(a(p)));return f*nr(Rrt(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function Ort(){const t=vSe(tme()).domain([1,10]);return t.copy=()=>xO(t,Ort()).base(t.base()),Bx.apply(t,arguments),t}function EOe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function POe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function _Se(t){var s=1,r=t(EOe(s),POe(s));return r.constant=function(n){return arguments.length?t(EOe(s=+n),POe(s)):s},Cw(r)}function Frt(){var t=_Se(tme());return t.copy=function(){return xO(t,Frt()).constant(t.constant())},Bx.apply(t,arguments)}function IOe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function Ocs(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Fcs(t){return t<0?-t*t:t*t}function bSe(t){var s=t(wm,wm),r=1;function n(){return r===1?t(wm,wm):r===.5?t(Ocs,Fcs):t(IOe(r),IOe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},Cw(s)}function wSe(){var t=bSe(tme());return t.copy=function(){return xO(t,wSe()).exponent(t.exponent())},Bx.apply(t,arguments),t}function zcs(){return wSe.apply(null,arguments).exponent(.5)}function LOe(t){return Math.sign(t)*t*t}function Bcs(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function zrt(){var t=xSe(),s=[0,1],r=!1,n;function a(o){var l=Bcs(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(LOe(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,Fce)).map(LOe)),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 zrt(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},Bx.apply(a,arguments),Cw(a)}function Brt(){var t=[],s=[],r=[],n;function a(){var l=0,i=Math.max(1,s.length);for(r=new Array(i-1);++l0?r[i-1]:t[0],i=r?[n[r-1],s]:[n[u-1],n[u]]},l.unknown=function(d){return arguments.length&&(o=d),l},l.thresholds=function(){return n.slice()},l.copy=function(){return $rt().domain([t,s]).range(a).unknown(o)},Bx.apply(Cw(l),arguments)}function qrt(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[pO(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 qrt().domain(t).range(s).unknown(r)},Bx.apply(a,arguments)}const Wye=new Date,Kye=new Date;function yu(t,s,r,n){function a(o){return t(o=arguments.length===0?new Date:new Date(+o)),o}return a.floor=o=>(t(o=new Date(+o)),o),a.ceil=o=>(t(o=new Date(o-1)),s(o,1),t(o),o),a.round=o=>{const l=a(o),i=a.ceil(o);return o-l(s(o=new Date(+o),l==null?1:Math.floor(l)),o),a.range=(o,l,i)=>{const d=[];if(o=a.ceil(o),i=i==null?1:Math.floor(i),!(o0))return d;let u;do d.push(u=new Date(+o)),s(o,i),t(o);while(uyu(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)=>(Wye.setTime(+o),Kye.setTime(+l),t(Wye),t(Kye),Math.floor(r(Wye,Kye))),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 qce=yu(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);qce.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?yu(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):qce);qce.range;const qv=1e3,gx=qv*60,Uv=gx*60,x1=Uv*24,jSe=x1*7,DOe=x1*30,Zye=x1*365,T4=yu(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*qv)},(t,s)=>(s-t)/qv,t=>t.getUTCSeconds());T4.range;const NSe=yu(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*qv)},(t,s)=>{t.setTime(+t+s*gx)},(t,s)=>(s-t)/gx,t=>t.getMinutes());NSe.range;const kSe=yu(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*gx)},(t,s)=>(s-t)/gx,t=>t.getUTCMinutes());kSe.range;const SSe=yu(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*qv-t.getMinutes()*gx)},(t,s)=>{t.setTime(+t+s*Uv)},(t,s)=>(s-t)/Uv,t=>t.getHours());SSe.range;const CSe=yu(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*Uv)},(t,s)=>(s-t)/Uv,t=>t.getUTCHours());CSe.range;const gO=yu(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*gx)/x1,t=>t.getDate()-1);gO.range;const sme=yu(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/x1,t=>t.getUTCDate()-1);sme.range;const Urt=yu(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/x1,t=>Math.floor(t/x1));Urt.range;function PC(t){return yu(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())*gx)/jSe)}const rme=PC(0),Uce=PC(1),$cs=PC(2),qcs=PC(3),QT=PC(4),Ucs=PC(5),Vcs=PC(6);rme.range;Uce.range;$cs.range;qcs.range;QT.range;Ucs.range;Vcs.range;function IC(t){return yu(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)/jSe)}const nme=IC(0),Vce=IC(1),Hcs=IC(2),Gcs=IC(3),JT=IC(4),Wcs=IC(5),Kcs=IC(6);nme.range;Vce.range;Hcs.range;Gcs.range;JT.range;Wcs.range;Kcs.range;const MSe=yu(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());MSe.range;const TSe=yu(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());TSe.range;const g1=yu(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());g1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:yu(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)});g1.range;const y1=yu(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());y1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:yu(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)});y1.range;function Vrt(t,s,r,n,a,o){const l=[[T4,1,qv],[T4,5,5*qv],[T4,15,15*qv],[T4,30,30*qv],[o,1,gx],[o,5,5*gx],[o,15,15*gx],[o,30,30*gx],[a,1,Uv],[a,3,3*Uv],[a,6,6*Uv],[a,12,12*Uv],[n,1,x1],[n,2,2*x1],[r,1,jSe],[s,1,DOe],[s,3,3*DOe],[t,1,Zye]];function i(u,p,f){const y=pw).right(l,y);if(_===l.length)return t.every(Ibe(u/Zye,p/Zye,f));if(_===0)return qce.every(Math.max(Ibe(u,p,f),1));const[b,N]=l[y/l[_-1][2]53)return null;"w"in ye||(ye.w=1),"Z"in ye?(pe=Xye(u6(ye.y,0,1)),Ge=pe.getUTCDay(),pe=Ge>4||Ge===0?Vce.ceil(pe):Vce(pe),pe=sme.offset(pe,(ye.V-1)*7),ye.y=pe.getUTCFullYear(),ye.m=pe.getUTCMonth(),ye.d=pe.getUTCDate()+(ye.w+6)%7):(pe=Yye(u6(ye.y,0,1)),Ge=pe.getDay(),pe=Ge>4||Ge===0?Uce.ceil(pe):Uce(pe),pe=gO.offset(pe,(ye.V-1)*7),ye.y=pe.getFullYear(),ye.m=pe.getMonth(),ye.d=pe.getDate()+(ye.w+6)%7)}else("W"in ye||"U"in ye)&&("w"in ye||(ye.w="u"in ye?ye.u%7:"W"in ye?1:0),Ge="Z"in ye?Xye(u6(ye.y,0,1)).getUTCDay():Yye(u6(ye.y,0,1)).getDay(),ye.m=0,ye.d="W"in ye?(ye.w+6)%7+ye.W*7-(Ge+5)%7:ye.w+ye.U*7-(Ge+6)%7);return"Z"in ye?(ye.H+=ye.Z/100|0,ye.M+=ye.Z%100,Xye(ye)):Yye(ye)}}function q(ve,Re,Ue,ye){for(var ct=0,pe=Re.length,Ge=Ue.length,tt,st;ct=Ge)return-1;if(tt=Re.charCodeAt(ct++),tt===37){if(tt=Re.charAt(ct++),st=L[tt in ROe?Re.charAt(ct++):tt],!st||(ye=st(ve,Ue,ye))<0)return-1}else if(tt!=Ue.charCodeAt(ye++))return-1}return ye}function $(ve,Re,Ue){var ye=u.exec(Re.slice(Ue));return ye?(ve.p=p.get(ye[0].toLowerCase()),Ue+ye[0].length):-1}function V(ve,Re,Ue){var ye=_.exec(Re.slice(Ue));return ye?(ve.w=b.get(ye[0].toLowerCase()),Ue+ye[0].length):-1}function ee(ve,Re,Ue){var ye=f.exec(Re.slice(Ue));return ye?(ve.w=y.get(ye[0].toLowerCase()),Ue+ye[0].length):-1}function Z(ve,Re,Ue){var ye=S.exec(Re.slice(Ue));return ye?(ve.m=C.get(ye[0].toLowerCase()),Ue+ye[0].length):-1}function J(ve,Re,Ue){var ye=N.exec(Re.slice(Ue));return ye?(ve.m=w.get(ye[0].toLowerCase()),Ue+ye[0].length):-1}function Y(ve,Re,Ue){return q(ve,s,Re,Ue)}function ce(ve,Re,Ue){return q(ve,r,Re,Ue)}function ae(ve,Re,Ue){return q(ve,n,Re,Ue)}function ie(ve){return l[ve.getDay()]}function le(ve){return o[ve.getDay()]}function fe(ve){return d[ve.getMonth()]}function xe(ve){return i[ve.getMonth()]}function he(ve){return a[+(ve.getHours()>=12)]}function we(ve){return 1+~~(ve.getMonth()/3)}function Ne(ve){return l[ve.getUTCDay()]}function Ve(ve){return o[ve.getUTCDay()]}function Te(ve){return d[ve.getUTCMonth()]}function Ae(ve){return i[ve.getUTCMonth()]}function ze(ve){return a[+(ve.getUTCHours()>=12)]}function Ee(ve){return 1+~~(ve.getUTCMonth()/3)}return{format:function(ve){var Re=O(ve+="",A);return Re.toString=function(){return ve},Re},parse:function(ve){var Re=U(ve+="",!1);return Re.toString=function(){return ve},Re},utcFormat:function(ve){var Re=O(ve+="",I);return Re.toString=function(){return ve},Re},utcParse:function(ve){var Re=U(ve+="",!0);return Re.toString=function(){return ve},Re}}}var ROe={"-":"",_:" ",0:"0"},Uu=/^\s*\d+/,eds=/^%/,tds=/[\\^$*+?|[\]().{}]/g;function Mo(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function rds(t,s,r){var n=Uu.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function nds(t,s,r){var n=Uu.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function ads(t,s,r){var n=Uu.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function ids(t,s,r){var n=Uu.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function ods(t,s,r){var n=Uu.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function OOe(t,s,r){var n=Uu.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function FOe(t,s,r){var n=Uu.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function lds(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 cds(t,s,r){var n=Uu.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function dds(t,s,r){var n=Uu.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function zOe(t,s,r){var n=Uu.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function uds(t,s,r){var n=Uu.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function BOe(t,s,r){var n=Uu.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function hds(t,s,r){var n=Uu.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function mds(t,s,r){var n=Uu.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function pds(t,s,r){var n=Uu.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function fds(t,s,r){var n=Uu.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function xds(t,s,r){var n=eds.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function gds(t,s,r){var n=Uu.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function yds(t,s,r){var n=Uu.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function $Oe(t,s){return Mo(t.getDate(),s,2)}function vds(t,s){return Mo(t.getHours(),s,2)}function _ds(t,s){return Mo(t.getHours()%12||12,s,2)}function bds(t,s){return Mo(1+gO.count(g1(t),t),s,3)}function Hrt(t,s){return Mo(t.getMilliseconds(),s,3)}function wds(t,s){return Hrt(t,s)+"000"}function jds(t,s){return Mo(t.getMonth()+1,s,2)}function Nds(t,s){return Mo(t.getMinutes(),s,2)}function kds(t,s){return Mo(t.getSeconds(),s,2)}function Sds(t){var s=t.getDay();return s===0?7:s}function Cds(t,s){return Mo(rme.count(g1(t)-1,t),s,2)}function Grt(t){var s=t.getDay();return s>=4||s===0?QT(t):QT.ceil(t)}function Mds(t,s){return t=Grt(t),Mo(QT.count(g1(t),t)+(g1(t).getDay()===4),s,2)}function Tds(t){return t.getDay()}function Ads(t,s){return Mo(Uce.count(g1(t)-1,t),s,2)}function Eds(t,s){return Mo(t.getFullYear()%100,s,2)}function Pds(t,s){return t=Grt(t),Mo(t.getFullYear()%100,s,2)}function Ids(t,s){return Mo(t.getFullYear()%1e4,s,4)}function Lds(t,s){var r=t.getDay();return t=r>=4||r===0?QT(t):QT.ceil(t),Mo(t.getFullYear()%1e4,s,4)}function Dds(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Mo(s/60|0,"0",2)+Mo(s%60,"0",2)}function qOe(t,s){return Mo(t.getUTCDate(),s,2)}function Rds(t,s){return Mo(t.getUTCHours(),s,2)}function Ods(t,s){return Mo(t.getUTCHours()%12||12,s,2)}function Fds(t,s){return Mo(1+sme.count(y1(t),t),s,3)}function Wrt(t,s){return Mo(t.getUTCMilliseconds(),s,3)}function zds(t,s){return Wrt(t,s)+"000"}function Bds(t,s){return Mo(t.getUTCMonth()+1,s,2)}function $ds(t,s){return Mo(t.getUTCMinutes(),s,2)}function qds(t,s){return Mo(t.getUTCSeconds(),s,2)}function Uds(t){var s=t.getUTCDay();return s===0?7:s}function Vds(t,s){return Mo(nme.count(y1(t)-1,t),s,2)}function Krt(t){var s=t.getUTCDay();return s>=4||s===0?JT(t):JT.ceil(t)}function Hds(t,s){return t=Krt(t),Mo(JT.count(y1(t),t)+(y1(t).getUTCDay()===4),s,2)}function Gds(t){return t.getUTCDay()}function Wds(t,s){return Mo(Vce.count(y1(t)-1,t),s,2)}function Kds(t,s){return Mo(t.getUTCFullYear()%100,s,2)}function Zds(t,s){return t=Krt(t),Mo(t.getUTCFullYear()%100,s,2)}function Yds(t,s){return Mo(t.getUTCFullYear()%1e4,s,4)}function Xds(t,s){var r=t.getUTCDay();return t=r>=4||r===0?JT(t):JT.ceil(t),Mo(t.getUTCFullYear()%1e4,s,4)}function Qds(){return"+0000"}function UOe(){return"%"}function VOe(t){return+t}function HOe(t){return Math.floor(+t/1e3)}var S5,Zrt,Yrt;Jds({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 Jds(t){return S5=Jcs(t),Zrt=S5.format,S5.parse,Yrt=S5.utcFormat,S5.utcParse,S5}function eus(t){return new Date(t)}function tus(t){return t instanceof Date?+t:+new Date(+t)}function ASe(t,s,r,n,a,o,l,i,d,u){var p=xSe(),f=p.invert,y=p.domain,_=u(".%L"),b=u(":%S"),N=u("%I:%M"),w=u("%I %p"),S=u("%a %d"),C=u("%b %d"),A=u("%B"),I=u("%Y");function L(O){return(d(O)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>Vls(t,o/n))},r.copy=function(){return ent(s).domain(t)},A1.apply(r,arguments)}function ime(){var t=0,s=.5,r=1,n=1,a,o,l,i,d,u=wm,p,f=!1,y;function _(N){return isNaN(N=+N)?y:(N=.5+((N=+p(N))-o)*(n*Ns}var nnt=lus,cus=ome,dus=nnt,uus=xE;function hus(t){return t&&t.length?cus(t,uus,dus):void 0}var mus=hus;const lme=ro(mus);function pus(t,s){return tt.e^o.s<0?1:-1;for(n=o.d.length,a=t.d.length,s=0,r=nt.d[s]^o.s<0?1:-1;return n===a?0:n>a^o.s<0?1:-1};Xn.decimalPlaces=Xn.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*Xl;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};Xn.dividedBy=Xn.div=function(t){return a1(this,new this.constructor(t))};Xn.dividedToIntegerBy=Xn.idiv=function(t){var s=this,r=s.constructor;return bl(a1(s,new r(t),0,1),r.precision)};Xn.equals=Xn.eq=function(t){return!this.cmp(t)};Xn.exponent=function(){return $d(this)};Xn.greaterThan=Xn.gt=function(t){return this.cmp(t)>0};Xn.greaterThanOrEqualTo=Xn.gte=function(t){return this.cmp(t)>=0};Xn.isInteger=Xn.isint=function(){return this.e>this.d.length-2};Xn.isNegative=Xn.isneg=function(){return this.s<0};Xn.isPositive=Xn.ispos=function(){return this.s>0};Xn.isZero=function(){return this.s===0};Xn.lessThan=Xn.lt=function(t){return this.cmp(t)<0};Xn.lessThanOrEqualTo=Xn.lte=function(t){return this.cmp(t)<1};Xn.logarithm=Xn.log=function(t){var s,r=this,n=r.constructor,a=n.precision,o=a+5;if(t===void 0)t=new n(10);else if(t=new n(t),t.s<1||t.eq(sf))throw Error(Dx+"NaN");if(r.s<1)throw Error(Dx+(r.s?"NaN":"-Infinity"));return r.eq(sf)?new n(0):(vc=!1,s=a1(BD(r,o),BD(t,o),o),vc=!0,bl(s,a))};Xn.minus=Xn.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?cnt(s,t):ont(s,(t.s=-t.s,t))};Xn.modulo=Xn.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(Dx+"NaN");return r.s?(vc=!1,s=a1(r,t,0,1).times(t),vc=!0,r.minus(s)):bl(new n(r),a)};Xn.naturalExponential=Xn.exp=function(){return lnt(this)};Xn.naturalLogarithm=Xn.ln=function(){return BD(this)};Xn.negated=Xn.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Xn.plus=Xn.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?ont(s,t):cnt(s,(t.s=-t.s,t))};Xn.precision=Xn.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(LS+t);if(s=$d(a)+1,n=a.d.length-1,r=n*Xl+1,n=a.d[n],n){for(;n%10==0;n/=10)r--;for(n=a.d[0];n>=10;n/=10)r++}return t&&s>r?s:r};Xn.squareRoot=Xn.sqrt=function(){var t,s,r,n,a,o,l,i=this,d=i.constructor;if(i.s<1){if(!i.s)return new d(0);throw Error(Dx+"NaN")}for(t=$d(i),vc=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=Vy(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=vE((t+1)/2)-(t<0||t%2),a==1/0?s="5e"+t:(s=a.toExponential(),s=s.slice(0,s.indexOf("e")+1)+t),n=new d(s)):n=new d(a.toString()),r=d.precision,a=l=r+3;;)if(o=n,n=o.plus(a1(i,o,l+2)).times(.5),Vy(o.d).slice(0,l)===(s=Vy(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(bl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return vc=!0,bl(n,r)};Xn.times=Xn.mul=function(t){var s,r,n,a,o,l,i,d,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,d=y.length,u=_.length,d=0;){for(s=0,a=d+n;a>n;)i=o[a]+_[n]*y[a-n-1]+s,o[a--]=i%Au|0,s=i/Au|0;o[a]=(o[a]+s)%Au|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,vc?bl(t,f.precision):t};Xn.toDecimalPlaces=Xn.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(x0(t,0,yE),s===void 0?s=n.rounding:x0(s,0,8),bl(r,t+$d(r)+1,s))};Xn.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=uC(n,!0):(x0(t,0,yE),s===void 0?s=a.rounding:x0(s,0,8),n=bl(new a(n),t+1,s),r=uC(n,!0,t+1)),r};Xn.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?uC(a):(x0(t,0,yE),s===void 0?s=o.rounding:x0(s,0,8),n=bl(new o(a),t+$d(a)+1,s),r=uC(n.abs(),!1,t+$d(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};Xn.toInteger=Xn.toint=function(){var t=this,s=t.constructor;return bl(new s(t),$d(t)+1,s.rounding)};Xn.toNumber=function(){return+this};Xn.toPower=Xn.pow=function(t){var s,r,n,a,o,l,i=this,d=i.constructor,u=12,p=+(t=new d(t));if(!t.s)return new d(sf);if(i=new d(i),!i.s){if(t.s<1)throw Error(Dx+"Infinity");return i}if(i.eq(sf))return i;if(n=d.precision,t.eq(sf))return bl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=p<0?-p:p)<=int){for(a=new d(sf),s=Math.ceil(n/Xl+4),vc=!1;r%2&&(a=a.times(i),KOe(a.d,s)),r=vE(r/2),r!==0;)i=i.times(i),KOe(i.d,s);return vc=!0,t.s<0?new d(sf).div(a):bl(a,n)}}else if(o<0)throw Error(Dx+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,vc=!1,a=t.times(BD(i,n+u)),vc=!0,a=lnt(a),a.s=o,a};Xn.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=$d(a),n=uC(a,r<=o.toExpNeg||r>=o.toExpPos)):(x0(t,1,yE),s===void 0?s=o.rounding:x0(s,0,8),a=bl(new o(a),t,s),r=$d(a),n=uC(a,t<=r||r<=o.toExpNeg,t)),n};Xn.toSignificantDigits=Xn.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(x0(t,1,yE),s===void 0?s=n.rounding:x0(s,0,8)),bl(new n(r),t,s)};Xn.toString=Xn.valueOf=Xn.val=Xn.toJSON=Xn[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=$d(t),r=t.constructor;return uC(t,s<=r.toExpNeg||s>=r.toExpPos)};function ont(t,s){var r,n,a,o,l,i,d,u,p=t.constructor,f=p.precision;if(!t.s||!s.s)return s.s||(s=new p(t)),vc?bl(s,f):s;if(d=t.d,u=s.d,l=t.e,a=s.e,d=d.slice(),o=l-a,o){for(o<0?(n=d,o=-o,i=u.length):(n=u,a=l,i=d.length),l=Math.ceil(f/Xl),i=l>i?l+1:i+1,o>i&&(o=i,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(i=d.length,o=u.length,i-o<0&&(o=i,n=u,u=d,d=n),r=0;o;)r=(d[--o]=d[o]+u[o]+r)/Au|0,d[o]%=Au;for(r&&(d.unshift(r),++a),i=d.length;d[--i]==0;)d.pop();return s.d=d,s.e=a,vc?bl(s,f):s}function x0(t,s,r){if(t!==~~t||tr)throw Error(LS+t)}function Vy(t){var s,r,n,a=t.length-1,o="",l=t[0];if(a>0){for(o+=l,s=1;sl?1:-1;else for(i=d=0;ia[i]?1:-1;break}return d}function r(n,a,o){for(var l=0;o--;)n[o]-=l,l=n[o]1;)n.shift()}return function(n,a,o,l){var i,d,u,p,f,y,_,b,N,w,S,C,A,I,L,O,U,q,$=n.constructor,V=n.s==a.s?1:-1,ee=n.d,Z=a.d;if(!n.s)return new $(n);if(!a.s)throw Error(Dx+"Division by zero");for(d=n.e-a.e,U=Z.length,L=ee.length,_=new $(V),b=_.d=[],u=0;Z[u]==(ee[u]||0);)++u;if(Z[u]>(ee[u]||0)&&--d,o==null?C=o=$.precision:l?C=o+($d(n)-$d(a))+1:C=o,C<0)return new $(0);if(C=C/Xl+2|0,u=0,U==1)for(p=0,Z=Z[0],C++;(u1&&(Z=t(Z,p),ee=t(ee,p),U=Z.length,L=ee.length),I=U,N=ee.slice(0,U),w=N.length;w=Au/2&&++O;do p=0,i=s(Z,N,U,w),i<0?(S=N[0],U!=w&&(S=S*Au+(N[1]||0)),p=S/O|0,p>1?(p>=Au&&(p=Au-1),f=t(Z,p),y=f.length,w=N.length,i=s(f,N,y,w),i==1&&(p--,r(f,U16)throw Error(ISe+$d(t));if(!t.s)return new p(sf);for(vc=!1,i=f,l=new p(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(c4(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new p(sf),p.precision=i;;){if(a=bl(a.times(t),i),r=r.times(++d),l=o.plus(a1(a,r,i)),Vy(l.d).slice(0,i)===Vy(o.d).slice(0,i)){for(;u--;)o=bl(o.times(o),i);return p.precision=f,s==null?(vc=!0,bl(o,f)):o}o=l}}function $d(t){for(var s=t.e*Xl,r=t.d[0];r>=10;r/=10)s++;return s}function Qye(t,s,r){if(s>t.LN10.sd())throw vc=!0,r&&(t.precision=r),Error(Dx+"LN10 precision limit exceeded");return bl(new t(t.LN10),s)}function H_(t){for(var s="";t--;)s+="0";return s}function BD(t,s){var r,n,a,o,l,i,d,u,p,f=1,y=10,_=t,b=_.d,N=_.constructor,w=N.precision;if(_.s<1)throw Error(Dx+(_.s?"NaN":"-Infinity"));if(_.eq(sf))return new N(0);if(s==null?(vc=!1,u=w):u=s,_.eq(10))return s==null&&(vc=!0),Qye(N,u);if(u+=y,N.precision=u,r=Vy(b),n=r.charAt(0),o=$d(_),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)_=_.times(t),r=Vy(_.d),n=r.charAt(0),f++;o=$d(_),n>1?(_=new N("0."+r),o++):_=new N(n+"."+r.slice(1))}else return d=Qye(N,u+2,w).times(o+""),_=BD(new N(n+"."+r.slice(1)),u-y).plus(d),N.precision=w,s==null?(vc=!0,bl(_,w)):_;for(i=l=_=a1(_.minus(sf),_.plus(sf),u),p=bl(_.times(_),u),a=3;;){if(l=bl(l.times(p),u),d=i.plus(a1(l,new N(a),u)),Vy(d.d).slice(0,u)===Vy(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(Qye(N,u+2,w).times(o+""))),i=a1(i,new N(f),u),N.precision=w,s==null?(vc=!0,bl(i,w)):i;i=d,a+=2}}function WOe(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=vE(r/Xl),t.d=[],n=(r+1)%Xl,r<0&&(n+=Xl),nHce||t.e<-Hce))throw Error(ISe+r)}else t.s=0,t.e=0,t.d=[0];return t}function bl(t,s,r){var n,a,o,l,i,d,u,p,f=t.d;for(l=1,o=f[0];o>=10;o/=10)l++;if(n=s-l,n<0)n+=Xl,a=s,u=f[p=0];else{if(p=Math.ceil((n+1)/Xl),o=f.length,p>=o)return t;for(u=o=f[p],l=1;o>=10;o/=10)l++;n%=Xl,a=n-Xl+l}if(r!==void 0&&(o=c4(10,l-a-1),i=u/o%10|0,d=s<0||f[p+1]!==void 0||u%o,d=r<4?(i||d)&&(r==0||r==(t.s<0?3:2)):i>5||i==5&&(r==4||d||r==6&&(n>0?a>0?u/c4(10,l-a):0:f[p-1])%10&1||r==(t.s<0?8:7))),s<1||!f[0])return d?(o=$d(t),f.length=1,s=s-o-1,f[0]=c4(10,(Xl-s%Xl)%Xl),t.e=vE(-s/Xl)||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=c4(10,Xl-n),f[p]=a>0?(u/c4(10,l-a)%c4(10,a)|0)*o:0),d)for(;;)if(p==0){(f[0]+=o)==Au&&(f[0]=1,++t.e);break}else{if(f[p]+=o,f[p]!=Au)break;f[p--]=0,o=1}for(n=f.length;f[--n]===0;)f.pop();if(vc&&(t.e>Hce||t.e<-Hce))throw Error(ISe+$d(t));return t}function cnt(t,s){var r,n,a,o,l,i,d,u,p,f,y=t.constructor,_=y.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new y(t),vc?bl(s,_):s;if(d=t.d,f=s.d,n=s.e,u=t.e,d=d.slice(),l=u-n,l){for(p=l<0,p?(r=d,l=-l,i=f.length):(r=f,n=u,i=d.length),a=Math.max(Math.ceil(_/Xl),i)+2,l>a&&(l=a,r.length=1),r.reverse(),a=l;a--;)r.push(0);r.reverse()}else{for(a=d.length,i=f.length,p=a0;--a)d[i++]=0;for(a=f.length;a>l;){if(d[--a]0?o=o.charAt(0)+"."+o.slice(1)+H_(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+H_(-a-1)+o,r&&(n=r-l)>0&&(o+=H_(n))):a>=l?(o+=H_(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+H_(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=H_(n))),t.s<0?"-"+o:o}function KOe(t,s){if(t.length>s)return t.length=s,!0}function dnt(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(LS+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 WOe(l,o.toString())}else if(typeof o!="string")throw Error(LS+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,Dus.test(o))WOe(l,o);else throw Error(LS+o)}if(a.prototype=Xn,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.clone=dnt,a.config=a.set=Rus,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(LS+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(LS+r+": "+n);return this}var LSe=dnt(Lus);sf=new LSe(1);const tl=LSe;function Ous(t){return $us(t)||Bus(t)||zus(t)||Fus()}function Fus(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zus(t,s){if(t){if(typeof t=="string")return Fbe(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 Fbe(t,s)}}function Bus(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function $us(t){if(Array.isArray(t))return Fbe(t)}function Fbe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=s?r.apply(void 0,a):t(s-l,ZOe(function(){for(var i=arguments.length,d=new Array(i),u=0;ut.length)&&(s=t.length);for(var r=0,n=new Array(s);r"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,a=!1,o=void 0;try{for(var l=t[Symbol.iterator](),i;!(n=(i=l.next()).done)&&(r.push(i.value),!(s&&r.length===s));n=!0);}catch(d){a=!0,o=d}finally{try{!n&&l.return!=null&&l.return()}finally{if(a)throw o}}return r}}function shs(t){if(Array.isArray(t))return t}function fnt(t){var s=$D(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function xnt(t,s,r){if(t.lte(0))return new tl(0);var n=ume.getDigitCount(t.toNumber()),a=new tl(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new tl(Math.ceil(o.div(l).toNumber())).add(r).mul(l),d=i.mul(a);return s?d:new tl(Math.ceil(d))}function rhs(t,s,r){var n=1,a=new tl(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new tl(10).pow(ume.getDigitCount(t)-1),a=new tl(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new tl(Math.floor(t)))}else t===0?a=new tl(Math.floor((s-1)/2)):r||(a=new tl(Math.floor(t)));var l=Math.floor((s-1)/2),i=Hus(Vus(function(d){return a.add(new tl(d-l).mul(n)).toNumber()}),zbe);return i(0,s)}function gnt(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 tl(0),tickMin:new tl(0),tickMax:new tl(0)};var o=xnt(new tl(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new tl(0):(l=new tl(t).add(s).div(2),l=l.sub(new tl(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),d=Math.ceil(new tl(s).sub(l).div(o).toNumber()),u=i+d+1;return u>r?gnt(t,s,r,n,a+1):(u0?d+(r-u):d,i=s>0?i:i+(r-u)),{step:o,tickMin:l.sub(new tl(i).mul(o)),tickMax:l.add(new tl(d).mul(o))})}function nhs(t){var s=$D(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=fnt([r,n]),d=$D(i,2),u=d[0],p=d[1];if(u===-1/0||p===1/0){var f=p===1/0?[u].concat($be(zbe(0,a-1).map(function(){return 1/0}))):[].concat($be(zbe(0,a-1).map(function(){return-1/0})),[p]);return r>n?Bbe(f):f}if(u===p)return rhs(u,a,o);var y=gnt(u,p,l,o),_=y.step,b=y.tickMin,N=y.tickMax,w=ume.rangeStep(b,N.add(new tl(.1).mul(_)),_);return r>n?Bbe(w):w}function ahs(t,s){var r=$D(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=fnt([n,a]),i=$D(l,2),d=i[0],u=i[1];if(d===-1/0||u===1/0)return[n,a];if(d===u)return[d];var p=Math.max(s,2),f=xnt(new tl(u).sub(d).div(p-1),o,0),y=[].concat($be(ume.rangeStep(new tl(d),new tl(u).sub(new tl(.99).mul(f)),f)),[u]);return n>a?Bbe(y):y}var ihs=mnt(nhs),ohs=mnt(ahs),lhs="Invariant failed";function hC(t,s){throw new Error(lhs)}var chs=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function eA(t){"@babel/helpers - typeof";return eA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},eA(t)}function Gce(){return Gce=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function xhs(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 ghs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function yhs(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,l=-1,i=(r=n==null?void 0:n.length)!==null&&r!==void 0?r:0;if(i<=1)return 0;if(o&&o.axisType==="angleAxis"&&Math.abs(Math.abs(o.range[1]-o.range[0])-360)<=1e-6)for(var d=o.range,u=0;u0?a[u-1].coordinate:a[i-1].coordinate,f=a[u].coordinate,y=u>=i-1?a[0].coordinate:a[u+1].coordinate,_=void 0;if(_m(f-p)!==_m(y-f)){var b=[];if(_m(y-f)===_m(d[1]-d[0])){_=y;var N=f+d[1]-d[0];b[0]=Math.min(N,(N+p)/2),b[1]=Math.max(N,(N+p)/2)}else{_=p;var w=y+d[1]-d[0];b[0]=Math.min(f,(w+f)/2),b[1]=Math.max(f,(w+f)/2)}var S=[Math.min(f,(_+f)/2),Math.max(f,(_+f)/2)];if(s>S[0]&&s<=S[1]||s>=b[0]&&s<=b[1]){l=a[u].index;break}}else{var C=Math.min(p,y),A=Math.max(p,y);if(s>(C+f)/2&&s<=(A+f)/2){l=a[u].index;break}}}else for(var I=0;I0&&I(n[I].coordinate+n[I-1].coordinate)/2&&s<=(n[I].coordinate+n[I+1].coordinate)/2||I===i-1&&s>(n[I].coordinate+n[I-1].coordinate)/2){l=n[I].index;break}return l},DSe=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?Zc(Zc({},s.type.defaultProps),s.props):s.props,l=o.stroke,i=o.fill,d;switch(a){case"Line":d=l;break;case"Area":case"Radar":d=l&&l!=="none"?l:i;break;default:d=i;break}return d},Dhs=function(s){var r=s.barSize,n=s.totalSize,a=s.stackGroups,o=a===void 0?{}:a;if(!o)return{};for(var l={},i=Object.keys(o),d=0,u=i.length;d=0});if(S&&S.length){var C=S[0].type.defaultProps,A=C!==void 0?Zc(Zc({},C),S[0].props):S[0].props,I=A.barSize,L=A[w];l[L]||(l[L]=[]);var O=yi(I)?r:I;l[L].push({item:S[0],stackList:S.slice(1),barSize:yi(O)?void 0:bm(O,n,0)})}}return l},Rhs=function(s){var r=s.barGap,n=s.barCategoryGap,a=s.bandSize,o=s.sizeList,l=o===void 0?[]:o,i=s.maxBarSize,d=l.length;if(d<1)return null;var u=bm(r,a,0,!0),p,f=[];if(l[0].barSize===+l[0].barSize){var y=!1,_=a/d,b=l.reduce(function(I,L){return I+L.barSize||0},0);b+=(d-1)*u,b>=a&&(b-=(d-1)*u,u=0),b>=a&&_>0&&(y=!0,_*=.9,b=d*_);var N=(a-b)/2>>0,w={offset:N-u,size:0};p=l.reduce(function(I,L){var O={item:L.item,position:{offset:w.offset+w.size+u,size:y?_:L.barSize}},U=[].concat(QOe(I),[O]);return w=U[U.length-1].position,L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){U.push({item:q,position:w})}),U},f)}else{var S=bm(n,a,0,!0);a-2*S-(d-1)*u<=0&&(u=0);var C=(a-2*S-(d-1)*u)/d;C>1&&(C>>=0);var A=i===+i?Math.min(C,i):C;p=l.reduce(function(I,L,O){var U=[].concat(QOe(I),[{item:L.item,position:{offset:S+(C+u)*O+(C-A)/2,size:A}}]);return L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){U.push({item:q,position:U[U.length-1].position})}),U},f)}return p},Ohs=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,d=l-(i.left||0)-(i.right||0),u=bnt({children:o,legendWidth:d});if(u){var p=a||{},f=p.width,y=p.height,_=u.align,b=u.verticalAlign,N=u.layout;if((N==="vertical"||N==="horizontal"&&b==="middle")&&_!=="center"&&Qr(s[_]))return Zc(Zc({},s),{},nT({},_,s[_]+(f||0)));if((N==="horizontal"||N==="vertical"&&_==="center")&&b!=="middle"&&Qr(s[b]))return Zc(Zc({},s),{},nT({},b,s[b]+(y||0)))}return s},Fhs=function(s,r,n){return yi(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},wnt=function(s,r,n,a,o){var l=r.props.children,i=gf(l,vO).filter(function(u){return Fhs(a,o,u.props.direction)});if(i&&i.length){var d=i.map(function(u){return u.props.dataKey});return s.reduce(function(u,p){var f=au(p,n);if(yi(f))return u;var y=Array.isArray(f)?[cme(f),lme(f)]:[f,f],_=d.reduce(function(b,N){var w=au(p,N,0),S=y[0]-Math.abs(Array.isArray(w)?w[0]:w),C=y[1]+Math.abs(Array.isArray(w)?w[1]:w);return[Math.min(S,b[0]),Math.max(C,b[1])]},[1/0,-1/0]);return[Math.min(_[0],u[0]),Math.max(_[1],u[1])]},[1/0,-1/0])}return null},zhs=function(s,r,n,a,o){var l=r.map(function(i){return wnt(s,i,n,o,a)}).filter(function(i){return!yi(i)});return l&&l.length?l.reduce(function(i,d){return[Math.min(i[0],d[0]),Math.max(i[1],d[1])]},[1/0,-1/0]):null},jnt=function(s,r,n,a,o){var l=r.map(function(d){var u=d.props.dataKey;return n==="number"&&u&&wnt(s,d,u,a)||w8(s,u,n,o)});if(n==="number")return l.reduce(function(d,u){return[Math.min(d[0],u[0]),Math.max(d[1],u[1])]},[1/0,-1/0]);var i={};return l.reduce(function(d,u){for(var p=0,f=u.length;p=2?_m(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!uO(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}})},Jye=new WeakMap,h9=function(s,r){if(typeof r!="function")return s;Jye.has(s)||Jye.set(s,new WeakMap);var n=Jye.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},Snt=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:$ce(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:b8(),realScaleType:"point"}:o==="category"?{scale:DD(),realScaleType:"band"}:{scale:$ce(),realScaleType:"linear"};if(lC(a)){var d="scale".concat(Khe(a));return{scale:(GOe[d]||b8)(),realScaleType:GOe[d]?d:"point"}}return ci(a)?{scale:a}:{scale:b8(),realScaleType:"point"}},eFe=1e-4,Cnt=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])-eFe,l=Math.max(a[0],a[1])+eFe,i=s(r[0]),d=s(r[n-1]);(il||dl)&&s.domain([r[0],r[n-1]])}},Bhs=function(s,r){if(!s)return null;for(var n=0,a=s.length;na)&&(o[1]=a),o[0]>a&&(o[0]=a),o[1]=0?(s[i][n][0]=o,s[i][n][1]=o+d,o=s[i][n][1]):(s[i][n][0]=l,s[i][n][1]=l+d,l=s[i][n][1])}},Uhs=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)}},Vhs={sign:qhs,expand:cJt,none:GT,silhouette:dJt,wiggle:uJt,positive:Uhs},Hhs=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=Vhs[n],l=lJt().keys(a).value(function(i,d){return+au(i,d,0)}).order(fbe).offset(o);return l(s)},Ghs=function(s,r,n,a,o,l){if(!s)return null;var i=l?r.reverse():r,d={},u=i.reduce(function(f,y){var _,b=(_=y.type)!==null&&_!==void 0&&_.defaultProps?Zc(Zc({},y.type.defaultProps),y.props):y.props,N=b.stackId,w=b.hide;if(w)return f;var S=b[n],C=f[S]||{hasStack:!1,stackGroups:{}};if(ou(N)){var A=C.stackGroups[N]||{numericAxisId:n,cateAxisId:a,items:[]};A.items.push(y),C.hasStack=!0,C.stackGroups[N]=A}else C.stackGroups[mE("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[y]};return Zc(Zc({},f),{},nT({},S,C))},d),p={};return Object.keys(u).reduce(function(f,y){var _=u[y];if(_.hasStack){var b={};_.stackGroups=Object.keys(_.stackGroups).reduce(function(N,w){var S=_.stackGroups[w];return Zc(Zc({},N),{},nT({},w,{numericAxisId:n,cateAxisId:a,items:S.items,stackedData:Hhs(s,S.items,o)}))},b)}return Zc(Zc({},f),{},nT({},y,_))},p)},Mnt=function(s,r){var n=r.realScaleType,a=r.type,o=r.tickCount,l=r.originalDomain,i=r.allowDecimals,d=n||r.scale;if(d!=="auto"&&d!=="linear")return null;if(o&&a==="number"&&l&&(l[0]==="auto"||l[1]==="auto")){var u=s.domain();if(!u.length)return null;var p=ihs(u,o,i);return s.domain([cme(p),lme(p)]),{niceTicks:p}}if(o&&a==="number"){var f=s.domain(),y=ohs(f,o,i);return{niceTicks:y}}return null};function tFe(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&&!yi(a[s.dataKey])){var i=vce(r,"value",a[s.dataKey]);if(i)return i.coordinate+n/2}return r[o]?r[o].coordinate+n/2:null}var d=au(a,yi(l)?s.dataKey:l);return yi(d)?null:s.scale(d)}var sFe=function(s){var r=s.axis,n=s.ticks,a=s.offset,o=s.bandSize,l=s.entry,i=s.index;if(r.type==="category")return n[i]?n[i].coordinate+a:null;var d=au(l,r.dataKey,r.domain[i]);return yi(d)?null:r.scale(d)-o/2+a},Whs=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]},Khs=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?Zc(Zc({},s.type.defaultProps),s.props):s.props,o=a.stackId;if(ou(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},Zhs=function(s){return s.reduce(function(r,n){return[cme(n.concat([r[0]]).filter(Qr)),lme(n.concat([r[1]]).filter(Qr))]},[1/0,-1/0])},Tnt=function(s,r,n){return Object.keys(s).reduce(function(a,o){var l=s[o],i=l.stackedData,d=i.reduce(function(u,p){var f=Zhs(p.slice(r,n+1));return[Math.min(u[0],f[0]),Math.max(u[1],f[1])]},[1/0,-1/0]);return[Math.min(d[0],a[0]),Math.max(d[1],a[1])]},[1/0,-1/0]).map(function(a){return a===1/0||a===-1/0?0:a})},rFe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,nFe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Hbe=function(s,r,n){if(ci(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(Qr(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(rFe.test(s[0])){var o=+rFe.exec(s[0])[1];a[0]=r[0]-o}else ci(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(Qr(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(nFe.test(s[1])){var l=+nFe.exec(s[1])[1];a[1]=r[1]+l}else ci(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},Kce=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=cSe(r,function(f){return f.coordinate}),l=1/0,i=1,d=o.length;it.length)&&(s=t.length);for(var r=0,n=new Array(s);r2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(s-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},nms=function(s,r,n,a,o){var l=s.width,i=s.height,d=s.startAngle,u=s.endAngle,p=bm(s.cx,l,l/2),f=bm(s.cy,i,i/2),y=Pnt(l,i,n),_=bm(s.innerRadius,y,0),b=bm(s.outerRadius,y,y*.8),N=Object.keys(r);return N.reduce(function(w,S){var C=r[S],A=C.domain,I=C.reversed,L;if(yi(C.range))a==="angleAxis"?L=[d,u]:a==="radiusAxis"&&(L=[_,b]),I&&(L=[L[1],L[0]]);else{L=C.range;var O=L,U=Qhs(O,2);d=U[0],u=U[1]}var q=Snt(C,o),$=q.realScaleType,V=q.scale;V.domain(A).range(L),Cnt(V);var ee=Mnt(V,Nv(Nv({},C),{},{realScaleType:$})),Z=Nv(Nv(Nv({},C),ee),{},{range:L,radius:b,realScaleType:$,scale:V,cx:p,cy:f,innerRadius:_,outerRadius:b,startAngle:d,endAngle:u});return Nv(Nv({},w),{},Ent({},S,Z))},{})},ams=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))},ims=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=ams({x:n,y:a},{x:o,y:l});if(i<=0)return{radius:i};var d=(n-o)/i,u=Math.acos(d);return a>l&&(u=2*Math.PI-u),{radius:i,angle:rms(u),angleInRadian:u}},oms=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}},lms=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},lFe=function(s,r){var n=s.x,a=s.y,o=ims({x:n,y:a},r),l=o.radius,i=o.angle,d=r.innerRadius,u=r.outerRadius;if(lu)return!1;if(l===0)return!0;var p=oms(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?Nv(Nv({},r),{},{radius:l,angle:lms(_,r)}):null},Int=function(s){return!k.isValidElement(s)&&!ci(s)&&typeof s!="boolean"?s.className:""};function HD(t){"@babel/helpers - typeof";return HD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},HD(t)}var cms=["offset"];function dms(t){return pms(t)||mms(t)||hms(t)||ums()}function ums(){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 hms(t,s){if(t){if(typeof t=="string")return Gbe(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 Gbe(t,s)}}function mms(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function pms(t){if(Array.isArray(t))return Gbe(t)}function Gbe(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 xms(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 cFe(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 Jd(t){for(var s=1;s=0?1:-1,A,I;a==="insideStart"?(A=_+C*l,I=N):a==="insideEnd"?(A=b-C*l,I=!N):a==="end"&&(A=b+C*l,I=N),I=S<=0?I:!I;var L=Dl(u,p,w,A),O=Dl(u,p,w,A+(I?1:-1)*359),U="M".concat(L.x,",").concat(L.y,` A`).concat(w,",").concat(w,",0,1,").concat(I?0:1,`, `).concat(O.x,",").concat(O.y),q=yi(s.id)?mE("recharts-radial-line-"):s.id;return ht.createElement("text",GD({},n,{dominantBaseline:"central",className:bi("recharts-radial-bar-label",i)}),ht.createElement("defs",null,ht.createElement("path",{id:q,d:U})),ht.createElement("textPath",{xlinkHref:"#".concat(q)},r))},jms=function(s){var r=s.viewBox,n=s.offset,a=s.position,o=r,l=o.cx,i=o.cy,d=o.innerRadius,u=o.outerRadius,p=o.startAngle,f=o.endAngle,y=(p+f)/2;if(a==="outside"){var _=Dl(l,i,u+n,y),b=_.x,N=_.y;return{x:b,y:N,textAnchor:b>=l?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"end"};var w=(d+u)/2,S=Dl(l,i,w,y),C=S.x,A=S.y;return{x:C,y:A,textAnchor:"middle",verticalAnchor:"middle"}},Nms=function(s){var r=s.viewBox,n=s.parentViewBox,a=s.offset,o=s.position,l=r,i=l.x,d=l.y,u=l.width,p=l.height,f=p>=0?1:-1,y=f*a,_=f>0?"end":"start",b=f>0?"start":"end",N=u>=0?1:-1,w=N*a,S=N>0?"end":"start",C=N>0?"start":"end";if(o==="top"){var A={x:i+u/2,y:d-f*a,textAnchor:"middle",verticalAnchor:_};return Jd(Jd({},A),n?{height:Math.max(d-n.y,0),width:u}:{})}if(o==="bottom"){var I={x:i+u/2,y:d+p+y,textAnchor:"middle",verticalAnchor:b};return Jd(Jd({},I),n?{height:Math.max(n.y+n.height-(d+p),0),width:u}:{})}if(o==="left"){var L={x:i-w,y:d+p/2,textAnchor:S,verticalAnchor:"middle"};return Jd(Jd({},L),n?{width:Math.max(L.x-n.x,0),height:p}:{})}if(o==="right"){var O={x:i+u+w,y:d+p/2,textAnchor:C,verticalAnchor:"middle"};return Jd(Jd({},O),n?{width:Math.max(n.x+n.width-O.x,0),height:p}:{})}var U=n?{width:u,height:p}:{};return o==="insideLeft"?Jd({x:i+w,y:d+p/2,textAnchor:C,verticalAnchor:"middle"},U):o==="insideRight"?Jd({x:i+u-w,y:d+p/2,textAnchor:S,verticalAnchor:"middle"},U):o==="insideTop"?Jd({x:i+u/2,y:d+y,textAnchor:"middle",verticalAnchor:b},U):o==="insideBottom"?Jd({x:i+u/2,y:d+p-y,textAnchor:"middle",verticalAnchor:_},U):o==="insideTopLeft"?Jd({x:i+w,y:d+y,textAnchor:C,verticalAnchor:b},U):o==="insideTopRight"?Jd({x:i+u-w,y:d+y,textAnchor:S,verticalAnchor:b},U):o==="insideBottomLeft"?Jd({x:i+w,y:d+p-y,textAnchor:C,verticalAnchor:_},U):o==="insideBottomRight"?Jd({x:i+u-w,y:d+p-y,textAnchor:S,verticalAnchor:_},U):cE(o)&&(Qr(o.x)||C4(o.x))&&(Qr(o.y)||C4(o.y))?Jd({x:i+bm(o.x,u),y:d+bm(o.y,p),textAnchor:"end",verticalAnchor:"end"},U):Jd({x:i+u/2,y:d+p/2,textAnchor:"middle",verticalAnchor:"middle"},U)},kms=function(s){return"cx"in s&&Qr(s.cx)};function Lu(t){var s=t.offset,r=s===void 0?5:s,n=fms(t,cms),a=Jd({offset:r},n),o=a.viewBox,l=a.position,i=a.value,d=a.children,u=a.content,p=a.className,f=p===void 0?"":p,y=a.textBreakAll;if(!o||yi(i)&&yi(d)&&!k.isValidElement(u)&&!ci(u))return null;if(k.isValidElement(u))return k.cloneElement(u,a);var _;if(ci(u)){if(_=k.createElement(u,a),k.isValidElement(_))return _}else _=_ms(a);var b=kms(o),N=Ba(a,!0);if(b&&(l==="insideStart"||l==="insideEnd"||l==="end"))return wms(a,_,N);var w=b?jms(a):Nms(a);return ht.createElement(dC,GD({className:bi("recharts-label",f)},N,w,{breakAll:y}),_)}Lu.displayName="Label";var Lnt=function(s){var r=s.cx,n=s.cy,a=s.angle,o=s.startAngle,l=s.endAngle,i=s.r,d=s.radius,u=s.innerRadius,p=s.outerRadius,f=s.x,y=s.y,_=s.top,b=s.left,N=s.width,w=s.height,S=s.clockWise,C=s.labelViewBox;if(C)return C;if(Qr(N)&&Qr(w)){if(Qr(f)&&Qr(y))return{x:f,y,width:N,height:w};if(Qr(_)&&Qr(b))return{x:_,y:b,width:N,height:w}}return Qr(f)&&Qr(y)?{x:f,y,width:0,height:0}:Qr(r)&&Qr(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:p||d||i||0,clockWise:S}:s.viewBox?s.viewBox:{}},Sms=function(s,r){return s?s===!0?ht.createElement(Lu,{key:"label-implicit",viewBox:r}):ou(s)?ht.createElement(Lu,{key:"label-implicit",viewBox:r,value:s}):k.isValidElement(s)?s.type===Lu?k.cloneElement(s,{key:"label-implicit",viewBox:r}):ht.createElement(Lu,{key:"label-implicit",content:s,viewBox:r}):ci(s)?ht.createElement(Lu,{key:"label-implicit",content:s,viewBox:r}):cE(s)?ht.createElement(Lu,GD({viewBox:r},s,{key:"label-implicit"})):null:null},Cms=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=Lnt(s),l=gf(a,Lu).map(function(d,u){return k.cloneElement(d,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=Sms(s.label,r||o);return[i].concat(dms(l))};Lu.parseViewBox=Lnt;Lu.renderCallByParent=Cms;function Mms(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var Tms=Mms;const Ams=ro(Tms);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 Ems=["valueAccessor"],Pms=["data","dataKey","clockWise","id","textBreakAll"];function Ims(t){return Oms(t)||Rms(t)||Dms(t)||Lms()}function Lms(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Dms(t,s){if(t){if(typeof t=="string")return Wbe(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 Wbe(t,s)}}function Rms(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Oms(t){if(Array.isArray(t))return Wbe(t)}function Wbe(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 $ms(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 qms=function(s){return Array.isArray(s.value)?Ams(s.value):s.value};function i1(t){var s=t.valueAccessor,r=s===void 0?qms:s,n=hFe(t,Ems),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,d=n.textBreakAll,u=hFe(n,Pms);return!a||!a.length?null:ht.createElement(No,{className:"recharts-label-list"},a.map(function(p,f){var y=yi(o)?r(p,f):au(p&&p.payload,o),_=yi(i)?{}:{id:"".concat(i,"-").concat(f)};return ht.createElement(Lu,Yce({},Ba(p,!0),u,_,{parentViewBox:p.parentViewBox,value:y,textBreakAll:d,viewBox:Lu.parseViewBox(yi(l)?p:uFe(uFe({},p),{},{clockWise:l})),key:"label-".concat(f),index:f}))}))}i1.displayName="LabelList";function Ums(t,s){return t?t===!0?ht.createElement(i1,{key:"labelList-implicit",data:s}):ht.isValidElement(t)||ci(t)?ht.createElement(i1,{key:"labelList-implicit",data:s,content:t}):cE(t)?ht.createElement(i1,Yce({data:s},t,{key:"labelList-implicit"})):null:null}function Vms(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=gf(n,i1).map(function(l,i){return k.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=Ums(t.label,s);return[o].concat(Ims(a))}i1.renderCallByParent=Vms;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 Kbe(){return Kbe=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 _=Dl(r,n,a,l),b=Dl(r,n,a,u);y+="L ".concat(b.x,",").concat(b.y,` A `).concat(a,",").concat(a,`,0, `).concat(+(Math.abs(d)>180),",").concat(+(l<=u),`, `).concat(_.x,",").concat(_.y," Z")}else y+="L ".concat(r,",").concat(n," Z");return y},Zms=function(s){var r=s.cx,n=s.cy,a=s.innerRadius,o=s.outerRadius,l=s.cornerRadius,i=s.forceCornerRadius,d=s.cornerIsExternal,u=s.startAngle,p=s.endAngle,f=_m(p-u),y=m9({cx:r,cy:n,radius:o,angle:u,sign:f,cornerRadius:l,cornerIsExternal:d}),_=y.circleTangency,b=y.lineTangency,N=y.theta,w=m9({cx:r,cy:n,radius:o,angle:p,sign:-f,cornerRadius:l,cornerIsExternal:d}),S=w.circleTangency,C=w.lineTangency,A=w.theta,I=d?Math.abs(u-p):Math.abs(u-p)-N-A;if(I<0)return i?"M ".concat(b.x,",").concat(b.y,` a`).concat(l,",").concat(l,",0,0,1,").concat(l*2,`,0 a`).concat(l,",").concat(l,",0,0,1,").concat(-l*2,`,0 `):Dnt({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(S.x,",").concat(S.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(C.x,",").concat(C.y,` `);if(a>0){var O=m9({cx:r,cy:n,radius:a,angle:u,sign:f,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),U=O.circleTangency,q=O.lineTangency,$=O.theta,V=m9({cx:r,cy:n,radius:a,angle:p,sign:-f,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),ee=V.circleTangency,Z=V.lineTangency,J=V.theta,Y=d?Math.abs(u-p):Math.abs(u-p)-$-J;if(Y<0&&l===0)return"".concat(L,"L").concat(r,",").concat(n,"Z");L+="L".concat(Z.x,",").concat(Z.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(ee.x,",").concat(ee.y,` A`).concat(a,",").concat(a,",0,").concat(+(Y>180),",").concat(+(f>0),",").concat(U.x,",").concat(U.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},Yms={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},Rnt=function(s){var r=pFe(pFe({},Yms),s),n=r.cx,a=r.cy,o=r.innerRadius,l=r.outerRadius,i=r.cornerRadius,d=r.forceCornerRadius,u=r.cornerIsExternal,p=r.startAngle,f=r.endAngle,y=r.className;if(l0&&Math.abs(p-f)<360?w=Zms({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(N,b/2),forceCornerRadius:d,cornerIsExternal:u,startAngle:p,endAngle:f}):w=Dnt({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:p,endAngle:f}),ht.createElement("path",Kbe({},Ba(r,!0),{className:_,d:w,role:"img"}))};function ZD(t){"@babel/helpers - typeof";return ZD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},ZD(t)}function Zbe(){return Zbe=Object.assign?Object.assign.bind():function(t){for(var s=1;scps.call(t,s));function LC(t,s){return t===s||!t&&!s&&t!==t&&s!==s}const hps="__v",mps="__o",pps="_owner",{getOwnPropertyDescriptor:vFe,keys:_Fe}=Object;function fps(t,s){return t.byteLength===s.byteLength&&Qce(new Uint8Array(t),new Uint8Array(s))}function xps(t,s,r){let n=t.length;if(s.length!==n)return!1;for(;n-- >0;)if(!r.equals(t[n],s[n],n,n,t,s,r))return!1;return!0}function gps(t,s){return t.byteLength===s.byteLength&&Qce(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(s.buffer,s.byteOffset,s.byteLength))}function yps(t,s){return LC(t.getTime(),s.getTime())}function vps(t,s){return t.name===s.name&&t.message===s.message&&t.cause===s.cause&&t.stack===s.stack}function _ps(t,s){return t===s}function bFe(t,s,r){const n=t.size;if(n!==s.size)return!1;if(!n)return!0;const a=new Array(n),o=t.entries();let l,i,d=0;for(;(l=o.next())&&!l.done;){const u=s.entries();let p=!1,f=0;for(;(i=u.next())&&!i.done;){if(a[f]){f++;continue}const y=l.value,_=i.value;if(r.equals(y[0],_[0],d,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;d++}return!0}const bps=LC;function wps(t,s,r){const n=_Fe(t);let a=n.length;if(_Fe(s).length!==a)return!1;for(;a-- >0;)if(!Bnt(t,s,r,n[a]))return!1;return!0}function x6(t,s,r){const n=yFe(t);let a=n.length;if(yFe(s).length!==a)return!1;let o,l,i;for(;a-- >0;)if(o=n[a],!Bnt(t,s,r,o)||(l=vFe(t,o),i=vFe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function jps(t,s){return LC(t.valueOf(),s.valueOf())}function Nps(t,s){return t.source===s.source&&t.flags===s.flags}function wFe(t,s,r){const n=t.size;if(n!==s.size)return!1;if(!n)return!0;const a=new Array(n),o=t.values();let l,i;for(;(l=o.next())&&!l.done;){const d=s.values();let u=!1,p=0;for(;(i=d.next())&&!i.done;){if(!a[p]&&r.equals(l.value,i.value,l.value,i.value,t,s,r)){u=a[p]=!0;break}p++}if(!u)return!1}return!0}function Qce(t,s){let r=t.byteLength;if(s.byteLength!==r||t.byteOffset!==s.byteOffset)return!1;for(;r-- >0;)if(t[r]!==s[r])return!1;return!0}function kps(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 Bnt(t,s,r,n){return(n===pps||n===mps||n===hps)&&(t.$$typeof||s.$$typeof)?!0:ups(s,n)&&r.equals(t[n],s[n],n,n,t,s,r)}const Sps="[object ArrayBuffer]",Cps="[object Arguments]",Mps="[object Boolean]",Tps="[object DataView]",Aps="[object Date]",Eps="[object Error]",Pps="[object Map]",Ips="[object Number]",Lps="[object Object]",Dps="[object RegExp]",Rps="[object Set]",Ops="[object String]",Fps={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},zps="[object URL]",Bps=Object.prototype.toString;function $ps({areArrayBuffersEqual:t,areArraysEqual:s,areDataViewsEqual:r,areDatesEqual:n,areErrorsEqual:a,areFunctionsEqual:o,areMapsEqual:l,areNumbersEqual:i,areObjectsEqual:d,arePrimitiveWrappersEqual:u,areRegExpsEqual:p,areSetsEqual:f,areTypedArraysEqual:y,areUrlsEqual:_,unknownTagComparators:b}){return function(w,S,C){if(w===S)return!0;if(w==null||S==null)return!1;const A=typeof w;if(A!==typeof S)return!1;if(A!=="object")return A==="number"?i(w,S,C):A==="function"?o(w,S,C):!1;const I=w.constructor;if(I!==S.constructor)return!1;if(I===Object)return d(w,S,C);if(Array.isArray(w))return s(w,S,C);if(I===Date)return n(w,S,C);if(I===RegExp)return p(w,S,C);if(I===Map)return l(w,S,C);if(I===Set)return f(w,S,C);const L=Bps.call(w);if(L===Aps)return n(w,S,C);if(L===Dps)return p(w,S,C);if(L===Pps)return l(w,S,C);if(L===Rps)return f(w,S,C);if(L===Lps)return typeof w.then!="function"&&typeof S.then!="function"&&d(w,S,C);if(L===zps)return _(w,S,C);if(L===Eps)return a(w,S,C);if(L===Cps)return d(w,S,C);if(Fps[L])return y(w,S,C);if(L===Sps)return t(w,S,C);if(L===Tps)return r(w,S,C);if(L===Mps||L===Ips||L===Ops)return u(w,S,C);if(b){let O=b[L];if(!O){const U=dps(w);U&&(O=b[U])}if(O)return O(w,S,C)}return!1}}function qps({circular:t,createCustomConfig:s,strict:r}){let n={areArrayBuffersEqual:fps,areArraysEqual:r?x6:xps,areDataViewsEqual:gps,areDatesEqual:yps,areErrorsEqual:vps,areFunctionsEqual:_ps,areMapsEqual:r?e0e(bFe,x6):bFe,areNumbersEqual:bps,areObjectsEqual:r?x6:wps,arePrimitiveWrappersEqual:jps,areRegExpsEqual:Nps,areSetsEqual:r?e0e(wFe,x6):wFe,areTypedArraysEqual:r?e0e(Qce,x6):Qce,areUrlsEqual:kps,unknownTagComparators:void 0};if(s&&(n=Object.assign({},n,s(n))),t){const a=f9(n.areArraysEqual),o=f9(n.areMapsEqual),l=f9(n.areObjectsEqual),i=f9(n.areSetsEqual);n=Object.assign({},n,{areArraysEqual:a,areMapsEqual:o,areObjectsEqual:l,areSetsEqual:i})}return n}function Ups(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function Vps({circular:t,comparator:s,createState:r,equals:n,strict:a}){if(r)return function(i,d){const{cache:u=t?new WeakMap:void 0,meta:p}=r();return s(i,d,{cache:u,equals:n,meta:p,strict:a})};if(t)return function(i,d){return s(i,d,{cache:new WeakMap,equals:n,meta:void 0,strict:a})};const o={cache:void 0,equals:n,meta:void 0,strict:a};return function(i,d){return s(i,d,o)}}const Hps=Tw();Tw({strict:!0});Tw({circular:!0});Tw({circular:!0,strict:!0});Tw({createInternalComparator:()=>LC});Tw({strict:!0,createInternalComparator:()=>LC});Tw({circular:!0,createInternalComparator:()=>LC});Tw({circular:!0,createInternalComparator:()=>LC,strict:!0});function Tw(t={}){const{circular:s=!1,createInternalComparator:r,createState:n,strict:a=!1}=t,o=qps(t),l=$ps(o),i=r?r(l):Ups(l);return Vps({circular:s,comparator:l,createState:n,equals:i,strict:a})}function Gps(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function jFe(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):Gps(a)};requestAnimationFrame(n)}function Ybe(t){"@babel/helpers - typeof";return Ybe=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},Ybe(t)}function Wps(t){return Xps(t)||Yps(t)||Zps(t)||Kps()}function Kps(){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 Zps(t,s){if(t){if(typeof t=="string")return NFe(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 NFe(t,s)}}function NFe(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:S<0?0:S},N=function(S){for(var C=S>1?1:S,A=C,I=0;I<8;++I){var L=f(A)-C,O=_(A);if(Math.abs(L-C)0&&arguments[0]!==void 0?arguments[0]:{},r=s.stiff,n=r===void 0?100:r,a=s.damping,o=a===void 0?8:a,l=s.dt,i=l===void 0?17:l,d=function(p,f,y){var _=-(p-f)*n,b=y*o,N=y+(_-b)*i/1e3,w=y*i/1e3+p;return Math.abs(w-f)t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Mfs(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 t0e(t){return Pfs(t)||Efs(t)||Afs(t)||Tfs()}function Tfs(){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 Afs(t,s){if(t){if(typeof t=="string")return twe(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 twe(t,s)}}function Efs(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Pfs(t){if(Array.isArray(t))return twe(t)}function twe(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 tde(t){return tde=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},tde(t)}var g0=function(t){Ofs(r,t);var s=Ffs(r);function r(n,a){var o;Ifs(this,r),o=s.call(this,n,a);var l=o.props,i=l.isActive,d=l.attributeName,u=l.from,p=l.to,f=l.steps,y=l.children,_=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(nwe(o)),o.changeStyle=o.changeStyle.bind(nwe(o)),!i||_<=0)return o.state={style:{}},typeof y=="function"&&(o.state={style:p}),rwe(o);if(f&&f.length)o.state={style:f[0].style};else if(u){if(typeof y=="function")return o.state={style:u},rwe(o);o.state={style:d?B6({},d,u):u}}else o.state={style:{}};return o}return Dfs(r,[{key:"componentDidMount",value:function(){var a=this.props,o=a.isActive,l=a.canBegin;this.mounted=!0,!(!o||!l)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(a){var o=this.props,l=o.isActive,i=o.canBegin,d=o.attributeName,u=o.shouldReAnimate,p=o.to,f=o.from,y=this.state.style;if(i){if(!l){var _={style:d?B6({},d,p):p};this.state&&y&&(d&&y[d]!==p||!d&&y!==p)&&this.setState(_);return}if(!(Hps(a.to,p)&&a.canBegin&&a.isActive)){var b=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var N=b||u?f:a.to;if(this.state&&y){var w={style:d?B6({},d,N):N};(d&&y[d]!==N||!d&&y!==N)&&this.setState(w)}this.runAnimation(mg(mg({},this.props),{},{from:N,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var o=this,l=a.from,i=a.to,d=a.duration,u=a.easing,p=a.begin,f=a.onAnimationEnd,y=a.onAnimationStart,_=kfs(l,i,pfs(u),d,this.changeStyle),b=function(){o.stopJSAnimation=_()};this.manager.start([y,p,b,d,f])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,d=a.onAnimationStart,u=l[0],p=u.style,f=u.duration,y=f===void 0?0:f,_=function(N,w,S){if(S===0)return N;var C=w.duration,A=w.easing,I=A===void 0?"ease":A,L=w.style,O=w.properties,U=w.onAnimationEnd,q=S>0?l[S-1]:w,$=O||Object.keys(L);if(typeof I=="function"||I==="spring")return[].concat(t0e(N),[o.runJSAnimation.bind(o,{from:q.style,to:L,duration:C,easing:I}),C]);var V=CFe($,C,I),ee=mg(mg(mg({},q.style),L),{},{transition:V});return[].concat(t0e(N),[ee,C,U]).filter(sfs)};return this.manager.start([d].concat(t0e(l.reduce(_,[p,Math.max(y,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=Qps());var o=a.begin,l=a.duration,i=a.attributeName,d=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 N=i?B6({},i,d):d,w=CFe(Object.keys(N),l,u);b.start([p,o,mg(mg({},N),{},{transition:w}),l,f])}},{key:"render",value:function(){var a=this.props,o=a.children;a.begin;var l=a.duration;a.attributeName,a.easing;var i=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var d=Cfs(a,Sfs),u=k.Children.count(o),p=this.state.style;if(typeof o=="function")return o(p);if(!i||u===0||l<=0)return o;var f=function(_){var b=_.props,N=b.style,w=N===void 0?{}:N,S=b.className,C=k.cloneElement(_,mg(mg({},d),{},{style:mg(mg({},w),p),className:S}));return C};return u===1?f(k.Children.only(o)):ht.createElement("div",null,k.Children.map(o,function(y){return f(y)}))}}]),r}(k.PureComponent);g0.displayName="Animate";g0.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};g0.propTypes={from:$o.oneOfType([$o.object,$o.string]),to:$o.oneOfType([$o.object,$o.string]),attributeName:$o.string,duration:$o.number,begin:$o.number,easing:$o.oneOfType([$o.string,$o.func]),steps:$o.arrayOf($o.shape({duration:$o.number.isRequired,style:$o.object.isRequired,easing:$o.oneOfType([$o.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),$o.func]),properties:$o.arrayOf("string"),onAnimationEnd:$o.func})),children:$o.oneOfType([$o.node,$o.func]),isActive:$o.bool,canBegin:$o.bool,onAnimationEnd:$o.func,shouldReAnimate:$o.bool,onAnimationStart:$o.func,onAnimationReStart:$o.func};function QD(t){"@babel/helpers - typeof";return QD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},QD(t)}function sde(){return sde=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0?1:-1,d=n>=0?1:-1,u=a>=0&&n>=0||a<0&&n<0?1:0,p;if(l>0&&o instanceof Array){for(var f=[0,0,0,0],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+d*f[0],",").concat(r)),p+="L ".concat(s+n-d*f[1],",").concat(r),f[1]>0&&(p+="A ".concat(f[1],",").concat(f[1],",0,0,").concat(u,`, `).concat(s+n,",").concat(r+i*f[1])),p+="L ".concat(s+n,",").concat(r+a-i*f[2]),f[2]>0&&(p+="A ".concat(f[2],",").concat(f[2],",0,0,").concat(u,`, `).concat(s+n-d*f[2],",").concat(r+a)),p+="L ".concat(s+d*f[3],",").concat(r+a),f[3]>0&&(p+="A ".concat(f[3],",").concat(f[3],",0,0,").concat(u,`, `).concat(s,",").concat(r+a-i*f[3])),p+="Z"}else if(l>0&&o===+o&&o>0){var b=Math.min(l,o);p="M ".concat(s,",").concat(r+i*b,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+d*b,",").concat(r,` L `).concat(s+n-d*b,",").concat(r,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+n,",").concat(r+i*b,` L `).concat(s+n,",").concat(r+a-i*b,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+n-d*b,",").concat(r+a,` L `).concat(s+d*b,",").concat(r+a,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s,",").concat(r+a-i*b," Z")}else p="M ".concat(s,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return p},Kfs=function(s,r){if(!s||!r)return!1;var n=s.x,a=s.y,o=r.x,l=r.y,i=r.width,d=r.height;if(Math.abs(i)>0&&Math.abs(d)>0){var u=Math.min(o,o+i),p=Math.max(o,o+i),f=Math.min(l,l+d),y=Math.max(l,l+d);return n>=u&&n<=p&&a>=f&&a<=y}return!1},Zfs={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},RSe=function(s){var r=DFe(DFe({},Zfs),s),n=k.useRef(),a=k.useState(-1),o=Bfs(a,2),l=o[0],i=o[1];k.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var I=n.current.getTotalLength();I&&i(I)}catch{}},[]);var d=r.x,u=r.y,p=r.width,f=r.height,y=r.radius,_=r.className,b=r.animationEasing,N=r.animationDuration,w=r.animationBegin,S=r.isAnimationActive,C=r.isUpdateAnimationActive;if(d!==+d||u!==+u||p!==+p||f!==+f||p===0||f===0)return null;var A=bi("recharts-rectangle",_);return C?ht.createElement(g0,{canBegin:l>0,from:{width:p,height:f,x:d,y:u},to:{width:p,height:f,x:d,y:u},duration:N,animationEasing:b,isActive:C},function(I){var L=I.width,O=I.height,U=I.x,q=I.y;return ht.createElement(g0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:N,isActive:S,easing:b},ht.createElement("path",sde({},Ba(r,!0),{className:A,d:RFe(U,q,L,O,y),ref:n})))}):ht.createElement("path",sde({},Ba(r,!0),{className:A,d:RFe(d,u,p,f,y)}))},Yfs=["points","className","baseLinePoints","connectNulls"];function lM(){return lM=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 Qfs(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 OFe(t){return sxs(t)||txs(t)||exs(t)||Jfs()}function Jfs(){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 exs(t,s){if(t){if(typeof t=="string")return awe(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 awe(t,s)}}function txs(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function sxs(t){if(Array.isArray(t))return awe(t)}function awe(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){FFe(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),FFe(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},N8=function(s,r){var n=rxs(s);r&&(n=[n.reduce(function(o,l){return[].concat(OFe(o),OFe(l))},[])]);var a=n.map(function(o){return o.reduce(function(l,i,d){return"".concat(l).concat(d===0?"M":"L").concat(i.x,",").concat(i.y)},"")}).join("");return n.length===1?"".concat(a,"Z"):a},nxs=function(s,r,n){var a=N8(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(N8(r.reverse(),n).slice(1))},axs=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=Xfs(s,Yfs);if(!r||!r.length)return null;var i=bi("recharts-polygon",n);if(a&&a.length){var d=l.stroke&&l.stroke!=="none",u=nxs(r,a,o);return ht.createElement("g",{className:i},ht.createElement("path",lM({},Ba(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),d?ht.createElement("path",lM({},Ba(l,!0),{fill:"none",d:N8(r,o)})):null,d?ht.createElement("path",lM({},Ba(l,!0),{fill:"none",d:N8(a,o)})):null)}var p=N8(r,o);return ht.createElement("path",lM({},Ba(l,!0),{fill:p.slice(-1)==="Z"?l.fill:"none",className:i,d:p}))};function iwe(){return iwe=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 hxs(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 mxs=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},pxs=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,o=a===void 0?0:a,l=s.top,i=l===void 0?0:l,d=s.left,u=d===void 0?0:d,p=s.width,f=p===void 0?0:p,y=s.height,_=y===void 0?0:y,b=s.className,N=uxs(s,ixs),w=oxs({x:n,y:o,top:i,left:u,width:f,height:_},N);return!Qr(n)||!Qr(o)||!Qr(f)||!Qr(_)||!Qr(i)||!Qr(u)?null:ht.createElement("path",owe({},Ba(w,!0),{className:bi("recharts-cross",b),d:mxs(n,o,f,_,i,u)}))},fxs=ome,xxs=nnt,gxs=k0;function yxs(t,s){return t&&t.length?fxs(t,gxs(s),xxs):void 0}var vxs=yxs;const _xs=ro(vxs);var bxs=ome,wxs=k0,jxs=ant;function Nxs(t,s){return t&&t.length?bxs(t,wxs(s),jxs):void 0}var kxs=Nxs;const Sxs=ro(kxs);var Cxs=["cx","cy","angle","ticks","axisLine"],Mxs=["ticks","tick","angle","tickFormatter","stroke"];function sA(t){"@babel/helpers - typeof";return sA=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},sA(t)}function k8(){return k8=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 Txs(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 Axs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function qFe(t,s){for(var r=0;rHFe?l=a==="outer"?"start":"end":o<-HFe?l=a==="outer"?"end":"start":l="middle",l}},{key:"renderAxisLine",value:function(){var n=this.props,a=n.cx,o=n.cy,l=n.radius,i=n.axisLine,d=n.axisLineType,u=V2(V2({},Ba(this.props,!1)),{},{fill:"none"},Ba(i,!1));if(d==="circle")return ht.createElement(hme,m4({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var p=this.props.ticks,f=p.map(function(y){return Dl(a,o,l,y.coordinate)});return ht.createElement(axs,m4({className:"recharts-polar-angle-axis-line"},u,{points:f}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,o=a.ticks,l=a.tick,i=a.tickLine,d=a.tickFormatter,u=a.stroke,p=Ba(this.props,!1),f=Ba(l,!1),y=V2(V2({},p),{},{fill:"none"},Ba(i,!1)),_=o.map(function(b,N){var w=n.getTickLineCoord(b),S=n.getTickTextAnchor(b),C=V2(V2(V2({textAnchor:S},p),{},{stroke:"none",fill:u},f),{},{index:N,payload:b,x:w.x2,y:w.y2});return ht.createElement(No,m4({className:bi("recharts-polar-angle-axis-tick",Int(l)),key:"tick-".concat(b.coordinate)},cC(n.props,b,N)),i&&ht.createElement("line",m4({className:"recharts-polar-angle-axis-tick-line"},y,w)),l&&s.renderTickItem(l,C,d?d(b.value,N):b.value))});return ht.createElement(No,{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(No,{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):ci(n)?l=n(a):l=ht.createElement(dC,m4({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(k.PureComponent);fme(xme,"displayName","PolarAngleAxis");fme(xme,"axisType","angleAxis");fme(xme,"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 Hxs=trt,Gxs=Hxs(Object.getPrototypeOf,Object),Wxs=Gxs,Kxs=M1,Zxs=Wxs,Yxs=T1,Xxs="[object Object]",Qxs=Function.prototype,Jxs=Object.prototype,Xnt=Qxs.toString,egs=Jxs.hasOwnProperty,tgs=Xnt.call(Object);function sgs(t){if(!Yxs(t)||Kxs(t)!=Xxs)return!1;var s=Zxs(t);if(s===null)return!0;var r=egs.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&Xnt.call(r)==tgs}var rgs=sgs;const ngs=ro(rgs);var ags=M1,igs=T1,ogs="[object Boolean]";function lgs(t){return t===!0||t===!1||igs(t)&&ags(t)==ogs}var cgs=lgs;const dgs=ro(cgs);function eR(t){"@babel/helpers - typeof";return eR=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},eR(t)}function ade(){return ade=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:d,y:u},to:{upperWidth:p,lowerWidth:f,height:y,x:d,y:u},duration:N,animationEasing:b,isActive:S},function(A){var I=A.upperWidth,L=A.lowerWidth,O=A.height,U=A.x,q=A.y;return ht.createElement(g0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:N,easing:b},ht.createElement("path",ade({},Ba(r,!0),{className:C,d:ZFe(U,q,I,L,O),ref:n})))}):ht.createElement("g",null,ht.createElement("path",ade({},Ba(r,!0),{className:C,d:ZFe(d,u,p,f,y)})))},bgs=["option","shapeType","propTransformer","activeClassName","isActive"];function tR(t){"@babel/helpers - typeof";return tR=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},tR(t)}function wgs(t,s){if(t==null)return{};var r=jgs(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 jgs(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 YFe(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 ide(t){for(var s=1;s0?xf(A,"paddingAngle",0):0;if(L){var U=Jp(L.endAngle-L.startAngle,A.endAngle-A.startAngle),q=Tl(Tl({},A),{},{startAngle:C+O,endAngle:C+U(N)+O});w.push(q),C=q.endAngle}else{var $=A.endAngle,V=A.startAngle,ee=Jp(0,$-V),Z=ee(N),J=Tl(Tl({},A),{},{startAngle:C+O,endAngle:C+Z+O});w.push(J),C=J.endAngle}}),ht.createElement(No,null,n.renderSectorsStatically(w))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(o){if(!o.altKey)switch(o.key){case"ArrowLeft":{var l=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"ArrowRight":{var i=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[i].focus(),a.setState({sectorToFocus:i});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,o=n.isAnimationActive,l=this.state.prevSectors;return o&&a&&a.length&&(!l||!yO(l,a))?this.renderSectorsWithAnimation():this.renderSectorsStatically(a)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var n=this,a=this.props,o=a.hide,l=a.sectors,i=a.className,d=a.label,u=a.cx,p=a.cy,f=a.innerRadius,y=a.outerRadius,_=a.isAnimationActive,b=this.state.isAnimationFinished;if(o||!l||!l.length||!Qr(u)||!Qr(p)||!Qr(f)||!Qr(y))return null;var N=bi("recharts-pie",i);return ht.createElement(No,{tabIndex:this.props.rootTabIndex,className:N,ref:function(S){n.pieRef=S}},this.renderSectors(),d&&this.renderLabels(l),Lu.renderCallByParent(this.props,null,!1),(!_||b)&&i1.renderCallByParent(this.props,l,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?C:C-1)*d,I=w-C*_-A,L=a.reduce(function(q,$){var V=au($,S,0);return q+(Qr(V)?V:0)},0),O;if(L>0){var U;O=a.map(function(q,$){var V=au(q,S,0),ee=au(q,p,$),Z=(Qr(V)?V:0)/L,J;$?J=U.endAngle+_m(N)*d*(V!==0?1:0):J=l;var Y=J+_m(N)*((V!==0?_:0)+Z*I),ce=(J+Y)/2,ae=(b.innerRadius+b.outerRadius)/2,ie=[{name:ee,value:V,payload:q,dataKey:S,type:y}],le=Dl(b.cx,b.cy,ae,ce);return U=Tl(Tl(Tl({percent:Z,cornerRadius:o,name:ee,tooltipPayload:ie,midAngle:ce,middleRadius:ae,tooltipPosition:le},q),b),{},{value:au(q,S),startAngle:J,endAngle:Y,payload:q,paddingAngle:_m(N)*d}),U})}return Tl(Tl({},b),{},{sectors:O,data:a})});var Vgs=Math.ceil,Hgs=Math.max;function Ggs(t,s,r,n){for(var a=-1,o=Hgs(Vgs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var Wgs=Ggs,Kgs=_rt,e7e=1/0,Zgs=17976931348623157e292;function Ygs(t){if(!t)return t===0?t:0;if(t=Kgs(t),t===e7e||t===-e7e){var s=t<0?-1:1;return s*Zgs}return t===t?t:0}var tat=Ygs,Xgs=Wgs,Qgs=eme,s0e=tat;function Jgs(t){return function(s,r,n){return n&&typeof n!="number"&&Qgs(s,r,n)&&(r=n=void 0),s=s0e(s),r===void 0?(r=s,s=0):r=s0e(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=a7e(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 mys(s,t),cys(s,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(n){var a=n.startX,o=n.endX,l=this.state.scaleValues,i=this.props,d=i.gap,u=i.data,p=u.length-1,f=Math.min(a,o),y=Math.max(a,o),_=s.getIndexInRange(l,f),b=s.getIndexInRange(l,y);return{startIndex:_-_%d,endIndex:b===p?p:b-b%d}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,d=au(o[n],i,n);return ci(l)?l(d,n):d}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(n){var a=this.state,o=a.slideMoveStartX,l=a.startX,i=a.endX,d=this.props,u=d.x,p=d.width,f=d.travellerWidth,y=d.startIndex,_=d.endIndex,b=d.onChange,N=n.pageX-o;N>0?N=Math.min(N,u+p-f-i,u+p-f-l):N<0&&(N=Math.max(N,u-l,u-i));var w=this.getIndex({startX:l+N,endX:i+N});(w.startIndex!==y||w.endIndex!==_)&&b&&b(w),this.setState({startX:l+N,endX:i+N,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=a7e(a)?a.changedTouches[0]:a;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:n,brushMoveStartX:o.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(n){var a=this.state,o=a.brushMoveStartX,l=a.movingTravellerId,i=a.endX,d=a.startX,u=this.state[l],p=this.props,f=p.x,y=p.width,_=p.travellerWidth,b=p.onChange,N=p.gap,w=p.data,S={startX:this.state.startX,endX:this.state.endX},C=n.pageX-o;C>0?C=Math.min(C,f+y-_-u):C<0&&(C=Math.max(C,f-u)),S[l]=u+C;var A=this.getIndex(S),I=A.startIndex,L=A.endIndex,O=function(){var q=w.length-1;return l==="startX"&&(i>d?I%N===0:L%N===0)||id?L%N===0:I%N===0)||i>d&&L===q};this.setState(Gp(Gp({},l,u+C),"brushMoveStartX",n.pageX),function(){b&&O()&&b(A)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var o=this,l=this.state,i=l.scaleValues,d=l.startX,u=l.endX,p=this.state[a],f=i.indexOf(p);if(f!==-1){var y=f+n;if(!(y===-1||y>=i.length)){var _=i[y];a==="startX"&&_>=u||a==="endX"&&_<=d||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,d=n.fill,u=n.stroke;return ht.createElement("rect",{stroke:u,fill:d,x:a,y:o,width:l,height:i})}},{key:"renderPanorama",value:function(){var n=this.props,a=n.x,o=n.y,l=n.width,i=n.height,d=n.data,u=n.children,p=n.padding,f=k.Children.only(u);return f?ht.cloneElement(f,{x:a,y:o,width:l,height:i,margin:p,compact:!0,data:d}):null}},{key:"renderTravellerLayer",value:function(n,a){var o,l,i=this,d=this.props,u=d.y,p=d.travellerWidth,f=d.height,y=d.traveller,_=d.ariaLabel,b=d.data,N=d.startIndex,w=d.endIndex,S=Math.max(n,this.props.x),C=r0e(r0e({},Ba(this.props,!1)),{},{x:S,y:u,width:p,height:f}),A=_||"Min value: ".concat((o=b[N])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=b[w])===null||l===void 0?void 0:l.name);return ht.createElement(No,{tabIndex:0,role:"slider","aria-label":A,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(L){["ArrowLeft","ArrowRight"].includes(L.key)&&(L.preventDefault(),L.stopPropagation(),i.handleTravellerMoveKeyboard(L.key==="ArrowRight"?1:-1,a))},onFocus:function(){i.setState({isTravellerFocused:!0})},onBlur:function(){i.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},s.renderTraveller(y,C))}},{key:"renderSlide",value:function(n,a){var o=this.props,l=o.y,i=o.height,d=o.stroke,u=o.travellerWidth,p=Math.min(n,a)+u,f=Math.max(Math.abs(a-n)-u,0);return 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:d,fillOpacity:.2,x:p,y:l,width:f,height:i})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,o=n.endIndex,l=n.y,i=n.height,d=n.travellerWidth,u=n.stroke,p=this.state,f=p.startX,y=p.endX,_=5,b={pointerEvents:"none",fill:u};return ht.createElement(No,{className:"recharts-brush-texts"},ht.createElement(dC,cde({textAnchor:"end",verticalAnchor:"middle",x:Math.min(f,y)-_,y:l+i/2},b),this.getTextOfTick(a)),ht.createElement(dC,cde({textAnchor:"start",verticalAnchor:"middle",x:Math.max(f,y)+d+_,y:l+i/2},b),this.getTextOfTick(o)))}},{key:"render",value:function(){var n=this.props,a=n.data,o=n.className,l=n.children,i=n.x,d=n.y,u=n.width,p=n.height,f=n.alwaysShowText,y=this.state,_=y.startX,b=y.endX,N=y.isTextActive,w=y.isSlideMoving,S=y.isTravellerMoving,C=y.isTravellerFocused;if(!a||!a.length||!Qr(i)||!Qr(d)||!Qr(u)||!Qr(p)||u<=0||p<=0)return null;var A=bi("recharts-brush",o),I=ht.Children.count(l)===1,L=oys("userSelect","none");return ht.createElement(No,{className:A,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:L},this.renderBackground(),I&&this.renderPanorama(),this.renderSlide(_,b),this.renderTravellerLayer(_,"startX"),this.renderTravellerLayer(b,"endX"),(N||w||S||C||f)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,o=n.y,l=n.width,i=n.height,d=n.stroke,u=Math.floor(o+i/2)-1;return ht.createElement(ht.Fragment,null,ht.createElement("rect",{x:a,y:o,width:l,height:i,fill:d,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):ci(n)?o=n(a):o=s.renderDefaultTraveller(a),o}},{key:"getDerivedStateFromProps",value:function(n,a){var o=n.data,l=n.width,i=n.x,d=n.travellerWidth,u=n.updateId,p=n.startIndex,f=n.endIndex;if(o!==a.prevData||u!==a.prevUpdateId)return r0e({prevData:o,prevTravellerWidth:d,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?fys({data:o,width:l,x:i,travellerWidth:d,startIndex:p,endIndex:f}):{scale:null,scaleValues:null});if(a.scale&&(l!==a.prevWidth||i!==a.prevX||d!==a.prevTravellerWidth)){a.scale.range([i,i+l-d]);var y=a.scale.domain().map(function(_){return a.scale(_)});return{prevData:o,prevTravellerWidth:d,prevUpdateId:u,prevX:i,prevWidth:l,startX:a.scale(n.startIndex),endX:a.scale(n.endIndex),scaleValues:y}}return null}},{key:"getIndexInRange",value:function(n,a){for(var o=n.length,l=0,i=o-1;i-l>1;){var d=Math.floor((l+i)/2);n[d]>a?i=d:l=d}return a>=n[i]?i:l}}])}(k.PureComponent);Gp(iA,"displayName","Brush");Gp(iA,"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 xys=lSe;function gys(t,s){var r;return xys(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var yys=gys,vys=Wst,_ys=k0,bys=yys,wys=_p,jys=eme;function Nys(t,s,r){var n=wys(t)?vys:bys;return r&&jys(t,s,r)&&(s=void 0),n(t,_ys(s))}var kys=Nys;const Sys=ro(kys);var c0=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},i7e=frt;function Cys(t,s,r){s=="__proto__"&&i7e?i7e(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var Mys=Cys,Tys=Mys,Ays=mrt,Eys=k0;function Pys(t,s){var r={};return s=Eys(s),Ays(t,function(n,a,o){Tys(r,a,s(n,a,o))}),r}var Iys=Pys;const Lys=ro(Iys);function Dys(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 Qys(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Jys(t,s){var r=t.x,n=t.y,a=Xys(t,Wys),o="".concat(r),l=parseInt(o,10),i="".concat(n),d=parseInt(i,10),u="".concat(s.height||a.height),p=parseInt(u,10),f="".concat(s.width||a.width),y=parseInt(f,10);return g6(g6(g6(g6(g6({},s),a),l?{x:l}:{}),d?{y:d}:{}),{},{height:p,width:y,name:s.name,radius:s.radius})}function l7e(t){return ht.createElement(Qnt,hwe({shapeType:"rectangle",propTransformer:Jys,activeClassName:"recharts-active-bar"},t))}var e0s=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=Qr(n)||bXt(n);return o?s(n,a):(o||hC(),r)}},t0s=["value","background"],iat;function oA(t){"@babel/helpers - typeof";return oA=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},oA(t)}function s0s(t,s){if(t==null)return{};var r=r0s(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 r0s(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function ude(){return ude=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(ce)0&&Math.abs(Y)0&&(J=Math.min((Ve||0)-(Y[Te-1]||0),J))}),Number.isFinite(J)){var ce=J/Z,ae=N.layout==="vertical"?n.height:n.width;if(N.padding==="gap"&&(U=ce*ae/2),N.padding==="no-gap"){var ie=bm(s.barCategoryGap,ce*ae),le=ce*ae/2;U=le-ie-(le-ie)/ae*ie}}}a==="xAxis"?q=[n.left+(A.left||0)+(U||0),n.left+n.width-(A.right||0)-(U||0)]:a==="yAxis"?q=d==="horizontal"?[n.top+n.height-(A.bottom||0),n.top+(A.top||0)]:[n.top+(A.top||0)+(U||0),n.top+n.height-(A.bottom||0)-(U||0)]:q=N.range,L&&(q=[q[1],q[0]]);var fe=Snt(N,o,y),xe=fe.scale,he=fe.realScaleType;xe.domain(S).range(q),Cnt(xe);var we=Mnt(xe,jg(jg({},N),{},{realScaleType:he}));a==="xAxis"?(ee=w==="top"&&!I||w==="bottom"&&I,$=n.left,V=f[O]-ee*N.height):a==="yAxis"&&(ee=w==="left"&&!I||w==="right"&&I,$=f[O]-ee*N.width,V=n.top);var Ne=jg(jg(jg({},N),we),{},{realScaleType:he,x:$,y:V,scale:xe,width:a==="xAxis"?n.width:N.width,height:a==="yAxis"?n.height:N.height});return Ne.bandSize=Kce(Ne,we),!N.hide&&a==="xAxis"?f[O]+=(ee?-1:1)*Ne.height:N.hide||(f[O]+=(ee?-1:1)*Ne.width),jg(jg({},_),{},vme({},b,Ne))},{})},uat=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)}},p0s=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return uat({x:r,y:n},{x:a,y:o})},hat=function(){function t(s){u0s(this,t),this.scale=s}return h0s(t,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.bandAware,o=n.position;if(r!==void 0){if(o)switch(o){case"start":return this.scale(r);case"middle":{var l=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+l}case"end":{var i=this.bandwidth?this.bandwidth():0;return this.scale(r)+i}default:return this.scale(r)}if(a){var d=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+d}return this.scale(r)}}},{key:"isInRange",value:function(r){var n=this.range(),a=n[0],o=n[n.length-1];return a<=o?r>=a&&r<=o:r>=o&&r<=a}}],[{key:"create",value:function(r){return new t(r)}}])}();vme(hat,"EPS",1e-4);var OSe=function(s){var r=Object.keys(s).reduce(function(n,a){return jg(jg({},n),{},vme({},a,hat.create(s[a])))},{});return jg(jg({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return Lys(a,function(d,u){return r[u].apply(d,{bandAware:l,position:i})})},isInRange:function(a){return aat(a,function(o,l){return r[l].isInRange(o)})}})};function f0s(t){return(t%180+180)%180}var x0s=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=f0s(a),l=o*Math.PI/180,i=Math.atan(n/r),d=l>i&&l-1?a[o?s[l]:l]:void 0}}var b0s=_0s,w0s=tat;function j0s(t){var s=w0s(t),r=s%1;return s===s?r?s-r:s:0}var N0s=j0s,k0s=ort,S0s=k0,C0s=N0s,M0s=Math.max;function T0s(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:C0s(r);return a<0&&(a=M0s(n+a,0)),k0s(t,S0s(s),a)}var A0s=T0s,E0s=b0s,P0s=A0s,I0s=E0s(P0s),L0s=I0s;const D0s=ro(L0s);var R0s=CYt(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("")}),FSe=k.createContext(void 0),zSe=k.createContext(void 0),mat=k.createContext(void 0),pat=k.createContext({}),fat=k.createContext(void 0),xat=k.createContext(0),gat=k.createContext(0),m7e=function(s){var r=s.state,n=r.xAxisMap,a=r.yAxisMap,o=r.offset,l=s.clipPathId,i=s.children,d=s.width,u=s.height,p=R0s(o);return ht.createElement(FSe.Provider,{value:n},ht.createElement(zSe.Provider,{value:a},ht.createElement(pat.Provider,{value:o},ht.createElement(mat.Provider,{value:p},ht.createElement(fat.Provider,{value:l},ht.createElement(xat.Provider,{value:u},ht.createElement(gat.Provider,{value:d},i)))))))},O0s=function(){return k.useContext(fat)},yat=function(s){var r=k.useContext(FSe);r==null&&hC();var n=r[s];return n==null&&hC(),n},F0s=function(){var s=k.useContext(FSe);return J_(s)},z0s=function(){var s=k.useContext(zSe),r=D0s(s,function(n){return aat(n.domain,Number.isFinite)});return r||J_(s)},vat=function(s){var r=k.useContext(zSe);r==null&&hC();var n=r[s];return n==null&&hC(),n},B0s=function(){var s=k.useContext(mat);return s},$0s=function(){return k.useContext(pat)},BSe=function(){return k.useContext(gat)},$Se=function(){return k.useContext(xat)};function lA(t){"@babel/helpers - typeof";return lA=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},lA(t)}function q0s(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function U0s(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 Nvs(t,s){return Sat(t,s+1)}function kvs(t,s,r,n,a){for(var o=(n||[]).slice(),l=s.start,i=s.end,d=0,u=1,p=l,f=function(){var b=n==null?void 0:n[d];if(b===void 0)return{v:Sat(n,u)};var N=d,w,S=function(){return w===void 0&&(w=r(b,N)),w},C=b.coordinate,A=d===0||xde(t,C,S,p,i);A||(d=0,p=l,u+=1),A&&(p=C+t*(S()/2+a),d+=u)},y;u<=o.length;)if(y=f(),y)return y.v;return[]}function iR(t){"@babel/helpers - typeof";return iR=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},iR(t)}function b7e(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 Ch(t){for(var s=1;s0?_.coordinate-w*t:_.coordinate})}else o[y]=_=Ch(Ch({},_),{},{tickCoord:_.coordinate});var S=xde(t,_.tickCoord,N,i,d);S&&(d=_.tickCoord-t*(N()/2+a),o[y]=Ch(Ch({},_),{},{isShow:!0}))},p=l-1;p>=0;p--)u(p);return o}function Avs(t,s,r,n,a,o){var l=(n||[]).slice(),i=l.length,d=s.start,u=s.end;if(o){var p=n[i-1],f=r(p,i-1),y=t*(p.coordinate+t*f/2-u);l[i-1]=p=Ch(Ch({},p),{},{tickCoord:y>0?p.coordinate-y*t:p.coordinate});var _=xde(t,p.tickCoord,function(){return f},d,u);_&&(u=p.tickCoord-t*(f/2+a),l[i-1]=Ch(Ch({},p),{},{isShow:!0}))}for(var b=o?i-1:i,N=function(C){var A=l[C],I,L=function(){return I===void 0&&(I=r(A,C)),I};if(C===0){var O=t*(A.coordinate-t*L()/2-d);l[C]=A=Ch(Ch({},A),{},{tickCoord:O<0?A.coordinate-O*t:A.coordinate})}else l[C]=A=Ch(Ch({},A),{},{tickCoord:A.coordinate});var U=xde(t,A.tickCoord,L,d,u);U&&(d=A.tickCoord+t*(L()/2+a),l[C]=Ch(Ch({},A),{},{isShow:!0}))},w=0;w=2?_m(a[1].coordinate-a[0].coordinate):1,S=jvs(o,w,_);return d==="equidistantPreserveStart"?kvs(w,S,N,a,l):(d==="preserveStart"||d==="preserveStartEnd"?y=Avs(w,S,N,a,l,d==="preserveStartEnd"):y=Tvs(w,S,N,a,l),y.filter(function(C){return C.isShow}))}var Evs=["viewBox"],Pvs=["viewBox"],Ivs=["ticks"];function uA(t){"@babel/helpers - typeof";return uA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},uA(t)}function dM(){return dM=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 Lvs(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 Dvs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function j7e(t,s){for(var r=0;r0?d(this.props):d(_)),l<=0||i<=0||!b||!b.length?null:ht.createElement(No,{className:bi("recharts-cartesian-axis",u),ref:function(w){n.layerReference=w}},o&&this.renderAxisLine(),this.renderTicks(b,this.state.fontSize,this.state.letterSpacing),Lu.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,Qd(Qd({},a),{},{className:i})):ci(n)?l=n(Qd(Qd({},a),{},{className:i})):l=ht.createElement(dC,dM({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(k.Component);HSe(_E,"displayName","CartesianAxis");HSe(_E,"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 qvs=["x1","y1","x2","y2","key"],Uvs=["offset"];function mC(t){"@babel/helpers - typeof";return mC=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},mC(t)}function N7e(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;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Wvs(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 Kvs=function(s){var r=s.fill;if(!r||r==="none")return null;var n=s.fillOpacity,a=s.x,o=s.y,l=s.width,i=s.height,d=s.ry;return ht.createElement("rect",{x:a,y:o,ry:d,width:l,height:i,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Tat(t,s){var r;if(ht.isValidElement(t))r=ht.cloneElement(t,s);else if(ci(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,d=k7e(s,qvs),u=Ba(d,!1);u.offset;var p=k7e(u,Uvs);r=ht.createElement("line",A4({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function Zvs(t){var s=t.x,r=t.width,n=t.horizontal,a=n===void 0?!0:n,o=t.horizontalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,d){var u=Ah(Ah({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(d),index:d});return Tat(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function Yvs(t){var s=t.y,r=t.height,n=t.vertical,a=n===void 0?!0:n,o=t.verticalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,d){var u=Ah(Ah({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(d),index:d});return Tat(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function Xvs(t){var s=t.horizontalFill,r=t.fillOpacity,n=t.x,a=t.y,o=t.width,l=t.height,i=t.horizontalPoints,d=t.horizontal,u=d===void 0?!0:d;if(!u||!s||!s.length)return null;var p=i.map(function(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],N=b?a+l-y:p[_+1]-y;if(N<=0)return null;var w=_%s.length;return ht.createElement("rect",{key:"react-".concat(_),y,x:n,height:N,width:o,stroke:"none",fill:s[w],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function Qvs(t){var s=t.vertical,r=s===void 0?!0:s,n=t.verticalFill,a=t.fillOpacity,o=t.x,l=t.y,i=t.width,d=t.height,u=t.verticalPoints;if(!r||!n||!n.length)return null;var p=u.map(function(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],N=b?o+i-y:p[_+1]-y;if(N<=0)return null;var w=_%n.length;return ht.createElement("rect",{key:"react-".concat(_),x:y,y:l,width:N,height:d,stroke:"none",fill:n[w],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var Jvs=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return knt(VSe(Ah(Ah(Ah({},_E.defaultProps),n),{},{ticks:Vv(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},e1s=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return knt(VSe(Ah(Ah(Ah({},_E.defaultProps),n),{},{ticks:Vv(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},C5={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function Aat(t){var s,r,n,a,o,l,i=BSe(),d=$Se(),u=$0s(),p=Ah(Ah({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:C5.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:C5.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:C5.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:C5.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:C5.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:C5.verticalFill,x:Qr(t.x)?t.x:u.left,y:Qr(t.y)?t.y:u.top,width:Qr(t.width)?t.width:u.width,height:Qr(t.height)?t.height:u.height}),f=p.x,y=p.y,_=p.width,b=p.height,N=p.syncWithTicks,w=p.horizontalValues,S=p.verticalValues,C=F0s(),A=z0s();if(!Qr(_)||_<=0||!Qr(b)||b<=0||!Qr(f)||f!==+f||!Qr(y)||y!==+y)return null;var I=p.verticalCoordinatesGenerator||Jvs,L=p.horizontalCoordinatesGenerator||e1s,O=p.horizontalPoints,U=p.verticalPoints;if((!O||!O.length)&&ci(L)){var q=w&&w.length,$=L({yAxis:A?Ah(Ah({},A),{},{ticks:q?w:A.ticks}):void 0,width:i,height:d,offset:u},q?!0:N);zg(Array.isArray($),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(mC($),"]")),Array.isArray($)&&(O=$)}if((!U||!U.length)&&ci(I)){var V=S&&S.length,ee=I({xAxis:C?Ah(Ah({},C),{},{ticks:V?S:C.ticks}):void 0,width:i,height:d,offset:u},V?!0:N);zg(Array.isArray(ee),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(mC(ee),"]")),Array.isArray(ee)&&(U=ee)}return ht.createElement("g",{className:"recharts-cartesian-grid"},ht.createElement(Kvs,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),ht.createElement(Zvs,A4({},p,{offset:u,horizontalPoints:O,xAxis:C,yAxis:A})),ht.createElement(Yvs,A4({},p,{offset:u,verticalPoints:U,xAxis:C,yAxis:A})),ht.createElement(Xvs,A4({},p,{horizontalPoints:O})),ht.createElement(Qvs,A4({},p,{verticalPoints:U})))}Aat.displayName="CartesianGrid";var t1s=["type","layout","connectNulls","ref"],s1s=["key"];function hA(t){"@babel/helpers - typeof";return hA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},hA(t)}function S7e(t,s){if(t==null)return{};var r=r1s(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 r1s(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 S8(){return S8=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(M5(d.slice(0,b)),[f-N]);break}var w=_.length%2===0?[0,y]:[y];return[].concat(M5(s.repeat(d,p)),M5(_),w).map(function(S){return"".concat(S,"px")}).join(", ")}),Ng(r,"id",mE("recharts-line-")),Ng(r,"pathRef",function(l){r.mainCurve=l}),Ng(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),Ng(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return m1s(s,t),c1s(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,d=o.yAxis,u=o.layout,p=o.children,f=gf(p,vO);if(!f)return null;var y=function(N,w){return{x:N.x,y:N.y,value:N.value,errorVal:au(N.payload,w)}},_={clipPath:n?"url(#clipPath-".concat(a,")"):null};return ht.createElement(No,_,f.map(function(b){return ht.cloneElement(b,{key:"bar-".concat(b.props.dataKey),data:l,xAxis:i,yAxis:d,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,d=i.dot,u=i.points,p=i.dataKey,f=Ba(this.props,!1),y=Ba(d,!0),_=u.map(function(N,w){var S=Vp(Vp(Vp({key:"dot-".concat(w),r:3},f),y),{},{index:w,cx:N.x,cy:N.y,value:N.value,dataKey:p,payload:N.payload,points:u});return s.renderDotItem(d,S)}),b={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return ht.createElement(No,S8({className:"recharts-line-dots",key:"dots"},b),_)}},{key:"renderCurveStatically",value:function(n,a,o,l){var i=this.props,d=i.type,u=i.layout,p=i.connectNulls;i.ref;var f=S7e(i,t1s),y=Vp(Vp(Vp({},Ba(f,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(o,")"):null,points:n},l),{},{type:d,layout:u,connectNulls:p});return ht.createElement(Xce,S8({},y,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,a){var o=this,l=this.props,i=l.points,d=l.strokeDasharray,u=l.isAnimationActive,p=l.animationBegin,f=l.animationDuration,y=l.animationEasing,_=l.animationId,b=l.animateNewValues,N=l.width,w=l.height,S=this.state,C=S.prevPoints,A=S.totalLength;return ht.createElement(g0,{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(C){var O=C.length/i.length,U=i.map(function(Z,J){var Y=Math.floor(J*O);if(C[Y]){var ce=C[Y],ae=Jp(ce.x,Z.x),ie=Jp(ce.y,Z.y);return Vp(Vp({},Z),{},{x:ae(L),y:ie(L)})}if(b){var le=Jp(N*2,Z.x),fe=Jp(w/2,Z.y);return Vp(Vp({},Z),{},{x:le(L),y:fe(L)})}return Vp(Vp({},Z),{},{x:Z.x,y:Z.y})});return o.renderCurveStatically(U,n,a)}var q=Jp(0,A),$=q(L),V;if(d){var ee="".concat(d).split(/[,\s]+/gim).map(function(Z){return parseFloat(Z)});V=o.getStrokeDasharray($,A,ee)}else V=o.generateSimpleStrokeDasharray(A,$);return o.renderCurveStatically(i,n,a,{strokeDasharray:V})})}},{key:"renderCurve",value:function(n,a){var o=this.props,l=o.points,i=o.isAnimationActive,d=this.state,u=d.prevPoints,p=d.totalLength;return i&&l&&l.length&&(!u&&p>0||!yO(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,d=a.className,u=a.xAxis,p=a.yAxis,f=a.top,y=a.left,_=a.width,b=a.height,N=a.isAnimationActive,w=a.id;if(o||!i||!i.length)return null;var S=this.state.isAnimationFinished,C=i.length===1,A=bi("recharts-line",d),I=u&&u.allowDataOverflow,L=p&&p.allowDataOverflow,O=I||L,U=yi(w)?this.id:w,q=(n=Ba(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},$=q.r,V=$===void 0?3:$,ee=q.strokeWidth,Z=ee===void 0?2:ee,J=IXt(l)?l:{},Y=J.clipDot,ce=Y===void 0?!0:Y,ae=V*2+Z;return ht.createElement(No,{className:A},I||L?ht.createElement("defs",null,ht.createElement("clipPath",{id:"clipPath-".concat(U)},ht.createElement("rect",{x:I?y:y-_/2,y:L?f:f-b/2,width:I?_:_*2,height:L?b:b*2})),!ce&&ht.createElement("clipPath",{id:"clipPath-dots-".concat(U)},ht.createElement("rect",{x:y-ae/2,y:f-ae/2,width:_+ae,height:b+ae}))):null,!C&&this.renderCurve(O,U),this.renderErrorBar(O,U),(C||l)&&this.renderDots(O,ce,U),(!N||S)&&i1.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(M5(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 s_s(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_s(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function n_s(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&Qr(a)&&Qr(o)?s.slice(a,o+1):[]};function Gat(t){return t==="number"?[0,"auto"]:void 0}var Ewe=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=Nme(r,s);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(d,u){var p,f=(p=u.props.data)!==null&&p!==void 0?p:r;f&&s.dataStartIndex+s.dataEndIndex!==0&&s.dataEndIndex-s.dataStartIndex>=n&&(f=f.slice(s.dataStartIndex,s.dataEndIndex+1));var y;if(l.dataKey&&!l.allowDuplicatedCategory){var _=f===void 0?i:f;y=vce(_,l.dataKey,a)}else y=f&&f[n]||i[n];return y?[].concat(xA(d),[Ant(u,y)]):d},[])},L7e=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=x_s(o,n),i=s.orderedTooltipTicks,d=s.tooltipAxis,u=s.tooltipTicks,p=Lhs(l,i,u,d);if(p>=0&&u){var f=u[p]&&u[p].value,y=Ewe(s,r,p,f),_=g_s(n,i,p,o);return{activeTooltipIndex:p,activeLabel:f,activePayload:y,activeCoordinate:_}}return null},y_s=function(s,r){var n=r.axes,a=r.graphicalItems,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,p=s.layout,f=s.children,y=s.stackOffset,_=Nnt(p,o);return n.reduce(function(b,N){var w,S=N.type.defaultProps!==void 0?xr(xr({},N.type.defaultProps),N.props):N.props,C=S.type,A=S.dataKey,I=S.allowDataOverflow,L=S.allowDuplicatedCategory,O=S.scale,U=S.ticks,q=S.includeHidden,$=S[l];if(b[$])return b;var V=Nme(s.data,{graphicalItems:a.filter(function(we){var Ne,Ve=l in we.props?we.props[l]:(Ne=we.type.defaultProps)===null||Ne===void 0?void 0:Ne[l];return Ve===$}),dataStartIndex:d,dataEndIndex:u}),ee=V.length,Z,J,Y;V1s(S.domain,I,C)&&(Z=Hbe(S.domain,null,I),_&&(C==="number"||O!=="auto")&&(Y=w8(V,A,"category")));var ce=Gat(C);if(!Z||Z.length===0){var ae,ie=(ae=S.domain)!==null&&ae!==void 0?ae:ce;if(A){if(Z=w8(V,A,C),C==="category"&&_){var le=jXt(Z);L&&le?(J=Z,Z=lde(0,ee)):L||(Z=aFe(ie,Z,N).reduce(function(we,Ne){return we.indexOf(Ne)>=0?we:[].concat(xA(we),[Ne])},[]))}else if(C==="category")L?Z=Z.filter(function(we){return we!==""&&!yi(we)}):Z=aFe(ie,Z,N).reduce(function(we,Ne){return we.indexOf(Ne)>=0||Ne===""||yi(Ne)?we:[].concat(xA(we),[Ne])},[]);else if(C==="number"){var fe=zhs(V,a.filter(function(we){var Ne,Ve,Te=l in we.props?we.props[l]:(Ne=we.type.defaultProps)===null||Ne===void 0?void 0:Ne[l],Ae="hide"in we.props?we.props.hide:(Ve=we.type.defaultProps)===null||Ve===void 0?void 0:Ve.hide;return Te===$&&(q||!Ae)}),A,o,p);fe&&(Z=fe)}_&&(C==="number"||O!=="auto")&&(Y=w8(V,A,"category"))}else _?Z=lde(0,ee):i&&i[$]&&i[$].hasStack&&C==="number"?Z=y==="expand"?[0,1]:Tnt(i[$].stackGroups,d,u):Z=jnt(V,a.filter(function(we){var Ne=l in we.props?we.props[l]:we.type.defaultProps[l],Ve="hide"in we.props?we.props.hide:we.type.defaultProps.hide;return Ne===$&&(q||!Ve)}),C,p,!0);if(C==="number")Z=Mwe(f,Z,$,o,U),ie&&(Z=Hbe(ie,Z,I));else if(C==="category"&&ie){var xe=ie,he=Z.every(function(we){return xe.indexOf(we)>=0});he&&(Z=xe)}}return xr(xr({},b),{},Ka({},$,xr(xr({},S),{},{axisType:o,domain:Z,categoricalDomain:Y,duplicateDomain:J,originalDomain:(w=S.domain)!==null&&w!==void 0?w:ce,isCategorical:_,layout:p})))},{})},v_s=function(s,r){var n=r.graphicalItems,a=r.Axis,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,p=s.layout,f=s.children,y=Nme(s.data,{graphicalItems:n,dataStartIndex:d,dataEndIndex:u}),_=y.length,b=Nnt(p,o),N=-1;return n.reduce(function(w,S){var C=S.type.defaultProps!==void 0?xr(xr({},S.type.defaultProps),S.props):S.props,A=C[l],I=Gat("number");if(!w[A]){N++;var L;return b?L=lde(0,_):i&&i[A]&&i[A].hasStack?(L=Tnt(i[A].stackGroups,d,u),L=Mwe(f,L,A,o)):(L=Hbe(I,jnt(y,n.filter(function(O){var U,q,$=l in O.props?O.props[l]:(U=O.type.defaultProps)===null||U===void 0?void 0:U[l],V="hide"in O.props?O.props.hide:(q=O.type.defaultProps)===null||q===void 0?void 0:q.hide;return $===A&&!V}),"number",p),a.defaultProps.allowDataOverflow),L=Mwe(f,L,A,o)),xr(xr({},w),{},Ka({},A,xr(xr({axisType:o},a.defaultProps),{},{hide:!0,orientation:xf(p_s,"".concat(o,".").concat(N%2),null),domain:L,originalDomain:I,isCategorical:b,layout:p})))}return w},{})},__s=function(s,r){var n=r.axisType,a=n===void 0?"xAxis":n,o=r.AxisComp,l=r.graphicalItems,i=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,p=s.children,f="".concat(a,"Id"),y=gf(p,o),_={};return y&&y.length?_=y_s(s,{axes:y,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:d,dataEndIndex:u}):l&&l.length&&(_=v_s(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:d,dataEndIndex:u})),_},b_s=function(s){var r=J_(s),n=Vv(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:cSe(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Kce(r,n)}},D7e=function(s){var r=s.children,n=s.defaultShowTooltip,a=Kp(r,iA),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}},w_s=function(s){return!s||!s.length?!1:s.some(function(r){var n=n1(r&&r.type);return n&&n.indexOf("Bar")>=0})},R7e=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"}},j_s=function(s,r){var n=s.props,a=s.graphicalItems,o=s.xAxisMap,l=o===void 0?{}:o,i=s.yAxisMap,d=i===void 0?{}:i,u=n.width,p=n.height,f=n.children,y=n.margin||{},_=Kp(f,iA),b=Kp(f,tT),N=Object.keys(d).reduce(function(L,O){var U=d[O],q=U.orientation;return!U.mirror&&!U.hide?xr(xr({},L),{},Ka({},q,L[q]+U.width)):L},{left:y.left||0,right:y.right||0}),w=Object.keys(l).reduce(function(L,O){var U=l[O],q=U.orientation;return!U.mirror&&!U.hide?xr(xr({},L),{},Ka({},q,xf(L,"".concat(q))+U.height)):L},{top:y.top||0,bottom:y.bottom||0}),S=xr(xr({},w),N),C=S.bottom;_&&(S.bottom+=_.props.height||iA.defaultProps.height),b&&r&&(S=Ohs(S,a,n,r));var A=u-S.left-S.right,I=p-S.top-S.bottom;return xr(xr({brushBottom:C},S),{},{width:Math.max(A,0),height:Math.max(I,0)})},N_s=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},GSe=function(s){var r=s.chartName,n=s.GraphicalChild,a=s.defaultTooltipEventType,o=a===void 0?"axis":a,l=s.validateTooltipEventTypes,i=l===void 0?["axis"]:l,d=s.axisComponents,u=s.legendContent,p=s.formatAxisMap,f=s.defaultProps,y=function(S,C){var A=C.graphicalItems,I=C.stackGroups,L=C.offset,O=C.updateId,U=C.dataStartIndex,q=C.dataEndIndex,$=S.barSize,V=S.layout,ee=S.barGap,Z=S.barCategoryGap,J=S.maxBarSize,Y=R7e(V),ce=Y.numericAxisName,ae=Y.cateAxisName,ie=w_s(A),le=[];return A.forEach(function(fe,xe){var he=Nme(S.data,{graphicalItems:[fe],dataStartIndex:U,dataEndIndex:q}),we=fe.type.defaultProps!==void 0?xr(xr({},fe.type.defaultProps),fe.props):fe.props,Ne=we.dataKey,Ve=we.maxBarSize,Te=we["".concat(ce,"Id")],Ae=we["".concat(ae,"Id")],ze={},Ee=d.reduce(function(Ot,ut){var Oe=C["".concat(ut.axisType,"Map")],Xe=we["".concat(ut.axisType,"Id")];Oe&&Oe[Xe]||ut.axisType==="zAxis"||hC();var at=Oe[Xe];return xr(xr({},Ot),{},Ka(Ka({},ut.axisType,at),"".concat(ut.axisType,"Ticks"),Vv(at)))},ze),ve=Ee[ae],Re=Ee["".concat(ae,"Ticks")],Ue=I&&I[Te]&&I[Te].hasStack&&Khs(fe,I[Te].stackGroups),ye=n1(fe.type).indexOf("Bar")>=0,ct=Kce(ve,Re),pe=[],Ge=ie&&Dhs({barSize:$,stackGroups:I,totalSize:N_s(Ee,ae)});if(ye){var tt,st,Ce=yi(Ve)?J:Ve,et=(tt=(st=Kce(ve,Re,!0))!==null&&st!==void 0?st:Ce)!==null&&tt!==void 0?tt:0;pe=Rhs({barGap:ee,barCategoryGap:Z,bandSize:et!==ct?et:ct,sizeList:Ge[Ae],maxBarSize:Ce}),et!==ct&&(pe=pe.map(function(Ot){return xr(xr({},Ot),{},{position:xr(xr({},Ot.position),{},{offset:Ot.position.offset-et/2})})}))}var Ct=fe&&fe.type&&fe.type.getComposedData;Ct&&le.push({props:xr(xr({},Ct(xr(xr({},Ee),{},{displayedData:he,props:S,dataKey:Ne,item:fe,bandSize:ct,barPosition:pe,offset:L,stackedData:Ue,layout:V,dataStartIndex:U,dataEndIndex:q}))),{},Ka(Ka(Ka({key:fe.key||"item-".concat(xe)},ce,Ee[ce]),ae,Ee[ae]),"animationId",O)),childIndex:RXt(fe,S.children),item:fe})}),le},_=function(S,C){var A=S.props,I=S.dataStartIndex,L=S.dataEndIndex,O=S.updateId;if(!QDe({props:A}))return null;var U=A.children,q=A.layout,$=A.stackOffset,V=A.data,ee=A.reverseStackOrder,Z=R7e(q),J=Z.numericAxisName,Y=Z.cateAxisName,ce=gf(U,n),ae=Ghs(V,ce,"".concat(J,"Id"),"".concat(Y,"Id"),$,ee),ie=d.reduce(function(we,Ne){var Ve="".concat(Ne.axisType,"Map");return xr(xr({},we),{},Ka({},Ve,__s(A,xr(xr({},Ne),{},{graphicalItems:ce,stackGroups:Ne.axisType===J&&ae,dataStartIndex:I,dataEndIndex:L}))))},{}),le=j_s(xr(xr({},ie),{},{props:A,graphicalItems:ce}),C==null?void 0:C.legendBBox);Object.keys(ie).forEach(function(we){ie[we]=p(A,ie[we],le,we.replace("Map",""),r)});var fe=ie["".concat(Y,"Map")],xe=b_s(fe),he=y(A,xr(xr({},ie),{},{dataStartIndex:I,dataEndIndex:L,updateId:O,graphicalItems:ce,stackGroups:ae,offset:le}));return xr(xr({formattedGraphicalItems:he,graphicalItems:ce,offset:le,stackGroups:ae},xe),ie)},b=function(w){function S(C){var A,I,L;return r_s(this,S),L=i_s(this,S,[C]),Ka(L,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),Ka(L,"accessibilityManager",new U1s),Ka(L,"handleLegendBBoxUpdate",function(O){if(O){var U=L.state,q=U.dataStartIndex,$=U.dataEndIndex,V=U.updateId;L.setState(xr({legendBBox:O},_({props:L.props,dataStartIndex:q,dataEndIndex:$,updateId:V},xr(xr({},L.state),{},{legendBBox:O}))))}}),Ka(L,"handleReceiveSyncEvent",function(O,U,q){if(L.props.syncId===O){if(q===L.eventEmitterSymbol&&typeof L.props.syncMethod!="function")return;L.applySyncEvent(U)}}),Ka(L,"handleBrushChange",function(O){var U=O.startIndex,q=O.endIndex;if(U!==L.state.dataStartIndex||q!==L.state.dataEndIndex){var $=L.state.updateId;L.setState(function(){return xr({dataStartIndex:U,dataEndIndex:q},_({props:L.props,dataStartIndex:U,dataEndIndex:q,updateId:$},L.state))}),L.triggerSyncEvent({dataStartIndex:U,dataEndIndex:q})}}),Ka(L,"handleMouseEnter",function(O){var U=L.getMouseInfo(O);if(U){var q=xr(xr({},U),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var $=L.props.onMouseEnter;ci($)&&$(q,O)}}),Ka(L,"triggeredAfterMouseMove",function(O){var U=L.getMouseInfo(O),q=U?xr(xr({},U),{},{isTooltipActive:!0}):{isTooltipActive:!1};L.setState(q),L.triggerSyncEvent(q);var $=L.props.onMouseMove;ci($)&&$(q,O)}),Ka(L,"handleItemMouseEnter",function(O){L.setState(function(){return{isTooltipActive:!0,activeItem:O,activePayload:O.tooltipPayload,activeCoordinate:O.tooltipPosition||{x:O.cx,y:O.cy}}})}),Ka(L,"handleItemMouseLeave",function(){L.setState(function(){return{isTooltipActive:!1}})}),Ka(L,"handleMouseMove",function(O){O.persist(),L.throttleTriggeredAfterMouseMove(O)}),Ka(L,"handleMouseLeave",function(O){L.throttleTriggeredAfterMouseMove.cancel();var U={isTooltipActive:!1};L.setState(U),L.triggerSyncEvent(U);var q=L.props.onMouseLeave;ci(q)&&q(U,O)}),Ka(L,"handleOuterEvent",function(O){var U=DXt(O),q=xf(L.props,"".concat(U));if(U&&ci(q)){var $,V;/.*touch.*/i.test(U)?V=L.getMouseInfo(O.changedTouches[0]):V=L.getMouseInfo(O),q(($=V)!==null&&$!==void 0?$:{},O)}}),Ka(L,"handleClick",function(O){var U=L.getMouseInfo(O);if(U){var q=xr(xr({},U),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var $=L.props.onClick;ci($)&&$(q,O)}}),Ka(L,"handleMouseDown",function(O){var U=L.props.onMouseDown;if(ci(U)){var q=L.getMouseInfo(O);U(q,O)}}),Ka(L,"handleMouseUp",function(O){var U=L.props.onMouseUp;if(ci(U)){var q=L.getMouseInfo(O);U(q,O)}}),Ka(L,"handleTouchMove",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&L.throttleTriggeredAfterMouseMove(O.changedTouches[0])}),Ka(L,"handleTouchStart",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&L.handleMouseDown(O.changedTouches[0])}),Ka(L,"handleTouchEnd",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&L.handleMouseUp(O.changedTouches[0])}),Ka(L,"handleDoubleClick",function(O){var U=L.props.onDoubleClick;if(ci(U)){var q=L.getMouseInfo(O);U(q,O)}}),Ka(L,"handleContextMenu",function(O){var U=L.props.onContextMenu;if(ci(U)){var q=L.getMouseInfo(O);U(q,O)}}),Ka(L,"triggerSyncEvent",function(O){L.props.syncId!==void 0&&a0e.emit(i0e,L.props.syncId,O,L.eventEmitterSymbol)}),Ka(L,"applySyncEvent",function(O){var U=L.props,q=U.layout,$=U.syncMethod,V=L.state.updateId,ee=O.dataStartIndex,Z=O.dataEndIndex;if(O.dataStartIndex!==void 0||O.dataEndIndex!==void 0)L.setState(xr({dataStartIndex:ee,dataEndIndex:Z},_({props:L.props,dataStartIndex:ee,dataEndIndex:Z,updateId:V},L.state)));else if(O.activeTooltipIndex!==void 0){var J=O.chartX,Y=O.chartY,ce=O.activeTooltipIndex,ae=L.state,ie=ae.offset,le=ae.tooltipTicks;if(!ie)return;if(typeof $=="function")ce=$(le,O);else if($==="value"){ce=-1;for(var fe=0;fe=0){var Ue,ye;if(J.dataKey&&!J.allowDuplicatedCategory){var ct=typeof J.dataKey=="function"?Re:"payload.".concat(J.dataKey.toString());Ue=vce(fe,ct,ce),ye=xe&&he&&vce(he,ct,ce)}else Ue=fe==null?void 0:fe[Y],ye=xe&&he&&he[Y];if(Ae||Te){var pe=O.props.activeIndex!==void 0?O.props.activeIndex:Y;return[k.cloneElement(O,xr(xr(xr({},$.props),Ee),{},{activeIndex:pe})),null,null]}if(!yi(Ue))return[ve].concat(xA(L.renderActivePoints({item:$,activePoint:Ue,basePoint:ye,childIndex:Y,isRange:xe})))}else{var Ge,tt=(Ge=L.getItemByXY(L.state.activeCoordinate))!==null&&Ge!==void 0?Ge:{graphicalItem:ve},st=tt.graphicalItem,Ce=st.item,et=Ce===void 0?O:Ce,Ct=st.childIndex,Ot=xr(xr(xr({},$.props),Ee),{},{activeIndex:Ct});return[k.cloneElement(et,Ot),null,null]}return xe?[ve,null,null]:[ve,null]}),Ka(L,"renderCustomized",function(O,U,q){return k.cloneElement(O,xr(xr({key:"recharts-customized-".concat(q)},L.props),L.state))}),Ka(L,"renderMap",{CartesianGrid:{handler:g9,once:!0},ReferenceArea:{handler:L.renderReferenceElement},ReferenceLine:{handler:g9},ReferenceDot:{handler:L.renderReferenceElement},XAxis:{handler:g9},YAxis:{handler:g9},Brush:{handler:L.renderBrush,once:!0},Bar:{handler:L.renderGraphicChild},Line:{handler:L.renderGraphicChild},Area:{handler:L.renderGraphicChild},Radar:{handler:L.renderGraphicChild},RadialBar:{handler:L.renderGraphicChild},Scatter:{handler:L.renderGraphicChild},Pie:{handler:L.renderGraphicChild},Funnel:{handler:L.renderGraphicChild},Tooltip:{handler:L.renderCursor,once:!0},PolarGrid:{handler:L.renderPolarGrid,once:!0},PolarAngleAxis:{handler:L.renderPolarAxis},PolarRadiusAxis:{handler:L.renderPolarAxis},Customized:{handler:L.renderCustomized}}),L.clipPathId="".concat((A=C.id)!==null&&A!==void 0?A:mE("recharts"),"-clip"),L.throttleTriggeredAfterMouseMove=brt(L.triggeredAfterMouseMove,(I=C.throttleDelay)!==null&&I!==void 0?I:1e3/60),L.state={},L}return c_s(S,w),a_s(S,[{key:"componentDidMount",value:function(){var A,I;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A:0,top:(I=this.props.margin.top)!==null&&I!==void 0?I:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var A=this.props,I=A.children,L=A.data,O=A.height,U=A.layout,q=Kp(I,Jm);if(q){var $=q.props.defaultIndex;if(!(typeof $!="number"||$<0||$>this.state.tooltipTicks.length-1)){var V=this.state.tooltipTicks[$]&&this.state.tooltipTicks[$].value,ee=Ewe(this.state,L,$,V),Z=this.state.tooltipTicks[$].coordinate,J=(this.state.offset.top+O)/2,Y=U==="horizontal",ce=Y?{x:Z,y:J}:{y:Z,x:J},ae=this.state.formattedGraphicalItems.find(function(le){var fe=le.item;return fe.type.name==="Scatter"});ae&&(ce=xr(xr({},ce),ae.props.points[$].tooltipPosition),ee=ae.props.points[$].tooltipPayload);var ie={activeTooltipIndex:$,isTooltipActive:!0,activeLabel:V,activePayload:ee,activeCoordinate:ce};this.setState(ie),this.renderCursor(q),this.accessibilityManager.setIndex($)}}}},{key:"getSnapshotBeforeUpdate",value:function(A,I){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==I.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==A.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==A.margin){var L,O;this.accessibilityManager.setDetails({offset:{left:(L=this.props.margin.left)!==null&&L!==void 0?L:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0}})}return null}},{key:"componentDidUpdate",value:function(A){ibe([Kp(A.children,Jm)],[Kp(this.props.children,Jm)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var A=Kp(this.props.children,Jm);if(A&&typeof A.props.shared=="boolean"){var I=A.props.shared?"axis":"item";return i.indexOf(I)>=0?I:o}return o}},{key:"getMouseInfo",value:function(A){if(!this.container)return null;var I=this.container,L=I.getBoundingClientRect(),O=lls(L),U={chartX:Math.round(A.pageX-O.left),chartY:Math.round(A.pageY-O.top)},q=L.width/I.offsetWidth||1,$=this.inRange(U.chartX,U.chartY,q);if(!$)return null;var V=this.state,ee=V.xAxisMap,Z=V.yAxisMap,J=this.getTooltipEventType(),Y=L7e(this.state,this.props.data,this.props.layout,$);if(J!=="axis"&&ee&&Z){var ce=J_(ee).scale,ae=J_(Z).scale,ie=ce&&ce.invert?ce.invert(U.chartX):null,le=ae&&ae.invert?ae.invert(U.chartY):null;return xr(xr({},U),{},{xValue:ie,yValue:le},Y)}return Y?xr(xr({},U),Y):null}},{key:"inRange",value:function(A,I){var L=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,O=this.props.layout,U=A/L,q=I/L;if(O==="horizontal"||O==="vertical"){var $=this.state.offset,V=U>=$.left&&U<=$.left+$.width&&q>=$.top&&q<=$.top+$.height;return V?{x:U,y:q}:null}var ee=this.state,Z=ee.angleAxisMap,J=ee.radiusAxisMap;if(Z&&J){var Y=J_(Z);return lFe({x:U,y:q},Y)}return null}},{key:"parseEventsOfWrapper",value:function(){var A=this.props.children,I=this.getTooltipEventType(),L=Kp(A,Jm),O={};L&&I==="axis"&&(L.props.trigger==="click"?O={onClick:this.handleClick}:O={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var U=_ce(this.props,this.handleOuterEvent);return xr(xr({},U),O)}},{key:"addListener",value:function(){a0e.on(i0e,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){a0e.removeListener(i0e,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(A,I,L){for(var O=this.state.formattedGraphicalItems,U=0,q=O.length;U{const{data:C,error:A}=await G.from("email_campaigns").select("*").eq("status","sent").order("sent_at",{ascending:!0});if(A)throw A;return C}}),{data:n}=ft({queryKey:["campaign-agent-profiles"],queryFn:async()=>{const{data:C,error:A}=await G.from("profiles").select("id, name, email");if(A)throw A;return C}});if(r)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading analytics..."});const a=s||[],o=new Map((n||[]).map(C=>[C.id,C])),l=a.reduce((C,A)=>C+(A.sent_count||0),0),i=a.reduce((C,A)=>C+(A.open_count||0),0),d=a.reduce((C,A)=>C+(A.click_count||0),0),u=a.reduce((C,A)=>C+(A.bounce_count||0),0),p=a.reduce((C,A)=>C+(A.complaint_count||0),0),f=l>0?(i/l*100).toFixed(1):"0.0",y=l>0?(d/l*100).toFixed(1):"0.0",_=[{label:"Campaigns Sent",value:a.length,icon:Nn,color:"text-foreground"},{label:"Total Emails Sent",value:l,icon:cr,color:"text-green-600"},{label:"Avg Open Rate",value:`${f}%`,icon:jn,color:"text-blue-600"},{label:"Avg Click Rate",value:`${y}%`,icon:sh,color:"text-purple-600"},{label:"Total Bounces",value:u,icon:Qc,color:"text-orange-600"},{label:"Complaints",value:p,icon:Yo,color:"text-destructive"}],b=new Map;a.forEach(C=>{var L,O;const A=C.user_id,I=b.get(A)||{name:((L=o.get(A))==null?void 0:L.name)||((O=o.get(A))==null?void 0:O.email)||"Unknown",campaigns:0,sent:0,opens:0,clicks:0};I.campaigns++,I.sent+=C.sent_count||0,I.opens+=C.open_count||0,I.clicks+=C.click_count||0,b.set(A,I)});const N=[...b.entries()].map(([C,A])=>({id:C,...A,openRate:A.sent>0?+(A.opens/A.sent*100).toFixed(1):0})).sort((C,A)=>A.sent-C.sent),w=N.slice(0,6).map(C=>({name:C.name,value:C.sent})),S=a.map(C=>{var A;return{name:C.name.length>20?C.name.slice(0,20)+"…":C.name,agent:((A=o.get(C.user_id))==null?void 0:A.name)||"Unknown",openRate:C.sent_count>0?+(C.open_count/C.sent_count*100).toFixed(1):0,clickRate:C.sent_count>0?+(C.click_count/C.sent_count*100).toFixed(1):0,sent:C.sent_count,date:C.sent_at?gs(new Date(C.sent_at),"MMM d"):""}});return e.jsx("div",{className:"space-y-6",children:a.length===0?e.jsx(Ie,{children:e.jsxs(Be,{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 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(C=>e.jsx(Ie,{children:e.jsxs(Be,{className:"p-4 text-center",children:[e.jsx(C.icon,{className:`h-5 w-5 mx-auto mb-1 ${C.color}`}),e.jsx("p",{className:"text-2xl font-bold",children:C.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.label})]})},C.label))}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Open & Click Rates by Campaign"})}),e.jsx(Be,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(sT,{width:"100%",height:"100%",children:e.jsxs(Wat,{data:S,children:[e.jsx(pC,{dataKey:"date",fontSize:11}),e.jsx(fC,{fontSize:11,unit:"%"}),e.jsx(Jm,{formatter:C=>`${C}%`}),e.jsx(v1,{dataKey:"openRate",fill:"hsl(220, 70%, 50%)",name:"Open Rate",radius:[2,2,0,0]}),e.jsx(v1,{dataKey:"clickRate",fill:"hsl(270, 70%, 50%)",name:"Click Rate",radius:[2,2,0,0]})]})})})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Send Volume by Agent"})}),e.jsx(Be,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(sT,{width:"100%",height:"100%",children:e.jsxs(Kat,{children:[e.jsx(S0,{data:w,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:({name:C,percent:A})=>`${C} (${(A*100).toFixed(0)}%)`,fontSize:11,children:w.map((C,A)=>e.jsx(mO,{fill:O7e[A%O7e.length]},A))}),e.jsx(Jm,{})]})})})})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Send Volume Trend"})}),e.jsx(Be,{children:e.jsx("div",{className:"h-[240px]",children:e.jsx(sT,{width:"100%",height:"100%",children:e.jsxs(k_s,{data:S,children:[e.jsx(pC,{dataKey:"date",fontSize:11}),e.jsx(fC,{fontSize:11}),e.jsx(Jm,{}),e.jsx(_O,{type:"monotone",dataKey:"sent",stroke:"hsl(142, 71%, 45%)",strokeWidth:2,name:"Emails Sent",dot:{r:4}})]})})})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Agent Performance"})}),e.jsx(Be,{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:N.map(C=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-2.5 font-medium",children:C.name}),e.jsx("td",{className:"py-2.5 text-center",children:C.campaigns}),e.jsx("td",{className:"py-2.5 text-center",children:C.sent}),e.jsx("td",{className:"py-2.5 text-center",children:C.opens}),e.jsx("td",{className:"py-2.5 text-center",children:C.clicks}),e.jsx("td",{className:"py-2.5 text-center",children:e.jsxs(Ye,{variant:"outline",children:[C.openRate,"%"]})})]},C.id))})]})})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Campaign Leaderboard"})}),e.jsx(Be,{children:e.jsx("div",{className:"space-y-2",children:[...a].sort((C,A)=>{const I=C.sent_count>0?C.open_count/C.sent_count:0;return(A.sent_count>0?A.open_count/A.sent_count:0)-I}).slice(0,10).map((C,A)=>{const I=C.sent_count>0?(C.open_count/C.sent_count*100).toFixed(1):"0.0",L=C.sent_count>0?(C.click_count/C.sent_count*100).toFixed(1):"0.0",O=o.get(C.user_id);return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/30 cursor-pointer",onClick:()=>t(`/admin/email-campaigns/${C.id}`),children:[e.jsxs("span",{className:"text-lg font-bold text-muted-foreground w-6",children:["#",A+1]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:C.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(O==null?void 0:O.name)||"Unknown"," · ",C.sent_at?gs(new Date(C.sent_at),"MMM d, yyyy"):""," · ",C.sent_count," sent"]})]}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(jn,{className:"h-3 w-3"})," ",I,"%"]}),e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(sh,{className:"h-3 w-3"})," ",L,"%"]})]})]},C.id)})})})]})]})})}const C_s=()=>e.jsx(Ls,{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(ta,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"analytics",children:"Analytics"}),e.jsx(ls,{value:"content",children:"Content"}),e.jsx(ls,{value:"email-campaigns",children:"Email Campaigns"}),e.jsx(ls,{value:"activity",children:"Activity"}),e.jsx(ls,{value:"shares",children:"Shares"})]}),e.jsx(js,{value:"analytics",className:"space-y-4",children:e.jsx(qWt,{})}),e.jsx(js,{value:"content",className:"space-y-4",children:e.jsx(VWt,{})}),e.jsx(js,{value:"email-campaigns",className:"space-y-4",children:e.jsx(S_s,{})}),e.jsx(js,{value:"activity",className:"space-y-4",children:e.jsx($Wt,{})}),e.jsx(js,{value:"shares",className:"space-y-4",children:e.jsx(ist,{})})]})]})});function M_s(){const t=es(),[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,d]=k.useState(null),[u,p]=k.useState(""),[f,y]=k.useState([]),[_,b]=k.useState([]),[N,w]=k.useState([]),[S,C]=k.useState(!1),[A,I]=k.useState(null),[L,O]=k.useState(""),{data:U,isLoading:q}=ft({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(ct)throw ct;return ye}}),{data:$}=ft({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(ct)throw ct;return ye}}),{data:V}=ft({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(ct)throw ct;return ye}}),{data:ee}=ft({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(ct)throw ct;return ye}}),{data:Z,isLoading:J}=ft({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(ct)throw ct;return ye}}),Y=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),d(null),p(""),y([]),b([]),w([]),a(null),O("")},ce=ye=>{a(ye),l({title:ye.title,description:ye.description||"",publish_date:ye.publish_date.split("T")[0],is_published:ye.is_published,category_id:ye.category_id||""}),p(ye.preview_image_url||""),O("");const ct=($==null?void 0:$.filter(tt=>tt.resource_id===ye.id))||[];y(ct.map(tt=>({id:tt.id,name:tt.name,file_url:tt.file_url,file_size:tt.file_size,sort_order:tt.sort_order})));const pe=(V==null?void 0:V.filter(tt=>tt.resource_id===ye.id))||[];b(pe.map(tt=>({id:tt.id,title:tt.title,video_url:tt.video_url,sort_order:tt.sort_order})));const Ge=(ee==null?void 0:ee.filter(tt=>tt.resource_id===ye.id))||[];w(Ge.map(tt=>({id:tt.id,title:tt.title,canva_share_link:tt.canva_share_link,sort_order:tt.sort_order}))),r(!0)},ae=ye=>{var pe;const ct=(pe=ye.target.files)==null?void 0:pe[0];ct&&(d(ct),p(URL.createObjectURL(ct)))},ie=()=>{y([...f,{name:"",file_url:"",sort_order:f.length}])},le=ye=>{y(f.filter((ct,pe)=>pe!==ye))},fe=(ye,ct,pe)=>{const Ge=[...f];if(ct==="file"&&pe instanceof File){const tt=pe.name.replace(/\.[^/.]+$/,"");Ge[ye]={...Ge[ye],file:pe,file_size:pe.size,name:Ge[ye].name||tt}}else Ge[ye]={...Ge[ye],[ct]:pe};y(Ge)},xe=()=>{b([..._,{title:"",video_url:"",sort_order:_.length}])},he=ye=>{b(_.filter((ct,pe)=>pe!==ye))},we=(ye,ct,pe)=>{const Ge=[..._];ct==="file"&&pe instanceof File?Ge[ye]={...Ge[ye],file:pe}:Ge[ye]={...Ge[ye],[ct]:pe},b(Ge)},Ne=()=>{w([...N,{title:"",canva_share_link:"",sort_order:N.length}])},Ve=ye=>{w(N.filter((ct,pe)=>pe!==ye))},Te=(ye,ct,pe)=>{const Ge=[...N];Ge[ye]={...Ge[ye],[ct]:pe},w(Ge)},Ae=async(ye,ct)=>{try{const pe=await G.functions.invoke("bunny-upload",{body:{action:"create",title:ye.name}});if(pe.error)throw pe.error;const{videoId:Ge,uploadUrl:tt,libraryId:st}=pe.data,Ce=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Ge,libraryId:st}});if(Ce.error)throw Ce.error;const{uploadUrl:et,apiKey:Ct}=Ce.data,Ot=new XMLHttpRequest;return Ot.open("PUT",et,!0),Ot.setRequestHeader("AccessKey",Ct),Ot.upload.onprogress=ut=>{if(ut.lengthComputable){const Oe=Math.round(ut.loaded/ut.total*100),Xe=[..._];Xe[ct]={...Xe[ct],uploadProgress:Oe},b(Xe)}},await new Promise((ut,Oe)=>{Ot.onload=()=>Ot.status>=200&&Ot.status<300?ut():Oe(new Error("Upload failed")),Ot.onerror=()=>Oe(new Error("Upload failed")),Ot.send(ye)}),`https://iframe.mediadelivery.net/embed/${st}/${Ge}`}catch(pe){throw console.error("Bunny upload error:",pe),pe}},ze=Et({mutationFn:async ye=>{const{data:ct,error:pe}=await G.from("brokerage_resource_categories").insert({name:ye,sort_order:(Z==null?void 0:Z.length)||0}).select().single();if(pe)throw pe;return ct},onSuccess:ye=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:ye.id}),O(""),me.success("Category created")},onError:ye=>{me.error("Failed to create category: "+ye.message)}}),Ee=Et({mutationFn:async()=>{C(!0);let ye=(n==null?void 0:n.preview_image_url)||null;if(i){const Ge=i.name.split(".").pop(),tt=`${Date.now()}.${Ge}`,{error:st}=await G.storage.from("brokerage-resources").upload(`previews/${tt}`,i);if(st)throw st;const{data:Ce}=G.storage.from("brokerage-resources").getPublicUrl(`previews/${tt}`);ye=Ce.publicUrl}const ct={title:o.title,description:o.description||null,preview_image_url:ye,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let pe;if(n){const{error:Ge}=await G.from("brokerage_resources").update(ct).eq("id",n.id);if(Ge)throw Ge;pe=n.id;const tt=($==null?void 0:$.filter(at=>at.resource_id===n.id).map(at=>at.id))||[],st=f.filter(at=>at.id).map(at=>at.id),Ce=tt.filter(at=>!st.includes(at));Ce.length>0&&await G.from("brokerage_resource_pdfs").delete().in("id",Ce);const et=(V==null?void 0:V.filter(at=>at.resource_id===n.id).map(at=>at.id))||[],Ct=_.filter(at=>at.id).map(at=>at.id),Ot=et.filter(at=>!Ct.includes(at));Ot.length>0&&await G.from("brokerage_resource_videos").delete().in("id",Ot);const ut=(ee==null?void 0:ee.filter(at=>at.resource_id===n.id).map(at=>at.id))||[],Oe=N.filter(at=>at.id).map(at=>at.id),Xe=ut.filter(at=>!Oe.includes(at));Xe.length>0&&await G.from("brokerage_resource_links").delete().in("id",Xe)}else{const{data:Ge,error:tt}=await G.from("brokerage_resources").insert(ct).select().single();if(tt)throw tt;pe=Ge.id}for(let Ge=0;Ge{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),Y(),C(!1)},onError:ye=>{me.error("Failed to save resource: "+ye.message),C(!1)}}),ve=Et({mutationFn:async ye=>{const{error:ct}=await G.from("brokerage_resources").delete().eq("id",ye);if(ct)throw ct},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:ye=>{me.error("Failed to delete: "+ye.message)}}),Re=ye=>{if(ye.preventDefault(),!o.title){me.error("Please enter a title");return}Ee.mutate()},Ue=ye=>{const ct=($==null?void 0:$.filter(tt=>tt.resource_id===ye).length)||0,pe=(V==null?void 0:V.filter(tt=>tt.resource_id===ye).length)||0,Ge=(ee==null?void 0:ee.filter(tt=>tt.resource_id===ye).length)||0;return{pdfCount:ct,videoCount:pe,linkCount:Ge}};return e.jsx(Ls,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:(U==null?void 0:U.length)||0})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:(U==null?void 0:U.filter(ye=>ye.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{Y(),r(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Ie,{children:e.jsx(Be,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Title"}),e.jsx(Nt,{children:"Category"}),e.jsx(Nt,{children:"Content"}),e.jsx(Nt,{children:"Publish Date"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:q?e.jsx(As,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):(U==null?void 0:U.length)===0?e.jsx(As,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No brokerage resources yet. Create your first one!"})}):U==null?void 0:U.map(ye=>{const{pdfCount:ct,videoCount:pe,linkCount:Ge}=Ue(ye.id),tt=Z==null?void 0:Z.find(st=>st.id===ye.category_id);return e.jsxs(As,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[ye.preview_image_url?e.jsx("img",{src:ye.preview_image_url,alt:ye.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(Lh,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ye.title}),ye.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:ye.description})]})]})}),e.jsx(dt,{children:tt?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:tt.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(mn,{className:"h-3.5 w-3.5"}),ct]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),pe]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(go,{className:"h-3.5 w-3.5"}),Ge]})]})}),e.jsx(dt,{children:gs(new Date(ye.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 ${ye.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:ye.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 st=($==null?void 0:$.filter(Ct=>Ct.resource_id===ye.id))||[],Ce=(V==null?void 0:V.filter(Ct=>Ct.resource_id===ye.id))||[],et=(ee==null?void 0:ee.filter(Ct=>Ct.resource_id===ye.id))||[];I({...ye,pdfs:st,videos:Ce,links:et})},children:e.jsx(jn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ce(ye),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&ve.mutate(ye.id)},children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})})]},ye.id)})})]})})}),e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(ms,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:Re,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(Lh,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Fe,{type:"file",accept:"image/*",onChange:ae})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"title",children:"Title *"}),e.jsx(Fe,{id:"title",value:o.title,onChange:ye=>l({...o,title:ye.target.value}),placeholder:"Resource Title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ge,{className:"flex items-center gap-2",children:[e.jsx(hh,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(zs,{value:o.category_id,onValueChange:ye=>l({...o,category_id:ye}),children:[e.jsx(Os,{className:"flex-1",children:e.jsx(qs,{placeholder:"Select a category"})}),e.jsx(Fs,{children:Z==null?void 0:Z.map(ye=>e.jsx(yt,{value:ye.id,children:ye.name},ye.id))})]}),o.category_id&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:e.jsx(Sr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{placeholder:"Or create new category...",value:L,onChange:ye=>O(ye.target.value),className:"flex-1"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",disabled:!L.trim()||ze.isPending,onClick:()=>ze.mutate(L.trim()),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Description"}),e.jsx(Yg,{content:o.description,onChange:ye=>l({...o,description:ye}),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(ge,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Fe,{id:"publish_date",type:"date",value:o.publish_date,onChange:ye=>l({...o,publish_date:ye.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(Lr,{checked:o.is_published,onCheckedChange:ye=>l({...o,is_published:ye})}),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(ge,{className:"flex items-center gap-2",children:[e.jsx(mn,{className:"h-4 w-4"}),"PDF Documents (",f.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ie,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),f.map((ye,ct)=>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:ye.name,onChange:pe=>fe(ct,"name",pe.target.value),className:"flex-1"}),e.jsx(Fe,{type:"file",accept:".pdf",onChange:pe=>{var tt;const Ge=(tt=pe.target.files)==null?void 0:tt[0];Ge&&fe(ct,"file",Ge)},className:"flex-1"}),ye.file_url&&!ye.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>le(ct),children:e.jsx(Sr,{className:"h-4 w-4"})})]},ct))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ge,{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Videos (",_.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:xe,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),_.map((ye,ct)=>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:ye.title,onChange:pe=>we(ct,"title",pe.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>he(ct),children:e.jsx(Sr,{className:"h-4 w-4"})})]}),e.jsx(Fe,{type:"file",accept:"video/*",onChange:pe=>{var tt;const Ge=(tt=pe.target.files)==null?void 0:tt[0];Ge&&we(ct,"file",Ge)}}),ye.uploadProgress!==void 0&&ye.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:`${ye.uploadProgress}%`}})}),ye.video_url&&!ye.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},ct))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ge,{className:"flex items-center gap-2",children:[e.jsx(go,{className:"h-4 w-4"}),"Canva Links (",N.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Ne,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),N.map((ye,ct)=>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:ye.title,onChange:pe=>Te(ct,"title",pe.target.value),className:"flex-1"}),e.jsx(Fe,{placeholder:"Canva Share Link",value:ye.canva_share_link,onChange:pe=>Te(ct,"canva_share_link",pe.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>Ve(ct),children:e.jsx(Sr,{className:"h-4 w-4"})})]},ct))]}),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:Ee.isPending||S,children:Ee.isPending||S?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:A==null?void 0:A.title})}),A&&e.jsxs("div",{className:"space-y-4",children:[A.preview_image_url&&e.jsx("img",{src:A.preview_image_url,alt:A.title,className:"w-full h-48 object-cover rounded-lg"}),A.description&&e.jsx("p",{className:"text-muted-foreground",children:A.description}),A.pdfs&&A.pdfs.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(mn,{className:"h-4 w-4"}),"PDF Documents (",A.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:A.pdfs.map(ye=>e.jsx("a",{href:ye.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:ye.name},ye.id))})]}),A.videos&&A.videos.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Videos (",A.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:A.videos.map(ye=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:ye.title})},ye.id))})]}),A.links&&A.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(go,{className:"h-4 w-4"}),"Canva Links (",A.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:A.links.map(ye=>e.jsx("a",{href:ye.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:ye.title},ye.id))})]})]})]})})]})})}const Zat=[{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 T_s(){const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[d,u]=k.useState(null),[p,f]=k.useState(!1),[y,_]=k.useState(!1),[b,N]=k.useState(""),[w,S]=k.useState(""),[C,A]=k.useState(""),[I,L]=k.useState(""),[O,U]=k.useState("Learn More"),[q,$]=k.useState("top"),[V,ee]=k.useState(""),[Z,J]=k.useState(!0),[Y,ce]=k.useState(""),[ae,ie]=k.useState("");k.useEffect(()=>{le()},[]);const le=async()=>{try{const{data:ze,error:Ee}=await G.from("dashboard_banners").select("*").order("placement").order("sort_order");if(Ee)throw Ee;s(ze||[])}catch(ze){me.error("Failed to load banners: "+ze.message)}finally{n(!1)}},fe=()=>{N(""),S(""),A(""),L(""),U("Learn More"),$("top"),ee(""),J(!0),ce(""),ie(""),u(null)},xe=ze=>{u(ze),N(ze.title),S(ze.description||""),A(ze.image_url),L(ze.link_url||""),U(ze.link_text||"Learn More"),$(ze.placement),ee(ze.section_after||""),J(ze.is_active),ce(ze.start_date?gs(new Date(ze.start_date),"yyyy-MM-dd'T'HH:mm"):""),ie(ze.end_date?gs(new Date(ze.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},he=async ze=>{var ve;const Ee=(ve=ze.target.files)==null?void 0:ve[0];if(Ee){f(!0);try{const Re=Ee.name.split(".").pop(),Ue=`${Date.now()}.${Re}`,{error:ye}=await G.storage.from("banner-images").upload(Ue,Ee);if(ye)throw ye;const{data:{publicUrl:ct}}=G.storage.from("banner-images").getPublicUrl(Ue);A(ct),me.success("Image uploaded successfully")}catch(Re){me.error("Failed to upload image: "+Re.message)}finally{f(!1)}}},we=async()=>{if(!b.trim()||!C){me.error("Please fill in required fields (title and image)");return}_(!0);try{const ze={title:b.trim(),description:w.trim()||null,image_url:C,link_url:I.trim()||null,link_text:O.trim()||"Learn More",placement:q,section_after:q==="between"?V:null,is_active:Z,start_date:Y?new Date(Y).toISOString():null,end_date:ae?new Date(ae).toISOString():null};if(d){const{error:Ee}=await G.from("dashboard_banners").update(ze).eq("id",d.id);if(Ee)throw Ee;me.success("Banner updated successfully")}else{const Ee=t.filter(Re=>Re.placement===q).length,{error:ve}=await G.from("dashboard_banners").insert({...ze,sort_order:Ee});if(ve)throw ve;me.success("Banner created successfully")}o(!1),fe(),le()}catch(ze){me.error("Failed to save banner: "+ze.message)}finally{_(!1)}},Ne=async()=>{if(d)try{const{error:ze}=await G.from("dashboard_banners").delete().eq("id",d.id);if(ze)throw ze;me.success("Banner deleted successfully"),i(!1),u(null),le()}catch(ze){me.error("Failed to delete banner: "+ze.message)}},Ve=async ze=>{try{const{error:Ee}=await G.from("dashboard_banners").update({is_active:!ze.is_active}).eq("id",ze.id);if(Ee)throw Ee;me.success(ze.is_active?"Banner deactivated":"Banner activated"),le()}catch(Ee){me.error("Failed to update banner: "+Ee.message)}},Te=t.filter(ze=>ze.placement==="top"),Ae=t.filter(ze=>ze.placement==="between");return r?e.jsx(Ls,{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(Ls,{title:"Dashboard Management",description:"Configure dashboard modules and banners",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Uo,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(mr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(fs,{open:a&&q==="top",onOpenChange:ze=>{ze||fe(),o(ze),ze&&$("top")},children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{onClick:()=>{fe(),$("top")},children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Add Hero Banner"]})}),e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsxs(bs,{children:[d?"Edit":"Create"," Banner"]}),e.jsx(Rr,{children:"Configure the banner's content and display settings"})]}),e.jsx(F7e,{title:b,setTitle:N,description:w,setDescription:S,imageUrl:C,linkUrl:I,setLinkUrl:L,linkText:O,setLinkText:U,placement:q,setPlacement:$,sectionAfter:V,setSectionAfter:ee,isActive:Z,setIsActive:J,startDate:Y,setStartDate:ce,endDate:ae,setEndDate:ie,handleImageUpload:he,uploading:p,showPlacementOptions:!1}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),fe()},children:"Cancel"}),e.jsx(K,{onClick:we,disabled:y,children:y?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Be,{children:Te.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:Te.map(ze=>e.jsx(z7e,{banner:ze,onEdit:()=>xe(ze),onDelete:()=>{u(ze),i(!0)},onToggleActive:()=>Ve(ze)},ze.id))})})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Uo,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(mr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(fs,{open:a&&q==="between",onOpenChange:ze=>{ze||fe(),o(ze),ze&&$("between")},children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{onClick:()=>{fe(),$("between")},children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Add Section Banner"]})}),e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsxs(bs,{children:[d?"Edit":"Create"," Section Banner"]}),e.jsx(Rr,{children:"Configure where this banner appears between sections"})]}),e.jsx(F7e,{title:b,setTitle:N,description:w,setDescription:S,imageUrl:C,linkUrl:I,setLinkUrl:L,linkText:O,setLinkText:U,placement:q,setPlacement:$,sectionAfter:V,setSectionAfter:ee,isActive:Z,setIsActive:J,startDate:Y,setStartDate:ce,endDate:ae,setEndDate:ie,handleImageUpload:he,uploading:p,showPlacementOptions:!0}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),fe()},children:"Cancel"}),e.jsx(K,{onClick:we,disabled:y,children:y?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Be,{children:Ae.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No section banners yet. Add your first banner above."}):e.jsx("div",{className:"space-y-3",children:Ae.map(ze=>e.jsx(z7e,{banner:ze,onEdit:()=>xe(ze),onDelete:()=>{u(ze),i(!0)},onToggleActive:()=>Ve(ze),showSection:!0},ze.id))})})]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Delete Banner"}),e.jsxs(Rr,{children:['Are you sure you want to delete "',d==null?void 0:d.title,'"? This action cannot be undone.']})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Ne,children:"Delete"})]})]})})]})}function F7e({title:t,setTitle:s,description:r,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:d,placement:u,setPlacement:p,sectionAfter:f,setSectionAfter:y,isActive:_,setIsActive:b,startDate:N,setStartDate:w,endDate:S,setEndDate:C,handleImageUpload:A,uploading:I,showPlacementOptions:L}){return e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"title",children:"Title *"}),e.jsx(Fe,{id:"title",placeholder:"Banner headline...",value:t,onChange:O=>s(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",placeholder:"Optional banner description...",value:r,onChange:O=>n(O.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Banner Image *"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Fe,{type:"file",accept:"image/*",onChange:A,disabled:I,className:"flex-1"}),I&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),a&&e.jsx("div",{className:"mt-2 relative rounded-lg overflow-hidden border",children:e.jsx("img",{src:a,alt:"Preview",className:"w-full h-40 object-cover"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(Fe,{id:"linkUrl",placeholder:"https://...",value:o,onChange:O=>l(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"linkText",children:"Button Text"}),e.jsx(Fe,{id:"linkText",placeholder:"Learn More",value:i,onChange:O=>d(O.target.value)})]})]}),L&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Placement"}),e.jsxs(zs,{value:f,onValueChange:y,children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select section placement..."})}),e.jsx(Fs,{children:Zat.map(O=>e.jsx(yt,{value:O.value,children:O.label},O.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ge,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(Fe,{id:"startDate",type:"datetime-local",value:N,onChange:O=>w(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ge,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(Fe,{id:"endDate",type:"datetime-local",value:S,onChange:O=>C(O.target.value)})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{id:"isActive",checked:_,onCheckedChange:b}),e.jsx(ge,{htmlFor:"isActive",children:"Active"})]})})]})}function z7e({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var d;const o=(d=Zat.find(u=>u.value===t.section_after))==null?void 0:d.label,[l,i]=k.useState(null);return k.useEffect(()=>{(async()=>{const{count:p}=await G.from("content_engagement_logs").select("*",{count:"exact",head:!0}).eq("resource_id",t.id).eq("action_type","click_link");i(p??0)})()},[t.id]),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(uu,{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(Ye,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(Ye,{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})]}),l!==null&&e.jsxs("div",{className:"flex items-center gap-1 text-destructive",title:"Button clicks",children:[e.jsx(Cm,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-semibold",children:l})]}),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(Kr,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(jn,{className:"h-4 w-4"}):e.jsx(hp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})]})}const y9={open:{label:"Open",icon:rn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:bc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:si,color:"bg-green-500"},closed:{label:"Closed",icon:Ql,color:"bg-muted-foreground"}},B7e={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function A_s(){var O,U;const{user:t}=$s(),s=es(),[r,n]=k.useState(null),[a,o]=k.useState(""),[l,i]=k.useState("all"),[d,u]=k.useState("all"),[p,f]=k.useState(!1),{data:y=[],isLoading:_}=ft({queryKey:["admin-support-tickets",l,d],queryFn:async()=>{let q=G.from("support_tickets").select("*, profiles!support_tickets_user_id_fkey(name, email)").order("created_at",{ascending:!1});l!=="all"&&(q=q.eq("status",l)),d!=="all"&&(q=q.eq("category",d));const{data:$,error:V}=await q;if(V)throw V;return $}}),{data:b=[]}=ft({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:q,error:$}=await G.from("user_roles").select("user_id").eq("role","admin");if($)throw $;const V=q.map(ae=>ae.user_id),{data:ee,error:Z}=await G.from("profiles").select("id, name, email").in("id",V);if(Z)throw Z;const{data:J,error:Y}=await G.from("support_notification_settings").select("user_id, receive_notifications");if(Y)throw Y;const ce=new Map((J==null?void 0:J.map(ae=>[ae.user_id,ae.receive_notifications]))||[]);return ee.map(ae=>({...ae,receives_notifications:ce.get(ae.id)||!1}))}}),{data:N=[]}=ft({queryKey:["admin-ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:q,error:$}=await G.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if($)throw $;return q},enabled:!!r}),w=Et({mutationFn:async({userId:q,enabled:$})=>{const{data:V}=await G.from("support_notification_settings").select("id").eq("user_id",q).maybeSingle();if(V){const{error:ee}=await G.from("support_notification_settings").update({receive_notifications:$}).eq("user_id",q);if(ee)throw ee}else{const{error:ee}=await G.from("support_notification_settings").insert({user_id:q,receive_notifications:$});if(ee)throw ee}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),me.success("Notification settings updated")},onError:()=>{me.error("Failed to update settings")}}),S=Et({mutationFn:async({ticketId:q,status:$})=>{const{error:V}=await G.from("support_tickets").update({status:$}).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")}}),C=Et({mutationFn:async({ticketId:q,assignedTo:$})=>{const{error:V}=await G.from("support_tickets").update({assigned_to:$}).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")}}),A=Et({mutationFn:async q=>{var V,ee;if(!r||!t)throw new Error("Missing data");const{error:$}=await G.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:q,is_admin_reply:!0});if($)throw $;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:(ee=r.profiles)==null?void 0:ee.name}})}catch(Z){console.error("Failed to send reply notification:",Z)}},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()&&A.mutate(a)};k.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?(y9[r.status].icon,e.jsx(Ls,{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(Ra,{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(Ye,{variant:"secondary",children:B7e[r.category]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((O=r.profiles)==null?void 0:O.name)||"Unknown"," (",(U=r.profiles)==null?void 0:U.email,")"]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm",children:"Status"})}),e.jsx(Be,{children:e.jsxs(zs,{value:r.status,onValueChange:q=>{S.mutate({ticketId:r.id,status:q}),n({...r,status:q})},children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"open",children:"Open"}),e.jsx(yt,{value:"in_progress",children:"In Progress"}),e.jsx(yt,{value:"resolved",children:"Resolved"}),e.jsx(yt,{value:"closed",children:"Closed"})]})]})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm",children:"Assigned To"})}),e.jsx(Be,{children:e.jsxs(zs,{value:r.assigned_to||"unassigned",onValueChange:q=>{const $=q==="unassigned"?null:q;C.mutate({ticketId:r.id,assignedTo:$}),n({...r,assigned_to:$})},children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Unassigned"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"unassigned",children:"Unassigned"}),b.map(q=>e.jsx(yt,{value:q.id,children:q.name},q.id))]})]})})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(mr,{children:["Created on ",gs(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Be,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Conversation"})}),e.jsxs(Be,{children:[e.jsx(di,{className:"h-[300px] pr-4",children:N.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:N.map(q=>{var $,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?`${(($=q.profiles)==null?void 0:$.name)||"Admin"} (Support)`:((V=q.profiles)==null?void 0:V.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:gs(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(jo,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_r,{placeholder:"Type your reply...",value:a,onChange:q=>o(q.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:I,disabled:!a.trim()||A.isPending,className:"self-end",children:e.jsx(Nn,{className:"h-4 w-4"})})]})]})]})]})})):e.jsx(Ls,{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(Ye,{variant:"destructive",className:"ml-2",children:[L," open"]})]})]}),e.jsxs(fs,{open:p,onOpenChange:f,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(So,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Email Notification Settings"}),e.jsx(Rr,{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(Ei,{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(Nm,{className:"h-4 w-4 text-primary"}):e.jsx(Wv,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Lr,{checked:q.receives_notifications,onCheckedChange:$=>w.mutate({userId:q.id,enabled:$})})]})]},q.id))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx(ta,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(Qn,{children:[e.jsx(ls,{value:"all",children:"All"}),e.jsx(ls,{value:"open",children:"Open"}),e.jsx(ls,{value:"in_progress",children:"In Progress"}),e.jsx(ls,{value:"resolved",children:"Resolved"}),e.jsx(ls,{value:"closed",children:"Closed"})]})}),e.jsxs(zs,{value:d,onValueChange:u,children:[e.jsx(Os,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"All Categories"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Categories"}),e.jsx(yt,{value:"general",children:"General Support"}),e.jsx(yt,{value:"technology",children:"Technology Support"}),e.jsx(yt,{value:"crm",children:"CRM Support"}),e.jsx(yt,{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(Ie,{children:e.jsxs(Be,{className:"text-center py-12",children:[e.jsx(bc,{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,ee;const $=y9[q.status].icon;return e.jsx(Ie,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(q),children:e.jsx(Be,{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(Ye,{variant:"outline",className:"text-xs",children:B7e[q.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(V=q.profiles)==null?void 0:V.name," • ",gs(new Date(q.created_at),"MMM d, yyyy")]}),q.assigned_to&&e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Ei,{className:"h-3 w-3"}),((ee=b.find(Z=>Z.id===q.assigned_to))==null?void 0:ee.name)||"Assigned"]})]})]}),e.jsxs(Ye,{className:y9[q.status].color,children:[e.jsx($,{className:"h-3 w-3 mr-1"}),y9[q.status].label]})]})})},q.id)})})})]})]})})}const Yat=fh.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 E_s({content:t,onChange:s,variables:r}){const n=Zke({extensions:[Xke,o4e.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),l4e.configure({types:["heading","paragraph"]}),c4e,Yat],content:t,onUpdate:({editor:l})=>{s(l.getHTML())}});k.useEffect(()=>{n&&t!==n.getHTML()&&n.commands.setContent(t)},[t,n]);const a=l=>{n&&n.chain().focus().insertContent(`{{${l.key}}}`).run()},o=()=>{if(!n)return;const l=n.getAttributes("link").href,i=window.prompt("URL",l);if(i!==null){if(i===""){n.chain().focus().extendMarkRange("link").unsetLink().run();return}n.chain().focus().extendMarkRange("link").setLink({href:i}).run()}};return n?e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:e.jsx(Y4,{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(aS,{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(Rh,{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(Yy,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("left").run(),className:n.isActive({textAlign:"left"})?"bg-muted":"",children:e.jsx(W4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("center").run(),className:n.isActive({textAlign:"center"})?"bg-muted":"",children:e.jsx(G4,{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(K4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:o,className:n.isActive("link")?"bg-muted":"",children:e.jsx(go,{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(Q4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),children:e.jsx(NS,{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(gS,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(BM,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(jd,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(xa,{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(Wke,{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(Ye,{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 P_s(){const t=es(),[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState(""),[i,d]=k.useState(""),[u,p]=k.useState(""),[f,y]=k.useState(!0),[_,b]=k.useState("visual"),{data:N,isLoading:w}=ft({queryKey:["email-templates"],queryFn:async()=>{const{data:L,error:O}=await G.from("email_templates").select("*").order("name");if(O)throw O;return L.map(U=>({...U,available_variables:U.available_variables||[]}))}}),S=Et({mutationFn:async L=>{const{error:O}=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(O)throw O},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),me.success("Email template updated successfully"),r(null)},onError:L=>{me.error("Failed to update template: "+L.message)}}),C=L=>{r(L),l(L.subject),d(L.body_html),p(L.description||""),y(L.is_active),b("visual")},A=()=>{s&&S.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:f})},I=(L,O)=>{let U=L;return O.forEach(q=>{const $=`{{${q.key}}}`,V=`[${q.label}]`;U=U.replace(new RegExp($.replace(/[{}]/g,"\\$&"),"g"),V)}),U};return s?e.jsxs(Ls,{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(Ra,{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(jn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{onClick:A,disabled:S.isPending,children:[e.jsx(wc,{className:"h-4 w-4 mr-2"}),S.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5"}),s.name]}),e.jsxs(mr,{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(ge,{htmlFor:"active-toggle",children:"Active"}),e.jsx(Lr,{id:"active-toggle",checked:f,onCheckedChange:y})]})]})}),e.jsxs(Be,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"description",children:"Description"}),e.jsx(_r,{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(ge,{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(ge,{children:"Email Body"}),e.jsx(ta,{value:_,onValueChange:L=>b(L),children:e.jsxs(Qn,{className:"h-8",children:[e.jsxs(ls,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(pS,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(ls,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(Q4,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),_==="visual"?e.jsx(E_s,{content:i,onChange:d,variables:s.available_variables}):e.jsx(_r,{value:i,onChange:L=>d(L.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"HTML email body"})]})]})]})]}),e.jsx(fs,{open:!!n,onOpenChange:()=>a(null),children:e.jsxs(ms,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Email Preview"}),e.jsxs(Rr,{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(Ls,{title:"Email Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Email Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage and customize system email templates"})]}),w?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((L,O)=>e.jsx(Ie,{children:e.jsxs(Lt,{children:[e.jsx(Ss,{className:"h-5 w-48"}),e.jsx(Ss,{className:"h-4 w-96"})]})},O))}):e.jsx("div",{className:"grid gap-4",children:N==null?void 0:N.map(L=>e.jsxs(Ie,{className:"hover:shadow-md transition-shadow",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ft,{className:"flex items-center gap-2 text-lg",children:[e.jsx(tr,{className:"h-5 w-5 text-muted-foreground"}),L.name,!L.is_active&&e.jsx(Ye,{variant:"secondary",children:"Inactive"})]}),e.jsx(mr,{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(jn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{size:"sm",onClick:()=>C(L),children:[e.jsx(Gc,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx(Be,{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(O=>e.jsx(Ye,{variant:"outline",className:"font-mono text-xs",children:`{{${O.key}}}`},O.key))})]})]})})]},L.id))}),e.jsx(fs,{open:!!n&&!s,onOpenChange:()=>a(null),children:e.jsxs(ms,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(ks,{children:[e.jsxs(bs,{children:["Email Preview: ",n==null?void 0:n.name]}),e.jsxs(Rr,{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 I_s(){const t=es(),[s,r]=k.useState("templates"),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,d]=k.useState(!1),[u,p]=k.useState(!1),[f,y]=k.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[_,b]=k.useState({name:"",description:"",icon:"📧"}),{data:N=[]}=ft({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:V,error:ee}=await G.from("email_template_categories").select("*").order("sort_order");if(ee)throw ee;return V}}),{data:w=[],isLoading:S}=ft({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:V,error:ee}=await G.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(ee)throw ee;return V}}),C=Et({mutationFn:async V=>{const ee={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:Z}=await G.from("agent_email_templates").update(ee).eq("id",V.id);if(Z)throw Z}else{const{error:Z}=await G.from("agent_email_templates").insert(ee);if(Z)throw Z}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),d(!1),me.success(n?"Template updated":"Template created")},onError:()=>me.error("Failed to save template")}),A=Et({mutationFn:async V=>{const{error:ee}=await G.from("agent_email_templates").delete().eq("id",V);if(ee)throw ee},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),me.success("Template deleted")}}),I=Et({mutationFn:async V=>{const ee={name:V.name,description:V.description||null,icon:V.icon};if(V.id){const{error:Z}=await G.from("email_template_categories").update(ee).eq("id",V.id);if(Z)throw Z}else{const Z=N.length>0?Math.max(...N.map(Y=>Y.sort_order))+1:0,{error:J}=await G.from("email_template_categories").insert({...ee,sort_order:Z});if(J)throw J}},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=Et({mutationFn:async V=>{const{error:ee}=await G.from("email_template_categories").delete().eq("id",V);if(ee)throw ee},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),me.success("Category deleted")}}),O=()=>{a(null),y({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),d(!0)},U=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}),d(!0)},q=()=>{l(null),b({name:"",description:"",icon:"📧"}),p(!0)},$=V=>{l(V),b({name:V.name,description:V.description||"",icon:V.icon}),p(!0)};return e.jsx(Ls,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(qu,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(ta,{value:s,onValueChange:r,children:[e.jsxs(Qn,{children:[e.jsxs(ls,{value:"templates",className:"gap-2",children:[e.jsx(tr,{className:"h-4 w-4"})," Templates"]}),e.jsxs(ls,{value:"categories",className:"gap-2",children:[e.jsx(Sm,{className:"h-4 w-4"})," Categories"]})]}),e.jsxs(js,{value:"templates",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:O,className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Ie,{children:e.jsx(Be,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Template"}),e.jsx(Nt,{className:"hidden md:table-cell",children:"Category"}),e.jsx(Nt,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:S?e.jsx(As,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:e.jsx(ps,{className:"h-6 w-6 animate-spin mx-auto"})})}):w.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):w.map(V=>e.jsxs(As,{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(Ye,{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(Ye,{variant:"secondary",children:V.tone}):"—"}),e.jsx(dt,{children:e.jsx(Ye,{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:()=>U(V),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&A.mutate(V.id)},children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},V.id))})]})})})]}),e.jsxs(js,{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(Bs,{className:"h-4 w-4"})," Add Category"]})}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:N.map(V=>e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{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:()=>$(V),children:e.jsx(pa,{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(yr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Be,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:V.description||"No description"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[w.filter(ee=>ee.category_id===V.id).length," templates"]})]})]},V.id))})]})]}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ms,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:n?"Edit Template":"New Template"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Title"}),e.jsx(Fe,{value:f.title,onChange:V=>y(ee=>({...ee,title:V.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Category"}),e.jsxs(zs,{value:f.category_id,onValueChange:V=>y(ee=>({...ee,category_id:V})),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select category"})}),e.jsx(Fs,{children:N.map(V=>e.jsxs(yt,{value:V.id,children:[V.icon," ",V.name]},V.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Subject Line"}),e.jsx(Fe,{value:f.subject,onChange:V=>y(ee=>({...ee,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(ge,{children:"Email Body"}),e.jsx(_r,{value:f.body,onChange:V=>y(ee=>({...ee,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(ge,{children:"Description (internal)"}),e.jsx(Fe,{value:f.description,onChange:V=>y(ee=>({...ee,description:V.target.value})),placeholder:"Short description for admin reference"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Tone"}),e.jsx(Fe,{value:f.tone,onChange:V=>y(ee=>({...ee,tone:V.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{checked:f.is_active,onCheckedChange:V=>y(ee=>({...ee,is_active:V}))}),e.jsx(ge,{children:"Active"})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>C.mutate({...f,id:n==null?void 0:n.id}),disabled:C.isPending||!f.title||!f.subject||!f.body,children:[C.isPending&&e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(ms,{className:"sm:max-w-[450px]",children:[e.jsx(ks,{children:e.jsx(bs,{children:o?"Edit Category":"New Category"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-[60px_1fr] gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Icon"}),e.jsx(Fe,{value:_.icon,onChange:V=>b(ee=>({...ee,icon:V.target.value})),className:"text-center text-lg"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Name"}),e.jsx(Fe,{value:_.name,onChange:V=>b(ee=>({...ee,name:V.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Description"}),e.jsx(Fe,{value:_.description,onChange:V=>b(ee=>({...ee,description:V.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(gn,{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(ps,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const L_s=({brokerageId:t})=>{var ua,$t;const{toast:s}=va(),r=br(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,d]=k.useState(""),[u,p]=k.useState("all"),[f,y]=k.useState(new Set),[_,b]=k.useState(!1),[N,w]=k.useState({}),[S,C]=k.useState(!1),[A,I]=k.useState(!1),[L,O]=k.useState({email:"",name:"",password:"",phone:""}),[U,q]=k.useState(!1),[$,V]=k.useState(null),[ee,Z]=k.useState(!1),[J,Y]=k.useState(!1),[ce,ae]=k.useState(!1),[ie,le]=k.useState(""),[fe,xe]=k.useState(!1),[he,we]=k.useState([]),[Ne,Ve]=k.useState(!1),[Te,Ae]=k.useState(!1),[ze,Ee]=k.useState(null),[ve,Re]=k.useState({name:"",phone:"",email:""}),[Ue,ye]=k.useState(!1),[ct,pe]=k.useState(!1),[Ge,tt]=k.useState(null),[st,Ce]=k.useState("asc"),[et,Ct]=k.useState(!1),[Ot,ut]=k.useState(null),[Oe,Xe]=k.useState(!1),[at,Ke]=k.useState(null),[He,gt]=k.useState(""),[Mt,Wt]=k.useState(!1),[xs,Cs]=k.useState(null);k.useEffect(()=>{Ar(),Us()},[t]);const Us=async()=>{try{const{data:Se,error:De}=await G.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(De)throw De;we((Se==null?void 0:Se.map(Ze=>Ze.user_id))||[])}catch(Se){console.error("Error loading brokerage managers:",Se)}},Ar=async()=>{try{l(!0);const{data:Se,error:De}=await G.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(De)throw De;const Ze=Se.agents||[];if(a(Ze),Ze.length>0){const xt=Ze.map(Pt=>Pt.id),{data:_t}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",xt);if(_t&&_t.length>0){const Pt=_t.map(Qt=>Qt.assistant_id),{data:Yt}=await G.from("profiles").select("id, name, email").in("id",Pt),Vt={};for(const Qt of _t){const Es=Yt==null?void 0:Yt.find(ys=>ys.id===Qt.assistant_id);Es&&(Vt[Qt.agent_id]={name:Es.name||"",email:Es.email||""})}w(Vt)}else w({})}}catch(Se){console.error("Error loading agents:",Se),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{l(!1)}},Bt=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:Se}}=await G.auth.getSession(),De=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({...L,brokerageId:t})}),Ze=await De.json();if(!De.ok)throw new Error(Ze.error||"Failed to create agent");s({title:"Success",description:`Agent ${L.email} created successfully`}),O({email:"",name:"",password:"",phone:""}),C(!1),Ar()}catch(Se){console.error("Error creating agent:",Se),s({title:"Error",description:Se.message||"Failed to create agent",variant:"destructive"})}finally{I(!1)}},Xs=async Se=>{try{const{data:{session:De}}=await G.auth.getSession(),Ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${De==null?void 0:De.access_token}`},body:JSON.stringify({userId:Se})}),xt=await Ze.json();if(!Ze.ok)throw new Error(xt.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch(De){console.error("Error resending welcome email:",De),s({title:"Error",description:De.message||"Failed to resend welcome email",variant:"destructive"})}},Nr=async(Se,De)=>{try{const{error:Ze}=await G.functions.invoke("send-password-reset",{body:{email:Se,redirectTo:window.location.origin}});if(Ze)throw Ze;s({title:"Password Reset Sent",description:`Password reset email sent to ${De}`})}catch(Ze){console.error("Error sending password reset:",Ze),s({title:"Error",description:Ze.message||"Failed to send password reset email",variant:"destructive"})}},Vs=Se=>{V(Se),q(!0)},ar=Se=>{Ee(Se),Re({name:Se.name,phone:Se.phone||"",email:Se.email}),Ae(!0)},Or=async()=>{if(!ze)return;if(!ve.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const Se=ve.email.trim().toLowerCase()!==ze.email.toLowerCase();ye(!0);try{if(Se){if(!ve.email.trim())throw new Error("Email is required");pe(!0);const{data:{session:Ze}}=await G.auth.getSession(),xt=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:ze.id,newEmail:ve.email.trim(),brokerageId:t})}),_t=await xt.json();if(pe(!1),!xt.ok)throw new Error(_t.error||"Failed to update email")}const{error:De}=await G.from("profiles").update({name:ve.name.trim(),phone:ve.phone.trim()||null}).eq("id",ze.id);if(De)throw De;s({title:"Success",description:"Agent profile updated successfully"}),Ae(!1),Ee(null),Ar()}catch(De){console.error("Error updating agent:",De),s({title:"Error",description:De.message||"Failed to update agent",variant:"destructive"})}finally{ye(!1),pe(!1)}},Rn=async()=>{if(!ie){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}xe(!0);try{const{data:{session:Se}}=await G.auth.getSession(),De=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({userId:ie,role:"brokerage_manager",action:"add",brokerageId:t})}),Ze=await De.json();if(!De.ok)throw new Error(Ze.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),ae(!1),le(""),Us()}catch(Se){console.error("Error adding brokerage manager:",Se),s({title:"Error",description:Se.message||"Failed to add brokerage manager",variant:"destructive"})}finally{xe(!1)}},bn=async Se=>{try{const{data:{session:De}}=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 ${De==null?void 0:De.access_token}`},body:JSON.stringify({userId:Se,role:"brokerage_manager",action:"remove",brokerageId:t})}),xt=await Ze.json();if(!Ze.ok)throw new Error(xt.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),Us()}catch(De){console.error("Error removing brokerage manager:",De),s({title:"Error",description:De.message||"Failed to remove brokerage manager",variant:"destructive"})}},ir=Se=>he.includes(Se),or=Se=>{Ke(Se),gt(""),Xe(!0)},hr=async()=>{if(!(!at||!He)){if(He.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}Wt(!0);try{const{data:{session:Se}}=await G.auth.getSession(),De=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({agentId:at.id,brokerageId:t,action:"set_password",newPassword:He})}),Ze=await De.json();if(!De.ok)throw new Error(Ze.error||"Failed to set password");s({title:"Success",description:`Password set for ${at.name}`}),Xe(!1),Ke(null),gt("")}catch(Se){console.error("Error setting password:",Se),s({title:"Error",description:Se.message||"Failed to set password",variant:"destructive"})}finally{Wt(!1)}}},an=async Se=>{Cs(Se.id);try{const{data:{session:De}}=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 ${De==null?void 0:De.access_token}`},body:JSON.stringify({agentId:Se.id,brokerageId:t,action:"claim_account"})}),xt=await Ze.json();if(!Ze.ok)throw new Error(xt.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${Se.name}`}),Ar()}catch(De){console.error("Error claiming account:",De),s({title:"Error",description:De.message||"Failed to claim account",variant:"destructive"})}finally{Cs(null)}},Gr=async()=>{if($){Z(!0);try{const{data:{session:Se}}=await G.auth.getSession(),De=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({userId:$.id,brokerageId:t})}),Ze=await De.json();if(!De.ok)throw new Error(Ze.error||"Failed to remove agent");s({title:"Success",description:`${$.name} has been removed from your brokerage`}),q(!1),V(null),Ar()}catch(Se){console.error("Error removing agent:",Se),s({title:"Error",description:Se.message||"Failed to remove agent",variant:"destructive"})}finally{Z(!1)}}},Va=Se=>{const De=Se.trim().split(" ");return De.length>1?De[De.length-1].toLowerCase():Se.toLowerCase()},$a=Se=>{Ge===Se?Ce(st==="asc"?"desc":"asc"):(tt(Se),Ce("asc"))},Xt=Se=>Ge!==Se?e.jsx(td,{className:"ml-1 h-4 w-4"}):st==="asc"?e.jsx(cu,{className:"ml-1 h-4 w-4"}):e.jsx(Ih,{className:"ml-1 h-4 w-4"}),Qa=n.filter(Se=>{if(u==="active"&&!Se.claimed||u==="pending"&&Se.claimed)return!1;if(!i)return!0;const De=i.toLowerCase();return Se.name.toLowerCase().includes(De)||Se.email.toLowerCase().includes(De)}),Cr=[...Qa].sort((Se,De)=>{if(!Ge)return 0;let Ze=0;return Ge==="name"?Ze=Va(Se.name).localeCompare(Va(De.name)):Ge==="status"&&(Ze=Se.claimed===De.claimed?0:Se.claimed?-1:1),st==="asc"?Ze:-Ze});Qa.filter(Se=>Se.claimed&&!ir(Se.id));const Fn=Se=>{y(De=>{const Ze=new Set(De);return Ze.has(Se)?Ze.delete(Se):Ze.add(Se),Ze})},Kt=()=>{f.size===Cr.length?y(new Set):y(new Set(Cr.map(Se=>Se.id)))},Mr=()=>{y(new Set)},On=async()=>{const Se=Array.from(f);if(Se.length===0)return;b(!0);let De=0,Ze=0;try{const{data:{session:xt}}=await G.auth.getSession();for(const _t of Se)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${xt==null?void 0:xt.access_token}`},body:JSON.stringify({userId:_t})})).ok?De++:Ze++}catch{Ze++}De>0?s({title:"Success",description:`Welcome emails sent to ${De} agent${De>1?"s":""}${Ze>0?` (${Ze} failed)`:""}`}):s({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),Mr()}catch(xt){console.error("Error bulk sending welcome emails:",xt),s({title:"Error",description:xt.message||"Failed to send welcome emails",variant:"destructive"})}finally{b(!1)}};return o?e.jsx(Ie,{children:e.jsx(Be,{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(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Agents"}),e.jsx(mr,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>ae(!0),children:[e.jsx(Ru,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(K,{variant:"outline",onClick:()=>Y(!0),children:[e.jsx(Zv,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(K,{onClick:()=>C(!0),children:[e.jsx(il,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs(Be,{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(tn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search agents...",value:i,onChange:Se=>d(Se.target.value),className:"pl-9"})]}),e.jsxs(zs,{value:u,onValueChange:Se=>p(Se),children:[e.jsx(Os,{className:"w-[160px]",children:e.jsx(qs,{placeholder:"Filter by status"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Agents"}),e.jsx(yt,{value:"active",children:"Active"}),e.jsx(yt,{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 De=n.filter(Ze=>f.has(Ze.id)&&Ze.email).map(Ze=>({email:Ze.email,name:Ze.name}));sessionStorage.setItem("campaign_direct_recipients",JSON.stringify(De)),r("/admin/email-campaigns/new?directMode=1",{state:{directRecipients:De}})},disabled:_,children:[e.jsx(dh,{className:"mr-2 h-4 w-4"}),"Email Agents (",f.size,")"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:On,disabled:_,children:[e.jsx(tr,{className:"mr-2 h-4 w-4"}),_?"Sending...":"Resend Welcome Email"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:Mr,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{className:"w-[40px]",children:e.jsx(Gi,{checked:Cr.length>0&&f.size===Cr.length,onCheckedChange:Kt,"aria-label":"Select all"})}),e.jsx(Nt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>$a("name"),children:["Name (Last)",Xt("name")]})}),e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>$a("status"),children:["Status",Xt("status")]})}),e.jsx(Nt,{children:"Actions"})]})}),e.jsx(Pn,{children:Cr.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):Cr.map(Se=>e.jsxs(As,{children:[e.jsx(dt,{children:e.jsx(Gi,{checked:f.has(Se.id),onCheckedChange:()=>Fn(Se.id),"aria-label":`Select ${Se.name}`})}),e.jsx(dt,{className:"font-medium",children:Se.name}),e.jsx(dt,{children:Se.email}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Se.claimed?e.jsx(Ye,{variant:"default",children:"Active"}):e.jsx(Ye,{variant:"secondary",children:"Pending"}),ir(Se.id)&&e.jsxs(Ye,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(Lb,{className:"mr-1 h-3 w-3"}),"Manager"]}),N[Se.id]&&e.jsxs(Ye,{variant:"outline",className:"text-xs",children:[e.jsx(cr,{className:"mr-1 h-3 w-3"}),"Asst: ",N[Se.id].name||N[Se.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:()=>{ut(Se),Ct(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(Bd,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>ar(Se),title:"Edit agent",children:e.jsx(pa,{className:"h-4 w-4"})}),!Se.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Xs(Se.id),title:"Resend welcome email",children:e.jsx(tr,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>an(Se),title:"Claim account for agent",disabled:xs===Se.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(Rb,{className:"h-4 w-4"})})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>or(Se),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx(yd,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Nr(Se.email,Se.name),title:"Send password reset email",children:e.jsx(iS,{className:"h-4 w-4"})}),ir(Se.id)&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>bn(Se.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(Ru,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Vs(Se),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},Se.id))})]})})]})]}),e.jsx(fs,{open:S,onOpenChange:C,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Add New Agent"}),e.jsx(Rr,{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(ge,{htmlFor:"name",children:"Name"}),e.jsx(Fe,{id:"name",value:L.name,onChange:Se=>O({...L,name:Se.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"email",children:"Email"}),e.jsx(Fe,{id:"email",type:"email",value:L.email,onChange:Se=>O({...L,email:Se.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Fe,{id:"phone",type:"tel",value:L.phone,onChange:Se=>O({...L,phone:Se.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"password",children:"Temporary Password"}),e.jsx(Fe,{id:"password",type:"password",value:L.password,onChange:Se=>O({...L,password:Se.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(K,{onClick:Bt,disabled:A,children:A?"Creating...":"Create Agent"})]})]})}),e.jsx(fs,{open:U,onOpenChange:q,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Remove Agent"}),e.jsxs(Rr,{children:["Are you sure you want to remove ",e.jsx("strong",{children:$==null?void 0:$.name})," from your brokerage? This will revoke their access to the dashboard."]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Gr,disabled:ee,children:ee?"Removing...":"Remove Agent"})]})]})}),e.jsx(Att,{open:J,onOpenChange:Y,fixedBrokerageId:t,onSuccess:Ar}),e.jsx(fs,{open:ce,onOpenChange:ae,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Add Brokerage Manager"}),e.jsx(Rr,{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(ge,{children:"Select Agent"}),e.jsxs(yo,{open:Ne,onOpenChange:Ve,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Ne,className:"w-full justify-between",children:[ie?((ua=n.find(Se=>Se.id===ie))==null?void 0:ua.name)+" ("+(($t=n.find(Se=>Se.id===ie))==null?void 0:$t.email)+")":"Select an agent to promote...",e.jsx(wx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(uo,{className:"w-full p-0",align:"start",children:e.jsxs(Ax,{children:[e.jsx(Ex,{placeholder:"Search by name or email..."}),e.jsxs(Px,{className:"max-h-[200px]",children:[e.jsx(Ix,{children:"No eligible agents found."}),e.jsx(Lx,{children:n.filter(Se=>!ir(Se.id)).map(Se=>e.jsxs(op,{value:`${Se.name} ${Se.email}`,onSelect:()=>{le(Se.id),Ve(!1)},children:[e.jsx(ea,{className:`mr-2 h-4 w-4 ${ie===Se.id?"opacity-100":"opacity-0"}`}),Se.name," (",Se.email,")"]},Se.id))})]})]})})]}),n.filter(Se=>!ir(Se.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>ae(!1),children:"Cancel"}),e.jsx(K,{onClick:Rn,disabled:fe||!ie,children:fe?"Adding...":"Add as Manager"})]})]})}),e.jsx(fs,{open:Te,onOpenChange:Ae,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Edit Agent"}),e.jsxs(Rr,{children:["Update profile information for ",ze==null?void 0:ze.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"edit-name",children:"Name"}),e.jsx(Fe,{id:"edit-name",value:ve.name,onChange:Se=>Re({...ve,name:Se.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"edit-email",children:"Email"}),e.jsx(Fe,{id:"edit-email",type:"email",value:ve.email,onChange:Se=>Re({...ve,email:Se.target.value}),placeholder:"agent@example.com"}),ve.email.trim().toLowerCase()!==(ze==null?void 0:ze.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(ge,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Fe,{id:"edit-phone",type:"tel",value:ve.phone,onChange:Se=>Re({...ve,phone:Se.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ae(!1),children:"Cancel"}),e.jsx(K,{onClick:Or,disabled:Ue||ct,children:ct?"Updating email...":Ue?"Saving...":"Save Changes"})]})]})}),Ot&&e.jsx(Ett,{open:et,onOpenChange:Se=>{Ct(Se),Se||ut(null)},userId:Ot.id,userName:Ot.name}),e.jsx(fs,{open:Oe,onOpenChange:Xe,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Set Password"}),e.jsxs(Rr,{children:["Set a new password for ",at==null?void 0:at.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(ge,{htmlFor:"new-password",children:"New Password"}),e.jsx(Fe,{id:"new-password",type:"password",value:He,onChange:Se=>gt(Se.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(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Xe(!1),children:"Cancel"}),e.jsx(K,{onClick:hr,disabled:Mt||!He||He.length<6,children:Mt?"Setting...":"Set Password"})]})]})})]})},D_s={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},R_s={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},O_s=t=>{switch(t){case"academy_video":return e.jsx(hn,{className:"h-4 w-4"});case"template":return e.jsx(mn,{className:"h-4 w-4"});case"toolbox":return e.jsx(mn,{className:"h-4 w-4"});case"newsletter":return e.jsx(Jv,{className:"h-4 w-4"});case"social_swag":return e.jsx(qr,{className:"h-4 w-4"});case"event":return e.jsx(nn,{className:"h-4 w-4"});default:return e.jsx(Kr,{className:"h-4 w-4"})}},F_s=({brokerageId:t})=>{const{toast:s}=va(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState([]),[d,u]=k.useState(!0),[p,f]=k.useState(null);k.useEffect(()=>{y()},[t]);const y=async()=>{try{u(!0);const{data:N,error:w}=await G.from("profiles").select("id, name, email").eq("brokerage_id",t);if(w)throw w;const S=N.map(ee=>ee.id),C=new Map(N.map(ee=>[ee.id,ee]));if(S.length===0){n([]),o([]),i([]);return}const{data:A,error:I}=await G.from("activity_logs").select("*").in("user_id",S).order("launched_at",{ascending:!1});if(I)throw I;const L=A.map(ee=>{var Z,J;return{id:ee.id,user_id:ee.user_id,app_name:ee.app_name,launched_at:ee.launched_at,user_name:((Z=C.get(ee.user_id))==null?void 0:Z.name)||"Unknown",user_email:((J=C.get(ee.user_id))==null?void 0:J.email)||"Unknown"}});n(L);const{data:O,error:U}=await G.from("content_engagement_logs").select("*").in("user_id",S).order("created_at",{ascending:!1});if(U)throw U;const q=(O||[]).map(ee=>{var Z,J;return{id:ee.id,user_id:ee.user_id,resource_type:ee.resource_type,resource_id:ee.resource_id,resource_title:ee.resource_title,action_type:ee.action_type,created_at:ee.created_at,user_name:((Z=C.get(ee.user_id))==null?void 0:Z.name)||"Unknown",user_email:((J=C.get(ee.user_id))==null?void 0:J.email)||"Unknown"}});o(q);const $=new Map;N.forEach(ee=>{$.set(ee.id,{user_id:ee.id,user_name:ee.name,user_email:ee.email,app_launches:0,content_views:0,last_activity:""})}),L.forEach(ee=>{const Z=$.get(ee.user_id);Z&&(Z.app_launches++,(!Z.last_activity||new Date(ee.launched_at)>new Date(Z.last_activity))&&(Z.last_activity=ee.launched_at))}),q.forEach(ee=>{const Z=$.get(ee.user_id);Z&&(Z.content_views++,(!Z.last_activity||new Date(ee.created_at)>new Date(Z.last_activity))&&(Z.last_activity=ee.created_at))});const V=Array.from($.values()).filter(ee=>ee.app_launches>0||ee.content_views>0).sort((ee,Z)=>new Date(Z.last_activity).getTime()-new Date(ee.last_activity).getTime());i(V)}catch(N){console.error("Error loading activity:",N),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{u(!1)}},_=N=>r.filter(w=>w.user_id===N),b=N=>a.filter(w=>w.user_id===N);return d?e.jsx(Ie,{children:e.jsx(Be,{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(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Agent Activity"}),e.jsx(mr,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx(Be,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Agent"}),e.jsx(Nt,{className:"text-center",children:"App Launches"}),e.jsx(Nt,{className:"text-center",children:"Content Views"}),e.jsx(Nt,{children:"Last Active"})]})}),e.jsx(Pn,{children:l.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(N=>e.jsxs(As,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f({id:N.user_id,name:N.user_name,email:N.user_email}),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:N.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:N.user_email})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(Co,{className:"h-3 w-3"}),N.app_launches]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),N.content_views]})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:N.last_activity&&jl(new Date(N.last_activity),{addSuffix:!0})})]},N.user_id))})]})})})]}),e.jsx(fs,{open:!!p,onOpenChange:N=>!N&&f(null),children:e.jsxs(ms,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(ks,{children:[e.jsxs(bs,{children:[p==null?void 0:p.name,"'s Activity"]}),e.jsx(Rr,{children:p==null?void 0:p.email})]}),e.jsxs(ta,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(Qn,{className:"grid w-full grid-cols-2",children:[e.jsx(ls,{value:"content",children:"Content Engagement"}),e.jsx(ls,{value:"apps",children:"App Launches"})]}),e.jsx(js,{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(As,{children:[e.jsx(Nt,{children:"Resource"}),e.jsx(Nt,{children:"Type"}),e.jsx(Nt,{children:"Action"}),e.jsx(Nt,{children:"Time"})]})}),e.jsx(Pn,{children:p&&b(p.id).length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):p&&b(p.id).map(N=>e.jsxs(As,{children:[e.jsx(dt,{className:"max-w-[200px] truncate font-medium",children:N.resource_title}),e.jsx(dt,{children:e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[O_s(N.resource_type),D_s[N.resource_type]||N.resource_type]})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:R_s[N.action_type]||N.action_type})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:jl(new Date(N.created_at),{addSuffix:!0})})]},N.id))})]})})}),e.jsx(js,{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(As,{children:[e.jsx(Nt,{children:"App"}),e.jsx(Nt,{children:"Time"})]})}),e.jsx(Pn,{children:p&&_(p.id).length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&_(p.id).map(N=>e.jsxs(As,{children:[e.jsx(dt,{children:e.jsx(Ye,{variant:"outline",children:N.app_name})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:jl(new Date(N.launched_at),{addSuffix:!0})})]},N.id))})]})})})]})]})})]})},z_s=({brokerageId:t})=>{const{toast:s}=va(),[r,n]=k.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=k.useState(!0);k.useEffect(()=>{l()},[t]);const l=async()=>{try{o(!0);const{data:i,error:d}=await G.from("profiles").select("id").eq("brokerage_id",t);if(d)throw d;const u=i.map(L=>L.id),p=u.length;if(u.length===0){o(!1);return}const{data:f,error: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,N=p-b,{count:w}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u),S=new Date;S.setDate(S.getDate()-7);const{count:C}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",S.toISOString()),A=new Date;A.setMonth(A.getMonth()-1);const{count:I}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",A.toISOString());n({totalAgents:p,activeAgents:b,pendingAgents:N,totalLaunches:w||0,launchesThisWeek:C||0,launchesThisMonth:I||0})}catch(i){console.error("Error loading analytics:",i),s({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{o(!1)}};return a?e.jsx(Ie,{children:e.jsx(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(cr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(si,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(ih,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"This Week"}),e.jsx(ih,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"This Month"}),e.jsx(ih,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Be,{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"})]})]})]})},B_s=({brokerageId:t})=>{const[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState({description:"",maxUses:""});k.useEffect(()=>{f()},[t]);const f=async()=>{try{const{data:S,error:C}=await G.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(C)throw C;r(S||[])}catch(S){console.error("Error loading invite codes:",S),me.error("Failed to load invite links")}finally{a(!1)}},y=()=>Math.random().toString(36).substring(2,8).toUpperCase(),_=async()=>{l(!0);try{const S=y(),{error:C}=await G.from("invite_codes").insert({code:S,description:u.description||null,max_uses:u.maxUses?parseInt(u.maxUses):null,brokerage_id:t,is_active:!0});if(C)throw C;me.success("Invite link created!"),d(!1),p({description:"",maxUses:""}),f()}catch(S){console.error("Error creating invite code:",S),me.error("Failed to create invite link")}finally{l(!1)}},b=async S=>{try{const{error:C}=await G.from("invite_codes").delete().eq("id",S);if(C)throw C;me.success("Invite link deleted"),r(s.filter(A=>A.id!==S))}catch(C){console.error("Error deleting invite code:",C),me.error("Failed to delete invite link")}},N=async(S,C)=>{try{const{error:A}=await G.from("invite_codes").update({is_active:!C}).eq("id",S);if(A)throw A;r(s.map(I=>I.id===S?{...I,is_active:!C}:I)),me.success(`Invite link ${C?"deactivated":"activated"}`)}catch(A){console.error("Error toggling invite code:",A),me.error("Failed to update invite link")}},w=S=>{const C=`${window.location.origin}/join?code=${S}`;navigator.clipboard.writeText(C),me.success("Link copied to clipboard!")};return n?e.jsx(Ie,{children:e.jsx(Be,{className:"flex items-center justify-center py-8",children:e.jsx(ps,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(go,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(mr,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(fs,{open:i,onOpenChange:d,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Create Invite Link"}),e.jsx(Rr,{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(ge,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Fe,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:S=>p({...u,description:S.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(Fe,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:S=>p({...u,maxUses:S.target.value})})]}),e.jsx(K,{onClick:_,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),e.jsx(Be,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(go,{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(S=>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:S.code}),e.jsx(Ye,{variant:S.is_active?"default":"secondary",children:S.is_active?"Active":"Inactive"})]}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:S.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[S.uses_count," uses",S.max_uses&&` / ${S.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(S.code),title:"Copy link",children:e.jsx(Ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(S.id,S.is_active),title:S.is_active?"Deactivate":"Activate",children:S.is_active?"Disable":"Enable"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(S.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(yr,{className:"h-4 w-4"})})]})]},S.id))})})]})},$_s=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,d]=k.useState(""),[u,p]=k.useState([]),[f,y]=k.useState(""),[_,b]=k.useState(!1),N=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),w=()=>{const I=i.trim().toLowerCase();if(I&&N(I)&&!u.includes(I)){if(u.length>=10){me.error("Maximum 10 emails per invite");return}p([...u,I]),d("")}else I&&!N(I)?me.error("Please enter a valid email address"):u.includes(I)&&me.error("Email already added")},S=I=>{p(u.filter(L=>L!==I))},C=I=>{(I.key==="Enter"||I.key===",")&&(I.preventDefault(),w())},A=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(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-[550px]",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5 text-primary"}),"Invite Broker Friends"]}),e.jsx(Rr,{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(Vi,{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(ge,{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=>d(I.target.value),onKeyDown:C,onBlur:w}),e.jsx(K,{type:"button",variant:"secondary",onClick:w,children:"Add"})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(I=>e.jsxs(Ye,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[I,e.jsx("button",{type:"button",onClick:()=>S(I),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Sr,{className:"h-3 w-3"})})]},I))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(_r,{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(qr,{className:"h-4 w-4 text-primary"}),"What they'll receive:"]}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Beautiful branded email from you"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Your personal message (if added)"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Key LevelUp features for brokerages"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Direct signup link with your referral code"]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:A,disabled:u.length===0||_,children:_?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent mr-2"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},q_s=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=k.useState([]),[a,o]=k.useState(!0);k.useEffect(()=>{l()},[t,s]);const l=async()=>{try{const{data:d,error:u}=await G.from("referral_invites").select("*").eq("referrer_brokerage_id",t).order("sent_at",{ascending:!1}).limit(20);if(u)throw u;n(d||[])}catch(d){console.error("Error fetching invites:",d)}finally{o(!1)}},i=d=>{switch(d){case"signed_up":return e.jsxs(Ye,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(si,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(Ye,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(Ql,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(rn,{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(tr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No invites sent yet"}),e.jsx("p",{className:"text-xs",children:"Start inviting broker friends to earn rewards!"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Recent Invites"}),r.map(d=>e.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:d.recipient_email}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sent ",gs(new Date(d.sent_at),"MMM d, yyyy")]})]}),i(d.status)]},d.id))]})},U_s=()=>{const{brokerageId:t,user:s}=$s(),[r,n]=k.useState(null),[a,o]=k.useState(""),[l,i]=k.useState(""),[d,u]=k.useState([]),[p,f]=k.useState(!0),[y,_]=k.useState(!1),[b,N]=k.useState(0);k.useEffect(()=>{t&&w()},[t]);const w=async()=>{try{const[O,U]=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})]);O.data&&o(O.data.name),U.data&&i(U.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:$}=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($||[])}catch(O){console.error("Error fetching referral data:",O)}finally{f(!1)}},S=()=>{const O=`https://dashboard.relevelup.com/?ref=${r}`;navigator.clipboard.writeText(O),me.success("Referral link copied to clipboard!")},C=d.filter(O=>O.status==="qualified").length,A=d.filter(O=>O.status==="pending").length,I=C*25,L=Math.max(0,Math.ceil((299-I)/25));return p?null:e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{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(Vi,{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(si,{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(qr,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs(Be,{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(tr,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(K,{onClick:S,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(Ya,{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(_c,{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(cr,{className:"h-5 w-5 mx-auto text-primary mb-1"}),e.jsx("p",{className:"text-2xl font-bold",children:C}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified Referrals"})]}),e.jsxs("div",{className:"text-center p-4 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-900",children:[e.jsx(rn,{className:"h-5 w-5 mx-auto text-amber-600 mb-1"}),e.jsx("p",{className:"text-2xl font-bold text-amber-700 dark:text-amber-400",children:A}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:"Pending (30 days)"})]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4",children:[e.jsx("h4",{className:"font-semibold text-sm mb-3",children:"How It Works"}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"1"}),e.jsx("p",{children:"Share your referral link or send an invite email to broker friends"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"2"}),e.jsx("p",{children:"They sign up and subscribe to LevelUp"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"3"}),e.jsx("p",{children:"After 30 days, you get $25/month off your membership - forever!"})]})]})]}),e.jsx(q_s,{brokerageId:t,refreshTrigger:b}),d.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your Referrals"}),d.slice(0,5).map(O=>{var U,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:((U=O.referred_brokerage)==null?void 0:U.name)||((q=O.referred_user)==null?void 0:q.email)||"Pending setup"}),e.jsxs(Ye,{variant:O.status==="qualified"?"default":O.status==="pending"?"secondary":"destructive",className:O.status==="qualified"?"bg-green-600":"",children:[O.status==="qualified"&&e.jsx(si,{className:"h-3 w-3 mr-1"}),O.status]})]},O.id)})]})]})]}),e.jsx($_s,{open:y,onOpenChange:_,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>N(O=>O+1)})]})},V_s=({brokerageId:t})=>{const s=br(),{teams:r,isLoading:n}=TC(t),{data:a,isLoading:o}=ft({queryKey:["team-aggregate-stats",t,r.map(p=>p.id)],queryFn:async()=>{if(r.length===0)return[];const p=r.map(O=>O.id),{data:f}=await G.from("team_members").select("team_id, user_id, role").in("team_id",p);if(!f||f.length===0)return r.map(O=>({team_id:O.id,team_name:O.name,member_count:0,leader_name:null,leader_avatar:null,total_contacts:0,total_deals:0,total_videos:0}));const y=f.map(O=>O.user_id),_=f.filter(O=>O.role==="team_leader").map(O=>O.user_id),{data:b}=await G.from("profiles").select("id, name, avatar_url").in("id",_),N=new Map((b||[]).map(O=>[O.id,O])),{data:w}=await G.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",y),{data:S}=await G.from("deal_pipeline").select("owner_user_id").in("owner_user_id",y),{data:C}=await G.from("agent_videos").select("owner_user_id").in("owner_user_id",y).eq("is_deleted",!1),A=new Map;(w||[]).forEach(O=>{A.set(O.owner_user_id,(A.get(O.owner_user_id)||0)+1)});const I=new Map;(S||[]).forEach(O=>{I.set(O.owner_user_id,(I.get(O.owner_user_id)||0)+1)});const L=new Map;return(C||[]).forEach(O=>{L.set(O.owner_user_id,(L.get(O.owner_user_id)||0)+1)}),r.map(O=>{const U=f.filter(Y=>Y.team_id===O.id),q=U.find(Y=>Y.role==="team_leader"),$=q?N.get(q.user_id):null,V=U.map(Y=>Y.user_id),ee=V.reduce((Y,ce)=>Y+(A.get(ce)||0),0),Z=V.reduce((Y,ce)=>Y+(I.get(ce)||0),0),J=V.reduce((Y,ce)=>Y+(L.get(ce)||0),0);return{team_id:O.id,team_name:O.name,member_count:U.length,leader_name:($==null?void 0:$.name)||null,leader_avatar:($==null?void 0:$.avatar_url)||null,total_contacts:ee,total_deals:Z,total_videos:J}})},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(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ss,{className:"h-5 w-32"})}),e.jsx(Be,{children:e.jsx(Ss,{className:"h-24 w-full"})})]},p))});if(r.length===0)return e.jsx(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(cr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create teams to organize your agents and track their performance."}),e.jsx(K,{onClick:()=>s("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((p,f)=>p+f.member_count,0),d=(a||[]).reduce((p,f)=>p+f.total_contacts,0),u=(a||[]).reduce((p,f)=>p+f.total_deals,0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 grid-cols-2 md:grid-cols-4",children:[e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(cr,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(cr,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(eS,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:d.toLocaleString()})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Lh,{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(Ie,{className:"hover:shadow-md transition-shadow",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ft,{className:"text-lg",children:p.team_name}),e.jsxs(Ye,{variant:"secondary",children:[p.member_count," members"]})]}),p.leader_name&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(vn,{className:"h-6 w-6",children:[e.jsx(Ca,{src:p.leader_avatar||""}),e.jsx(_n,{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(km,{className:"h-3 w-3 text-amber-500"}),p.leader_name]})]})]}),e.jsx(Be,{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 →"})})]})},H_s=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=$s(),i=br(),{toast:d}=va(),[u,p]=k.useState(""),[f,y]=k.useState(!0),_=o||(a.length>0?a[0].id:r);k.useEffect(()=>{if(!t||!s&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),_?b():a.length===0&&!r&&y(!1)},[t,s,n,_,i,a,o]);const b=async()=>{if(!_){y(!1);return}try{const{data:N,error:w}=await G.from("brokerages").select("name").eq("id",_).single();if(w)throw w;p(N.name)}catch(N){console.error("Error loading brokerage info:",N),d({title:"Error",description:"Failed to load brokerage information",variant:"destructive"})}finally{y(!1)}};return f?e.jsx(Ls,{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(Ls,{title:u||"Manage Brokerages",description:"Brokerage Management Dashboard",children:e.jsxs("div",{className:"space-y-6",children:[a.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Managing:"}),e.jsxs(zs,{value:o||"",onValueChange:l,children:[e.jsxs(Os,{className:"w-[280px]",children:[e.jsx(ma,{className:"mr-2 h-4 w-4"}),e.jsx(qs,{placeholder:"Select brokerage"})]}),e.jsx(Fs,{children:a.map(N=>e.jsx(yt,{value:N.id,children:N.name},N.id))})]})]}),e.jsxs(ta,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(Qn,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(ls,{value:"agents",children:"Agents"}),e.jsx(ls,{value:"teams",children:"Teams"}),e.jsx(ls,{value:"invite",children:"Invite Links"}),e.jsx(ls,{value:"referrals",children:"Referrals"}),e.jsx(ls,{value:"leaderboard",children:"Leaderboard"}),e.jsx(ls,{value:"activity",children:"Activity"}),e.jsx(ls,{value:"analytics",children:"Analytics"}),e.jsx(ls,{value:"shares",children:"Shares"})]}),e.jsx(js,{value:"agents",className:"space-y-4",children:e.jsx(L_s,{brokerageId:_})}),e.jsx(js,{value:"teams",className:"space-y-4",children:e.jsx(V_s,{brokerageId:_})}),e.jsx(js,{value:"invite",className:"space-y-4",children:e.jsx(B_s,{brokerageId:_})}),e.jsx(js,{value:"referrals",className:"space-y-4",children:e.jsx(U_s,{})}),e.jsx(js,{value:"leaderboard",className:"space-y-4",children:e.jsx(Zet,{brokerageId:_,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(js,{value:"activity",className:"space-y-4",children:e.jsx(F_s,{brokerageId:_})}),e.jsx(js,{value:"analytics",className:"space-y-4",children:e.jsx(z_s,{brokerageId:_})}),e.jsx(js,{value:"shares",className:"space-y-4",children:e.jsx(ist,{brokerageOnly:!0,brokerageId:_})})]})]})}):e.jsx(Ls,{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(ma,{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 G_s({brokerageId:t,canManage:s}){const{user:r}=$s(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,d]=k.useState(!1),[u,p]=k.useState(null),[f,y]=k.useState(null),[_,b]=k.useState(!1),[N,w]=k.useState(""),[S,C]=k.useState(""),[A,I]=k.useState(!1),L=async()=>{try{const{data:V,error:ee}=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(ee)throw ee;const Z=V;if(Z&&Z.length>0){const J=[...new Set(Z.map(ie=>ie.created_by))],{data:Y}=await G.from("profiles").select("id, name, avatar_url").in("id",J),ce=new Map((Y==null?void 0:Y.map(ie=>[ie.id,ie]))||[]),ae=Z.map(ie=>({...ie,author:ce.get(ie.created_by)||{name:"Unknown",avatar_url:null}}));a(ae)}else a([])}catch(V){console.error("Error fetching announcements:",V)}finally{l(!1)}};k.useEffect(()=>{L()},[t]);const O=()=>{w(""),C(""),I(!1),p(null)},U=V=>{V?(p(V),w(V.title),C(V.content),I(V.is_pinned)):O(),d(!0)},q=async()=>{if(!N.trim()||!S.trim()){me.error("Please fill in all fields");return}b(!0);try{if(u){const{error:V}=await G.from("brokerage_announcements").update({title:N.trim(),content:S.trim(),is_pinned:A,pinned_at:A?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:N.trim(),content:S.trim(),is_pinned:A,pinned_at:A?new Date().toISOString():null});if(V)throw V;me.success("Announcement created")}d(!1),O(),L()}catch(V){console.error("Error saving announcement:",V),me.error("Failed to save announcement")}finally{b(!1)}},$=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(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(dh,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(dh,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(K,{size:"sm",onClick:()=>U(),className:"gap-1",children:[e.jsx(Bs,{className:"h-4 w-4"}),"New"]})]}),e.jsx(Be,{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 ee,Z,J,Y;return e.jsx("div",{className:`p-4 rounded-lg border ${V.is_pinned?"bg-primary/5 border-primary/20":"bg-muted/30"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[V.is_pinned&&e.jsx(Ib,{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(vn,{className:"h-5 w-5",children:[e.jsx(Ca,{src:((ee=V.author)==null?void 0:ee.avatar_url)||void 0}),e.jsx(_n,{className:"text-[10px]",children:((J=(Z=V.author)==null?void 0:Z.name)==null?void 0:J.charAt(0))||"?"})]}),e.jsx("span",{children:(Y=V.author)==null?void 0:Y.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:gs(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:()=>U(V),children:e.jsx(pa,{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(yr,{className:"h-4 w-4"})})]})]})},V.id)})})})]}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:u?"Edit Announcement":"New Announcement"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"title",children:"Title"}),e.jsx(Fe,{id:"title",value:N,onChange:V=>w(V.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"content",children:"Content"}),e.jsx(_r,{id:"content",value:S,onChange:V=>C(V.target.value),placeholder:"Write your announcement...",rows:4})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{id:"pinned",checked:A,onCheckedChange:I}),e.jsxs(ge,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(Ib,{className:"h-4 w-4"}),"Pin to top"]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:q,disabled:_,children:_?"Saving...":u?"Update":"Create"})]})]})]})}),e.jsx(Ll,{open:!!f,onOpenChange:()=>y(null),children:e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Delete Announcement"}),e.jsx(vl,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:$,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function W_s({brokerageId:t,canManage:s=!1}){const{startImpersonation:r,isLoading:n}=fue(),{user:a}=$s(),[o,l]=k.useState([]),[i,d]=k.useState(!0),[u,p]=k.useState(""),[f,y]=k.useState(new Set);k.useEffect(()=>{(async()=>{try{const{data:N,error:w}=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(w)throw w;if(l(N||[]),N&&N.length>0){const S=N.map(A=>A.id),{data:C}=await G.from("agent_assistant_assignments").select("agent_id").in("agent_id",S);C&&y(new Set(C.map(A=>A.agent_id)))}}catch(N){console.error("Error fetching agents:",N)}finally{d(!1)}})()},[t]);const _=o.filter(b=>{var N,w;return b.name.toLowerCase().includes(u.toLowerCase())||b.email.toLowerCase().includes(u.toLowerCase())||((N=b.title)==null?void 0:N.toLowerCase().includes(u.toLowerCase()))||((w=b.areas_served)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))});return i?e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(Be,{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(b=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-48 bg-muted rounded-lg"})},b))})})]}):e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5 text-primary"}),"Agent Roster",e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",o.length,")"]})]}),e.jsxs("div",{className:"relative w-full sm:w-64",children:[e.jsx(tn,{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:u,onChange:b=>p(b.target.value),className:"pl-9"})]})]}),e.jsx(Be,{children:_.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:u?"No agents match your search":"No agents in this brokerage yet"}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:_.map(b=>e.jsx(K_s,{agent:b,hasAssistant:f.has(b.id),canImpersonate:s&&b.id!==(a==null?void 0:a.id),onImpersonate:()=>r(b.id,"/my-brokerage"),impersonationLoading:n},b.id))})})]})}function K_s({agent:t,hasAssistant:s,canImpersonate:r,onImpersonate:n,impersonationLoading:a}){const o=t.name.split(" ").map(l=>l[0]).join("").toUpperCase().slice(0,2);return e.jsxs("div",{className:"group relative bg-card border rounded-xl p-4 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex flex-col items-center text-center mb-3",children:[e.jsxs(vn,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[e.jsx(Ca,{src:t.avatar_url||void 0,alt:t.name}),e.jsx(_n,{className:"text-lg bg-primary/10 text-primary",children:o})]}),e.jsx("h3",{className:"font-semibold text-sm leading-tight",children:t.name}),t.title&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t.title}),s&&e.jsx(Ye,{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(La,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.areas_served})]}),t.years_experience&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:[t.years_experience," ",t.years_experience===1?"year":"years"," experience"]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r&&e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:n,disabled:a,children:e.jsx(dS,{className:"h-4 w-4"})})}),e.jsxs(Il,{children:["Login as ",t.name]})]}),t.phone&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`tel:${t.phone}`,title:`Call ${t.name}`,children:e.jsx(Tn,{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(tr,{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(fp,{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(hu,{className:"h-4 w-4"})})})]})]})}function Z_s({brokerageId:t}){const[s,r]=k.useState([]),[n,a]=k.useState(!0);if(k.useEffect(()=>{(async()=>{try{const{data:d,error:u}=await G.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!d||d.length===0){r([]),a(!1);return}const p=d.map(N=>N.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(d.map(N=>[N.id,N])),b=(f||[]).filter(N=>N.total_points>0).map(N=>{const w=_.get(N.user_id);return{user_id:N.user_id,total_points:N.total_points,name:(w==null?void 0:w.name)||"Unknown",avatar_url:(w==null?void 0:w.avatar_url)||null}});r(b)}catch(d){console.error("Error fetching leaderboard:",d)}finally{a(!1)}})()},[t]),n)return e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Hi,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx(Be,{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(Qv,{className:Rt("h-5 w-5",o(i))}):e.jsx("span",{className:"w-5 text-center text-sm text-muted-foreground",children:i});return e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Hi,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx(Be,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No points earned yet. Attend events to earn points!"}):e.jsx("div",{className:"space-y-2",children:s.slice(0,10).map((i,d)=>{const u=i.name.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2),p=d+1;return e.jsxs("div",{className:Rt("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(vn,{className:"h-8 w-8",children:[e.jsx(Ca,{src:i.avatar_url||void 0}),e.jsx(_n,{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 Y_s({brokerageId:t}){const s=br(),[r,n]=k.useState([]),[a,o]=k.useState(!0);k.useEffect(()=>{(async()=>{try{const{data:d,error:u}=await G.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!d||d.length===0){n([]),o(!1);return}const p=d.map(N=>N.id),f=new Map(d.map(N=>[N.id,N])),{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(N=>({id:N.id,slug:N.slug,property_address:N.property_address,city:N.city,price:N.price,property_type:N.property_type,agent_id:N.agent_id,agent:f.get(N.agent_id)||null,photos:N.listing_photos||[]}));n(b)}catch(d){console.error("Error fetching listings:",d)}finally{o(!1)}})()},[t]);const l=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(i);return a?e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Mn,{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(Bs,{className:"h-4 w-4"}),"Add Listing"]})]}),e.jsxs(Be,{children:[r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Mn,{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(Bs,{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(Mn,{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(Kr,{className:"h-3 w-3 ml-1"})]})]})]})}function X_s(){const{user:t,isAdmin:s,isBrokerageManager:r}=$s(),n=br(),[a,o]=k.useState(!0),[l,i]=k.useState(null),[d,u]=k.useState(""),[p,f]=k.useState(0),[y,_]=k.useState(!1),[b,N]=k.useState(!1);return k.useEffect(()=>{(async()=>{if(t)try{const{data:S}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(S!=null&&S.brokerage_id)){o(!1);return}i(S.brokerage_id);const{data:C}=await G.from("brokerages").select("name").eq("id",S.brokerage_id).maybeSingle();C&&u(C.name);const{count:A}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",S.brokerage_id);if(f(A||0),s)_(!0),N(!0);else if(r){const{data:I}=await G.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",S.brokerage_id).maybeSingle();_(!!I),N(!!I)}}catch(S){console.error("Error fetching brokerage info:",S)}finally{o(!1)}})()},[t,s,r]),a?e.jsx(Ls,{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(Ls,{title:d||"My Brokerage",description:"Team Hub",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-lg px-4 py-2",children:[e.jsx(cr,{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(oh,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(K,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(Mn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(G_s,{brokerageId:l,canManage:y}),e.jsx(W_s,{brokerageId:l,canManage:y}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(Z_s,{brokerageId:l}),e.jsx(Y_s,{brokerageId:l})]})]})}):e.jsx(Ls,{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(ma,{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 Q_s(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 J_s(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 $7e={video:{icon:Co,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:mn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:Do,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:nn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Rl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function ebs({item:t,canManage:s}){const[r,n]=k.useState(!1),[a,o]=k.useState(null),l=Z8t(),i=br(),d=$7e[t.content_type]||$7e.link,u=d.icon,p=k.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?Q_s(t.url):null,[t]);k.useEffect(()=>{p||!t.url||t.content_type!=="video"||!J_s(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(Ie,{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(Be,{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(Ye,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${d.color}`,children:[e.jsx(u,{className:"h-3 w-3 mr-1"}),d.label]}),t.category&&e.jsxs(Ye,{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:["📅 ",gs(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",gs(new Date(t.created_at),"MMM d, yyyy")]})]}),s&&e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,onClick:b=>b.stopPropagation(),children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(cx,{className:"h-4 w-4"})})}),e.jsx(jd,{align:"end",children:e.jsxs(xa,{onClick:b=>{b.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(yr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(Ll,{open:r,onOpenChange:n,children:e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Delete Content"}),e.jsxs(vl,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:_,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function tbs(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 q7e=[{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 sbs({brokerageId:t,categories:s}){var we;const{user:r}=$s(),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,d]=k.useState(""),[u,p]=k.useState("📁"),[f,y]=k.useState(!1);k.useRef(null);const[_,b]=k.useState("video"),[N,w]=k.useState(""),[S,C]=k.useState(""),[A,I]=k.useState(""),[L,O]=k.useState(""),[U,q]=k.useState(""),[$,V]=k.useState(""),[ee,Z]=k.useState(""),J=K8t(),Y=Y8t(t),ce=X8t(),ae=Q8t(t),ie=()=>{b("video"),w(""),C(""),I(""),O(""),q(""),V(""),Z("")},le=async(Ne,Ve)=>{var Ae;const Te=(Ae=Ne.target.files)==null?void 0:Ae[0];if(Te){y(!0);try{const ze=Te.name.split(".").pop(),Ee=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${ze}`,{error:ve}=await G.storage.from("brokerage-content").upload(Ee,Te);if(ve)throw ve;const{data:{publicUrl:Re}}=G.storage.from("brokerage-content").getPublicUrl(Ee);Ve==="file"?(O(Re),_==="graphic"&&!U&&q(Re)):q(Re),me.success("File uploaded")}catch(ze){me.error(ze.message||"Upload failed")}finally{y(!1)}}},fe=async()=>{if(!N.trim()){me.error("Title is required");return}if(r)try{await J.mutateAsync({brokerage_id:t,category_id:ee||null,content_type:_,title:N.trim(),description:S.trim()||null,url:A.trim()||null,file_url:L.trim()||null,thumbnail_url:U.trim()||null,event_date:$?new Date($).toISOString():null,created_by:r.id}),me.success("Content added!"),ie(),a(!1)}catch(Ne){me.error(Ne.message||"Failed to add content")}},xe=async()=>{if(i.trim())try{await Y.mutateAsync({name:i.trim(),icon:u,sort_order:s.length}),d(""),p("📁"),me.success("Category created")}catch(Ne){me.error(Ne.message||"Failed to create category")}},he=async()=>{try{await ae.mutateAsync(),me.success("Default categories created")}catch{me.error("Failed to create defaults")}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(fs,{open:n,onOpenChange:a,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Content"]})}),e.jsxs(ms,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Add Brokerage Content"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Content Type"}),e.jsxs(zs,{value:_,onValueChange:b,children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:q7e.map(Ne=>e.jsx(yt,{value:Ne.value,children:Ne.label},Ne.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(we=q7e.find(Ne=>Ne.value===_))==null?void 0:we.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Category"}),e.jsxs(zs,{value:ee,onValueChange:Z,children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select category (optional)"})}),e.jsx(Fs,{children:s.map(Ne=>e.jsxs(yt,{value:Ne.id,children:[Ne.icon," ",Ne.name]},Ne.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Title *"}),e.jsx(Fe,{value:N,onChange:Ne=>w(Ne.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Description"}),e.jsx(_r,{value:S,onChange:Ne=>C(Ne.target.value),placeholder:"Brief description...",rows:2})]}),["video","link","graphic","event"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:_==="video"?"Video URL":_==="graphic"?"Canva / Image URL":_==="event"?"Event Link (Zoom, etc.)":"URL"}),e.jsx(Fe,{value:A,onChange:Ne=>{const Ve=Ne.target.value;if(I(Ve),_==="video"&&!U){const Te=tbs(Ve);Te&&q(Te)}},placeholder:"https://..."})]}),["pdf","graphic"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{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:Ne=>le(Ne,"file"),disabled:f}),f&&e.jsx(ps,{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(ge,{children:"Thumbnail Image (optional)"}),e.jsx(Fe,{type:"file",accept:"image/*",onChange:Ne=>le(Ne,"thumbnail"),disabled:f}),U&&e.jsxs("div",{className:"relative w-20 h-20 rounded overflow-hidden",children:[e.jsx("img",{src:U,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(Sr,{className:"h-3 w-3"})})]})]}),_==="event"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Event Date & Time"}),e.jsx(Fe,{type:"datetime-local",value:$,onChange:Ne=>V(Ne.target.value)})]}),e.jsxs(K,{onClick:fe,disabled:J.isPending||!N.trim(),className:"w-full",children:[J.isPending?e.jsx(ps,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Content"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",children:[e.jsx(So,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(ms,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Manage Categories"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[s.length===0&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No categories yet"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:he,disabled:ae.isPending,children:[ae.isPending?e.jsx(ps,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Default Categories"]})]}),s.map(Ne=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border",children:[e.jsxs("span",{className:"text-sm",children:[Ne.icon," ",Ne.name]}),!Ne.is_default&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await ce.mutateAsync(Ne.id),me.success("Category deleted")},children:e.jsx(Sr,{className:"h-4 w-4"})})]},Ne.id)),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[e.jsx(Fe,{value:u,onChange:Ne=>p(Ne.target.value),className:"w-14 text-center",maxLength:2}),e.jsx(Fe,{value:i,onChange:Ne=>d(Ne.target.value),placeholder:"New category name",className:"flex-1",onKeyDown:Ne=>Ne.key==="Enter"&&xe()}),e.jsx(K,{size:"sm",onClick:xe,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function rbs(){const{user:t,isAdmin:s,isBrokerageManager:r}=$s(),[n,a]=k.useState(!0),[o,l]=k.useState(null),[i,d]=k.useState(""),[u,p]=k.useState(!1),[f,y]=k.useState(null),[_,b]=k.useState("");k.useEffect(()=>{(async()=>{if(t)try{const{data:I}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(I!=null&&I.brokerage_id)){a(!1);return}l(I.brokerage_id);const{data:L}=await G.from("brokerages").select("name").eq("id",I.brokerage_id).maybeSingle();if(L&&d(L.name),s)p(!0);else if(r){const{data:O}=await G.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",I.brokerage_id).maybeSingle();p(!!O)}}catch(I){console.error("Error fetching brokerage info:",I)}finally{a(!1)}})()},[t,s,r]);const{data:N=[]}=H8t(o),{data:w=[],isLoading:S}=G8t(o,f),C=k.useMemo(()=>{if(!_.trim())return w;const A=_.toLowerCase();return w.filter(I=>{var L;return I.title.toLowerCase().includes(A)||((L=I.description)==null?void 0:L.toLowerCase().includes(A))||I.content_type.toLowerCase().includes(A)})},[w,_]);return n?e.jsx(Ls,{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(Ls,{title:`${i} Content`,description:"Brokerage Content Hub",children:e.jsxs("div",{className:"space-y-6",children:[u&&o&&e.jsx(sbs,{brokerageId:o,categories:N}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(tn,{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:A=>b(A.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{variant:f===null?"default":"outline",size:"sm",onClick:()=>y(null),children:"All"}),N.map(A=>e.jsxs(K,{variant:f===A.id?"default":"outline",size:"sm",onClick:()=>y(A.id),children:[e.jsx("span",{className:"mr-1",children:A.icon}),A.name]},A.id))]})]}),S?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):C.length===0?e.jsx(Ie,{className:"bg-muted/30 border-dashed",children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Sm,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:_.trim()?"No matching content found":"No content yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:_.trim()?"Try a different search term or category.":u?"Add your first piece of content above.":"Your brokerage hasn't added content yet."})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:C.map(A=>e.jsx(ebs,{item:A,canManage:u},A.id))})]})}):e.jsx(Ls,{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(ma,{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 U7e={video:{icon:Co,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:mn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:Do,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:nn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Rl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function nbs(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 abs(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function ibs(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function obs(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function lbs(){const{contentId:t}=ho(),{data:s,isLoading:r}=ft({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(Ls,{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(Ls,{title:"Brokerage Content",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ma,{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(da,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=U7e[s.content_type]||U7e.link,a=n.icon,o=s.url||s.file_url,l=o&&abs(o)?nbs(o):null,i=o&&ibs(o)?obs(o):null,d=l||i;return e.jsx(Ls,{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(da,{to:"/brokerage-content",children:[e.jsx(Ra,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ye,{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(Ye,{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 ",gs(new Date(s.created_at),"MMMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),d&&e.jsx(Ie,{className:"overflow-hidden",children:e.jsx("div",{className:"relative w-full bg-black",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:d,className:"absolute top-0 left-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:s.title})})}),s.content_type==="graphic"&&s.file_url&&!d&&e.jsx(Ie,{className:"overflow-hidden",children:e.jsx("img",{src:s.file_url,alt:s.title,className:"w-full max-h-[600px] object-contain bg-muted"})}),!d&&s.content_type!=="graphic"&&s.thumbnail_url&&e.jsx(Ie,{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(Ie,{children:e.jsx(Be,{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(Ie,{children:e.jsxs(Be,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(nn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Event Date"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:gs(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(Xa,{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(Kr,{className:"h-4 w-4 mr-2"}),d?"Open on YouTube":s.content_type==="event"?"Join Event":s.content_type==="graphic"?"Open in Canva":"Open Link"]})})]})]})})}function cbs(){const t=br(),[s,r]=k.useState(""),[n,a]=k.useState("grid"),{data:o,isLoading:l}=ft({queryKey:["newsletters"],queryFn:async()=>{const{data:A,error:I}=await G.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(I)throw I;return A}}),{data:i}=ft({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:A}=await G.from("newsletter_likes").select("newsletter_id");return A||[]}}),{data:d}=ft({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:A}=await G.from("newsletter_comments").select("newsletter_id");return A||[]}}),{data:u}=ft({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[A,I,L,O]=await Promise.all([G.from("newsletter_canva_links").select("newsletter_id"),G.from("newsletter_pdfs").select("newsletter_id"),G.from("newsletter_videos").select("newsletter_id"),G.from("newsletter_drive_links").select("newsletter_id")]);return{canva:A.data||[],pdfs:I.data||[],videos:L.data||[],drives:O.data||[]}}}),p=A=>(i==null?void 0:i.filter(I=>I.newsletter_id===A).length)||0,f=A=>(d==null?void 0:d.filter(I=>I.newsletter_id===A).length)||0,y=A=>{var I;return((I=u==null?void 0:u.canva)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},_=A=>{var I;return((I=u==null?void 0:u.pdfs)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},b=A=>{var I;return((I=u==null?void 0:u.videos)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},N=A=>{var I;return((I=u==null?void 0:u.drives)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},w=A=>y(A)+_(A)+b(A)+N(A),S=o==null?void 0:o.filter(A=>{var I;return A.title.toLowerCase().includes(s.toLowerCase())||((I=A.description)==null?void 0:I.toLowerCase().includes(s.toLowerCase()))}),C=A=>{t(`/newsletters/${A}`)};return e.jsx(Ls,{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(tn,{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:A=>r(A.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(pp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Rh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[(S==null?void 0:S.length)||0," item",(S==null?void 0:S.length)!==1?"s":""," found"]}),l&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((A,I)=>e.jsx(Ie,{children:e.jsxs(Be,{className:"p-0",children:[e.jsx(Ss,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(Ss,{className:"h-5 w-3/4"}),e.jsx(Ss,{className:"h-4 w-full"})]})]})},I))}),!l&&(S==null?void 0:S.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(mn,{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&&S&&S.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:S.map(A=>{const I=w(A.id),L=y(A.id),O=_(A.id),U=b(A.id);return n==="grid"?e.jsxs(Ie,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(A.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:A.preview_image_url?e.jsx("img",{src:A.preview_image_url,alt:A.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(mn,{className:"h-16 w-16"})})}),e.jsxs(Be,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:A.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[e.jsx(nn,{className:"h-3 w-3"}),gs(new Date(A.publish_date),"MMM d, yyyy")]})]}),A.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:A.description.replace(/<[^>]*>/g,"")}),I>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[L>0&&e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Rl,{className:"h-3 w-3"})," ",L," Template",L>1?"s":""]}),O>0&&e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Xa,{className:"h-3 w-3"})," ",O," PDF",O>1?"s":""]}),U>0&&e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Co,{className:"h-3 w-3"})," ",U," Video",U>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(Ou,{className:"h-3 w-3"})," ",p(A.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(bc,{className:"h-3 w-3"})," ",f(A.id)]})]})]})]},A.id):e.jsx(Ie,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(A.id),children:e.jsxs("div",{className:"flex flex-row",children:[e.jsx("div",{className:"relative overflow-hidden bg-muted w-40 sm:w-48 shrink-0",children:A.preview_image_url?e.jsx("img",{src:A.preview_image_url,alt:A.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground min-h-[100px]",children:e.jsx(mn,{className:"h-10 w-10"})})}),e.jsxs(Be,{className:"p-4 flex-1 flex flex-col justify-center gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:A.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:[e.jsx(nn,{className:"h-3 w-3"}),gs(new Date(A.publish_date),"MMM d, yyyy")]})]}),A.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:A.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[I>0&&e.jsxs("span",{children:[I," resource",I>1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ou,{className:"h-3 w-3"})," ",p(A.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(bc,{className:"h-3 w-3"})," ",f(A.id)]})]})]})]})},A.id)})})]})})}function dbs({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(Ie,{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(Be,{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 ubs(){const{id:t}=ho(),s=br(),{user:r}=$s(),{toast:n}=va(),a=es(),{trackEngagement:o}=JA(),[l,i]=k.useState(""),{data:d,isLoading:u}=ft({queryKey:["newsletter",t],queryFn:async()=>{const{data:L,error:O}=await G.from("newsletter_content").select("*").eq("id",t).single();if(O)throw O;return L},enabled:!!t});k.useEffect(()=>{d&&o("newsletter",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p}=ft({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}=ft({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}=ft({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:_}=ft({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}=ft({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_likes").select("*").eq("newsletter_id",t);return L||[]},enabled:!!t}),{data:N}=ft({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return L||[]},enabled:!!t}),w=b==null?void 0:b.some(L=>L.user_id===(r==null?void 0:r.id)),S=Et({mutationFn:async()=>{w?await G.from("newsletter_likes").delete().eq("newsletter_id",t).eq("user_id",r==null?void 0:r.id):await G.from("newsletter_likes").insert({newsletter_id:t,user_id:r==null?void 0:r.id})},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-likes",t]})}}),C=Et({mutationFn:async L=>{const{error:O}=await G.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:L});if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),A=Et({mutationFn:async L=>{const{error:O}=await G.from("newsletter_comments").delete().eq("id",L);if(O)throw O},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 O=L.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(O)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://iframe.mediadelivery.net/embed/${O[1]}/${O[2]}?autoplay=false`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}if(L.includes("youtube.com")||L.includes("youtu.be")){const O=L.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([^&\s]+)/);if(O)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${O[1]}`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}return e.jsxs("a",{href:L,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(Co,{className:"h-4 w-4"})," Watch Video"]})};return u?e.jsx(Ls,{title:"",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ss,{className:"h-8 w-32"}),e.jsx(Ss,{className:"h-64 w-full"}),e.jsx(Ss,{className:"h-32 w-full"})]})}):d?e.jsx(Ls,{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(Ra,{className:"mr-2 h-4 w-4"})," Back to Newsletters"]}),d.preview_image_url&&e.jsx("img",{src:d.preview_image_url,alt:d.title,className:"w-full h-64 md:h-80 object-cover rounded-lg"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:d.title}),e.jsx("p",{className:"text-muted-foreground mt-1",children:gs(new Date(d.publish_date),"MMMM d, yyyy")})]}),d.description&&e.jsx("div",{className:"text-lg text-muted-foreground prose prose-sm max-w-none dark:prose-invert [&_p]:mb-4 [&_p:last-child]:mb-0 whitespace-pre-line",dangerouslySetInnerHTML:{__html:d.description}}),e.jsx(dbs,{rows:d.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(rE,{resourceType:"newsletter",resourceId:d.id,resourceTitle:d.title}),e.jsxs(K,{variant:w?"default":"outline",size:"sm",onClick:()=>S.mutate(),children:[e.jsx(Za,{className:`h-4 w-4 mr-1 ${w?"fill-current":""}`}),(b==null?void 0:b.length)||0," ",(b==null?void 0:b.length)===1?"Like":"Likes"]})]}),_&&_.length>0&&e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Canva Templates"})}),e.jsx(Be,{className:"space-y-2",children:_.map(L=>e.jsxs("a",{href:L.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",d.id,d.title,"click_canva"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(Rl,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(Kr,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},L.id))})]}),p&&p.length>0&&e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(Be,{className:"space-y-2",children:p.map(L=>e.jsxs("a",{href:L.drive_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",d.id,d.title,"click_link"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(Kr,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:L.title})]},L.id))})]}),f&&f.length>0&&e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(Be,{className:"space-y-2",children:f.map(L=>e.jsxs("a",{href:L.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",d.id,d.title,"click_pdf"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(mn,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:L.name}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]}),y&&y.length>0&&e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Videos"})}),e.jsx(Be,{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(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"text-lg",children:["Comments (",(N==null?void 0:N.length)||0,")"]})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(_r,{placeholder:"Write a comment...",value:l,onChange:L=>i(L.target.value),className:"flex-1"}),e.jsx(K,{onClick:()=>l.trim()&&C.mutate(l),disabled:!l.trim()||C.isPending,children:e.jsx(Nn,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:N==null?void 0:N.map(L=>{var O,U,q;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(vn,{className:"h-8 w-8",children:e.jsx(_n,{children:((U=(O=L.profiles)==null?void 0:O.name)==null?void 0:U[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:gs(new Date(L.created_at),"MMM d, yyyy")}),L.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>A.mutate(L.id),children:e.jsx(yr,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:L.content})]})]},L.id)})})]})]})]})}):e.jsx(Ls,{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 hbs({rows:t,onChange:s}){const[r,n]=k.useState(null),a=()=>{s([...t,{columns:[{title:"",description:""},{title:"",description:""},{title:"",description:""}]}])},o=u=>{s(t.filter((p,f)=>f!==u))},l=(u,p,f,y)=>{const _=[...t];_[u]={..._[u],columns:_[u].columns.map((b,N)=>N===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 N=`content-blocks/${Date.now()}-${y.name}`,{error:w}=await G.storage.from("newsletter-content").upload(N,y);if(!w){const{data:S}=G.storage.from("newsletter-content").getPublicUrl(N);l(u,p,"image_url",S.publicUrl)}}finally{n(null)}},d=(u,p)=>{l(u,p,"image_url","")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{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(Bs,{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(Ie,{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(Sr,{className:"h-4 w-4"})}),e.jsxs(Be,{className:"p-4 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(uu,{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:()=>d(p,y),children:e.jsx(Sr,{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(Uo,{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(_r,{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 mbs(){const{toast:t}=va(),s=es(),[r,n]=k.useState(!1),[a,o]=k.useState(null),[l,i]=k.useState({title:"",description:"",publish_date:gs(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[d,u]=k.useState(null),[p,f]=k.useState(null),[y,_]=k.useState([]),[b,N]=k.useState([]),[w,S]=k.useState([]),[C,A]=k.useState([]),[I,L]=k.useState([]),[O,U]=k.useState([]),[q,$]=k.useState(!1),{data:V,isLoading:ee}=ft({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:Te,error:Ae}=await G.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Ae)throw Ae;return Te}}),Z=Et({mutationFn:async Te=>{const{data:Ae,error:ze}=await G.from("newsletter_content").insert({title:Te.title,description:Te.description||null,preview_image_url:Te.preview_image_url,publish_date:Te.publish_date,is_published:Te.is_published,content_blocks:Te.content_blocks}).select().single();if(ze)throw ze;return Ae},onSuccess:async Te=>{await ce(Te.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),Te.is_published&&GHt(Te.title,Te.id),le()},onError:Te=>{t({title:"Error creating newsletter",description:Te.message,variant:"destructive"})}}),J=Et({mutationFn:async Te=>{const{error:Ae}=await G.from("newsletter_content").update({title:Te.title,description:Te.description||null,preview_image_url:Te.preview_image_url,publish_date:Te.publish_date,is_published:Te.is_published,content_blocks:Te.content_blocks}).eq("id",Te.id);if(Ae)throw Ae;return Te.id},onSuccess:async Te=>{await ce(Te),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),le()},onError:Te=>{t({title:"Error updating newsletter",description:Te.message,variant:"destructive"})}}),Y=Et({mutationFn:async Te=>{const{error:Ae}=await G.from("newsletter_content").delete().eq("id",Te);if(Ae)throw Ae},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:Te=>{t({title:"Error deleting newsletter",description:Te.message,variant:"destructive"})}}),ce=async Te=>{await G.from("newsletter_drive_links").delete().eq("newsletter_id",Te),await G.from("newsletter_pdfs").delete().eq("newsletter_id",Te),await G.from("newsletter_videos").delete().eq("newsletter_id",Te),await G.from("newsletter_canva_links").delete().eq("newsletter_id",Te);for(const Ae of O){const ze=`${Te}/${Date.now()}-${Ae.file.name}`,{error:Ee}=await G.storage.from("newsletter-content").upload(ze,Ae.file);if(!Ee){const{data:ve}=G.storage.from("newsletter-content").getPublicUrl(ze);b.push({name:Ae.name,file_url:ve.publicUrl,file_size:Ae.file.size,sort_order:b.length})}}y.length>0&&await G.from("newsletter_drive_links").insert(y.map((Ae,ze)=>({newsletter_id:Te,title:Ae.title,drive_url:Ae.drive_url,sort_order:ze}))),b.length>0&&await G.from("newsletter_pdfs").insert(b.map((Ae,ze)=>({newsletter_id:Te,name:Ae.name,file_url:Ae.file_url,file_size:Ae.file_size||null,sort_order:ze}))),w.length>0&&await G.from("newsletter_videos").insert(w.map((Ae,ze)=>({newsletter_id:Te,title:Ae.title,video_url:Ae.video_url,sort_order:ze}))),C.length>0&&await G.from("newsletter_canva_links").insert(C.map((Ae,ze)=>({newsletter_id:Te,title:Ae.title,canva_share_link:Ae.canva_share_link,sort_order:ze})))},ae=async Te=>{o(Te),i({title:Te.title,description:Te.description||"",publish_date:gs(new Date(Te.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:Te.is_published}),f(Te.preview_image_url),L(Te.content_blocks||[]);const[Ae,ze,Ee,ve]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",Te.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",Te.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",Te.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",Te.id).order("sort_order")]);_(Ae.data||[]),N(ze.data||[]),S(Ee.data||[]),A(ve.data||[]),U([]),n(!0)},ie=async Te=>{const[Ae,ze,Ee,ve]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",Te.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",Te.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",Te.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",Te.id).order("sort_order")]);o(null),i({title:`${Te.title} (Copy)`,description:Te.description||"",publish_date:gs(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),f(Te.preview_image_url),L(Te.content_blocks||[]),_((Ae.data||[]).map(({id:Re,...Ue})=>Ue)),N((ze.data||[]).map(({id:Re,...Ue})=>Ue)),S((Ee.data||[]).map(({id:Re,...Ue})=>Ue)),A((ve.data||[]).map(({id:Re,...Ue})=>Ue)),U([]),n(!0)},le=()=>{n(!1),o(null),i({title:"",description:"",publish_date:gs(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),f(null),_([]),N([]),S([]),A([]),L([]),U([])},fe=async Te=>{var ze;const Ae=(ze=Te.target.files)==null?void 0:ze[0];Ae&&(u(Ae),f(URL.createObjectURL(Ae)))},xe=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}$(!0);let Te=p;if(d){const Ae=`previews/${Date.now()}-${d.name}`,{error:ze}=await G.storage.from("newsletter-content").upload(Ae,d);if(!ze){const{data:Ee}=G.storage.from("newsletter-content").getPublicUrl(Ae);Te=Ee.publicUrl}}a?J.mutate({id:a.id,...l,preview_image_url:Te,content_blocks:I}):Z.mutate({...l,preview_image_url:Te,content_blocks:I}),$(!1)},he=()=>_([...y,{title:"",drive_url:"",sort_order:y.length}]),we=()=>S([...w,{title:"",video_url:"",sort_order:w.length}]),Ne=()=>A([...C,{title:"",canva_share_link:"",sort_order:C.length}]),Ve=Te=>{const Ae=Te.target.files;if(!Ae)return;const ze=Array.from(Ae).map(Ee=>({file:Ee,name:Ee.name.replace(/\.[^/.]+$/,"")}));U([...O,...ze])};return e.jsx(Ls,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.length)||0})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.filter(Te=>Te.is_published).length)||0})})]})]}),e.jsxs(fs,{open:r,onOpenChange:Te=>!Te&&le(),children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"})," Add Newsletter"]})}),e.jsxs(ms,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:a?"Edit Newsletter":"Add Newsletter"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Title *"}),e.jsx(Fe,{value:l.title,onChange:Te=>i({...l,title:Te.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Publish Date"}),e.jsx(Fe,{type:"datetime-local",value:l.publish_date,onChange:Te=>i({...l,publish_date:Te.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Description"}),e.jsx(Yg,{content:l.description,onChange:Te=>i({...l,description:Te}),placeholder:"Newsletter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(Sr,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(Fe,{type:"file",accept:"image/*",onChange:fe,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(Da,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{checked:l.is_published,onCheckedChange:Te=>i({...l,is_published:Te})}),e.jsx(ge,{children:"Published"})]}),e.jsx(hbs,{rows:I,onChange:L}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{className:"text-base font-medium",children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Ne,children:[e.jsx(Bs,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),C.map((Te,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Fe,{placeholder:"Link title",value:Te.title,onChange:ze=>{const Ee=[...C];Ee[Ae].title=ze.target.value,A(Ee)},className:"w-1/3"}),e.jsx(Fe,{placeholder:"Canva share link",value:Te.canva_share_link,onChange:ze=>{const Ee=[...C];Ee[Ae].canva_share_link=ze.target.value,A(Ee)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>A(C.filter((ze,Ee)=>Ee!==Ae)),children:e.jsx(Sr,{className:"h-4 w-4"})})]},Ae))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{className:"text-base font-medium",children:"Google Drive Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:he,children:[e.jsx(Bs,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),y.map((Te,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Fe,{placeholder:"Link title",value:Te.title,onChange:ze=>{const Ee=[...y];Ee[Ae].title=ze.target.value,_(Ee)},className:"w-1/3"}),e.jsx(Fe,{placeholder:"Google Drive URL",value:Te.drive_url,onChange:ze=>{const Ee=[...y];Ee[Ae].drive_url=ze.target.value,_(Ee)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>_(y.filter((ze,Ee)=>Ee!==Ae)),children:e.jsx(Sr,{className:"h-4 w-4"})})]},Ae))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{className:"text-base font-medium",children:"PDF Files"}),e.jsxs("div",{children:[e.jsx(Fe,{type:"file",accept:".pdf",multiple:!0,onChange:Ve,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(Da,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),b.map((Te,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(mn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:Te.name}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>N(b.filter((ze,Ee)=>Ee!==Ae)),children:e.jsx(Sr,{className:"h-4 w-4"})})]},`existing-${Ae}`)),O.map((Te,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(mn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{value:Te.name,onChange:ze=>{const Ee=[...O];Ee[Ae].name=ze.target.value,U(Ee)},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:()=>U(O.filter((ze,Ee)=>Ee!==Ae)),children:e.jsx(Sr,{className:"h-4 w-4"})})]},`pending-${Ae}`))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{className:"text-base font-medium",children:"Video Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:we,children:[e.jsx(Bs,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),w.map((Te,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Fe,{placeholder:"Video title",value:Te.title,onChange:ze=>{const Ee=[...w];Ee[Ae].title=ze.target.value,S(Ee)},className:"w-1/3"}),e.jsx(Fe,{placeholder:"Video URL",value:Te.video_url,onChange:ze=>{const Ee=[...w];Ee[Ae].video_url=ze.target.value,S(Ee)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>S(w.filter((ze,Ee)=>Ee!==Ae)),children:e.jsx(Sr,{className:"h-4 w-4"})})]},Ae))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:le,children:"Cancel"}),e.jsx(K,{onClick:xe,disabled:q||Z.isPending||J.isPending,children:q?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Ie,{children:e.jsx(Be,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Publish Date"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:ee?e.jsx(As,{children:e.jsx(dt,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(V==null?void 0:V.length)===0?e.jsx(As,{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(Te=>e.jsxs(As,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Te.preview_image_url?e.jsx("img",{src:Te.preview_image_url,alt:Te.title,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(mn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Te.title}),Te.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Te.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(dt,{children:gs(new Date(Te.publish_date),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Te.is_published?"bg-green-100 text-green-800 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:Te.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:()=>ae(Te),title:"Edit",children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ie(Te),title:"Duplicate",children:e.jsx(Ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm("Are you sure you want to delete this newsletter?")&&Y.mutate(Te.id)},children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},Te.id))})]})})})]})})}const V7e={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 pbs(){const{user:t}=$s(),{toast:s}=va(),r=br(),n=es(),[a,o]=k.useState(""),[l,i]=k.useState("popular"),[d,u]=k.useState(!1),[p,f]=k.useState(""),[y,_]=k.useState(""),[b,N]=k.useState(!1),{data:w=[],isLoading:S}=ft({queryKey:["wishlist-items",l,b],queryFn:async()=>{let O=G.from("wishlist_items").select("*");b&&t&&(O=O.eq("user_id",t.id)),l==="latest"?O=O.order("created_at",{ascending:!1}):l==="popular"?O=O.order("vote_count",{ascending:!1}):l==="trending"&&(O=O.order("vote_count",{ascending:!1}));const{data:U,error:q}=await O;if(q)throw q;const $=[...new Set((U==null?void 0:U.map(ae=>ae.user_id))||[])],{data:V}=await G.from("profiles").select("id, name").in("id",$),ee=new Map((V==null?void 0:V.map(ae=>[ae.id,ae]))||[]);let Z=[];if(t){const{data:ae}=await G.from("wishlist_votes").select("item_id").eq("user_id",t.id);Z=(ae==null?void 0:ae.map(ie=>ie.item_id))||[]}const J=(U==null?void 0:U.map(ae=>ae.id))||[],{data:Y}=await G.from("wishlist_comments").select("item_id").in("item_id",J),ce=new Map;return Y==null||Y.forEach(ae=>{ce.set(ae.item_id,(ce.get(ae.item_id)||0)+1)}),U==null?void 0:U.map(ae=>{const ie=ee.get(ae.user_id),le=(ie==null?void 0:ie.name)||"Unknown";return{...ae,user_name:le,user_initials:le.split(" ").map(fe=>fe[0]).join("").toUpperCase().slice(0,2),has_voted:Z.includes(ae.id),comment_count:ce.get(ae.id)||0}})}}),C=Et({mutationFn:async({title:O,description:U})=>{const{error:q}=await G.from("wishlist_items").insert({user_id:t.id,title:O,description:U});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:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),A=Et({mutationFn:async({itemId:O,hasVoted:U})=>{if(U){const{error:q}=await G.from("wishlist_votes").delete().eq("item_id",O).eq("user_id",t.id);if(q)throw q;return{itemId:O,wasAdded:!1}}else{const{error:q}=await G.from("wishlist_votes").insert({item_id:O,user_id:t.id});if(q)throw q;return{itemId:O,wasAdded:!0}}},onSuccess:async O=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),O!=null&&O.wasAdded){const U=w.find($=>$.id===O.itemId),q=((U==null?void 0:U.vote_count)||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:O.itemId,voteCount:q}}).catch(console.error)}},onError:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),I=w.filter(O=>O.title.toLowerCase().includes(a.toLowerCase())||O.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}C.mutate({title:p.trim(),description:y.trim()})};return e.jsx(Ls,{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(Eb,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold",children:"Wishlist"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Share ideas and vote on what we build next"})]})]}),e.jsxs(fs,{open:d,onOpenChange:u,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Submit a New Idea"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"title",children:"Title"}),e.jsx(Fe,{id:"title",placeholder:"Give your idea a clear title...",value:p,onChange:O=>f(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:y,onChange:O=>_(O.target.value),rows:4})]}),e.jsx(K,{onClick:L,className:"w-full",disabled:C.isPending,children:C.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ps,{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(tn,{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:O=>o(O.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ta,{value:l,onValueChange:O=>i(O),children:e.jsxs(Qn,{children:[e.jsx(ls,{value:"popular",children:"Most Popular"}),e.jsx(ls,{value:"latest",children:"Latest"}),e.jsx(ls,{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:()=>N(!b),children:b?"Show All Ideas":"My Ideas"})}),S?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ps,{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(Eb,{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(Bs,{className:"h-4 w-4 mr-2"}),"Add Idea"]})]}):e.jsx("div",{className:"space-y-3",children:I.map(O=>e.jsx("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>r(`/wishlist/${O.id}`),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:U=>{U.stopPropagation(),A.mutate({itemId:O.id,hasVoted:O.has_voted||!1})},className:Rt("flex flex-col items-center justify-center min-w-[50px] py-2 px-3 rounded-lg border transition-colors",O.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(cu,{className:Rt("h-4 w-4",O.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:O.vote_count})]}),e.jsx(vn,{className:"h-10 w-10 bg-primary/20",children:e.jsx(_n,{className:"bg-primary/20 text-primary text-sm font-medium",children:O.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:O.title}),e.jsx(Ye,{className:Rt("text-xs",V7e[O.status].color),children:V7e[O.status].label})]}),e.jsx("p",{className:"text-muted-foreground text-sm line-clamp-2",children:O.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:O.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(O.created_at).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Si,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:O.comment_count})]})]})},O.id))})]})})}const H7e={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 fbs(){const{itemId:t}=ho(),s=br(),{user:r}=$s(),{toast:n}=va(),a=es(),[o,l]=k.useState(""),{data:i=!1}=ft({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:w,error:S}=await G.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!S&&!!w},enabled:!!r}),{data:d,isLoading:u}=ft({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:w,error:S}=await G.from("wishlist_items").select("*").eq("id",t).single();if(S)throw S;const{data:C}=await G.from("profiles").select("name").eq("id",w.user_id).single();let A=!1;if(r){const{data:I}=await G.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();A=!!I}return{...w,user_name:(C==null?void 0:C.name)||"Unknown",user_initials:((C==null?void 0:C.name)||"U").split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),has_voted:A}}}),{data:p=[],isLoading:f}=ft({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:w,error:S}=await G.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(S)throw S;const C=[...new Set((w==null?void 0:w.map(L=>L.user_id))||[])],{data:A}=await G.from("profiles").select("id, name").in("id",C),I=new Map((A==null?void 0:A.map(L=>[L.id,L]))||[]);return w==null?void 0:w.map(L=>{const O=I.get(L.user_id),U=(O==null?void 0:O.name)||"Unknown";return{...L,user_name:U,user_initials:U.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2)}})}}),y=Et({mutationFn:async w=>{if(w){const{error:S}=await G.from("wishlist_votes").delete().eq("item_id",t).eq("user_id",r.id);if(S)throw S;return{wasAdded:!1}}else{const{error:S}=await G.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(S)throw S;return{wasAdded:!0}}},onSuccess:async w=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),w!=null&&w.wasAdded&&d){const S=(d.vote_count||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:S}}).catch(console.error)}},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),_=Et({mutationFn:async w=>{const{error:S}=await G.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:w});if(S)throw S},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),b=Et({mutationFn:async w=>{const{error:S}=await G.from("wishlist_comments").delete().eq("id",w);if(S)throw S},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),N=()=>{o.trim()&&_.mutate(o.trim())};return u?e.jsx(Ls,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(Ss,{className:"h-8 w-32 mb-6"}),e.jsx(Ss,{className:"h-48 w-full mb-6"}),e.jsx(Ss,{className:"h-32 w-full"})]})}):d?e.jsx(Ls,{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(Ra,{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(d.has_voted),className:Rt("flex flex-col items-center justify-center min-w-[60px] py-3 px-4 rounded-lg border transition-colors",d.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(cu,{className:Rt("h-5 w-5",d.has_voted&&"fill-current")}),e.jsx("span",{className:"text-lg font-bold",children:d.vote_count}),e.jsx("span",{className:"text-xs",children:"votes"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h1",{className:"text-xl font-bold",children:d.title}),e.jsx(Ye,{className:Rt("text-xs",H7e[d.status].color),children:H7e[d.status].label})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap mb-4",children:d.description}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(vn,{className:"h-6 w-6",children:e.jsx(_n,{className:"bg-primary/20 text-primary text-xs",children:d.user_initials})}),e.jsx("span",{children:d.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(d.created_at).toLocaleDateString()})]})]})]})}),e.jsxs("div",{className:"bg-card border rounded-lg p-6",children:[e.jsxs("h2",{className:"text-lg font-semibold mb-4",children:["Comments (",p.length,")"]}),e.jsxs("div",{className:"flex gap-3 mb-6",children:[e.jsx(mce,{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:N,disabled:!o.trim()||_.isPending,size:"icon",className:"h-auto",children:_.isPending?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(Nn,{className:"h-4 w-4"})})]}),f?e.jsx("div",{className:"space-y-4",children:[1,2].map(w=>e.jsx(Ss,{className:"h-20 w-full"},w))}):p.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No comments yet. Be the first to share your thoughts!"}):e.jsx("div",{className:"space-y-4",children:p.map(w=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/30 rounded-lg",children:[e.jsx(vn,{className:"h-8 w-8",children:e.jsx(_n,{className:"bg-primary/20 text-primary text-xs",children:w.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:w.user_name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(w.created_at).toLocaleDateString()})]}),e.jsx(N4e,{content:w.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===w.user_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>b.mutate(w.id),children:e.jsx(yr,{className:"h-4 w-4"})})]},w.id))})]})]})}):e.jsx(Ls,{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 G7e={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"}},W7e=["open","under_review","planned","in_progress","launched","declined"];function xbs(){const{toast:t}=va(),s=br(),r=es(),[n,a]=k.useState(""),[o,l]=k.useState("all"),[i,d]=k.useState(!1),[u,p]=k.useState(null),{data:f=[],isLoading:y}=ft({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:S,error:C}=await G.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(C)throw C;const A=[...new Set((S==null?void 0:S.map($=>$.user_id))||[])],{data:I}=await G.from("profiles").select("id, name, email").in("id",A),L=new Map((I==null?void 0:I.map($=>[$.id,$]))||[]),O=(S==null?void 0:S.map($=>$.id))||[],{data:U}=await G.from("wishlist_comments").select("item_id").in("item_id",O),q=new Map;return U==null||U.forEach($=>{q.set($.item_id,(q.get($.item_id)||0)+1)}),S==null?void 0:S.map($=>{const V=L.get($.user_id);return{...$,user_name:(V==null?void 0:V.name)||"Unknown",user_email:(V==null?void 0:V.email)||"",comment_count:q.get($.id)||0}})}}),_=Et({mutationFn:async({itemId:S,status:C})=>{const{error:A}=await G.from("wishlist_items").update({status:C}).eq("id",S);if(A)throw A},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:S=>{t({title:"Error",description:S.message,variant:"destructive"})}}),b=Et({mutationFn:async S=>{const{error:C}=await G.from("wishlist_items").delete().eq("id",S);if(C)throw C},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),d(!1),p(null),t({title:"Item deleted!"})},onError:S=>{t({title:"Error",description:S.message,variant:"destructive"})}}),N=f.filter(S=>{const C=S.title.toLowerCase().includes(n.toLowerCase())||S.description.toLowerCase().includes(n.toLowerCase())||S.user_name.toLowerCase().includes(n.toLowerCase()),A=o==="all"||S.status===o;return C&&A}),w={total:f.length,open:f.filter(S=>S.status==="open").length,inProgress:f.filter(S=>S.status==="in_progress").length,launched:f.filter(S=>S.status==="launched").length,highVotes:f.filter(S=>S.vote_count>=10).length};return e.jsx(Ls,{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(Ra,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Wishlist Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Review and manage community ideas"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Ideas"}),e.jsx("p",{className:"text-2xl font-bold",children:w.total})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Open"}),e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:w.open})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"In Progress"}),e.jsx("p",{className:"text-2xl font-bold text-orange-600",children:w.inProgress})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Launched"}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:w.launched})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"10+ Votes"}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:w.highVotes})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(tn,{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:S=>a(S.target.value),className:"pl-10"})]}),e.jsxs(zs,{value:o,onValueChange:S=>l(S),children:[e.jsx(Os,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"Filter by status"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Statuses"}),W7e.map(S=>e.jsx(yt,{value:S,children:G7e[S].label},S))]})]})]}),y?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(S=>e.jsx(Ss,{className:"h-16 w-full"},S))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{className:"w-[60px]",children:"Votes"}),e.jsx(Nt,{children:"Title"}),e.jsx(Nt,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(Nt,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Pn,{children:N.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):N.map(S=>e.jsxs(As,{className:Rt(S.vote_count>=10&&"bg-primary/5"),children:[e.jsx(dt,{children:e.jsx(Ye,{variant:S.vote_count>=10?"default":"secondary",children:S.vote_count})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium line-clamp-1",children:S.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(dt,{className:"hidden md:table-cell",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:S.user_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.user_email})]})}),e.jsx(dt,{className:"hidden sm:table-cell",children:S.comment_count}),e.jsx(dt,{children:e.jsxs(zs,{value:S.status,onValueChange:C=>_.mutate({itemId:S.id,status:C}),children:[e.jsx(Os,{className:"w-[140px] h-8",children:e.jsx(qs,{})}),e.jsx(Fs,{children:W7e.map(C=>e.jsx(yt,{value:C,children:G7e[C].label},C))})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${S.id}`,"_blank"),children:e.jsx(Kr,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(S.id),d(!0)},children:e.jsx(yr,{className:"h-4 w-4"})})]})})]},S.id))})]})}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Delete Wishlist Item"})}),e.jsx("p",{className:"text-muted-foreground",children:"Are you sure you want to delete this idea? This will also delete all votes and comments."}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:()=>u&&b.mutate(u),disabled:b.isPending,children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function gbs(){const{user:t}=$s(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,d]=k.useState(null),[u,p]=k.useState(!1),[f,y]=k.useState(null),[_,b]=k.useState(""),[N,w]=k.useState(""),[S,C]=k.useState(""),[A,I]=k.useState(""),[L,O]=k.useState(""),[U,q]=k.useState(!1),[$,V]=k.useState(""),[ee,Z]=k.useState("once"),[J,Y]=k.useState([]),[ce,ae]=k.useState([]),[ie,le]=k.useState(!1),[fe,xe]=k.useState(!1),[he,we]=k.useState([]),[Ne,Ve]=k.useState({total:0,dismissed:0});k.useEffect(()=>{Te()},[]);const Te=async()=>{const{data:Oe,error:Xe}=await G.from("levelup_briefs").select("*").order("created_at",{ascending:!1});Xe?(me.error("Failed to fetch briefs"),console.error(Xe)):r(Oe||[]),a(!1)},Ae=()=>{b(""),w(""),C(""),I(""),O(""),q(!1),V(new Date().toISOString().slice(0,16)),Z("once"),Y([]),ae([]),d(null)},ze=()=>{Ae(),l(!0)},Ee=async Oe=>{d(Oe),b(Oe.title),w(Oe.description||""),C(Oe.video_url||""),I(Oe.graphic_url||""),O(Oe.graphic_link_url||""),q(Oe.is_published),V(Oe.publish_date.slice(0,16)),Z(Oe.show_frequency);const{data:Xe}=await G.from("levelup_brief_links").select("*").eq("brief_id",Oe.id).order("sort_order");Y((Xe==null?void 0:Xe.map(Ke=>({title:Ke.title,url:Ke.url})))||[]);const{data:at}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Oe.id).order("sort_order");if(at){const Ke=[];for(const He of at){const{data:gt}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",He.id).order("sort_order");Ke.push({question:He.question,poll_type:He.poll_type,options:(gt==null?void 0:gt.map(Mt=>Mt.option_text))||[]})}ae(Ke)}l(!0)},ve=async Oe=>{var at;const Xe=(at=Oe.target.files)==null?void 0:at[0];if(Xe){le(!0);try{const Ke=await G.functions.invoke("bunny-upload",{body:{action:"create",title:Xe.name.replace(/\.[^/.]+$/,"")}});if(Ke.error)throw Ke.error;const{videoId:He,libraryId:gt}=Ke.data,Mt=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:He}});if(Mt.error)throw Mt.error;const{uploadUrl:Wt,apiKey:xs}=Mt.data,Cs=new XMLHttpRequest;await new Promise((Ar,Bt)=>{Cs.upload.addEventListener("progress",Xs=>{if(Xs.lengthComputable){const Nr=Math.round(Xs.loaded/Xs.total*100);console.log("Upload progress:",Nr)}}),Cs.addEventListener("load",()=>{Cs.status>=200&&Cs.status<300?Ar():Bt(new Error(`Upload failed with status ${Cs.status}`))}),Cs.addEventListener("error",()=>Bt(new Error("Upload failed"))),Cs.open("PUT",Wt),Cs.setRequestHeader("AccessKey",xs),Cs.send(Xe)});const Us=`https://player.mediadelivery.net/embed/${gt}/${He}`;C(Us),me.success("Video uploaded successfully! It may take a few minutes to process.")}catch(Ke){console.error("Upload error:",Ke),me.error("Failed to upload video")}finally{le(!1)}}},Re=async()=>{if(!_.trim()){me.error("Title is required");return}try{let Oe;if(i){const{error:Xe}=await G.from("levelup_briefs").update({title:_,description:N||null,video_url:S||null,graphic_url:A||null,graphic_link_url:L||null,is_published:U,publish_date:$,show_frequency:ee}).eq("id",i.id);if(Xe)throw Xe;Oe=i.id,await G.from("levelup_brief_links").delete().eq("brief_id",Oe);const{data:at}=await G.from("levelup_brief_polls").select("id").eq("brief_id",Oe);if(at)for(const Ke of at)await G.from("levelup_brief_poll_options").delete().eq("poll_id",Ke.id);await G.from("levelup_brief_polls").delete().eq("brief_id",Oe)}else{const{data:Xe,error:at}=await G.from("levelup_briefs").insert({title:_,description:N||null,video_url:S||null,graphic_url:A||null,graphic_link_url:L||null,is_published:U,publish_date:$,show_frequency:ee,created_by:t==null?void 0:t.id}).select().single();if(at)throw at;Oe=Xe.id}if(J.length>0){const Xe=J.map((at,Ke)=>({brief_id:Oe,title:at.title,url:at.url,sort_order:Ke}));await G.from("levelup_brief_links").insert(Xe)}for(let Xe=0;Xe0){const gt=at.options.map((Mt,Wt)=>({poll_id:Ke.id,option_text:Mt,sort_order:Wt}));await G.from("levelup_brief_poll_options").insert(gt)}}me.success(i?"Brief updated":"Brief created"),l(!1),Ae(),Te()}catch(Oe){console.error("Error saving brief:",Oe),me.error("Failed to save brief")}},Ue=async Oe=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:Xe}=await G.from("levelup_briefs").delete().eq("id",Oe);if(Xe)throw Xe;me.success("Brief deleted"),Te()}catch(Xe){console.error("Error deleting brief:",Xe),me.error("Failed to delete brief")}},ye=async Oe=>{y(Oe);const{count:Xe}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Oe.id),{count:at}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Oe.id).not("dismissed_at","is",null);Ve({total:Xe||0,dismissed:at||0});const{data:Ke}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Oe.id).order("sort_order");if(Ke){const He=[];for(const gt of Ke){const{data:Mt}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",gt.id).order("sort_order"),{data:Wt}=await G.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",gt.id),xs=[...new Set((Wt==null?void 0:Wt.map(Xs=>Xs.user_id))||[])];let Cs={};if(xs.length>0){const{data:Xs}=await G.from("profiles").select("id, name, email").in("id",xs);Xs&&Xs.forEach(Nr=>{Cs[Nr.id]=Nr.name||Nr.email||"Unknown"})}const Us=(Wt||[]).map(Xs=>({optionId:Xs.option_id,userName:Cs[Xs.user_id]||"Unknown",userId:Xs.user_id})),Ar={};let Bt=0;Mt&&Mt.forEach(Xs=>{const Nr=(Wt==null?void 0:Wt.filter(Vs=>Vs.option_id===Xs.id).length)||0;Ar[Xs.id]=Nr,Bt+=Nr}),He.push({...gt,options:Mt||[],results:Ar,respondents:Us,totalResponses:gt.poll_type==="single"?new Set(Wt==null?void 0:Wt.map(Xs=>Xs.user_id)).size:Bt})}we(He)}p(!0)},ct=()=>{Y([...J,{title:"",url:""}])},pe=(Oe,Xe,at)=>{const Ke=[...J];Ke[Oe][Xe]=at,Y(Ke)},Ge=Oe=>{Y(J.filter((Xe,at)=>at!==Oe))},tt=()=>{ae([...ce,{question:"",poll_type:"single",options:["",""]}])},st=(Oe,Xe)=>{const at=[...ce];at[Oe].question=Xe,ae(at)},Ce=(Oe,Xe)=>{const at=[...ce];at[Oe].poll_type=Xe,ae(at)},et=Oe=>{const Xe=[...ce];Xe[Oe].options.push(""),ae(Xe)},Ct=(Oe,Xe,at)=>{const Ke=[...ce];Ke[Oe].options[Xe]=at,ae(Ke)},Ot=(Oe,Xe)=>{const at=[...ce];at[Oe].options=at[Oe].options.filter((Ke,He)=>He!==Xe),ae(at)},ut=Oe=>{ae(ce.filter((Xe,at)=>at!==Oe))};return e.jsxs(Ls,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(K,{onClick:ze,children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Ie,{children:e.jsx(Be,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Title"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{children:"Frequency"}),e.jsx(Nt,{children:"Publish Date"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:n?e.jsx(As,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(Oe=>e.jsxs(As,{children:[e.jsx(dt,{className:"font-medium",children:Oe.title}),e.jsx(dt,{children:e.jsx(Ye,{variant:Oe.is_published?"default":"secondary",children:Oe.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"capitalize",children:Oe.show_frequency.replace("_"," ")}),e.jsx(dt,{children:gs(new Date(Oe.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:()=>ye(Oe),children:e.jsx(so,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ee(Oe),children:e.jsx(Gc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ue(Oe.id),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})})]},Oe.id))})]})})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ms,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(ta,{defaultValue:"content",className:"w-full",children:[e.jsxs(Qn,{className:"grid w-full grid-cols-4",children:[e.jsx(ls,{value:"content",children:"Content"}),e.jsx(ls,{value:"media",children:"Media"}),e.jsx(ls,{value:"links",children:"Links"}),e.jsx(ls,{value:"polls",children:"Polls"})]}),e.jsxs(js,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Title *"}),e.jsx(Fe,{value:_,onChange:Oe=>b(Oe.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Description"}),e.jsx(Yg,{content:N,onChange:Oe=>w(Oe),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(ge,{children:"Publish Date"}),e.jsx(Fe,{type:"datetime-local",value:$,onChange:Oe=>V(Oe.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Show Frequency"}),e.jsxs(zs,{value:ee,onValueChange:Z,children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"once",children:"Once (until dismissed)"}),e.jsx(yt,{value:"every_login",children:"Every login"}),e.jsx(yt,{value:"daily",children:"Daily"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Lr,{checked:U,onCheckedChange:q}),e.jsx(ge,{children:"Publish immediately"})]})]}),e.jsxs(js,{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(ge,{children:"Upload Video to Bunny.net"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Fe,{type:"file",accept:"video/*",onChange:ve,disabled:ie})}),ie&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Or paste embed URL"}),e.jsx(Fe,{value:S,onChange:Oe=>C(Oe.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),S&&e.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:S,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(ge,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Fe,{type:"file",accept:"image/*",onChange:async Oe=>{var at;const Xe=(at=Oe.target.files)==null?void 0:at[0];if(Xe){xe(!0);try{const Ke=Xe.name.split(".").pop(),He=`brief-graphics/${Date.now()}.${Ke}`,{error:gt}=await G.storage.from("banner-images").upload(He,Xe,{upsert:!0});if(gt)throw gt;const{data:Mt}=G.storage.from("banner-images").getPublicUrl(He);I(Mt.publicUrl),me.success("Image uploaded!")}catch(Ke){console.error(Ke),me.error("Failed to upload image")}finally{xe(!1)}}},disabled:fe})}),fe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Or paste Image URL"}),e.jsx(Fe,{value:A,onChange:Oe=>I(Oe.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Click-through Link (optional)"}),e.jsx(Fe,{value:L,onChange:Oe=>O(Oe.target.value),placeholder:"https://example.com/landing-page"})]}),A&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted border",children:e.jsx("img",{src:A,alt:"Brief graphic preview",className:"w-full object-contain max-h-64"})})]})]}),e.jsxs(js,{value:"links",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ge,{children:"Quick Links"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ct,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),J.map((Oe,Xe)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(Fe,{value:Oe.title,onChange:at=>pe(Xe,"title",at.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(Fe,{value:Oe.url,onChange:at=>pe(Xe,"url",at.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ge(Xe),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]},Xe)),J.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No links added yet"})]}),e.jsxs(js,{value:"polls",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ge,{children:"Polls"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:tt,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),ce.map((Oe,Xe)=>e.jsx(Ie,{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:Oe.question,onChange:at=>st(Xe,at.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(zs,{value:Oe.poll_type,onValueChange:at=>Ce(Xe,at),children:[e.jsx(Os,{className:"w-32",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"single",children:"Single"}),e.jsx(yt,{value:"multi",children:"Multi-select"})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ut(Xe),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[Oe.options.map((at,Ke)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:at,onChange:He=>Ct(Xe,Ke,He.target.value),placeholder:`Option ${Ke+1}`}),Oe.options.length>2&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ot(Xe,Ke),children:e.jsx(yr,{className:"h-4 w-4 text-muted-foreground"})})]},Ke)),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>et(Xe),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},Xe)),ce.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls added yet"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:Re,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(ms,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsxs(bs,{children:["Results: ",f==null?void 0:f.title]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx(Be,{children:e.jsx("p",{className:"text-2xl font-bold",children:Ne.total})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx(Be,{children:e.jsx("p",{className:"text-2xl font-bold",children:Ne.dismissed})})]})]}),he.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),he.map(Oe=>e.jsxs(Ie,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:Oe.question}),e.jsx("div",{className:"space-y-2",children:Oe.options.map(Xe=>{const at=Oe.results[Xe.id]||0,Ke=Oe.totalResponses>0?Math.round(at/Oe.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:[at," (",Ke,"%)"]})]}),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:`${Ke}%`}})}),at>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(Oe.respondents||[]).filter(He=>He.optionId===Xe.id).map((He,gt)=>e.jsx(Ye,{variant:"secondary",className:"text-xs font-normal",children:He.userName},gt))})]},Xe.id)})})]},Oe.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const ybs=()=>{const{user:t}=$s(),{toast:s}=va(),r=es(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,d]=k.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=k.useState(null),[f,y]=k.useState(""),{data:_=[],isLoading:b}=ft({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:L,error:O}=await G.from("additional_services").select("*").order("publish_date",{ascending:!1});if(O)throw O;return L}}),N=Et({mutationFn:async L=>{let O=L.existingImageUrl;if(L.image){const q=L.image.name.split(".").pop(),$=`${Date.now()}-${Math.random().toString(36).substring(7)}.${q}`,{error:V}=await G.storage.from("service-images").upload($,L.image);if(V)throw V;const{data:ee}=G.storage.from("service-images").getPublicUrl($);O=ee.publicUrl}const U={name:L.item.name,description:L.item.description||null,preview_image_url:O,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(U).eq("id",L.itemId);if(q)throw q}else{const{error:q}=await G.from("additional_services").insert(U);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),S()},onError:L=>{s({title:"Error saving service",description:L.message,variant:"destructive"})}}),w=Et({mutationFn:async L=>{const{error:O}=await G.from("additional_services").delete().eq("id",L);if(O)throw O},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"})}}),S=()=>{d({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),y(""),l(null)},C=L=>{l(L),d({name:L.name,description:L.description||"",signup_link_url:L.signup_link_url,publish_date:L.publish_date?new Date(L.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:L.is_published}),y(L.preview_image_url||""),a(!0)},A=L=>{var U;const O=(U=L.target.files)==null?void 0:U[0];O&&(p(O),y(URL.createObjectURL(O)))},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}N.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(Ls,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(L=>L.is_published).length})})]})]}),e.jsxs(fs,{open:n,onOpenChange:L=>{a(L),L||S()},children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add Service"]})}),e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:o?"Edit Service":"Add New Service"})}),e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"name",children:"Name *"}),e.jsx(Fe,{id:"name",value:i.name,onChange:L=>d({...i,name:L.target.value}),placeholder:"Enter service name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Description"}),e.jsx(Yg,{content:i.description,onChange:L=>d({...i,description:L}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"signup_link_url",children:"Signup Link URL *"}),e.jsx(Fe,{id:"signup_link_url",type:"url",value:i.signup_link_url,onChange:L=>d({...i,signup_link_url:L.target.value}),placeholder:"https://example.com/signup"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Fe,{id:"publish_date",type:"date",value:i.publish_date,onChange:L=>d({...i,publish_date:L.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Lr,{id:"is_published",checked:i.is_published,onCheckedChange:L=>d({...i,is_published:L})}),e.jsx(ge,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(Sr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(Uo,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(Fe,{type:"file",accept:"image/*",onChange:A,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:N.isPending,children:N.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ie,{children:e.jsx(Be,{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(As,{children:[e.jsx(Nt,{className:"w-16",children:"Preview"}),e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Signup Link"}),e.jsx(Nt,{children:"Publish Date"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:_.map(L=>e.jsxs(As,{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(Uo,{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(Kr,{className:"h-3 w-3"}),"Link"]})}),e.jsx(dt,{children:new Date(L.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(Ye,{variant:L.is_published?"default":"secondary",children:L.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(L),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&w.mutate(L.id)},children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})})]},L.id))})]})})})]})})};function vbs(){const{toast:t}=va(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});k.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:w,error:S}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(S)throw S;r(w.coupons||[])}catch(w){console.error("Error fetching coupons:",w),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 w={action:"create",name:u.name,duration:u.duration,promotion_code:u.promotionCode.trim()||void 0};u.discountType==="percent"?w.percent_off=parseFloat(u.percentOff):(w.amount_off=Math.round(parseFloat(u.amountOff)*100),w.currency="usd"),u.duration==="repeating"&&(w.duration_in_months=parseInt(u.durationInMonths));const{data:S,error:C}=await G.functions.invoke("stripe-manage-coupons",{body:w});if(C)throw C;t({title:"Success",description:"Coupon created successfully"}),d(!1),p({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),f()}catch(w){console.error("Error creating coupon:",w),t({title:"Error",description:w.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},_=async w=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:S}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:w}});if(S)throw S;t({title:"Success",description:"Coupon deleted successfully"}),f()}catch(S){console.error("Error deleting coupon:",S),t({title:"Error",description:S.message||"Failed to delete coupon",variant:"destructive"})}},b=w=>w.percent_off?`${w.percent_off}% off`:w.amount_off?`$${(w.amount_off/100).toFixed(2)} off`:"N/A",N=w=>{switch(w.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${w.duration_in_months} months`;default:return w.duration}};return e.jsx(Ls,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(fs,{open:i,onOpenChange:d,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Create New Coupon"}),e.jsx(Rr,{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(ge,{children:"Promotion Code (what users will type)"}),e.jsx(Fe,{placeholder:"e.g., BROKERAGE50",value:u.promotionCode,onChange:w=>p({...u,promotionCode:w.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")}),className:"font-mono uppercase"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters and numbers only. This is the code users enter at checkout."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Coupon Name (internal label)"}),e.jsx(Fe,{placeholder:"e.g., 50% Off Brokerage Launch",value:u.name,onChange:w=>p({...u,name:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Discount Type"}),e.jsxs(zs,{value:u.discountType,onValueChange:w=>{const S=w==="amount"&&u.duration==="forever"?"once":u.duration;p({...u,discountType:w,duration:S})},children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(RM,{className:"mr-2 h-4 w-4"}),"Percentage Off"]})}),e.jsx(yt,{value:"amount",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(_c,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),u.discountType==="percent"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Percent Off"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{type:"number",min:"1",max:"100",placeholder:"20",value:u.percentOff,onChange:w=>p({...u,percentOff:w.target.value})}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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:w=>p({...u,amountOff:w.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Duration"}),e.jsxs(zs,{value:u.duration,onValueChange:w=>p({...u,duration:w}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"once",children:"Once (first payment only)"}),e.jsx(yt,{value:"repeating",children:"Multiple months"}),e.jsxs(yt,{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(ge,{children:"Number of Months"}),e.jsx(Fe,{type:"number",min:"1",placeholder:"3",value:u.durationInMonths,onChange:w=>p({...u,durationInMonths:w.target.value})})]}),e.jsx(K,{onClick:y,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Active Coupons"}),e.jsx(mr,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx(Be,{children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ps,{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(As,{children:[e.jsx(Nt,{children:"Promo Code"}),e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Discount"}),e.jsx(Nt,{children:"Duration"}),e.jsx(Nt,{children:"Redemptions"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:s.map(w=>{var S;return e.jsxs(As,{children:[e.jsx(dt,{className:"font-mono font-medium",children:((S=w.promotion_codes)==null?void 0:S.length)>0?w.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(dt,{children:w.name||"-"}),e.jsx(dt,{children:b(w)}),e.jsx(dt,{children:N(w)}),e.jsx(dt,{children:w.times_redeemed}),e.jsx(dt,{children:e.jsx(Ye,{variant:w.valid?"default":"secondary",children:w.valid?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(w.id),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})})]},w.id)})})]})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"How to Use Coupons"})}),e.jsxs(Be,{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 l0e={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 _bs(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState("all"),[l,i]=k.useState(null),{data:d,isLoading:u,refetch:p}=ft({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:S,error:C}=await G.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(C)throw C;return S}}),{data:f}=ft({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:S,error:C}=await G.from("brokerages").select("*").order("name");if(C)throw C;return await Promise.all((S||[]).map(async I=>{const{data:L}=await G.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",I.id),{data:O}=await G.from("user_roles").select("user_id").eq("role","brokerage_manager"),U=(O==null?void 0:O.map(V=>V.user_id))||[],q=(L==null?void 0:L.filter(V=>U.includes(V.id)))||[],$=(L==null?void 0:L.length)||0;return{...I,managers:q,agentCount:$}}))}}),{data:y}=ft({queryKey:["admin-website-subscriptions"],queryFn:async()=>{const{data:S,error:C}=await G.from("local_move_subscriptions").select("*").order("created_at",{ascending:!1});if(C)throw C;return S}}),_=S=>{if(S.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(S.brokerage_id&&!S.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(S.is_trial&&S.trial_expires_at)return new Date(S.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(S.subscription_status==="active"||S.subscription_status==="trialing"){const C=l0e[S.subscription_product_id];return{status:(C==null?void 0:C.name)||"Active",badge:S.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return S.subscription_status==="canceled"||S.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},b=d==null?void 0:d.filter(S=>{var A,I;if(!(((A=S.name)==null?void 0:A.toLowerCase().includes(t.toLowerCase()))||((I=S.email)==null?void 0:I.toLowerCase().includes(t.toLowerCase()))))return!1;if(a!=="all"){const L=S.subscription_source||"platform";if(a==="platform"&&L==="local_move_website"||a==="local_move_website"&&L!=="local_move_website")return!1}switch(_(S),r){case"active":return S.subscription_status==="active";case"trialing":return S.subscription_status==="trialing"||S.is_trial&&new Date(S.trial_expires_at)>new Date;case"grandfathered":return S.is_grandfathered;case"brokerage":return S.brokerage_id&&!S.subscription_product_id&&!S.is_grandfathered;case"expired":return S.subscription_status==="canceled"||S.subscription_status==="past_due"||S.is_trial&&new Date(S.trial_expires_at)<=new Date;case"none":return!S.subscription_status||S.subscription_status==="none";default:return!0}}),N={totalUsers:(d==null?void 0:d.length)||0,activeSubscriptions:(d==null?void 0:d.filter(S=>S.subscription_status==="active").length)||0,trials:(d==null?void 0:d.filter(S=>S.subscription_status==="trialing"||S.is_trial&&new Date(S.trial_expires_at)>new Date).length)||0,grandfathered:(d==null?void 0:d.filter(S=>S.is_grandfathered).length)||0,brokerageMembers:(d==null?void 0:d.filter(S=>S.brokerage_id&&!S.subscription_product_id&&!S.is_grandfathered).length)||0,individualSubscribers:(d==null?void 0:d.filter(S=>S.subscription_status==="active"&&S.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(d==null?void 0:d.filter(S=>S.subscription_status==="active"&&(S.subscription_product_id==="prod_Tc08MupgoVySDG"||S.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},w=S=>{window.open(`https://dashboard.stripe.com/customers/${S}`,"_blank")};return e.jsx(Ls,{title:"Subscription Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(K,{onClick:()=>p(),variant:"outline",size:"sm",children:[e.jsx(to,{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(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cr,{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:N.totalUsers})]})}),e.jsx(Ie,{className:"border-green-500/50",children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(jx,{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:N.activeSubscriptions})]})}),e.jsx(Ie,{className:"border-blue-500/50",children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rn,{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:N.trials})]})}),e.jsx(Ie,{className:"border-purple-500/50",children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(km,{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:N.grandfathered})]})}),e.jsx(Ie,{className:"border-orange-500/50",children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ma,{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:N.brokerageMembers})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rb,{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:N.individualSubscribers})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ma,{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:N.brokerageSubscribers})]})})]}),e.jsxs(ta,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"users",children:"All Users"}),e.jsx(ls,{value:"brokerages",children:"Brokerages"}),e.jsxs(ls,{value:"websites",className:"gap-2",children:[e.jsx(gd,{className:"h-4 w-4"}),"Website Subscriptions",y&&y.length>0&&e.jsx(Ye,{variant:"secondary",className:"ml-1",children:y.length})]})]}),e.jsxs(js,{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(tn,{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:S=>s(S.target.value),className:"pl-9"})]}),e.jsxs(zs,{value:a,onValueChange:S=>o(S),children:[e.jsx(Os,{className:"w-[200px]",children:e.jsx(qs,{placeholder:"Source"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Sources"}),e.jsx(yt,{value:"platform",children:"Platform"}),e.jsx(yt,{value:"local_move_website",children:"Local Move Website"})]})]}),e.jsxs(zs,{value:r,onValueChange:S=>n(S),children:[e.jsx(Os,{className:"w-[200px]",children:e.jsx(qs,{placeholder:"Filter by status"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Statuses"}),e.jsx(yt,{value:"active",children:"Active Subscriptions"}),e.jsx(yt,{value:"trialing",children:"Trials"}),e.jsx(yt,{value:"grandfathered",children:"Grandfathered"}),e.jsx(yt,{value:"brokerage",children:"Brokerage Members"}),e.jsx(yt,{value:"expired",children:"Expired/Canceled"}),e.jsx(yt,{value:"none",children:"No Subscription"})]})]})]}),e.jsx(Ie,{children:e.jsx(Be,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"User"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{children:"Plan"}),e.jsx(Nt,{children:"Brokerage"}),e.jsx(Nt,{children:"End Date"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:u?e.jsx(As,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(b==null?void 0:b.length)===0?e.jsx(As,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):b==null?void 0:b.map(S=>{var I,L;const C=_(S),A=l0e[S.subscription_product_id];return e.jsxs(As,{children:[e.jsx(dt,{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(dt,{children:e.jsx(Ye,{variant:C.variant,children:C.badge})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm",children:S.is_grandfathered?"Legacy Access":S.brokerage_id&&!S.subscription_product_id?"Brokerage Subscription":(A==null?void 0:A.name)||C.status})}),e.jsx(dt,{children:(I=S.brokerages)!=null&&I.name?e.jsx("span",{className:"text-sm",children:S.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(dt,{children:S.subscription_end_date?e.jsx("span",{className:"text-sm",children:gs(new Date(S.subscription_end_date),"MMM d, yyyy")}):S.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",gs(new Date(S.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:[S.stripe_customer_id&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(S.stripe_customer_id),children:e.jsx(Kr,{className:"h-4 w-4"})}),e.jsxs(fs,{children:[e.jsx(ui,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",onClick:()=>i(S),children:"Details"})}),e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Subscription Details"}),e.jsxs(Rr,{children:[S.name," (",S.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(Ye,{variant:C.variant,className:"mt-1",children:C.badge})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Plan"}),e.jsx("p",{className:"font-medium",children:S.is_grandfathered?"Grandfathered (Legacy)":S.brokerage_id&&!S.subscription_product_id?"Brokerage Subscription":(A==null?void 0:A.name)||"None"})]}),S.brokerage_id&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Brokerage"}),e.jsx("p",{className:"font-medium",children:((L=S.brokerages)==null?void 0:L.name)||"Unknown"})]}),S.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:gs(new Date(S.subscription_end_date),"MMMM d, yyyy")})]}),S.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:gs(new Date(S.trial_expires_at),"MMMM d, yyyy")})]}),S.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:S.stripe_customer_id})]})]}),S.stripe_customer_id&&e.jsxs(K,{className:"w-full",onClick:()=>w(S.stripe_customer_id),children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},S.id)})})]})})})]}),e.jsx(js,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:f==null?void 0:f.map(S=>{var A,I;const C=(A=S.managers)==null?void 0:A.some(L=>L.subscription_status==="active"&&(L.subscription_product_id==="prod_Tc08MupgoVySDG"||L.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(ma,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-lg",children:S.name}),e.jsxs(mr,{children:[S.agentCount," agents"]})]})]}),e.jsx(Ye,{variant:C?"default":"outline",children:C?"Active Subscription":"No Active Subscription"})]})}),e.jsx(Be,{children:((I=S.managers)==null?void 0:I.length)>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Managers:"}),S.managers.map(L=>{const O=l0e[L.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:L.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:L.email})]}),e.jsx("div",{className:"text-right",children:O?e.jsxs("div",{children:[e.jsx(Ye,{variant:"default",children:O.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:O.price})]}):e.jsx(Ye,{variant:"outline",children:"No Subscription"})})]},L.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},S.id)})})}),e.jsx(js,{value:"websites",className:"space-y-4",children:e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(gd,{className:"h-5 w-5 text-primary"}),"Local Move Website Subscriptions"]}),e.jsx(mr,{children:"$249 setup fee + $99/mo subscriptions from TheLocalMove.com agent websites"})]}),e.jsx(Be,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Agent"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{children:"Setup Fee"}),e.jsx(Nt,{children:"Monthly"}),e.jsx(Nt,{children:"Next Renewal"}),e.jsx(Nt,{children:"Started"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:y?y.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No website subscriptions yet"})}):y.map(S=>e.jsxs(As,{children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.agent_name||"—"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.agent_email})]})}),e.jsx(dt,{children:e.jsx(Ye,{variant:S.status==="active"?"default":S.status==="canceled"?"destructive":"outline",children:S.status})}),e.jsx(dt,{children:S.setup_fee_paid?e.jsxs(Ye,{variant:"secondary",children:["Paid · $",(S.setup_fee_amount_cents/100).toFixed(0)]}):e.jsx(Ye,{variant:"outline",children:"Unpaid"})}),e.jsxs(dt,{className:"font-medium",children:["$",(S.monthly_amount_cents/100).toFixed(0),"/mo"]}),e.jsx(dt,{children:S.current_period_end?e.jsx("span",{className:"text-sm",children:gs(new Date(S.current_period_end),"MMM d, yyyy")}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm",children:gs(new Date(S.created_at),"MMM d, yyyy")})}),e.jsx(dt,{className:"text-right",children:S.stripe_customer_id&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(S.stripe_customer_id),children:e.jsx(Kr,{className:"h-4 w-4"})})})]},S.id)):e.jsx(As,{children:e.jsx(dt,{colSpan:7,className:"text-center py-8",children:"Loading…"})})})]})})]})})]})]})})}function bbs(){const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(""),[l,i]=k.useState("all"),[d,u]=k.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});k.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:b,error:N}=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(N)throw N;s(b||[]);const w=(b==null?void 0:b.filter(A=>A.status==="qualified").length)||0,S=(b==null?void 0:b.filter(A=>A.status==="pending").length)||0,C=(b==null?void 0:b.filter(A=>A.status==="cancelled").length)||0;u({total:(b==null?void 0:b.length)||0,qualified:w,pending:S,cancelled:C,totalDiscounts:w*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 S,C,A,I,L,O;const N=((C=(S=b.referrer_brokerage)==null?void 0:S.name)==null?void 0:C.toLowerCase().includes(a.toLowerCase()))||((I=(A=b.referred_brokerage)==null?void 0:A.name)==null?void 0:I.toLowerCase().includes(a.toLowerCase()))||((O=(L=b.referred_user)==null?void 0:L.email)==null?void 0:O.toLowerCase().includes(a.toLowerCase())),w=l==="all"||b.status===l;return N&&w}),_=b=>{switch(b){case"qualified":return e.jsxs(Ye,{className:"bg-green-100 text-green-800",children:[e.jsx(si,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(Ye,{variant:"secondary",children:[e.jsx(rn,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(Ye,{variant:"destructive",children:[e.jsx(Ql,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(Ye,{children:b})}};return e.jsx(Ls,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(K,{onClick:f,variant:"outline",children:[e.jsx(to,{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(Ie,{children:e.jsx(Be,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Referrals"})]})]})})}),e.jsx(Ie,{children:e.jsx(Be,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(si,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.qualified}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified"})]})]})})}),e.jsx(Ie,{children:e.jsx(Be,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rn,{className:"h-5 w-5 text-amber-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.pending}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending"})]})]})})}),e.jsx(Ie,{children:e.jsx(Be,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ql,{className:"h-5 w-5 text-red-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.cancelled}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Cancelled"})]})]})})}),e.jsx(Ie,{children:e.jsx(Be,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_c,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:["$",d.totalDiscounts]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Discounts"})]})]})})})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"All Referrals"}),e.jsx(mr,{children:"View and manage all referral relationships"})]}),e.jsxs(Be,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(tn,{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(zs,{value:l,onValueChange:i,children:[e.jsx(Os,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"Filter by status"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Statuses"}),e.jsx(yt,{value:"pending",children:"Pending"}),e.jsx(yt,{value:"qualified",children:"Qualified"}),e.jsx(yt,{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(As,{children:[e.jsx(Nt,{children:"Referrer"}),e.jsx(Nt,{children:"Referred"}),e.jsx(Nt,{children:"Signup Date"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{children:"Qualified Date"}),e.jsx(Nt,{children:"Discount"})]})}),e.jsx(Pn,{children:y.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):y.map(b=>{var N,w,S,C;return e.jsxs(As,{children:[e.jsx(dt,{className:"font-medium",children:((N=b.referrer_brokerage)==null?void 0:N.name)||"Unknown"}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{children:((w=b.referred_brokerage)==null?void 0:w.name)||((S=b.referred_user)==null?void 0:S.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(C=b.referred_user)==null?void 0:C.email})]})}),e.jsx(dt,{children:gs(new Date(b.signup_date),"MMM d, yyyy")}),e.jsx(dt,{children:_(b.status)}),e.jsx(dt,{children:b.qualified_date?gs(new Date(b.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(dt,{children:b.discount_applied?e.jsx(Ye,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},b.id)})})]})]})]})]})})}const c0e=[{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"}],wbs=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function jbs(){const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(null),[d,u]=k.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});k.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:C,error:A}=await G.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(A)throw A;s(C||[])}catch(C){console.error("Error fetching checklist items:",C),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=C=>{i(C),u({title:C.title,description:C.description||"",action_type:C.action_type,target_role:C.target_role,is_active:C.is_active}),o(!0)},_=async()=>{if(!d.title.trim()){me.error("Title is required");return}try{if(l){const{error:C}=await G.from("onboarding_checklist_items").update({title:d.title,description:d.description||null,action_type:d.action_type,target_role:d.target_role,is_active:d.is_active}).eq("id",l.id);if(C)throw C;me.success("Checklist item updated")}else{const C=t.filter(I=>I.target_role===d.target_role).reduce((I,L)=>Math.max(I,L.sort_order),-1),{error:A}=await G.from("onboarding_checklist_items").insert({title:d.title,description:d.description||null,action_type:d.action_type,target_role:d.target_role,is_active:d.is_active,sort_order:C+1});if(A)throw A;me.success("Checklist item created")}o(!1),p()}catch(C){console.error("Error saving checklist item:",C),me.error("Failed to save checklist item")}},b=async C=>{if(confirm("Are you sure you want to delete this checklist item?"))try{const{error:A}=await G.from("onboarding_checklist_items").delete().eq("id",C);if(A)throw A;me.success("Checklist item deleted"),p()}catch(A){console.error("Error deleting checklist item:",A),me.error("Failed to delete checklist item")}},N=async C=>{try{const{error:A}=await G.from("onboarding_checklist_items").update({is_active:!C.is_active}).eq("id",C.id);if(A)throw A;me.success(C.is_active?"Item deactivated":"Item activated"),p()}catch(A){console.error("Error toggling item:",A),me.error("Failed to update item")}},w=t.filter(C=>C.target_role==="brokerage_manager"),S=t.filter(C=>C.target_role==="agent");return e.jsxs(Ls,{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(Bs,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Ye,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(Be,{children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{className:"w-12",children:"#"}),e.jsx(Nt,{children:"Title"}),e.jsx(Nt,{children:"Action Type"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:w.map((C,A)=>{var I;return e.jsxs(As,{children:[e.jsx(dt,{className:"text-muted-foreground",children:A+1}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:C.title}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:C.description})]})}),e.jsx(dt,{children:e.jsx(Ye,{variant:"outline",children:((I=c0e.find(L=>L.value===C.action_type))==null?void 0:I.label)||C.action_type})}),e.jsx(dt,{children:e.jsx(Lr,{checked:C.is_active,onCheckedChange:()=>N(C)})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(C),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(C.id),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Ye,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(Be,{children:S.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(As,{children:[e.jsx(Nt,{className:"w-12",children:"#"}),e.jsx(Nt,{children:"Title"}),e.jsx(Nt,{children:"Action Type"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:S.map((C,A)=>{var I;return e.jsxs(As,{children:[e.jsx(dt,{className:"text-muted-foreground",children:A+1}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:C.title}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:C.description})]})}),e.jsx(dt,{children:e.jsx(Ye,{variant:"outline",children:((I=c0e.find(L=>L.value===C.action_type))==null?void 0:I.label)||C.action_type})}),e.jsx(dt,{children:e.jsx(Lr,{checked:C.is_active,onCheckedChange:()=>N(C)})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(C),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(C.id),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]})]}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:l?"Edit Checklist Item":"Add Checklist Item"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"title",children:"Title *"}),e.jsx(Fe,{id:"title",value:d.title,onChange:C=>u({...d,title:C.target.value}),placeholder:"e.g., Watch your first academy video"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",value:d.description,onChange:C=>u({...d,description:C.target.value}),placeholder:"Optional description for the checklist item",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Target Role"}),e.jsxs(zs,{value:d.target_role,onValueChange:C=>u({...d,target_role:C}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:wbs.map(C=>e.jsx(yt,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Action Type"}),e.jsxs(zs,{value:d.action_type,onValueChange:C=>u({...d,action_type:C}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:c0e.map(C=>e.jsx(yt,{value:C.value,children:C.label},C.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{id:"is_active",checked:d.is_active,onCheckedChange:C=>u({...d,is_active:C})}),e.jsx(ge,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:_,children:l?"Save Changes":"Create Item"})]})]})})]})}function Nbs(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState("name"),[l,i]=k.useState("asc"),[d,u]=k.useState(""),[p,f]=k.useState(""),[y,_]=k.useState(""),[b,N]=k.useState(""),{data:w}=ft({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:V,error:ee}=await G.from("brokerages").select("id, name").order("name");if(ee)throw ee;return V}}),S=async V=>{let Z=[],J=0,Y=!0;for(;Y;){const{data:ce,error:ae}=await V(J,J+1e3-1);if(ae)throw ae;ce&&ce.length>0?(Z=[...Z,...ce],J+=1e3,Y=ce.length===1e3):Y=!1}return Z},{data:C,isLoading:A}=ft({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const V=await S((Ee,ve)=>G.from("profiles").select("id, name, email, brokerage_id, created_at").range(Ee,ve)),{data:ee}=await G.from("brokerages").select("id, name"),Z=new Map((ee==null?void 0:ee.map(Ee=>[Ee.id,Ee.name]))||[]),[{data:J},{data:Y},{data:ce},{data:ae},{data:ie},{data:le},{data:fe}]=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")]),xe=new Map;J==null||J.forEach(Ee=>xe.set(Ee.owner_user_id,Ee.contact_count));const he=new Map;Y==null||Y.forEach(Ee=>he.set(Ee.owner_user_id,Ee.video_count));const we=new Map;ce==null||ce.forEach(Ee=>we.set(Ee.owner_user_id,Ee.popby_count));const Ne=new Map;ae==null||ae.forEach(Ee=>Ne.set(Ee.agent_id,Ee.listing_count));const Ve=new Map;ie==null||ie.forEach(Ee=>Ve.set(Ee.owner_user_id,Ee.deal_count));const Te=new Map;le==null||le.forEach(Ee=>Te.set(Ee.owner_user_id,{total:Ee.portal_count,active:Ee.active_portal_count}));const Ae=new Map;return fe==null||fe.forEach(Ee=>Ae.set(Ee.owner_user_id,{total:Ee.card_count,sent:Ee.sent_card_count,views:Ee.total_card_views})),V.map(Ee=>{const ve=Te.get(Ee.id),Re=Ae.get(Ee.id);return{id:Ee.id,name:Ee.name||"Unknown",email:Ee.email||"",brokerage_id:Ee.brokerage_id,brokerage_name:Ee.brokerage_id&&Z.get(Ee.brokerage_id)||null,contact_count:xe.get(Ee.id)||0,video_count:he.get(Ee.id)||0,popby_count:we.get(Ee.id)||0,listing_count:Ne.get(Ee.id)||0,deal_count:Ve.get(Ee.id)||0,portal_count:(ve==null?void 0:ve.total)||0,active_portal_count:(ve==null?void 0:ve.active)||0,card_count:(Re==null?void 0:Re.total)||0,sent_card_count:(Re==null?void 0:Re.sent)||0,total_card_views:(Re==null?void 0:Re.views)||0,created_at:Ee.created_at}})}}),I=k.useMemo(()=>{if(!C)return[];let V=C.filter(ee=>{const Z=t.toLowerCase(),J=!t||ee.name.toLowerCase().includes(Z)||ee.email.toLowerCase().includes(Z),Y=r==="all"||r==="none"&&!ee.brokerage_id||ee.brokerage_id===r,ce=parseInt(d)||0,ae=parseInt(p)||0,ie=parseInt(y)||0,le=parseInt(b)||0,fe=ee.contact_count>=ce&&ee.video_count>=ae&&ee.popby_count>=ie&&ee.listing_count>=le;return J&&Y&&fe});return V.sort((ee,Z)=>{let J=0;return a==="name"?J=ee.name.localeCompare(Z.name):J=ee[a]-Z[a],l==="asc"?J:-J}),V},[C,t,r,a,l,d,p,y,b]),L=V=>{a===V?i(l==="asc"?"desc":"asc"):(o(V),i("desc"))},O=()=>{const V=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],ee=I.map(ae=>[ae.name,ae.email,ae.brokerage_name||"None",ae.contact_count,ae.video_count,ae.popby_count,ae.listing_count,ae.deal_count,`${ae.portal_count} (${ae.active_portal_count})`,ae.card_count,ae.sent_card_count,ae.total_card_views]),Z=[V.join(","),...ee.map(ae=>ae.map(ie=>`"${ie}"`).join(","))].join(` `),J=new Blob([Z],{type:"text/csv"}),Y=URL.createObjectURL(J),ce=document.createElement("a");ce.href=Y,ce.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,ce.click(),URL.revokeObjectURL(Y)},U=k.useMemo(()=>I.length?I.reduce((V,ee)=>({contacts:V.contacts+ee.contact_count,videos:V.videos+ee.video_count,popbys:V.popbys+ee.popby_count,listings:V.listings+ee.listing_count,deals:V.deals+ee.deal_count,portals:V.portals+ee.portal_count,activePortals:V.activePortals+ee.active_portal_count,cards:V.cards+ee.card_count,sentCards:V.sentCards+ee.sent_card_count,cardViews:V.cardViews+ee.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=k.useMemo(()=>I.length?{portals:I.filter(V=>V.portal_count>0).length,cards:I.filter(V=>V.card_count>0).length}:{portals:0,cards:0},[I]),$=({field:V,children:ee})=>e.jsx(Nt,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>L(V),children:e.jsxs("div",{className:"flex items-center gap-1",children:[ee,e.jsx(td,{className:`h-3 w-3 ${a===V?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(S1,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ie,{className:"border-blue-500/20 bg-gradient-to-br from-blue-500/5 to-transparent",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Kv,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),e.jsx(Be,{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:U.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:U.activePortals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Active Portals"})]})]})})]}),e.jsxs(Ie,{className:"border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-transparent",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(tr,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),e.jsx(Be,{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:U.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:U.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:U.cardViews}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Views"})]})]})})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(mr,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:O,children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),e.jsxs(Be,{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(tn,{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(zs,{value:r,onValueChange:n,children:[e.jsxs(Os,{children:[e.jsx(ma,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(qs,{placeholder:"Brokerage"})]}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Brokerages"}),e.jsx(yt,{value:"none",children:"No Brokerage"}),w==null?void 0:w.map(V=>e.jsx(yt,{value:V.id,children:V.name},V.id))]})]})}),e.jsx("div",{children:e.jsx(Fe,{type:"number",placeholder:"Min contacts",value:d,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:U.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:U.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:U.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:U.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:U.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:U.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:U.cards.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Cards"})]})]}),A?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(ps,{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(As,{children:[e.jsx($,{field:"name",children:"Name"}),e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{children:"Brokerage"}),e.jsx($,{field:"contact_count",children:"Contacts"}),e.jsx($,{field:"video_count",children:"Videos"}),e.jsx($,{field:"popby_count",children:"Popbys"}),e.jsx($,{field:"listing_count",children:"Listings"}),e.jsx($,{field:"deal_count",children:"Deals"}),e.jsx($,{field:"portal_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Kv,{className:"h-3 w-3 text-blue-500"}),"Portals"]})}),e.jsx($,{field:"card_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(tr,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(Pn,{children:I.length===0?e.jsx(As,{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(As,{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(Ye,{variant:"secondary",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx(Ye,{variant:V.contact_count>0?"default":"outline",children:V.contact_count})}),e.jsx(dt,{children:e.jsx(Ye,{variant:V.video_count>0?"default":"outline",children:V.video_count})}),e.jsx(dt,{children:e.jsx(Ye,{variant:V.popby_count>0?"default":"outline",children:V.popby_count})}),e.jsx(dt,{children:e.jsx(Ye,{variant:V.listing_count>0?"default":"outline",children:V.listing_count})}),e.jsx(dt,{children:e.jsx(Ye,{variant:V.deal_count>0?"default":"outline",children:V.deal_count})}),e.jsx(dt,{children:V.portal_count>0?e.jsxs(Jl,{children:[e.jsx(ec,{children:e.jsxs(Ye,{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(Il,{children:[e.jsxs("p",{children:[V.portal_count," total portals"]}),e.jsxs("p",{children:[V.active_portal_count," currently active"]})]})]}):e.jsx(Ye,{variant:"outline",children:"0"})}),e.jsx(dt,{children:V.card_count>0?e.jsxs(Jl,{children:[e.jsx(ec,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ye,{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(Nn,{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(jn,{className:"h-3 w-3"}),V.total_card_views]})]})}),e.jsxs(Il,{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(Ye,{variant:"outline",children:"0"})})]},V.id))})]})})]})]})]})})}function kbs(){va(),es();const[t,s]=k.useState("user-analytics"),{data:r}=ft({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}=ft({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}=ft({queryKey:["admin-action-types"],queryFn:async()=>{const{data:_,error:b}=await G.from("action_types").select("*").order("sort_order");if(b)throw b;return _}}),{data:i,isLoading:d}=ft({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}=ft({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}=ft({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(Ls,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(ta,{value:t,onValueChange:s,children:[e.jsxs(Qn,{className:"grid w-full grid-cols-9",children:[e.jsxs(ls,{value:"user-analytics",className:"gap-2",children:[e.jsx(so,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(ls,{value:"relationship-types",className:"gap-2",children:[e.jsx(cr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(ls,{value:"action-types",className:"gap-2",children:[e.jsx(Tn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(ls,{value:"scripts",className:"gap-2",children:[e.jsx(mn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(ls,{value:"video-scripts",className:"gap-2",children:[e.jsx(Ld,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(ls,{value:"plans",className:"gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(ls,{value:"popbys",className:"gap-2",children:[e.jsx(Vi,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(ls,{value:"settings",className:"gap-2",children:[e.jsx(So,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(ls,{value:"feature-flags",className:"gap-2",children:[e.jsx(Yv,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Flags"})]})]}),e.jsx(js,{value:"user-analytics",className:"mt-6",children:e.jsx(Nbs,{})}),e.jsx(js,{value:"relationship-types",className:"mt-6",children:e.jsx(Sbs,{types:n||[],isLoading:a})}),e.jsx(js,{value:"action-types",className:"mt-6",children:e.jsx(Cbs,{types:o||[],isLoading:l})}),e.jsx(js,{value:"scripts",className:"mt-6",children:e.jsx(Mbs,{scripts:i||[],actionTypes:o||[],isLoading:d})}),e.jsx(js,{value:"video-scripts",className:"mt-6",children:e.jsx(Pbs,{})}),e.jsx(js,{value:"plans",className:"mt-6",children:e.jsx(Tbs,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),e.jsx(js,{value:"popbys",className:"mt-6",children:e.jsx(Ebs,{items:f||[],isLoading:y})}),e.jsx(js,{value:"settings",className:"mt-6",children:e.jsx(Ibs,{})}),e.jsx(js,{value:"feature-flags",className:"mt-6",children:e.jsx(Abs,{flags:r||[]})})]})]})})}function Sbs({types:t,isLoading:s}){const{toast:r}=va(),n=es(),[a,o]=k.useState(null),[l,i]=k.useState(!1),d=Et({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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Relationship Types"}),e.jsx(mr,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),e.jsx(Be,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ps,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{className:"w-12"}),e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Description"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(p=>e.jsxs(As,{children:[e.jsx(dt,{children:e.jsx(uu,{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(Lr,{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(pa,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsxs(bs,{children:[a?"Edit":"Add"," Relationship Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);d.mutate({id:a==null?void 0:a.id,name:f.get("name"),description:f.get("description"),icon:f.get("icon")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{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(ge,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(ge,{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(gn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Cbs({types:t,isLoading:s}){const{toast:r}=va(),n=es(),[a,o]=k.useState(null),[l,i]=k.useState(!1),d=Et({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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Action Types"}),e.jsx(mr,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),e.jsx(Be,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ps,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Description"}),e.jsx(Nt,{children:"Color"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(p=>e.jsxs(As,{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(Lr,{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(pa,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsxs(bs,{children:[a?"Edit":"Add"," Action Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);d.mutate({id:a==null?void 0:a.id,name:f.get("name"),description:f.get("description"),icon:f.get("icon"),color:f.get("color")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{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(ge,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(ge,{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(ge,{htmlFor:"color",children:"Color"}),e.jsx(Fe,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(gn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Mbs({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=va(),a=es(),[o,l]=k.useState(null),[i,d]=k.useState(!1),u=Et({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"]}),d(!1),l(null),n({title:"Saved successfully"})},onError:f=>{n({title:"Error",description:f.message,variant:"destructive"})}}),p=Et({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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Script Library"}),e.jsx(mr,{children:"Create and manage scripts for each action type"})]}),e.jsxs(K,{onClick:()=>{l(null),d(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Be,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ps,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Title"}),e.jsx(Nt,{children:"Action Type"}),e.jsx(Nt,{children:"Tone"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(f=>{var y;return e.jsxs(As,{children:[e.jsx(dt,{className:"font-medium",children:f.title}),e.jsx(dt,{children:e.jsx(Ye,{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(Ye,{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),d(!0)},children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutate(f.id),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})]},f.id)})})]})}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ms,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsxs(bs,{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(ge,{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(ge,{htmlFor:"action_type_id",children:"Action Type"}),e.jsxs(zs,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select action type"})}),e.jsx(Fs,{children:s.map(f=>e.jsx(yt,{value:f.id,children:f.name},f.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{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(ge,{htmlFor:"script_body",children:"Script Body"}),e.jsx(_r,{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(gn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:u.isPending,children:[u.isPending&&e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Tbs({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=va(),o=es(),[l,i]=k.useState(null),[d,u]=k.useState(!1),[p,f]=k.useState(null),[y,_]=k.useState(!1),[b,N]=k.useState(null),[w,S]=k.useState(null),{data:C}=ft({queryKey:["plan-items",p],queryFn:async()=>{if(!p)return[];const{data:$,error:V}=await G.from("touchpoint_plan_items").select("*").eq("plan_id",p).order("month_number");if(V)throw V;return $},enabled:!!p}),A=Et({mutationFn:async $=>{if($.id){const{error:V}=await G.from("touchpoint_plans").update({name:$.name,description:$.description,active:$.active}).eq("id",$.id);if(V)throw V}else{const{error:V}=await G.from("touchpoint_plans").insert([{name:$.name,description:$.description,active:!0}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),u(!1),i(null),a({title:"Saved successfully"})},onError:$=>{a({title:"Error",description:$.message,variant:"destructive"})}}),I=Et({mutationFn:async $=>{if($.id){const{error:V}=await G.from("touchpoint_plan_items").update({action_type_id:$.action_type_id,default_script_id:$.default_script_id,notes:$.notes}).eq("id",$.id);if(V)throw V}else{const{error:V}=await G.from("touchpoint_plan_items").insert([{plan_id:$.plan_id,month_number:$.month_number,action_type_id:$.action_type_id,default_script_id:$.default_script_id,notes:$.notes}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]}),a({title:"Item saved"})}}),L=Et({mutationFn:async $=>{const{error:V}=await G.from("touchpoint_plan_items").delete().eq("id",$);if(V)throw V},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]})}}),O=Et({mutationFn:async $=>{const{data:V,error:ee}=await G.from("action_scripts").insert([{...$,active:!0}]).select().single();if(ee)throw ee;return V},onSuccess:async $=>{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:$.id}),_(!1),N(null),a({title:"Script created and assigned"})},onError:$=>{a({title:"Error",description:$.message,variant:"destructive"})}}),U=($,V,ee)=>{N({month:$,actionTypeId:V,itemId:ee}),_(!0)},q=$=>r.find(V=>V.id===$);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Touchpoint Plans"}),e.jsx(mr,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(K,{onClick:()=>{i(null),u(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),e.jsx(Be,{children:n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ps,{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($=>e.jsxs(Ie,{className:`cursor-pointer transition-colors ${p===$.id?"border-primary":""}`,onClick:()=>f($.id),children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ft,{className:"text-base",children:$.name}),e.jsx(K,{variant:"ghost",size:"icon",onClick:V=>{V.stopPropagation(),i($),u(!0)},children:e.jsx(pa,{className:"h-4 w-4"})})]})}),e.jsxs(Be,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:$.description}),e.jsx(Ye,{variant:$.active?"default":"secondary",className:"mt-2",children:$.active?"Active":"Inactive"})]})]},$.id))})})]}),p&&e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Plan Schedule"}),e.jsx(mr,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx(Be,{children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:12},($,V)=>V+1).map($=>{const V=C==null?void 0:C.find(J=>J.month_number===$),ee=V!=null&&V.default_script_id?q(V.default_script_id):null,Z=r.filter(J=>J.action_type_id===(V==null?void 0:V.action_type_id)&&J.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 ",$]}),e.jsxs(zs,{value:(V==null?void 0:V.action_type_id)||"none",onValueChange:J=>{J==="none"&&V?L.mutate(V.id):J!=="none"&&I.mutate({id:V==null?void 0:V.id,plan_id:p,month_number:$,action_type_id:J,default_script_id:null})},children:[e.jsx(Os,{className:"w-40",children:e.jsx(qs,{placeholder:"No action"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"No action"}),s.filter(J=>J.active).map(J=>e.jsx(yt,{value:J.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[J.color&&e.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:J.color}}),J.name]})},J.id))]})]}),V&&e.jsxs(e.Fragment,{children:[e.jsxs(zs,{value:V.default_script_id||"none",onValueChange:J=>{S(null),I.mutate({id:V.id,default_script_id:J==="none"?null:J})},children:[e.jsx(Os,{className:"w-56",children:e.jsx(qs,{placeholder:"Select script"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"No default script"}),Z.map(J=>e.jsxs(yt,{value:J.id,children:[J.title," ",J.tone&&`(${J.tone})`]},J.id))]})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>U($,V.action_type_id,V.id),children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"}),"New Script"]}),ee&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>S((w==null?void 0:w.id)===ee.id?null:ee),children:(w==null?void 0:w.id)===ee.id?"Hide":"Preview"})]})]}),w&&(V==null?void 0:V.default_script_id)===w.id&&e.jsxs("div",{className:"ml-24 p-3 bg-muted rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ye,{variant:"outline",children:w.title}),w.tone&&e.jsx(Ye,{variant:"secondary",children:w.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:w.script_body})]})]},$)})})})]}),e.jsx(fs,{open:d,onOpenChange:u,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsxs(bs,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),e.jsxs("form",{onSubmit:$=>{$.preventDefault();const V=new FormData($.currentTarget);A.mutate({id:l==null?void 0:l.id,name:V.get("name"),description:V.get("description"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{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(ge,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(gn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:A.isPending,children:[A.isPending&&e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(fs,{open:y,onOpenChange:_,children:e.jsxs(ms,{className:"max-w-2xl",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Create New Script"}),e.jsxs(Rr,{children:["Create a script for Month ",b==null?void 0:b.month,". Use ","{{FirstName}}",", ","{{LastName}}",", and ","{{AgentName}}"," as placeholders."]})]}),e.jsxs("form",{onSubmit:$=>{$.preventDefault();const V=new FormData($.currentTarget);O.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(ge,{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(ge,{htmlFor:"script_tone",children:"Tone"}),e.jsx(Fe,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"script_body",children:"Script Body"}),e.jsx(_r,{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(gn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:O.isPending,children:[O.isPending&&e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function Abs({flags:t}){const{toast:s}=va(),r=es(),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(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Feature Flags"}),e.jsx(mr,{children:"Control which features are enabled for members"})]}),e.jsx(Be,{children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Flag"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{children:"Notes"}),e.jsx(Nt,{children:"Last Updated"})]})}),e.jsx(Pn,{children:t.map(a=>e.jsxs(As,{children:[e.jsx(dt,{className:"font-mono text-sm",children:a.key}),e.jsx(dt,{children:e.jsx(Lr,{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 Ebs({items:t,isLoading:s}){const{toast:r}=va(),n=es(),[a,o]=k.useState(null),[l,i]=k.useState(!1),d=Et({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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Popby Ideas"}),e.jsx(mr,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsx(Be,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ps,{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(Vi,{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(As,{children:[e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Description"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(f=>e.jsxs(As,{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(Lr,{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(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p(f.id),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})})]},f.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsxs(bs,{children:[a?"Edit":"Add"," Popby Idea"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const y=new FormData(f.currentTarget);d.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(ge,{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(ge,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(gn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Pbs(){var _;const{toast:t}=va(),s=es(),[r,n]=k.useState(null),[a,o]=k.useState(!1),{data:l,isLoading:i}=ft({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:b,error:N}=await G.from("video_script_categories").select("*").order("sort_order");if(N)throw N;return b}}),{data:d,isLoading:u}=ft({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:b,error:N}=await G.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(N)throw N;return b}}),p=Et({mutationFn:async b=>{var N,w;if(b.id){const{error:S}=await G.from("video_scripts").update({title:b.title,script_text:b.script_text,category_id:b.category_id,tags:((N=b.tags)==null?void 0:N.split(",").map(C=>C.trim()).filter(Boolean))||[]}).eq("id",b.id);if(S)throw S}else{const{error:S}=await G.from("video_scripts").insert([{title:b.title,script_text:b.script_text,category_id:b.category_id||null,tags:((w=b.tags)==null?void 0:w.split(",").map(C=>C.trim()).filter(Boolean))||[]}]);if(S)throw S}},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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Video Scripts"}),e.jsx(mr,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(K,{onClick:()=>{n(null),o(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Be,{children:u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ps,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Title"}),e.jsx(Nt,{children:"Category"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:d==null?void 0:d.map(b=>{var N;return e.jsxs(As,{children:[e.jsx(dt,{className:"font-medium",children:b.title}),e.jsx(dt,{className:"text-muted-foreground",children:((N=b.category)==null?void 0:N.name)||"Uncategorized"}),e.jsx(dt,{children:e.jsx(Lr,{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(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(b.id),children:e.jsx(yr,{className:"h-4 w-4"})})]})]},b.id)})})]})}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ms,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsxs(bs,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault();const N=new FormData(b.currentTarget);p.mutate({id:r==null?void 0:r.id,title:N.get("title"),script_text:N.get("script_text"),category_id:N.get("category_id")||null,tags:N.get("tags")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{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(ge,{htmlFor:"category_id",children:"Category"}),e.jsxs(zs,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select category"})}),e.jsx(Fs,{children:l==null?void 0:l.map(b=>e.jsx(yt,{value:b.id,children:b.name},b.id))})]})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"script_text",children:"Script Text"}),e.jsx(_r,{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(ge,{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(gn,{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(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Ibs(){const{toast:t}=va(),[s,r]=k.useState(""),[n,a]=k.useState(!0),[o,l]=k.useState(!1);k.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(Ie,{children:e.jsx(Be,{className:"flex justify-center py-8",children:e.jsx(ps,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(La,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(mr,{children:"Configure the map feature for popbys"})]}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"mapbox-token",children:"Mapbox Public Token"}),e.jsx(Fe,{id:"mapbox-token",placeholder:"pk.eyJ1I...",value:s,onChange:d=>r(d.target.value)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token at"," ",e.jsx("a",{href:"https://mapbox.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"mapbox.com"}),". This token will be used by all agents for the popby map feature."]})]}),e.jsxs(K,{onClick:i,disabled:o,children:[o&&e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(Ye,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const Lbs=()=>{const[t,s]=k.useState(""),[r,n]=k.useState("grid"),a=br(),{data:o=[],isLoading:l}=ft({queryKey:["additional-services"],queryFn:async()=>{const{data:d,error:u}=await G.from("additional_services").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(u)throw u;return d}}),i=o.filter(d=>{var p;return d.name.toLowerCase().includes(t.toLowerCase())||((p=d.description)==null?void 0:p.toLowerCase().includes(t.toLowerCase()))});return e.jsx(Ls,{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(tn,{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:d=>s(d.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[t&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:r==="grid"?"secondary":"outline",size:"icon",onClick:()=>n("grid"),className:"rounded-full",children:e.jsx(pp,{className:"h-4 w-4"})}),e.jsx(K,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(Rh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," service",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(4)].map((d,u)=>e.jsx(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsx(Ss,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(Ss,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ss,{className:"h-4 w-full mb-4"})]})},u))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:t?"No services match your search":"No additional services available yet"}),t&&e.jsx(K,{variant:"outline",onClick:()=>s(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(d=>e.jsxs(Ie,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${r==="list"?"flex flex-row":""}`,onClick:()=>a(`/additional-services/${d.id}`),children:[e.jsx("div",{className:`relative overflow-hidden bg-muted ${r==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:d.preview_image_url?e.jsx("img",{src:d.preview_image_url,alt:d.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(qr,{className:"h-8 w-8"})})}),e.jsxs(Be,{className:`p-4 flex flex-col ${r==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:d.name}),d.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 flex-1",children:Jde(d.description)})]})]},d.id))})]})})},Dbs=()=>{const{serviceId:t}=ho(),s=br(),{data:r,isLoading:n}=ft({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(Ls,{title:"Loading...",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(Ss,{className:"h-8 w-48"}),e.jsx(Ss,{className:"h-64 w-full rounded-lg"}),e.jsx(Ss,{className:"h-24 w-full"})]})}):r?e.jsx(Ls,{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(Ra,{className:"h-4 w-4"}),"Back to Services"]}),e.jsx(Ie,{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(qr,{className:"h-16 w-16"})})})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:r.name}),e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(nn,{className:"h-4 w-4 mr-1"}),"Published ",gs(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(Kr,{className:"h-5 w-5"}),"Sign Up Now"]})})]})})]})}):e.jsx(Ls,{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(Ra,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},y6=[{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 Rbs(){const[t,s]=k.useState(y6[0].id),r=y6.find(n=>n.id===t)||y6[0];return e.jsx(Ls,{title:"AI Toolkit",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(bM,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"AI Toolkit"}),e.jsx("p",{className:"text-muted-foreground",children:"Powerful AI tools to boost your real estate business"})]})]}),e.jsx("div",{className:"md:hidden",children:e.jsxs(zs,{value:t,onValueChange:s,children:[e.jsx(Os,{className:"w-full",children:e.jsx(qs,{placeholder:"Select a tool"})}),e.jsx(Fs,{children:y6.map(n=>e.jsx(yt,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(ta,{value:t,onValueChange:s,className:"w-full",children:e.jsx(Qn,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:y6.map(n=>e.jsx(ls,{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 K7e="agent-os-onboarding-completed",v9=[{icon:Jy,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:Fh,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:cr,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:xd,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:Vi,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:so,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"]}],Obs=()=>{const[t,s]=k.useState(!1),[r,n]=k.useState(0),[a,o]=k.useState(!1);k.useEffect(()=>{if(!localStorage.getItem(K7e)){const b=setTimeout(()=>s(!0),500);return()=>clearTimeout(b)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):d()},i=()=>{d()},d=()=>{localStorage.setItem(K7e,"true"),s(!1)},u=v9[r],p=u.icon,f=r===v9.length-1,y=_=>{_||d(),s(_)};return e.jsx(fs,{open:t,onOpenChange:y,children:e.jsxs(ms,{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(qr,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(ks,{className:"text-center sm:text-center pb-2",children:[e.jsx(bs,{className:`text-2xl font-bold transition-all duration-300 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.title}),e.jsx(Rr,{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(ea,{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:v9.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}=$s();return ft({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})},zbs=()=>{const t=es(),{user:s}=$s();return Et({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=dl(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"]}),cn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{cn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},Bbs=()=>{const t=es();return Et({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"]}),cn({title:"Snooze cancelled"})},onError:s=>{cn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},$bs=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function kme({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=k.useState(null),l=zbs(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},d=u=>gs(dl(new Date,u),"MMM d, yyyy");return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(rn,{className:"h-5 w-5"}),"Snooze Touch"]}),e.jsxs(Rr,{children:["Postpone the next scheduled touch for ",n,". Select how long to snooze."]})]}),e.jsx("div",{className:"space-y-3 py-4",children:$bs.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:Rt("w-full flex items-center justify-between p-3 rounded-lg border transition-colors",a===u.days?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-accent/50"),children:[e.jsx("span",{className:"font-medium",children:u.label}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(nn,{className:"h-3.5 w-3.5"}),"Until ",d(u.days)]})]},u.days))}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const qbs={Crown:km,FileText:mn,Users:cr,Globe:gd,Star:Gn,Phone:Tn,MessageSquare:Si,PenTool:Pb,Video:hn,Gift:Vi};function Ubs({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=br(),[d,u]=k.useState("name"),[p,f]=k.useState("asc"),[y,_]=k.useState(null),[b,N]=k.useState(""),w=L=>{d===L?f(O=>O==="asc"?"desc":"asc"):(u(L),f("asc"))},S=k.useMemo(()=>[...t].sort((L,O)=>{var q,$;let U=0;switch(d){case"name":{const V=`${L.contact.first_name} ${L.contact.last_name||""}`.toLowerCase(),ee=`${O.contact.first_name} ${O.contact.last_name||""}`.toLowerCase();U=V.localeCompare(ee);break}case"relationship_type":U=(L.relationshipTypeName||"").localeCompare(O.relationshipTypeName||"");break;case"action_type":U=(((q=L.actionType)==null?void 0:q.name)||"").localeCompare((($=O.actionType)==null?void 0:$.name)||"");break;case"last_touch":U=(L.monthNumber||0)-(O.monthNumber||0);break}return p==="asc"?U:-U}),[t,d,p]),C=L=>qbs[L||"Phone"]||Tn,A=({field:L,children:O})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>w(L),children:[O,d===L?p==="asc"?e.jsx(cu,{className:"ml-2 h-4 w-4"}):e.jsx(Ih,{className:"ml-2 h-4 w-4"}):e.jsx(td,{className:"ml-2 h-4 w-4 opacity-50"})]}),I=(L,O,U)=>{_(L),N(`${O} ${U||""}`.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(As,{className:"bg-muted/50",children:[e.jsx(Nt,{className:"w-[180px]",children:e.jsx(A,{field:"name",children:"Contact"})}),e.jsx(Nt,{className:"w-[130px]",children:e.jsx(A,{field:"relationship_type",children:"Type"})}),e.jsx(Nt,{className:"w-[120px]",children:e.jsx(A,{field:"action_type",children:"Action"})}),e.jsx(Nt,{className:"w-[130px]",children:"Phone"}),e.jsx(Nt,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(Pn,{children:S.map((L,O)=>{var Z,J,Y,ce,ae,ie;const U=L.isSpecialDate,q=L.specialDateType,$=U?q==="birthday"?lh:Mn:C(((Z=L.actionType)==null?void 0:Z.icon)||null),V=L.contact.phone,ee=L.contact.email;return e.jsxs(As,{className:Rt("hover:bg-muted/50 transition-colors",U&&q==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",U&&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(Ye,{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:U?e.jsx(Ye,{className:Rt("gap-1",q==="birthday"&&"bg-pink-500 hover:bg-pink-600",q==="anniversary"&&"bg-purple-500 hover:bg-purple-600"),children:q==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(lh,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Mn,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx($,{className:"h-3 w-3"}),(J=L.actionType)==null?void 0:J.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(Tn,{className:"h-3.5 w-3.5"})}),V&&e.jsx("a",{href:a(L.contact.phone,(Y=L.script)==null?void 0:Y.script_body,L.contact),className:"p-1.5 rounded bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 transition-colors",title:"Text",children:e.jsx(Si,{className:"h-3.5 w-3.5"})}),ee&&(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(tr,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(L.contact.email,(ce=L.script)==null?void 0:ce.script_body,(ae=L.script)==null?void 0:ae.email_subject,(ie=L.actionType)==null?void 0:ie.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(tr,{className:"h-3.5 w-3.5"})})),U&&e.jsxs("button",{onClick:()=>{const le=`${L.contact.first_name}${L.contact.last_name?" "+L.contact.last_name:""}`,fe=q==="birthday"?"birthday":"home_anniversary",xe=new URLSearchParams({cardType:fe,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?${xe.toString()}`)},className:Rt("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(tr,{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(uh,{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(Hn,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${L.contact.id}-${O}`)})})]})}),e.jsx(kme,{open:!!y,onOpenChange:L=>!L&&_(null),contactId:y||"",contactName:b})]})}function bp(){const{data:t,isLoading:s}=ft({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 Vbs({onSelect:t}){const[s,r]=k.useState(null),{data:n=[],isLoading:a}=ft({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:d,error:u}=await G.from("email_template_categories").select("*").order("sort_order");if(u)throw u;return d}}),{data:o=[],isLoading:l}=ft({queryKey:["agent-email-templates",s],queryFn:async()=>{let d=G.from("agent_email_templates").select("*").eq("is_active",!0).order("sort_order");s&&(d=d.eq("category_id",s));const{data:u,error:p}=await d;if(p)throw p;return u}}),i=n.find(d=>d.id===s);return a?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(ps,{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(wl,{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(ps,{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(di,{className:"max-h-[280px]",children:e.jsx("div",{className:"space-y-1",children:o.map(d=>e.jsxs("button",{onClick:()=>t(d),className:"w-full p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium text-sm",children:d.title}),d.tone&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] shrink-0",children:d.tone})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:d.subject})]},d.id))})})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground px-1 mb-2",children:"Select a category"}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-1 pr-1",children:n.map(d=>e.jsxs("button",{onClick:()=>r(d.id),className:"w-full flex items-center justify-between p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-lg",children:d.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:d.name}),d.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:d.description})]})]}),e.jsx(ja,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},d.id))})]})}function WSe(){var a;const{user:t}=$s(),{data:s,isLoading:r}=ft({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,staleTime:60*1e3,queryFn:async()=>{var u,p,f,y;const[o,l]=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()]),i=o.data,d=l.data;return{reply_to_email:((u=i==null?void 0:i.reply_to_email)==null?void 0:u.trim())||((p=d==null?void 0:d.email)==null?void 0:p.trim())||t.email||null,display_name:((f=i==null?void 0:i.display_name)==null?void 0:f.trim())||((y=d==null?void 0:d.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}}function Sme(){const{user:t}=$s(),s=es(),{data:r,isLoading:n}=ft({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=Et({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=Et({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}=ft({queryKey:["contact-intake-submissions",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:u,error:p}=await G.from("contact_intake_submissions").select("*").eq("agent_user_id",t.id).order("created_at",{ascending:!1}).limit(100);if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),d=Et({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page. Create your Connect page first.");const{data:p,error:f}=await G.from("contact_intake_tokens").insert({contact_id:u,intake_page_id:r.id}).select("token").single();if(f)throw f;return`${window.location.origin}/connect/${r.slug}?t=${p.token}`}});return{intakePage:r,isLoading:n,createPage:a,updatePage:o,submissions:l,loadingSubmissions:i,generateUpdateLink:d}}const Hbs=5*1024*1024,gv=50,Gbs=["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 Wbs(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function Kbs(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 j_(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 E1({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const{user:d}=$s(),u=es(),{isReady:p,settings:f}=WSe(),{intakePage:y}=Sme(),_=y?`https://contacts.relevelup.com/${y.slug}`:null,b=!!n&&n.length>0,N=b&&p,w=b?n:r?[r]:[],S=w[0],C=b?Math.ceil(w.length/gv):1,A=b&&w.length>gv,[I,L]=k.useState((S==null?void 0:S.email)||""),[O,U]=k.useState(a),[q,$]=k.useState(o),[V,ee]=k.useState(!1),[Z,J]=k.useState(!1),[Y,ce]=k.useState([]),[ae,ie]=k.useState(a),[le,fe]=k.useState(o),[xe,he]=k.useState("composing"),[we,Ne]=k.useState(0),[Ve,Te]=k.useState(0),[Ae,ze]=k.useState(0),[Ee,ve]=k.useState(0),Re=k.useRef(!1),[Ue,ye]=k.useState(null);k.useEffect(()=>{t&&(L((S==null?void 0:S.email)||""),ie(a),fe(o),U(j_(a,S||{first_name:""})),$(j_(o,S||{first_name:""})),J(!a&&!o),ce([]),he("composing"),Ne(0),Te(0),ze(0),ve(0),Re.current=!1,ye(null))},[t,S,a,o]);const ct=async Ke=>{const He=Ke.target.files;if(!He)return;const gt=Y.reduce((Wt,xs)=>Wt+xs.size,0),Mt=[];for(const Wt of Array.from(He)){if(!Gbs.includes(Wt.type)){me.error(`${Wt.name}: Unsupported file type`);continue}if(gt+Wt.size>Hbs){me.error("Total attachments exceed 5MB limit");break}try{const xs=await Kbs(Wt);Mt.push({name:Wt.name,type:Wt.type,size:Wt.size,data:xs})}catch{me.error(`Failed to read ${Wt.name}`)}}ce(Wt=>[...Wt,...Mt]),Ke.target.value=""},pe=Ke=>{ce(He=>He.filter((gt,Mt)=>Mt!==Ke))},Ge=Ke=>{ie(Ke.subject),fe(Ke.body),U(j_(Ke.subject,S||{first_name:""})),$(j_(Ke.body,S||{first_name:""})),J(!1)},tt=Ke=>Ke.split(/\n\n+/).map(He=>`

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

`).join(""),st=async Ke=>{const He=j_(ae,Ke),gt=j_(le,Ke),Mt=tt(gt);try{if(N){const Wt=(f==null?void 0:f.display_name)||"ReLevelUp",xs=`${Wt.toLowerCase().replace(/[^a-z]/g,".")}@send.relevelup.com`,Cs=`${Wt} <${xs}>`,{data:Us,error:Ar}=await G.functions.invoke("ses-send-campaign",{body:{action:"test_send",to:Ke.email,from_email:Cs,subject:He,body_html:Mt,reply_to:(f==null?void 0:f.reply_to_email)||void 0}});if(Ar)throw Ar;if(!(Us!=null&&Us.success))throw new Error((Us==null?void 0:Us.error)||"Failed to send")}else{const{data:Wt,error:xs}=await G.functions.invoke("gmail-send",{body:{to:Ke.email,subject:He,body:Mt,contactId:Ke.id,attachments:Y.map(({name:Cs,type:Us,data:Ar})=>({name:Cs,type:Us,data:Ar}))}});if(xs)throw xs;if(!(Wt!=null&&Wt.success))throw new Error((Wt==null?void 0:Wt.error)||"Failed to send")}return d&&await G.from("bulk_email_sends").insert({user_id:d.id,contact_id:Ke.id,contact_email:Ke.email,subject:He,source:N?"ses_bulk":"sphere_gaps"}),!0}catch(Wt){return console.error("Send error:",Wt),me.error("Failed to send to "+Ke.first_name+": "+(Wt instanceof Error?Wt.message:"Unknown error")),!1}},Ce=()=>{const Ke=we*gv;return w.slice(Ke,Ke+gv)},et=async()=>{if(!O||!q){me.error("Please fill in subject and message");return}const Ke=Ce();ee(!0),he("sending");let He=0,gt=0;for(let Wt=0;WtsetTimeout(Cs,150));Te(Wt=>Wt+He),ze(Wt=>Wt+gt),ee(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),we>=C-1||Re.current?he("all_done"):he("batch_complete")},Ct=async()=>{if(!O||!q){me.error("Please fill in subject and message");return}if(!b){ee(!0);const Ke=await st(S);ee(!1),Ke&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),me.success("Email sent successfully!"),s(!1),i==null||i());return}await et()},Ot=async()=>{Ne(Ke=>Ke+1),ve(0),await new Promise(Ke=>setTimeout(Ke,50)),await et()};k.useEffect(()=>{},[we]);const ut=()=>{if(V){Re.current=!0;return}s(!1),i==null||i()},Oe=we*gv,Xe=Math.min(Oe+gv,w.length),at=b&&w.length>0?Math.round((Ve+Ae)/w.length*100):0;return e.jsx(fs,{open:t,onOpenChange:ut,children:e.jsxs(ms,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:`h-5 w-5 ${N?"text-orange-500":"text-red-500"}`}),b?`Send to ${w.length} Contacts`:"Compose Email"]}),N?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,b&&xe==="composing"&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Composing email for ",e.jsxs("span",{className:"font-medium",children:[w.length," contacts"]}),". You'll review each personalized email before sending."]})]}),xe==="sending"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(ps,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending batch ",we+1," of ",C,"..."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Ee," of ",Ce().length," in this batch"]})]}),e.jsx(pi,{value:Ee/Ce().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",Ve+Ae," / ",w.length]}),e.jsxs("span",{children:[Ve," sent • ",Ae," failed"]})]}),e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{Re.current=!0},children:"Stop Sending"})]}),xe==="batch_complete"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(Hn,{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:[Ve," sent, ",Ae," failed so far"]})]}),e.jsx(pi,{value:at,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[w.length-Ve-Ae," contacts remaining (",C-we-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:ut,children:"Done for Now"}),e.jsxs(K,{className:"flex-1 gap-2",onClick:Ot,children:[e.jsx(Nn,{className:"h-4 w-4"}),"Send Next ",Math.min(gv,w.length-Xe)," Contacts"]})]})]}),xe==="all_done"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(Hn,{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:[Ve," emails sent successfully",Ae>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",Ae," failed"]})]})]}),e.jsx(K,{className:"w-full",onClick:ut,children:"Close"})]}),xe==="composing"&&e.jsxs("div",{className:"space-y-4",children:[Z?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(mn,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>J(!1),className:"h-7 px-2 text-xs",children:[e.jsx(Sr,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(Vbs,{onSelect:Ge})]}):e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>J(!0),children:[e.jsx(mn,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(jo,{}),!b&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{htmlFor:"gmail-to",children:"To"}),e.jsx(Fe,{id:"gmail-to",value:I,onChange:Ke=>L(Ke.target.value),placeholder:"recipient@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{htmlFor:"gmail-subject",children:"Subject"}),e.jsx(Fe,{id:"gmail-subject",value:O,onChange:Ke=>{U(Ke.target.value),ie(Ke.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(ge,{htmlFor:"gmail-body",children:"Message"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Ye,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{$(Ke=>Ke+"{{first_name}}"),fe(Ke=>Ke+"{{first_name}}")},children:"{{first_name}}"}),e.jsx(Ye,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{$(Ke=>Ke+"{{last_name}}"),fe(Ke=>Ke+"{{last_name}}")},children:"{{last_name}}"}),_&&e.jsx(Ye,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-primary/10 border-primary/40 text-primary",onClick:()=>{const Ke=` When you get a sec, can you share your latest contact info with me? It only takes about a minute: ${_} `;$(He=>He+Ke),fe(He=>He+Ke)},title:"Insert your Connect Page link",children:"+ Connect Page"})]})]}),e.jsx(_r,{id:"gmail-body",value:q,onChange:Ke=>{$(Ke.target.value),fe(Ke.target.value)},placeholder:"Write your message...",rows:10,className:"resize-y"}),b&&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 Ke;return(Ke=document.getElementById("gmail-attachments"))==null?void 0:Ke.click()},disabled:V,children:[e.jsx(fS,{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})]}),Y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:Y.map((Ke,He)=>e.jsxs(Ye,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(fS,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[140px] truncate text-xs",children:Ke.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",Wbs(Ke.size),")"]}),e.jsx("button",{type:"button",onClick:()=>pe(He),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Sr,{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"}),b?e.jsxs(K,{onClick:()=>{ye(w[0]||null),he("reviewing")},disabled:!O||!q,className:"gap-2",children:["Review Emails",e.jsx(ti,{className:"h-4 w-4"})]}):e.jsxs(K,{onClick:Ct,disabled:V||!O||!q,className:"gap-2",children:[V?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(Nn,{className:"h-4 w-4"}),V?"Sending...":"Send Email"]})]})]}),xe==="reviewing"&&b&&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."]}),A&&e.jsxs("p",{className:"text-xs text-amber-600 bg-amber-500/10 rounded-md px-2.5 py-1.5",children:["📦 ",w.length," contacts will be sent in ",C," batches of up to ",gv,". You'll confirm before each batch."]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ge,{children:["Recipients (",w.length,")"]}),e.jsx("div",{className:"bg-muted p-1.5 rounded-md space-y-0.5 max-h-32 overflow-y-auto",children:w.map(Ke=>e.jsxs("div",{className:`text-sm px-2 py-1 rounded cursor-pointer transition-colors ${(Ue==null?void 0:Ue.id)===Ke.id?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>ye(Ke),children:[Ke.first_name," ",Ke.last_name," — ",Ke.email]},Ke.id))})]}),Ue&&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(tr,{className:"h-3.5 w-3.5"}),"Preview for ",Ue.first_name," ",Ue.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:"})," ",Ue.email]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Subject:"})," ",j_(ae,Ue)]})]}),e.jsx(jo,{}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-background rounded p-2.5 max-h-40 overflow-y-auto border",children:j_(le,Ue)})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>{he("composing"),ye(null)},children:[e.jsx(Ra,{className:"h-4 w-4 mr-1"}),"Back to Edit"]}),e.jsxs(K,{onClick:Ct,disabled:V,className:"gap-2",children:[V?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(Nn,{className:"h-4 w-4"}),A?`Send First ${gv}`:`Send to ${w.length}`]})]})]})]})})}function Zbs(){const t=br(),{data:s}=Uh(),{data:r}=KR(),n=ahe(),{isGmailConnected:a,gmailEmail:o}=bp(),[l,i]=k.useState(null),[d,u]=k.useState(!1),[p,f]=k.useState(new Set),y=Am(new Date),_=dl(y,30),b=I=>{if(!I)return null;const L=I.split(/[-/T]/);if(L.length<3)return null;const O=parseInt(L[1],10)-1,U=parseInt(L[2],10);return isNaN(O)||isNaN(U)?null:new Date(y.getFullYear(),O,U)},N=k.useMemo(()=>{if(!s)return[];const I=[];for(const L of s){if(L.birthday){const O=b(L.birthday);O&&(rl(O,y)||YS(O,y)&&XS(O,_))&&I.push({contact:L,type:"birthday",date:O,daysUntil:nf(O,y),dateStr:L.birthday})}if(L.home_anniversary){const O=b(L.home_anniversary);O&&(rl(O,y)||YS(O,y)&&XS(O,_))&&I.push({contact:L,type:"anniversary",date:O,daysUntil:nf(O,y),dateStr:L.home_anniversary})}}return I.sort((L,O)=>L.daysUntil-O.daysUntil),I},[s]),w=async I=>{const L=(r==null?void 0:r.find(O=>O.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(O=>new Set(O).add(`${I.contact.id}-${I.type}`)),cn({title:"Touch logged!",description:`Logged outreach for ${I.contact.first_name}`})}catch{cn({title:"Error",description:"Failed to log touch",variant:"destructive"})}},S=I=>{const L=`${I.contact.first_name}${I.contact.last_name?" "+I.contact.last_name:""}`,O=I.type==="birthday"?"birthday":"home_anniversary",U=new URLSearchParams({cardType:O,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?${U.toString()}`)},C=I=>I===0?"Today!":I===1?"Tomorrow":`${I} days`,A=I=>I===0?"bg-red-500/15 text-red-600 dark:text-red-400 border-red-500/30":I<=3?"bg-amber-500/15 text-amber-600 dark:text-amber-400 border-amber-500/30":I<=7?"bg-blue-500/15 text-blue-600 dark:text-blue-400 border-blue-500/30":"bg-muted text-muted-foreground border-border";return e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(xd,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(Ye,{variant:"secondary",className:"text-xs font-normal",children:"Next 30 days"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[N.length," event",N.length!==1?"s":""]})]})}),e.jsxs(Be,{className:"space-y-2",children:[N.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(lh,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No birthdays or anniversaries in the next 30 days."}),e.jsx("p",{className:"text-xs mt-1",children:"Add dates to your contacts to see upcoming milestones here."})]}),N.map((I,L)=>{var $,V;const O=`${I.contact.id}-${I.type}`,U=p.has(O),q=`${(($=I.contact.first_name)==null?void 0:$[0])||""}${((V=I.contact.last_name)==null?void 0:V[0])||""}`.toUpperCase();return e.jsxs("div",{className:Rt("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(vn,{className:Rt("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(_n,{className:Rt("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(Ye,{variant:"outline",className:Rt("text-[10px] shrink-0 whitespace-nowrap",A(I.daysUntil)),children:C(I.daysUntil)})]}),e.jsxs("div",{className:Rt("text-xs flex items-center gap-1.5 mt-0.5",I.type==="birthday"?"text-pink-600/80 dark:text-pink-400/80":"text-blue-600/80 dark:text-blue-400/80"),children:[I.type==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(lh,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Mn,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:gs(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(Tn,{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(Si,{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(tr,{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(hn,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("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:()=>S(I),children:[e.jsx(qr,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:Rt("h-7 w-7",U&&"text-green-600"),title:"Log a touch",disabled:U||n.isPending,onClick:()=>w(I),children:e.jsx(Hn,{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(jn,{className:"h-3.5 w-3.5"})})]})]},`${O}-${L}`)})]})]}),a&&l&&e.jsx(E1,{open:d,onOpenChange:u,contact:l,gmailEmail:o})]})}function Ybs(t){const[s,r]=k.useState([]),[n,a]=k.useState(!1),{data:o,isLoading:l}=ft({queryKey:["active-visitors",t],queryFn:async()=>{if(!t)return[];try{await G.rpc("cleanup_stale_visitors")}catch{}const{data:p}=await G.from("lead_site_active_visitors").select("*").eq("lead_site_id",t).gte("last_seen_at",new Date(Date.now()-2*60*1e3).toISOString()).order("last_seen_at",{ascending:!1});if(!p)return[];const f=p.map(b=>b.contact_id).filter(Boolean);let y={};if(f.length>0){const{data:b}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",f);(b||[]).forEach(N=>{y[N.id]=N})}const _=p.map(b=>b.auth_user_id).filter(Boolean);if(_.length>0){const{data:b}=await G.from("lead_site_consumer_profiles").select("user_id, name, phone, contact_id").eq("lead_site_id",t).in("user_id",_);(b||[]).forEach(N=>{const w=p.find(S=>S.auth_user_id===N.user_id);w&&!w.contact_id&&N.contact_id&&(w.contact_id=N.contact_id),w&&!y[w.contact_id||""]&&N.name&&(y[w.contact_id||w.auth_user_id||""]={first_name:N.name.split(" ")[0],last_name:N.name.split(" ").slice(1).join(" ")||null,email:null,phone:N.phone})})}return p.map(b=>{var N,w;return{...b,contact_name:y[b.contact_id||b.auth_user_id||""]?`${y[b.contact_id||b.auth_user_id||""].first_name} ${y[b.contact_id||b.auth_user_id||""].last_name||""}`.trim():null,contact_email:((N=y[b.contact_id||b.auth_user_id||""])==null?void 0:N.email)||null,contact_phone:((w=y[b.contact_id||b.auth_user_id||""])==null?void 0:w.phone)||null}})},enabled:!!t,refetchInterval:6e4});k.useEffect(()=>{if(!t)return;const p=G.channel(`active-visitors-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"lead_site_active_visitors",filter:`lead_site_id=eq.${t}`},f=>{f.eventType==="INSERT"?r(y=>y.find(b=>b.id===f.new.id)?y:[f.new,...y]):f.eventType==="UPDATE"?r(y=>y.map(_=>_.id===f.new.id?{..._,...f.new}:_)):f.eventType==="DELETE"&&r(y=>y.filter(_=>_.id!==f.old.id))}).subscribe(f=>{f==="SUBSCRIBED"&&a(!0)});return()=>{G.removeChannel(p)}},[t]);const i=n&&s.length>0?Xbs([...s,...o||[]]):o||[],d=Date.now(),u=i.filter(p=>d-new Date(p.last_seen_at).getTime()<2*60*1e3);return{activeVisitors:u,isLoading:l,count:u.length}}function Xbs(t){const s=new Set;return t.filter(r=>s.has(r.id)?!1:(s.add(r.id),!0))}const Qbs={property_view:{label:"Viewed",icon:jn,color:"text-blue-500",bgColor:"bg-blue-500/10"},new_lead:{label:"New Lead",icon:il,color:"text-emerald-500",bgColor:"bg-emerald-500/10"},saved_listing:{label:"Saved",icon:Za,color:"text-rose-500",bgColor:"bg-rose-500/10"}};function Jbs(){const{user:t}=$s(),s=br(),{isGmailConnected:r,gmailEmail:n}=bp(),{leadSite:a}=QA(),{count:o}=Ybs(a==null?void 0:a.id),[l,i]=k.useState(!1),[d,u]=k.useState(null),{data:p,isLoading:f}=ft({queryKey:["lead-site-activity",t==null?void 0:t.id],queryFn:async()=>{const{data:S,error:C}=await G.rpc("get_lead_site_activity",{_user_id:t.id});if(C)throw C;return S},enabled:!!t,refetchInterval:6e4});if(f||!(p!=null&&p.has_site))return null;const y=(p.activities||[]).filter(S=>S.visitor_name&&S.visitor_name!=="Site Visitor"),_=y.filter(S=>S.activity_type==="new_lead"),b=(p.activities||[]).filter(S=>S.activity_type==="property_view").length,N=(p.activities||[]).filter(S=>S.activity_type==="saved_listing").length,w=S=>{if(S.visitor_email)if(r){const C=(S.visitor_name||"").split(" ");u({id:S.contact_id||"",first_name:C[0]||"",last_name:C.slice(1).join(" ")||null,email:S.visitor_email}),i(!0)}else window.location.href=`mailto:${S.visitor_email}`};return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-primary/10 rounded-lg",children:e.jsx(gd,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Website Activity"}),o>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 text-[11px] font-semibold",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-emerald-500"})]}),o," Live"]})]})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"text-primary gap-1",onClick:()=>s("/mission-control/website-activity"),children:["View All",e.jsx(ti,{className:"h-4 w-4"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-emerald-500/5 border border-emerald-200 dark:border-emerald-800",children:[e.jsx(il,{className:"h-4 w-4 text-emerald-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-emerald-600 dark:text-emerald-400",children:_.length}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"New Leads"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-blue-500/5 border border-blue-200 dark:border-blue-800",children:[e.jsx(jn,{className:"h-4 w-4 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-blue-600 dark:text-blue-400",children:b}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Views"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-rose-500/5 border border-rose-200 dark:border-rose-800",children:[e.jsx(Za,{className:"h-4 w-4 text-rose-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-rose-600 dark:text-rose-400",children:N}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Saved"})]})]})]}),y.length>0?e.jsxs("div",{className:"space-y-2",children:[y.slice(0,5).map((S,C)=>{const A=Qbs[S.activity_type],I=A.icon,L=jl(new Date(S.occurred_at),{addSuffix:!0});return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:shadow-sm transition-shadow",children:[e.jsx("div",{className:`p-1.5 rounded-md ${A.bgColor}`,children:e.jsx(I,{className:`h-3.5 w-3.5 ${A.color}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("button",{className:"font-medium text-sm text-primary hover:underline text-left truncate block",onClick:()=>{S.contact_id&&s(`/mission-control/contacts/${S.contact_id}`)},children:S.visitor_name}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:A.label}),S.mls_number&&e.jsxs("span",{children:["· MLS# ",S.mls_number]}),S.lead_type&&e.jsxs("span",{children:["· ",S.lead_type]}),e.jsxs("span",{children:["· ",L]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[S.visitor_email&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>w(S),children:e.jsx(tr,{className:"h-3.5 w-3.5"})}),S.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`tel:${S.visitor_phone}`,children:e.jsx(Tn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`sms:${S.visitor_phone}`,children:e.jsx(Si,{className:"h-3.5 w-3.5"})})]}),S.contact_id&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>s(`/mission-control/contacts/${S.contact_id}`),children:e.jsx(ja,{className:"h-3.5 w-3.5"})})]})]},`${S.activity_type}-${S.occurred_at}-${C}`)}),y.length>5&&e.jsxs(K,{variant:"outline",className:"w-full text-xs",onClick:()=>s("/mission-control/website-activity"),children:["View ",y.length-5," more activities",e.jsx(ti,{className:"h-3.5 w-3.5 ml-1"})]})]}):e.jsx(Ie,{children:e.jsxs(Be,{className:"p-6 text-center",children:[e.jsx(ih,{className:"h-8 w-8 text-muted-foreground/30 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No actionable website activity yet."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:b>0?`${b} anonymous listing views recorded.`:"Lead engagement will appear here as visitors interact with your site."}),e.jsxs(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>s("/mission-control/website-activity"),children:["View Full Activity",e.jsx(ti,{className:"h-3.5 w-3.5 ml-1"})]})]})}),r&&d&&e.jsx(E1,{open:l,onOpenChange:i,contact:d,gmailEmail:n})]})}const Z7e={Crown:km,FileText:mn,Users:cr,Globe:gd,Star:Gn,Phone:Tn,MessageSquare:Si,PenTool:Pb,Video:hn,Gift:Vi},ews={"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 tws(){var Ct,Ot,ut,Oe,Xe,at;const t=br(),{user:s}=$s(),{data:r}=Mf(),{data:n}=IXe(),{data:a}=Uh(),{data:o}=KR(),{data:l}=FXe(),i=U8t(),d=xke(),u=$8t(90),p=ahe(),[f,y]=k.useState(null),[_,b]=k.useState(null),[N,w]=k.useState(!1),[S,C]=k.useState(""),[A,I]=k.useState(!1),[L,O]=k.useState(""),[U,q]=k.useState(ble()),[$,V]=k.useState("cards"),[ee,Z]=k.useState(!1),[J,Y]=k.useState(null),[ce,ae]=k.useState(null),[ie,le]=k.useState(""),{isGmailConnected:fe,gmailEmail:xe}=bp(),he=()=>{const Ke=parseInt(L,10);if(isNaN(Ke)||Ke<1){cn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}q(Ke),OXe(Ke),I(!1),cn({title:"Goal updated",description:`Weekly touch goal set to ${Ke}`})},we=()=>{O(U.toString()),I(!0)};k.useEffect(()=>{(async()=>{if(!(s!=null&&s.id))return;const{data:He}=await G.from("profiles").select("name").eq("id",s.id).single();He!=null&&He.name&&C(He.name.split(" ")[0])})()},[s==null?void 0:s.id]),k.useEffect(()=>{i.mutate()},[]);const Ne=Am(new Date),Ve=dl(Ne,7),Te=Ke=>{if(!Ke)return null;const He=Ke.split(/[-/T]/);if(He.length<3)return null;const gt=parseInt(He[1],10)-1,Mt=parseInt(He[2],10);return isNaN(gt)||isNaN(Mt)?null:new Date(Ne.getFullYear(),gt,Mt)},Ae=(a==null?void 0:a.filter(Ke=>{const He=Te(Ke.birthday),gt=Te(Ke.home_anniversary);return He&&rl(He,Ne)||gt&&rl(gt,Ne)}))||[];a!=null&&a.filter(Ke=>{if(!Ke.birthday&&!Ke.home_anniversary)return!1;const He=gt=>{if(!gt)return!1;const Mt=Te(gt);return Mt?YS(Mt,Ne)&&XS(Mt,Ve):!1};return He(Ke.birthday)||He(Ke.home_anniversary)}).slice(0,5);const ze=[],Ee=(o==null?void 0:o.find(Ke=>Ke.name==="Call"))||(o==null?void 0:o[0]);for(const Ke of Ae){const He=Te(Ke.birthday),gt=Te(Ke.home_anniversary),Mt=He&&rl(He,Ne),Wt=gt&&rl(gt,Ne);Mt&&ze.push({contact:Ke,actionType:Ee||{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:((ut=(Ot=(Ct=Ke.tags)==null?void 0:Ct[0])==null?void 0:Ot.relationship_type)==null?void 0:ut.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),Wt&&ze.push({contact:Ke,actionType:Ee||{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:((at=(Xe=(Oe=Ke.tags)==null?void 0:Oe[0])==null?void 0:Xe.relationship_type)==null?void 0:at.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const Re=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((Ke,He)=>{var Mt,Wt,xs;const gt=o==null?void 0:o[He%((o==null?void 0:o.length)||1)];return gt?{contact:Ke,actionType:gt,planName:"Quick Touch",relationshipTypeName:((xs=(Wt=(Mt=Ke.tags)==null?void 0:Mt[0])==null?void 0:Wt.relationship_type)==null?void 0:xs.name)||"",monthNumber:0}:null}).filter(Boolean))||[],Ue=[...ze,...Re],ye=async(Ke,He,gt)=>{await p.mutateAsync({contactId:Ke,actionTypeId:He,scriptUsedId:gt}),w(!1),b(null)},ct=Ke=>{Ke.script?(b(Ke),w(!0)):ye(Ke.contact.id,Ke.actionType.id)},pe=Ke=>Z7e[Ke||"Phone"]||Tn,Ge=Ke=>Z7e[Ke||"Users"]||cr,tt=(Ke,He)=>Ke.replace(/\{\{FirstName\}\}/g,He.first_name).replace(/\{\{LastName\}\}/g,He.last_name||"").replace(/\{\{AgentName\}\}/g,S||"there"),st=(Ke,He)=>({Call:`Thinking of you, ${He}!`,Text:`Quick hello, ${He}`,Email:`Checking in, ${He}`,"Handwritten Note":`A note for ${He}`,Video:`Video message for ${He}`,Gift:`Something special for you, ${He}`})[Ke]||`Hello ${He}!`,Ce=(Ke,He,gt)=>{const Mt=`sms:${Ke}`;if(He&>){const Wt=tt(He,gt);return`${Mt}?body=${encodeURIComponent(Wt)}`}return Mt},et=(Ke,He,gt,Mt,Wt)=>{const xs=`mailto:${Ke}`,Cs=[];if(Wt){const Us=gt||st(Mt||"Email",Wt.first_name);if(Cs.push(`subject=${encodeURIComponent(Us)}`),He){const Ar=tt(He,Wt);Cs.push(`body=${encodeURIComponent(Ar)}`)}}return Cs.length>0?`${xs}?${Cs.join("&")}`:xs};return e.jsxs(e.Fragment,{children:[e.jsxs(Ls,{title:"Mission Control",description:"Your relationship-first contact system",children:[e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Mission Control"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsx(Jbs,{}),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(Ke=>Ke.active).map(Ke=>{const He=Ge(Ke.icon),gt=(n==null?void 0:n[Ke.id])||0,Mt=f===Ke.id,Wt=ews[Ke.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{Mt?(y(null),t("/mission-control/contacts")):(y(Ke.id),t(`/mission-control/contacts?type=${Ke.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${Mt?Wt:"bg-card hover:bg-accent"} `,children:[e.jsx(He,{className:"h-5 w-5"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:Ke.name}),e.jsxs("div",{className:`text-sm ${Mt?"opacity-90":"text-muted-foreground"}`,children:[gt," Contacts"]})]})]},Ke.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(Ld,{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(ja,{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(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(qr,{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:$==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("cards"),title:"Card view",children:e.jsx(pp,{className:"h-4 w-4"})}),e.jsx(K,{variant:$==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("table"),title:"Table view",children:e.jsx(Rh,{className:"h-4 w-4"})})]})]}),e.jsx(Ie,{children:e.jsx(Be,{className:"p-4",children:Ue.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"})]}):$==="table"?e.jsx(Ubs,{actions:Ue,onMarkComplete:ye,onViewScript:ct,isLoading:p.isPending,buildSmsLink:Ce,buildEmailLink:et,onGmailCompose:fe?Ke=>{Y(Ke),Z(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[Ue.map((Ke,He)=>{var Bt,Xs,Nr,Vs,ar,Or,Rn;const gt=Ke.isSpecialDate,Mt=Ke.specialDateType,Wt=gt?Mt==="birthday"?lh:Mn:pe(((Bt=Ke.actionType)==null?void 0:Bt.icon)||null),xs=Ke.contact.phone,Cs=Ke.contact.email,Us=gt?Mt==="birthday"?"#EC4899":"#8B5CF6":((Xs=Ke.actionType)==null?void 0:Xs.color)||"#3B82F6",Ar=gt?Mt==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(Nr=Ke.actionType)==null?void 0:Nr.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${gt?"ring-2 ring-offset-2":""}`,style:gt?{"--tw-ring-color":Us}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:Us},children:[e.jsx(Wt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:Ar})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${Ke.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[Ke.contact.first_name," ",Ke.contact.last_name]}),e.jsxs("div",{className:"flex gap-1.5",children:[xs&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${Ke.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(Tn,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:Ce(Ke.contact.phone,(Vs=Ke.script)==null?void 0:Vs.script_body,Ke.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(Si,{className:"h-3 w-3"}),"Text"]})]}),Cs&&(fe?e.jsxs("button",{onClick:()=>{Y({id:Ke.contact.id,first_name:Ke.contact.first_name,last_name:Ke.contact.last_name,email:Ke.contact.email}),Z(!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(tr,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:et(Ke.contact.email,(ar=Ke.script)==null?void 0:ar.script_body,(Or=Ke.script)==null?void 0:Or.email_subject,(Rn=Ke.actionType)==null?void 0:Rn.name,Ke.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(tr,{className:"h-3 w-3"}),"Email"]}))]}),gt&&e.jsxs("button",{onClick:()=>{const bn=`${Ke.contact.first_name}${Ke.contact.last_name?" "+Ke.contact.last_name:""}`,ir=Mt==="birthday"?"birthday":"home_anniversary",or=new URLSearchParams({cardType:ir,contactId:Ke.contact.id,name:bn,...Ke.contact.address?{address:Ke.contact.address}:{},...Mt==="anniversary"&&Ke.contact.home_anniversary?{date:Ke.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${or.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(tr,{className:"h-3 w-3"}),"Send ",Mt==="birthday"?"Birthday":"Anniversary"," Card"]}),!xs&&!Cs&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[Ke.relationshipTypeName&&e.jsx(Ye,{variant:"secondary",className:"text-xs",children:Ke.relationshipTypeName}),Ke.monthNumber>0&&e.jsxs(Ye,{variant:"outline",className:"text-xs",children:["Month ",Ke.monthNumber]})]}),Ke.script&&e.jsx(K,{size:"sm",variant:"outline",className:"w-full",onClick:()=>ct(Ke),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:()=>{ae(Ke.contact.id),le(`${Ke.contact.first_name} ${Ke.contact.last_name||""}`.trim())},children:[e.jsx(uh,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(K,{size:"sm",className:"flex-1",onClick:()=>{var bn;return ye(Ke.contact.id,Ke.actionType.id,(bn=Ke.script)==null?void 0:bn.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]},Ke.contact.id+He)}),e.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"h-full w-full",children:[e.jsx(dx,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(jd,{children:e.jsx(xa,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ft,{className:"text-lg",children:"Momentum"}),e.jsxs(fs,{open:A,onOpenChange:I,children:[e.jsx(ui,{asChild:!0,children:e.jsx("button",{onClick:we,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(So,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(ms,{className:"sm:max-w-[360px]",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Set Weekly Goal"}),e.jsx(Rr,{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(ge,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),e.jsx(Fe,{id:"weekly-goal-ic",type:"number",min:"1",value:L,onChange:Ke=>O(Ke.target.value),placeholder:"20",onKeyDown:Ke=>{Ke.key==="Enter"&&he()}})]}),e.jsx(K,{onClick:he,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsx(pi,{value:Math.min(d.actionsThisWeek/U*100,100),className:"h-3 w-full max-w-full"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ch,{className:"h-5 w-5 text-orange-500"}),e.jsxs("span",{className:"font-medium",children:[d.actionsThisWeek," / ",U]}),e.jsx("span",{className:"text-muted-foreground",children:"Actions Completed This Week"})]}),d.streak>0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-lg",children:"🔥"}),e.jsx("span",{className:"font-medium",children:"Great Job!"}),e.jsxs("span",{className:"text-muted-foreground",children:["Keep Your Streak Going! (",d.streak," days)"]})]}),u.count>0&&e.jsxs("button",{onClick:()=>t("/mission-control/contacts?filter=not-touched-90"),className:"flex items-start gap-2 text-sm pt-2 border-t w-full text-left hover:bg-accent/50 -mx-4 px-4 py-2 rounded-md transition-colors",children:[e.jsx(rn,{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(ja,{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(JXe,{}),e.jsx(Zbs,{})]})]}),e.jsx(fs,{open:N,onOpenChange:w,children:e.jsxs(ms,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(bs,{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:tt(_.script.script_body,_.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>w(!1),children:"Close"}),e.jsx(K,{className:"flex-1",onClick:()=>{var Ke;return ye(_.contact.id,_.actionType.id,(Ke=_.script)==null?void 0:Ke.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(Obs,{})]}),fe&&J&&e.jsx(E1,{open:ee,onOpenChange:Z,contact:J,gmailEmail:xe}),e.jsx(kme,{open:!!ce,onOpenChange:Ke=>!Ke&&ae(null),contactId:ce||"",contactName:ie})]})}var Xat="Toggle",KSe=k.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=Bu({prop:r,onChange:a,defaultProp:n??!1,caller:Xat});return e.jsx(dn.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...o,ref:s,onClick:Tr(t.onClick,()=>{t.disabled||i(!l)})})});KSe.displayName=Xat;var Qat=KSe,Aw="ToggleGroup",[Jat]=bd(Aw,[gw]),eit=gw(),ZSe=ht.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(sws,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(rws,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${Aw}\``)});ZSe.displayName=Aw;var[tit,sit]=Jat(Aw),sws=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=Bu({prop:r,defaultProp:n??"",onChange:a,caller:Aw});return e.jsx(tit,{scope:t.__scopeToggleGroup,type:"single",value:ht.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:ht.useCallback(()=>i(""),[i]),children:e.jsx(rit,{...o,ref:s})})}),rws=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=Bu({prop:r,defaultProp:n??[],onChange:a,caller:Aw}),d=ht.useCallback(p=>i((f=[])=>[...f,p]),[i]),u=ht.useCallback(p=>i((f=[])=>f.filter(y=>y!==p)),[i]);return e.jsx(tit,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:d,onItemDeactivate:u,children:e.jsx(rit,{...o,ref:s})})});ZSe.displayName=Aw;var[nws,aws]=Jat(Aw),rit=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...d}=t,u=eit(r),p=xw(l),f={role:"group",dir:p,...d};return e.jsx(nws,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(gue,{asChild:!0,...u,orientation:o,dir:p,loop:i,children:e.jsx(dn.div,{...f,ref:s})}):e.jsx(dn.div,{...f,ref:s})})}),wde="ToggleGroupItem",nit=ht.forwardRef((t,s)=>{const r=sit(wde,t.__scopeToggleGroup),n=aws(wde,t.__scopeToggleGroup),a=eit(t.__scopeToggleGroup),o=r.value.includes(t.value),l=n.disabled||t.disabled,i={...t,pressed:o,disabled:l},d=ht.useRef(null);return n.rovingFocus?e.jsx(yue,{asChild:!0,...a,focusable:!l,active:o,ref:d,children:e.jsx(Y7e,{...i,ref:s})}):e.jsx(Y7e,{...i,ref:s})});nit.displayName=wde;var Y7e=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=sit(wde,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(KSe,{...i,...a,ref:s,onPressedChange:d=>{d?o.onItemActivate(n):o.onItemDeactivate(n)}})}),ait=ZSe,iit=nit;const oit=wC("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"}}),iws=k.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(Qat,{ref:a,className:Rt(oit({variant:s,size:r,className:t})),...n}));iws.displayName=Qat.displayName;const lit=k.createContext({size:"default",variant:"default"}),cit=k.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(ait,{ref:o,className:Rt("flex items-center justify-center gap-1",t),...a,children:e.jsx(lit.Provider,{value:{variant:s,size:r},children:n})}));cit.displayName=ait.displayName;const dit=k.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=k.useContext(lit);return e.jsx(iit,{ref:o,className:Rt(oit({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});dit.displayName=iit.displayName;const ows=[{value:"bidirectional",label:"Two-Way",icon:td,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:cu,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:Ih,tooltip:"Only pull BoldTrail → Agent OS"}];function Pwe({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(cit,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:ows.map(a=>e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsxs(dit,{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(Il,{children:a.tooltip})]},a.value))})]})}function lws(){const t=es(),[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState(null),[f,y]=k.useState(null),[_,b]=k.useState(0),N=k.useRef(!1),{data:w}=ft({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:$,error:V}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(V)throw V;return $}}),S=(w==null?void 0:w.sync_direction)||"bidirectional",C=u??S,A=Et({mutationFn:async()=>{const{data:$,error:V}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(V)throw V;if($!=null&&$.error)throw new Error($.error);return $},onSuccess:$=>{p(null),a($),r(!0)},onError:$=>{me.error($.message||"Failed to generate sync preview")}}),I=Et({mutationFn:async()=>{N.current=!1,y("Initializing sync..."),b(5);const{data:$,error:V}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:C}});if(V)throw V;if($!=null&&$.error)throw new Error($.error);const ee=$;let Z=ee.sync_log_id,J=ee.next_phase,Y=ee.next_offset;const ce=ee.push_total||0,ae=ee.pull_total||0,ie=ee.update_total||0,le=ce+ae+ie;let fe=0,xe=0,he=0;for(;J!=="finalize"&&!N.current;){J==="push"?(y(`Pushing contacts to BoldTrail... (${fe}/${ce})`),b(le>0?fe/le*90:0)):J==="pull"?(y(`Pulling contacts from BoldTrail... (${xe}/${ae})`),b(le>0?(ce+xe)/le*90:0)):J==="update"&&(y(`Updating existing contacts... (${he}/${ie})`),b(le>0?(ce+ae+he)/le*90:0));const{data:Ve,error:Te}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:J,offset:Y,sync_log_id:Z,sync_direction:C}});if(Te)throw Te;if(Ve!=null&&Ve.error)throw new Error(Ve.error);const Ae=Ve;fe+=Ae.chunk_pushed||0,xe+=Ae.chunk_pulled||0,he+=Ae.chunk_updated||0,Ae.progress&&y(Ae.progress),J=Ae.next_phase,Y=Ae.next_offset}y("Finalizing sync..."),b(95);const{data:we,error:Ne}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:Z,sync_direction:C}});if(Ne)throw Ne;return b(100),we},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"]});const V=[`Pushed ${$.contacts_pushed||0}`,`pulled ${$.contacts_pulled||0}`,`updated ${$.contacts_updated||0}`,`skipped ${$.contacts_skipped||0} duplicates`];me.success(`Sync complete! ${V.join(", ")}.`)},onError:$=>{y(null),b(0),me.error($.message||"Sync failed")}});if(!(w!=null&&w.connected))return null;const L=C==="pull_only"?0:(n==null?void 0:n.to_push)??0,O=C==="push_only"?0:(n==null?void 0:n.to_pull)??0,U=(n==null?void 0:n.to_update)??0,q=L>0||O>0||U>0;return e.jsxs(e.Fragment,{children:[e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",onClick:()=>A.mutate(),disabled:A.isPending,className:"shrink-0",children:A.isPending?e.jsx(to,{className:"h-4 w-4 animate-spin"}):e.jsx(td,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(Il,{children:"Sync with BoldTrail"})]}),e.jsx(fs,{open:s,onOpenChange:$=>{I.isPending||r($)},children:e.jsxs(ms,{className:"sm:max-w-lg",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(td,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Rr,{children:"Review what will happen when you sync your contacts."})]}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(Pwe,{value:C,onChange:p,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${C==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:L}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(cu,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${C==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:O}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Ih,{className:"h-3 w-3"})," Pull to Agent OS"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-amber-600",children:U}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(OM,{className:"h-3 w-3"})," To update"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-muted-foreground",children:n.already_synced}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(cr,{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"]}),U>0&&e.jsxs("div",{className:"text-xs text-muted-foreground text-center bg-amber-50 dark:bg-amber-950/30 rounded-md p-2",children:[e.jsx(OM,{className:"h-3 w-3 inline mr-1"}),U," contacts have missing fields that will be filled from the other system"]}),L>0&&e.jsxs(uf,{open:o,onOpenChange:l,children:[e.jsx(hf,{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(cu,{className:"h-3 w-3 text-emerald-600"}),L," contacts to push to BoldTrail"]}),e.jsx(Fi,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(mf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.push_preview.map(($,V)=>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})]},V)),n.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",n.to_push-20," more"]})]})})]}),O>0&&e.jsxs(uf,{open:i,onOpenChange:d,children:[e.jsx(hf,{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(Ih,{className:"h-3 w-3 text-blue-600"}),O," contacts to pull from BoldTrail"]}),e.jsx(Fi,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(mf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.pull_preview.map(($,V)=>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})]},V)),n.to_pull>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",n.to_pull-20," more"]})]})})]}),!q&&!I.isPending&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer or update."}),I.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(pi,{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||!q,className:"gap-2",children:[I.isPending?e.jsx(to,{className:"h-4 w-4 animate-spin"}):e.jsx(td,{className:"h-4 w-4"}),I.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const cws=()=>{const{user:t}=$s();return ft({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})},Cme=t=>{const{user:s}=$s();return ft({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})},YSe=()=>{const{user:t}=$s();return ft({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})},uit=()=>{const{user:t}=$s();return ft({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})},dws=()=>{const{data:t}=Uh(),{data:s}=Mf(),{data:r}=Cme(),{data:n}=uit(),{data:a}=YSe(),o=new Map;r==null||r.forEach(p=>{const f=o.get(p.contact_id);(!f||new Date(p.completed_at)>new Date(f))&&o.set(p.contact_id,p.completed_at)});const l=new Map;a==null||a.forEach(p=>l.set(p.relationship_type_id,p.frequency_days));const i=new Map;n==null||n.filter(p=>p.is_active).forEach(p=>{i.set(p.contact_id,p.frequency_days)});const d=Am(new Date);return(t||[]).map(p=>{let f=90;if(i.has(p.id))f=i.get(p.id);else if(p.tags&&p.tags.length>0){const w=p.tags.map(S=>l.get(S.relationship_type_id)).filter(S=>S!==void 0);w.length>0&&(f=Math.min(...w))}const y=o.get(p.id)||null,_=y?Vg(d,Am(new Date(y))):null,b=_===null||_>=f,N=b&&_!==null?_-f:0;return{...p,lastPopby:y,daysSinceLastPopby:_,frequencyDays:f,isDue:b,daysOverdue:N}}).sort((p,f)=>f.daysOverdue-p.daysOverdue)},hit=()=>dws().filter(s=>s.isDue),uws=()=>{const t=es(),{user:s}=$s();return Et({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"]}),cn({title:"Popby item created!"})},onError:r=>{cn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},hws=()=>{const t=es(),{user:s}=$s();return Et({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"]}),cn({title:"Popby logged!"})},onError:r=>{cn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},mws=()=>{const t=es(),{user:s}=$s();return Et({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"]}),cn({title:"Frequency updated!"})},onError:r=>{cn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},pws=()=>{const{data:t}=Cme(30),s=hit(),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 fws(){const{user:t}=$s();return ft({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 mit(t){const{data:s}=fws(),{data:r}=uit(),{data:n}=YSe(),{data:a}=Fbs();return k.useMemo(()=>{const o=a==null?void 0:a.find(w=>w.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=Am(new Date);if(l&&!XS(l,i))return{nextTouchDate:l,daysUntil:Vg(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const u=((s==null?void 0:s.filter(w=>w.contact_id===t.id))||[]).sort((w,S)=>new Date(S.completed_at).getTime()-new Date(w.completed_at).getTime())[0],p=u?new Date(u.completed_at):null;let f=90;const y=r==null?void 0:r.find(w=>w.contact_id===t.id&&w.is_active);if(y)f=y.frequency_days;else if(t.tags&&t.tags.length>0){const w=t.tags.map(S=>{const C=n==null?void 0:n.find(A=>A.relationship_type_id===S.relationship_type_id);return C==null?void 0:C.frequency_days}).filter(S=>S!==void 0);w.length>0&&(f=Math.min(...w))}if(!p)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:f,lastTouchDate:null,snoozedUntil:null};const _=dl(Am(p),f),b=Vg(_,i);let N;return b<0?N="overdue":b<=7?N="due-soon":N="on-track",{nextTouchDate:_,daysUntil:b,status:N,frequencyDays:f,lastTouchDate:p,snoozedUntil:null}},[t,s,r,n,a])}function Iwe({contact:t}){const s=mit(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:co,text:`${Math.abs(s.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:rn,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:Hn,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:uh,text:`Snoozed until ${gs(s.snoozedUntil,"MMM d")}`,className:"bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300"};case"never-touched":return{variant:"outline",icon:nn,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(Ye,{variant:n.variant,className:Rt("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function xws({contact:t,onLogTouch:s,onSnooze:r}){const n=mit(t),a=Bbs(),[o,l]=k.useState(!1),i=()=>{switch(n.status){case"overdue":return"text-destructive";case"due-soon":return"text-amber-600 dark:text-amber-400";case"on-track":return"text-emerald-600 dark:text-emerald-400";case"snoozed":return"text-slate-600 dark:text-slate-400";case"never-touched":return"text-muted-foreground"}},d=()=>{switch(n.status){case"overdue":return e.jsx(co,{className:"h-5 w-5 text-destructive"});case"due-soon":return e.jsx(rn,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx(Hn,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return e.jsx(uh,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return e.jsx(nn,{className:"h-5 w-5 text-muted-foreground"})}},u=()=>{switch(n.status){case"overdue":return`${Math.abs(n.daysUntil)} days overdue`;case"due-soon":return n.daysUntil===0?"Due today!":`Due in ${n.daysUntil} days`;case"on-track":return`On track - ${n.daysUntil} days remaining`;case"snoozed":return`Snoozed for ${n.daysUntil} more days`;case"never-touched":return"No touches logged yet"}},p=async()=>{await a.mutateAsync(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs(Be,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d(),e.jsx("span",{className:Rt("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:"})," ",gs(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:"})," ",gs(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:"})," ",gs(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(Sr,{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(uh,{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(kme,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const d0e=768;function bE(){const[t,s]=k.useState(void 0);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${d0e-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}function gws(){const{user:t}=$s(),{hasLeadSite:s,leadSite:r}=QA(),{data:n,isLoading:a}=ft({queryKey:["website-active-contacts",t==null?void 0:t.id,r==null?void 0:r.id],queryFn:async()=>{if(!r)return new Set;const{data:o}=await G.from("lead_site_visitors").select("contact_id").eq("lead_site_id",r.id).not("contact_id","is",null),{data:l}=await G.from("lead_site_consumer_profiles").select("contact_id").eq("lead_site_id",r.id).not("contact_id","is",null),i=new Set;return(o||[]).forEach(d=>{d.contact_id&&i.add(d.contact_id)}),(l||[]).forEach(d=>{d.contact_id&&i.add(d.contact_id)}),i},enabled:!!t&&s,staleTime:5*60*1e3});return{activeContactIds:n??new Set,hasLeadSite:s,isLoading:a}}const yws={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"}},vws={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 C8({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=yws[t.status],l=vws[n],i=e.jsxs("div",{className:Rt("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:Rt("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(S1,{children:e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:i}),e.jsx(Il,{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:Rt("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(pi,{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 _ws=[{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}],_9=t=>{if(!t||!t.trim())return null;const s=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(s))return s;const r=s.match(/^(\d{1,2})[\/\-](\d{1,2})(?:[\/\-](\d{2,4}))?$/);if(r){const a=r[1].padStart(2,"0"),o=r[2].padStart(2,"0");let l="2000";r[3]&&(l=r[3].length===2?(parseInt(r[3])>50?"19":"20")+r[3]:r[3]);const i=parseInt(a),d=parseInt(o);if(i>=1&&i<=12&&d>=1&&d<=31)return`${l}-${a}-${o}`}const n=new Date(s);return isNaN(n.getTime())?null:n.toISOString().split("T")[0]},bws=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=$s(),{toast:o}=va(),l=k.useRef(null),[i,d]=k.useState("upload"),[u,p]=k.useState([]),[f,y]=k.useState([]),[_,b]=k.useState({}),[N,w]=k.useState([]),[S,C]=k.useState([]),[A,I]=k.useState(!1),[L,O]=k.useState(null),U=()=>{d("upload"),p([]),y([]),b({}),w([]),C([]),O(null),l.current&&(l.current.value="")},q=()=>{U(),s(!1)},$=xe=>{const he=xe.split(` `).map(Te=>Te.trim()).filter(Te=>Te);if(he.length===0)return{headers:[],data:[]};const we=Te=>{const Ae=[];let ze="",Ee=!1;for(let ve=0;ve{var Ne;const he=(Ne=xe.target.files)==null?void 0:Ne[0];if(!he)return;const we=new FileReader;we.onload=Ve=>{var ve;const Te=(ve=Ve.target)==null?void 0:ve.result,{headers:Ae,data:ze}=$(Te);if(Ae.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(Ae),y(ze);const Ee={};Ae.forEach(Re=>{const Ue=Re.toLowerCase().replace(/[_\s-]/g,"");Ue.includes("firstname")||Ue==="first"?Ee.first_name=Re:Ue.includes("lastname")||Ue==="last"?Ee.last_name=Re:Ue.includes("spouse")&&Ue.includes("email")?Ee.spouse_email=Re:Ue.includes("spouse")||Ue.includes("partner")?Ee.spouse_name=Re:Ue.includes("email")?Ee.email=Re:Ue.includes("phone")||Ue.includes("mobile")||Ue.includes("cell")?Ee.phone=Re:Ue.includes("address")||Ue.includes("street")?Ee.address=Re:Ue==="city"?Ee.city=Re:Ue==="state"||Ue==="province"?Ee.state=Re:Ue==="zip"||Ue==="zipcode"||Ue==="postalcode"?Ee.zip=Re:Ue.includes("company")||Ue.includes("organization")||Ue.includes("business")?Ee.company_name=Re:Ue.includes("jobtitle")||Ue.includes("title")&&!Ue.includes("spouse")?Ee.job_title=Re:Ue.includes("birthday")||Ue.includes("dob")||Ue.includes("birthdate")?Ee.birthday=Re:Ue.includes("anniversary")||Ue.includes("homeanniversary")?Ee.home_anniversary=Re:(Ue.includes("notes")||Ue.includes("comment"))&&(Ee.notes=Re)}),b(Ee),d("mapping")},we.readAsText(he)},ee=(xe,he)=>{b(we=>{if(he==="none"){const{[xe]:Ne,...Ve}=we;return Ve}return{...we,[xe]:he}})},Z=xe=>{w(he=>he.includes(xe)?he.filter(we=>we!==xe):[...he,xe])},J=async()=>{if(!(a!=null&&a.id))return;const{data:xe}=await G.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),he=new Set((xe||[]).filter(Ve=>Ve.email).map(Ve=>Ve.email.toLowerCase())),we=new Set((xe||[]).filter(Ve=>Ve.phone).map(Ve=>Ve.phone.replace(/[^0-9]/g,""))),Ne=f.map(Ve=>{const Te=Ue=>{const ye=_[Ue];if(!ye)return"";const ct=u.indexOf(ye);return ct>=0?(Ve[ct]||"").trim():""},Ae=Te("first_name"),ze=Te("email"),Ee=Te("phone"),ve=Ae.length>0,Re=!!(ze&&he.has(ze.toLowerCase())||Ee&&we.has(Ee.replace(/[^0-9]/g,"")));return{first_name:Ae,last_name:Te("last_name"),email:ze,phone:Ee,address:Te("address"),city:Te("city"),state:Te("state"),zip:Te("zip"),spouse_name:Te("spouse_name"),spouse_email:Te("spouse_email"),company_name:Te("company_name"),job_title:Te("job_title"),birthday:Te("birthday"),home_anniversary:Te("home_anniversary"),notes:Te("notes"),isValid:ve,isDuplicate:Re,error:ve?void 0:"First name is required"}});C(Ne),d("preview")},Y=xe=>{const he=xe.trim().split(/\s+/);return{first_name:he[0],last_name:he.length>1?he.slice(1).join(" "):null}},ce=async()=>{if(!(a!=null&&a.id))return;const xe=S.filter(Ve=>Ve.isValid);if(xe.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}I(!0);let he=0,we=0,Ne=0;try{for(const Ve of xe)try{let Te=null;if(Ve.email){const{data:Ee}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ve.email).maybeSingle();Te=Ee}if(!Te&&Ve.phone){const Ee=Ve.phone.replace(/[^0-9]/g,""),{data:ve}=await G.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(ve){const Re=ve.find(Ue=>Ue.phone&&Ue.phone.replace(/[^0-9]/g,"")===Ee);Re&&(Te={id:Re.id})}}const Ae={owner_user_id:a.id,first_name:Ve.first_name,last_name:Ve.last_name||null,email:Ve.email||null,phone:Ve.phone||null,address:Ve.address||null,city:Ve.city||null,state:Ve.state||null,zip:Ve.zip||null,spouse_name:Ve.spouse_name||null,spouse_email:Ve.spouse_email||null,company_name:Ve.company_name||null,job_title:Ve.job_title||null,birthday:_9(Ve.birthday),home_anniversary:_9(Ve.home_anniversary),notes:Ve.notes||null};let ze=null;if(Te){const{data:Ee}=await G.from("innercircle_contacts").select("*").eq("id",Te.id).single();if(Ee){const ve={},Re=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const Ue of Re){const ye=Ee[Ue],ct=Ae[Ue];(!ye||ye==="")&&ct&&(ve[Ue]=ct)}Object.keys(ve).length>0&&await G.from("innercircle_contacts").update(ve).eq("id",Te.id)}ze=Te.id,we++}else{const{data:Ee,error:ve}=await G.from("innercircle_contacts").insert(Ae).select("id").single();ve?(console.error("Insert error for contact:",Ve.first_name,ve),Ne++):Ee?(ze=Ee.id,N.length>0&&await G.from("innercircle_contact_tags").insert(N.map(Re=>({contact_id:Ee.id,relationship_type_id:Re}))),he++):Ne++}if(ze&&Ve.spouse_name){const Ee=Y(Ve.spouse_name);let ve=null;if(Ve.spouse_email){const{data:Ue}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ve.spouse_email).maybeSingle();ve=Ue}if(!ve){const{data:Ue}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",Ee.first_name).eq("last_name",Ee.last_name||Ve.last_name||"").maybeSingle();ve=Ue}let Re=null;if(ve){Re=ve.id;const Ue=_9(Ve.home_anniversary);Ue&&await G.from("innercircle_contacts").update({home_anniversary:Ue}).eq("id",ve.id).is("home_anniversary",null)}else{const{data:Ue}=await G.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:Ee.first_name,last_name:Ee.last_name||Ve.last_name||null,email:Ve.spouse_email||null,address:Ve.address||null,city:Ve.city||null,state:Ve.state||null,zip:Ve.zip||null,home_anniversary:_9(Ve.home_anniversary),spouse_name:`${Ve.first_name}${Ve.last_name?" "+Ve.last_name:""}`,spouse_email:Ve.email||null,notes:`Spouse of ${Ve.first_name} ${Ve.last_name||""} (imported via CSV)`.trim()}).select("id").single();Ue&&(Re=Ue.id,he++)}Re&&(await G.from("innercircle_contacts").update({spouse_contact_id:Re}).eq("id",ze),await G.from("innercircle_contacts").update({spouse_contact_id:ze}).eq("id",Re))}}catch(Te){console.error("Error importing contact:",Te),Ne++}O({created:he,updated:we,failed:Ne}),d("result"),(he>0||we>0)&&n(),o({title:"Import Complete",description:`${he} created, ${we} updated${Ne>0?`, ${Ne} failed`:""}.`})}catch(Ve){console.error("Import error:",Ve),o({title:"Import Failed",description:Ve.message||"Failed to import contacts",variant:"destructive"})}finally{I(!1)}},ae=S.filter(xe=>xe.isValid).length,ie=S.filter(xe=>!xe.isValid).length,le=S.filter(xe=>xe.isValid&&xe.isDuplicate).length,fe=ae-le;return e.jsx(fs,{open:t,onOpenChange:q,children:e.jsxs(ms,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Zv,{className:"h-5 w-5"}),"Import Contacts from CSV"]}),e.jsx(Rr,{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(Da,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),e.jsx(K,{onClick:()=>{var xe;return(xe=l.current)==null?void 0:xe.click()},children:"Select CSV File"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[e.jsx("p",{className:"font-medium mb-2",children:"Supported Fields:"}),e.jsx("p",{className:"text-muted-foreground text-xs mb-3",children:"First Name, Last Name, Email, Phone, Street Address, City, State, Zip, Spouse Name, Spouse Email, Company, Job Title, Birthday, Home Anniversary, Notes"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const xe=`First Name,Last Name,Email,Phone,Street Address,City,State,Zip,Spouse Name,Spouse Email,Company,Job Title,Birthday,Home Anniversary,Notes John,Doe,john@example.com,555-123-4567,123 Main St,Austin,TX,78701,Jane Doe,jane@example.com,ABC Realty,Real Estate Agent,1985-06-15,2020-03-22,Met at open house`,he=new Blob([xe],{type:"text/csv"}),we=URL.createObjectURL(he),Ne=document.createElement("a");Ne.href=we,Ne.download="contact_import_template.csv",Ne.click(),URL.revokeObjectURL(we)},children:[e.jsx(Xa,{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(ge,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),e.jsx("div",{className:"grid gap-3",children:_ws.map(xe=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(ge,{className:"w-40 text-sm",children:[xe.label,xe.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(zs,{value:_[xe.key]||"none",onValueChange:he=>ee(xe.key,he),children:[e.jsx(Os,{className:"w-48",children:e.jsx(qs,{placeholder:"Select column..."})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"-- Not mapped --"}),u.map(he=>e.jsx(yt,{value:he,children:he},he))]})]})]},xe.key))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ge,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(xe=>e.jsx(Ye,{variant:N.includes(xe.id)?"default":"outline",className:"cursor-pointer",onClick:()=>Z(xe.id),children:xe.name},xe.id))})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-sm",children:e.jsxs("p",{className:"text-muted-foreground",children:["Preview: ",f.length," row(s) found in CSV"]})})]}),i==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:[fe," new"]})]}),le>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(co,{className:"h-4 w-4"}),e.jsxs("span",{children:[le," existing (will merge gaps)"]})]}),ie>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(co,{className:"h-4 w-4"}),e.jsxs("span",{children:[ie," 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(As,{className:"bg-muted/30",children:[e.jsx(Nt,{children:"First Name"}),e.jsx(Nt,{children:"Last Name"}),e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{children:"Phone"}),e.jsx(Nt,{children:"Status"})]})}),e.jsx(Pn,{children:S.slice(0,100).map((xe,he)=>e.jsxs(As,{children:[e.jsx(dt,{children:xe.first_name}),e.jsx(dt,{children:xe.last_name}),e.jsx(dt,{children:xe.email}),e.jsx(dt,{children:xe.phone}),e.jsx(dt,{children:xe.isValid?xe.isDuplicate?e.jsx(Ye,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(Ye,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(Ye,{variant:"destructive",children:xe.error||"Invalid"})})]},he))})]}),S.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",S.length," contacts"]})]})]}),i==="result"&&L&&e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx(Hn,{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(gn,{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:U,children:"Back"}),e.jsx(K,{onClick:J,disabled:!_.first_name,children:"Continue"})]}),i==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>d("mapping"),children:"Back"}),e.jsx(K,{onClick:ce,disabled:A||ae===0,children:A?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${ae} Contact${ae!==1?"s":""}`})]}),i==="result"&&e.jsx(K,{onClick:q,children:"Done"})]})]})})};function wws(){return"contacts"in navigator&&"ContactsManager"in window}function jws(t){const s=[],r=t.split("BEGIN:VCARD").filter(n=>n.trim());for(const n of r){const a=n.split(/\r?\n/);let o="",l="",i="",d="",u="";for(const p of a){const f=p.replace(/^\s+/,"");if(f.startsWith("N:")||f.startsWith("N;")){const _=f.substring(f.indexOf(":")+1).split(";");l=(_[0]||"").trim(),o=(_[1]||"").trim()}if((f.startsWith("FN:")||f.startsWith("FN;"))&&!o){const _=f.substring(f.indexOf(":")+1).trim().split(" ");o=_[0]||"",l=_.slice(1).join(" ")}(f.startsWith("EMAIL")||f.match(/^item\d+\.EMAIL/i))&&!i&&(i=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("TEL")||f.match(/^item\d+\.TEL/i))&&!d&&(d=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("ADR")||f.match(/^item\d+\.ADR/i))&&!u&&(u=f.substring(f.indexOf(":")+1).split(";").map(b=>b.trim()).filter(Boolean).join(", "))}(o||l)&&s.push({first_name:o,last_name:l,email:i,phone:d,address:u})}return s}function Nws({open:t,onOpenChange:s,onComplete:r}){const{user:n}=$s(),{data:a}=Uh(),o=nhe(),l=k.useRef(null),[i,d]=k.useState("choose"),[u,p]=k.useState([]),[f,y]=k.useState(new Set),[_,b]=k.useState(0),[N,w]=k.useState(0),S=wws(),C=k.useCallback(ee=>{if(!a)return ee;const Z=new Set(a.filter(Y=>Y.email).map(Y=>Y.email.toLowerCase())),J=new Set(a.filter(Y=>Y.phone).map(Y=>Y.phone.replace(/\D/g,"")));return ee.map(Y=>{var ie,le;const ce=(ie=Y.email)==null?void 0:ie.toLowerCase(),ae=(le=Y.phone)==null?void 0:le.replace(/\D/g,"");return ce&&Z.has(ce)?{...Y,isDuplicate:!0,duplicateField:"email"}:ae&&ae.length>=7&&J.has(ae)?{...Y,isDuplicate:!0,duplicateField:"phone"}:Y})},[a]),A=async()=>{try{const ee=["name","email","tel","address"],Z=await navigator.contacts.select(ee,{multiple:!0});if(!Z||Z.length===0)return;const J=Z.map(ae=>{var fe,xe,he,we;const le=(((fe=ae.name)==null?void 0:fe[0])||"").split(" ");return{first_name:le[0]||"",last_name:le.slice(1).join(" "),email:((xe=ae.email)==null?void 0:xe[0])||"",phone:((he=ae.tel)==null?void 0:he[0])||"",address:(we=ae.address)!=null&&we[0]?[ae.address[0].streetAddress,ae.address[0].city,ae.address[0].region,ae.address[0].postalCode].filter(Boolean).join(", "):""}}),Y=C(J);p(Y);const ce=new Set;Y.forEach((ae,ie)=>{ae.isDuplicate||ce.add(ie)}),y(ce),d("preview")}catch(ee){console.error("Contact Picker error:",ee),cn({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},I=ee=>{var Y;const Z=(Y=ee.target.files)==null?void 0:Y[0];if(!Z)return;const J=new FileReader;J.onload=ce=>{var xe;const ae=(xe=ce.target)==null?void 0:xe.result,ie=jws(ae);if(ie.length===0){cn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const le=C(ie);p(le);const fe=new Set;le.forEach((he,we)=>{he.isDuplicate||fe.add(we)}),y(fe),d("preview")},J.readAsText(Z),l.current&&(l.current.value="")},L=async()=>{const ee=u.filter((J,Y)=>f.has(Y));if(ee.length===0)return;d("importing");let Z=0;for(const J of ee)try{await o.mutateAsync({first_name:J.first_name,last_name:J.last_name||void 0,email:J.email||void 0,phone:J.phone||void 0,address:J.address||void 0}),Z++,w(Math.round(Z/ee.length*100))}catch(Y){console.error(`Failed to import ${J.first_name} ${J.last_name}:`,Y)}b(Z),d("done")},O=ee=>{y(Z=>{const J=new Set(Z);return J.has(ee)?J.delete(ee):J.add(ee),J})},U=()=>{f.size===u.length?y(new Set):y(new Set(u.map((ee,Z)=>Z)))},q=ee=>{ee||(d("choose"),p([]),y(new Set),b(0),w(0),i==="done"&&r()),s(ee)},$=u.filter(ee=>ee.isDuplicate).length,V=f.size;return e.jsx(fs,{open:t,onOpenChange:q,children:e.jsxs(ms,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(s0,{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(Rr,{children:"Add contacts from your phone directly into Agent OS."})]}),i==="choose"&&e.jsxs("div",{className:"space-y-4 pt-2",children:[S&&e.jsxs(K,{onClick:A,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(s0,{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:[S&&e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),S&&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:S?"outline":"default",onClick:()=>{var ee;return(ee=l.current)==null?void 0:ee.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(Da,{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:S?"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"}),!S&&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",$>0&&e.jsxs("span",{className:"text-amber-600 ml-1",children:["(",$," already exist)"]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:U,children:f.size===u.length?"Deselect All":"Select All"})]}),e.jsx(di,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:u.map((ee,Z)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${ee.isDuplicate?"opacity-60":""}`,onClick:()=>O(Z),children:[e.jsx(Gi,{checked:f.has(Z),onCheckedChange:()=>O(Z),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:[ee.first_name," ",ee.last_name]}),ee.isDuplicate&&e.jsxs(Ye,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",ee.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[ee.phone&&e.jsx("div",{children:ee.phone}),ee.email&&e.jsx("div",{className:"truncate",children:ee.email})]})]})]},Z))})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d("choose"),children:"Back"}),e.jsxs(K,{onClick:L,disabled:V===0,children:["Import ",V," Contact",V!==1?"s":""]})]})]}),i==="importing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(ps,{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:[N,"% 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:`${N}%`}})})]}),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(ea,{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 XSe(){const t=_a();return ft({queryKey:["drip-campaigns",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("drip_campaigns").select("*").or(`owner_user_id.eq.${t},is_starter.eq.true`).order("is_starter",{ascending:!1}).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function kws(t){return ft({queryKey:["drip-campaign",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("drip_campaigns").select("*").eq("id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function Sws(){const t=_a(),s=es();return Et({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("drip_campaigns").insert({owner_user_id:t,name:r.name,description:r.description??null,category:r.category??"nurture",icon:r.icon??"🌱",cover_color:r.cover_color??"from-emerald-500 to-teal-600",goal:r.goal??null,is_active:!1}).select().single();if(a)throw a;return n},onSuccess:()=>s.invalidateQueries({queryKey:["drip-campaigns"]})})}function pit(){const t=es();return Et({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("drip_campaigns").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["drip-campaigns"]}),t.invalidateQueries({queryKey:["drip-campaign",r.id]})}})}function Cws(){const t=es();return Et({mutationFn:async s=>{const{error:r}=await G.from("drip_campaigns").delete().eq("id",s);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["drip-campaigns"]})})}function Mws(){const t=_a(),s=es();return Et({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const[{data:n,error:a},{data:o,error:l}]=await Promise.all([G.from("drip_campaigns").select("*").eq("id",r).single(),G.from("drip_campaign_steps").select("*").eq("campaign_id",r).order("step_order")]);if(a)throw a;if(l)throw l;const{data:i,error:d}=await G.from("drip_campaigns").insert({owner_user_id:t,name:n.name,description:n.description,category:n.category,icon:n.icon,cover_color:n.cover_color,goal:n.goal,is_active:!1,is_starter:!1}).select().single();if(d)throw d;if(o&&o.length>0){const u=o.map(f=>({campaign_id:i.id,step_order:f.step_order,channel:f.channel,subject:f.subject,body:f.body,video_url:f.video_url,delay_type:f.delay_type,delay_days:f.delay_days,delay_hours:f.delay_hours,anchor_field:f.anchor_field,anchor_offset_days:f.anchor_offset_days,send_window_start:f.send_window_start,send_window_end:f.send_window_end})),{error:p}=await G.from("drip_campaign_steps").insert(u);if(p)throw p}return i},onSuccess:()=>s.invalidateQueries({queryKey:["drip-campaigns"]})})}function fit(t){return ft({queryKey:["drip-campaign-steps",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("drip_campaign_steps").select("*").eq("campaign_id",t).order("step_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function Tws(){const t=es();return Et({mutationFn:async s=>{const{data:r,error:n}=await G.from("drip_campaign_steps").insert({campaign_id:s.campaign_id,step_order:s.step_order,channel:s.channel??"email",subject:s.subject??"",body:s.body??"",video_url:s.video_url??null,delay_type:s.delay_type??"relative",delay_days:s.delay_days??0,delay_hours:s.delay_hours??0,anchor_field:s.anchor_field??null,anchor_offset_days:s.anchor_offset_days??0}).select().single();if(n)throw n;return r},onSuccess:(s,r)=>t.invalidateQueries({queryKey:["drip-campaign-steps",r.campaign_id]})})}function Aws(){const t=es();return Et({mutationFn:async({id:s,campaign_id:r,...n})=>{const{data:a,error:o}=await G.from("drip_campaign_steps").update(n).eq("id",s).select().single();if(o)throw o;return{data:a,campaign_id:r}},onSuccess:s=>t.invalidateQueries({queryKey:["drip-campaign-steps",s.campaign_id]})})}function Ews(){const t=es();return Et({mutationFn:async({id:s,campaign_id:r})=>{const{error:n}=await G.from("drip_campaign_steps").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>t.invalidateQueries({queryKey:["drip-campaign-steps",s]})})}function Pws(t){return ft({queryKey:["campaign-enrollments",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("drip_campaign_enrollments").select("*, contact:innercircle_contacts(id, first_name, last_name, email)").eq("campaign_id",t).order("enrolled_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Iws(t){return ft({queryKey:["campaign-enrollment-count",t],queryFn:async()=>{if(!t)return 0;const{count:s,error:r}=await G.from("drip_campaign_enrollments").select("id",{count:"exact",head:!0}).eq("campaign_id",t).eq("status","active");if(r)throw r;return s??0},enabled:!!t,staleTime:3e4})}function xit(){const t=es();return Et({mutationFn:async({campaignId:s,contactIds:r})=>{const{data:n,error:a}=await G.functions.invoke("enroll-contacts-in-campaign",{body:{campaign_id:s,contact_ids:r}});if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["campaign-enrollments"]}),t.invalidateQueries({queryKey:["contact-campaigns"]})}})}function Lws(){const t=es();return Et({mutationFn:async({id:s,status:r})=>{const n={status:r};r==="paused"&&(n.paused_at=new Date().toISOString()),r==="exited"&&(n.exited_at=new Date().toISOString(),n.exit_reason="manual");const{data:a,error:o}=await G.from("drip_campaign_enrollments").update(n).eq("id",s).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["campaign-enrollments"]}),t.invalidateQueries({queryKey:["contact-campaigns"]})}})}const Dws=[{key:"{{client_first_name}}",label:"Client First Name"},{key:"{{client_last_name}}",label:"Client Last Name"},{key:"{{agent_name}}",label:"Your Name"},{key:"{{agent_phone}}",label:"Your Phone"},{key:"{{review_link}}",label:"Review Link"}],Mme={nurture:"New Lead Nurture",sphere:"Sphere of Influence",buyer:"Buyer",seller:"Seller",fsbo:"FSBO",past_client:"Past Client",birthday:"Birthday",anniversary:"Home Anniversary",custom:"Custom"},Rws={nurture:"from-emerald-500 to-teal-600",sphere:"from-rose-500 to-pink-600",buyer:"from-cyan-500 to-blue-600",seller:"from-indigo-500 to-purple-600",fsbo:"from-red-500 to-orange-600",past_client:"from-purple-500 to-violet-600",birthday:"from-amber-500 to-orange-600",anniversary:"from-blue-500 to-indigo-600",custom:"from-slate-500 to-gray-600"},Ows=["🌱","💎","🏠","🔑","📧","💌","🎂","🥂","🤝","⭐","🎉","📞"];function git({open:t,onOpenChange:s,campaignId:r}){const[n,a]=k.useState(r??null),[o,l]=k.useState("details");k.useEffect(()=>{a(r??null),l("details")},[r,t]);const i=n,d=!!i,{data:u}=kws(i||void 0),{data:p,isLoading:f}=fit(i||void 0),y=Sws(),_=pit(),b=Tws(),[N,w]=k.useState(""),[S,C]=k.useState(""),[A,I]=k.useState("nurture"),[L,O]=k.useState("🌱"),[U,q]=k.useState("");k.useEffect(()=>{u?(w(u.name),C(u.description||""),I(u.category),O(u.icon),q(u.goal||"")):d||(w(""),C(""),I("nurture"),O("🌱"),q(""))},[u,d,t]);const $=Rws[A],V=async()=>{if(!N.trim()){me.error("Give your campaign a name");return}try{if(d&&i)await _.mutateAsync({id:i,name:N,description:S,category:A,icon:L,goal:U,cover_color:$}),me.success("Campaign updated");else{const Z=await y.mutateAsync({name:N,description:S,category:A,icon:L,goal:U,cover_color:$});return me.success("Campaign created — now add your first step!"),a(Z.id),l("steps"),Z}}catch(Z){me.error(Z.message||"Failed to save")}},ee=async()=>{if(!i){me.error("Save the campaign first, then add steps");return}const Z=((p==null?void 0:p.length)||0)+1;try{await b.mutateAsync({campaign_id:i,step_order:Z,channel:"email",subject:"",body:"",delay_type:"relative",delay_days:Z===1?0:2,delay_hours:0})}catch{me.error("Failed to add step")}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-3xl max-h-[90vh] flex flex-col p-0 overflow-hidden",children:[e.jsx("div",{className:`bg-gradient-to-br ${$} p-5 text-white shrink-0`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-4xl drop-shadow-sm",children:L}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(bs,{className:"text-lg font-bold text-white",children:d?"Edit Campaign":"Create New Campaign"}),e.jsx(Rr,{className:"text-white/85 text-xs mt-0.5",children:"Design a multi-step nurture sequence. Steps are sent in order with your chosen delays."})]})]})}),e.jsxs(ta,{value:o,onValueChange:Z=>l(Z),className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(Qn,{className:"mx-5 mt-4 grid grid-cols-2 w-fit",children:[e.jsx(ls,{value:"details",children:"Details"}),e.jsxs(ls,{value:"steps",disabled:!d,children:["Steps ",p&&p.length>0&&e.jsx(Ye,{variant:"secondary",className:"ml-1.5 text-[10px]",children:p.length})]})]}),e.jsx(js,{value:"details",className:"flex-1 overflow-hidden mt-0",children:e.jsx(di,{className:"h-full",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Campaign Name *"}),e.jsx(Fe,{value:N,onChange:Z=>w(Z.target.value),placeholder:"e.g. New Buyer Lead — 7 Touch Nurture",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Description"}),e.jsx(_r,{value:S,onChange:Z=>C(Z.target.value),placeholder:"What's this campaign for? When should you use it?",rows:2,className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Goal (optional)"}),e.jsx(Fe,{value:U,onChange:Z=>q(Z.target.value),placeholder:"e.g. Book a buyer consultation within 14 days",className:"mt-1"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Category"}),e.jsxs(zs,{value:A,onValueChange:Z=>I(Z),children:[e.jsx(Os,{className:"mt-1",children:e.jsx(qs,{})}),e.jsx(Fs,{children:Object.entries(Mme).map(([Z,J])=>e.jsx(yt,{value:Z,children:J},Z))})]})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Icon"}),e.jsx("div",{className:"flex gap-1.5 flex-wrap mt-1",children:Ows.map(Z=>e.jsx("button",{type:"button",onClick:()=>O(Z),className:`h-8 w-8 rounded-md text-lg flex items-center justify-center transition-all ${L===Z?"bg-primary/15 ring-2 ring-primary":"hover:bg-muted"}`,children:Z},Z))})]})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:d?"Save changes, then jump to the Steps tab to manage your sequence.":"Save to create the campaign, then you can add steps to it."})})]})})}),e.jsx(js,{value:"steps",className:"flex-1 overflow-hidden mt-0",children:e.jsx(di,{className:"h-full",children:e.jsx("div",{className:"p-5 space-y-3",children:f?e.jsx("div",{className:"text-center text-sm text-muted-foreground py-8",children:"Loading steps…"}):!p||p.length===0?e.jsxs("div",{className:"text-center py-10 border border-dashed rounded-xl",children:[e.jsx(qr,{className:"h-8 w-8 text-muted-foreground/40 mx-auto mb-2"}),e.jsx("p",{className:"text-sm font-medium mb-1",children:"No steps yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Build your sequence — each step waits for its delay, then sends."}),e.jsxs(K,{size:"sm",onClick:ee,disabled:b.isPending,children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1.5"})," Add first step"]})]}):e.jsxs(e.Fragment,{children:[p.map((Z,J)=>e.jsx(Fws,{step:Z,index:J,totalSteps:p.length},Z.id)),e.jsxs(K,{variant:"outline",size:"sm",onClick:ee,disabled:b.isPending,className:"w-full",children:[b.isPending?e.jsx(ps,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1.5"}),"Add another step"]})]})})})})]}),e.jsxs(gn,{className:"border-t p-4 shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:d?"Done":"Cancel"}),e.jsxs(K,{onClick:V,disabled:y.isPending||_.isPending,children:[(y.isPending||_.isPending)&&e.jsx(ps,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),d?"Save Changes":"Create Campaign"]})]})]})})}function Fws({step:t,index:s,totalSteps:r}){const n=Aws(),a=Ews(),[o,l]=k.useState(!1),[i,d]=k.useState(t),[u,p]=k.useState(!1);k.useEffect(()=>d(t),[t]);const f=JSON.stringify(i)!==JSON.stringify(t),y=async()=>{p(!0);try{await n.mutateAsync({id:t.id,campaign_id:t.campaign_id,channel:i.channel,subject:i.subject,body:i.body,video_url:i.video_url,delay_type:i.delay_type,delay_days:i.delay_days,delay_hours:i.delay_hours,anchor_field:i.anchor_field,anchor_offset_days:i.anchor_offset_days}),me.success(`Step ${s+1} saved`)}catch{me.error("Failed to save step")}finally{p(!1)}},_=async()=>{if(confirm(`Delete step ${s+1}?`))try{await a.mutateAsync({id:t.id,campaign_id:t.campaign_id}),me.success("Step deleted")}catch{me.error("Failed to delete")}},b=w=>{d({...i,body:i.body+w})},N=()=>{if(i.delay_type==="calendar_anchor"){const S=i.anchor_field==="birthday"?"birthday":"home anniversary",C=i.anchor_offset_days||0;return C===0?`On their ${S}`:C<0?`${Math.abs(C)}d before ${S}`:`${C}d after ${S}`}if(s===0&&!i.delay_days&&!i.delay_hours)return"Sends immediately";const w=[];return i.delay_days&&w.push(`${i.delay_days}d`),i.delay_hours&&w.push(`${i.delay_hours}h`),s===0?`After ${w.join(" ")||"0"}`:`+${w.join(" ")||"0"}`};return e.jsxs("div",{className:"border rounded-lg bg-card overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 hover:bg-muted/30 cursor-pointer",onClick:()=>l(!o),children:[e.jsx("div",{className:"h-7 w-7 shrink-0 rounded-full bg-primary/10 text-primary flex items-center justify-center text-xs font-semibold",children:s+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[i.delay_type==="calendar_anchor"?e.jsx(nn,{className:"h-3 w-3"}):e.jsx(rn,{className:"h-3 w-3"}),e.jsx("span",{children:N()}),e.jsx("span",{children:"·"}),i.channel==="email"?e.jsx(tr,{className:"h-3 w-3"}):e.jsx(Si,{className:"h-3 w-3"}),e.jsx("span",{className:"capitalize",children:i.channel})]}),e.jsx("p",{className:"text-sm font-medium truncate mt-0.5",children:i.subject||e.jsx("span",{className:"text-muted-foreground italic",children:"No subject"})})]}),o?e.jsx(lf,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Fi,{className:"h-4 w-4 text-muted-foreground"})]}),o&&e.jsxs("div",{className:"border-t p-4 space-y-3 bg-muted/10",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Channel"}),e.jsxs(zs,{value:i.channel,onValueChange:w=>d({...i,channel:w}),children:[e.jsx(Os,{className:"mt-1 h-9",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"email",children:"📧 Email"}),e.jsx(yt,{value:"sms",children:"💬 SMS"})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Timing Type"}),e.jsxs(zs,{value:i.delay_type,onValueChange:w=>d({...i,delay_type:w}),children:[e.jsx(Os,{className:"mt-1 h-9",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"relative",children:"⏱ Relative delay"}),e.jsx(yt,{value:"calendar_anchor",children:"📅 Calendar date"})]})]})]})]}),i.delay_type==="relative"?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Days delay"}),e.jsx(Fe,{type:"number",min:0,value:i.delay_days,onChange:w=>d({...i,delay_days:parseInt(w.target.value)||0}),className:"mt-1 h-9"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Hours delay"}),e.jsx(Fe,{type:"number",min:0,max:23,value:i.delay_hours,onChange:w=>d({...i,delay_hours:parseInt(w.target.value)||0}),className:"mt-1 h-9"})]})]}):e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Anchor"}),e.jsxs(zs,{value:i.anchor_field||"birthday",onValueChange:w=>d({...i,anchor_field:w}),children:[e.jsx(Os,{className:"mt-1 h-9",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"birthday",children:"🎂 Birthday"}),e.jsx(yt,{value:"home_anniversary",children:"🏠 Home Anniversary"})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Offset (days, negative = before)"}),e.jsx(Fe,{type:"number",value:i.anchor_offset_days||0,onChange:w=>d({...i,anchor_offset_days:parseInt(w.target.value)||0}),className:"mt-1 h-9",placeholder:"0 = on the day, -7 = week before"})]})]}),i.channel==="email"&&e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Subject Line"}),e.jsx(Fe,{value:i.subject,onChange:w=>d({...i,subject:w.target.value}),placeholder:"e.g. Quick question about your home search, {{client_first_name}}",className:"mt-1 h-9"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(ge,{className:"text-xs",children:i.channel==="email"?"Email Body":"SMS Message"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:i.channel==="sms"?`${i.body.length}/160`:`${i.body.length} chars`})]}),e.jsx(_r,{value:i.body,onChange:w=>d({...i,body:w.target.value}),placeholder:i.channel==="email"?`Hi {{client_first_name}}, I wanted to reach out and...`:"Hi {{client_first_name}}, just checking in!",rows:i.channel==="email"?6:3,className:"mt-1 font-mono text-xs"}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground mr-1",children:"Insert:"}),Dws.map(w=>e.jsx("button",{type:"button",onClick:()=>b(w.key),className:"text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary hover:bg-primary/20",children:w.label},w.key))]})]}),i.channel==="email"&&e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Video URL (optional)"}),e.jsx(Fe,{value:i.video_url||"",onChange:w=>d({...i,video_url:w.target.value||null}),placeholder:"https://...",className:"mt-1 h-9"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:_,className:"text-destructive hover:text-destructive",children:[e.jsx(yr,{className:"h-3.5 w-3.5 mr-1"})," Delete step"]}),e.jsxs(K,{size:"sm",onClick:y,disabled:!f||u,children:[u&&e.jsx(ps,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save step"]})]})]})]})}function zws({open:t,onOpenChange:s,contactIds:r,onSuccess:n}){const{data:a,isLoading:o}=XSe(),l=xit(),[i,d]=k.useState(""),[u,p]=k.useState(null),[f,y]=k.useState(!1),_=(a||[]).filter(w=>!w.is_starter),b=_.filter(w=>w.name.toLowerCase().includes(i.toLowerCase())||(w.description||"").toLowerCase().includes(i.toLowerCase())),N=async()=>{if(u)try{const w=await l.mutateAsync({campaignId:u,contactIds:r}),S=[`${w.enrolled} enrolled`];w.skipped>0&&S.push(`${w.skipped} skipped`),w.errors>0&&S.push(`${w.errors} errors`),me.success(S.join(" · ")),s(!1),p(null),n==null||n()}catch(w){me.error(w.message||"Failed to enroll contacts")}};return e.jsxs(fs,{open:t,onOpenChange:s,children:[e.jsxs(ms,{className:"max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(qr,{className:"h-4 w-4 text-primary"}),"Enroll in Drip Campaign"]}),e.jsxs(Rr,{children:[r.length," contact",r.length!==1?"s":""," will be added to the selected campaign. Already-enrolled contacts will be skipped."]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(tn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search campaigns...",value:i,onChange:w=>d(w.target.value),className:"pl-9 h-9"})]}),e.jsx(di,{className:"h-[320px] -mx-1 px-1",children:o?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"Loading..."}):b.length===0?e.jsx("div",{className:"text-center py-8",children:_.length===0?e.jsxs(e.Fragment,{children:[e.jsx(qr,{className:"h-8 w-8 text-muted-foreground/40 mx-auto mb-2"}),e.jsx("p",{className:"text-sm font-medium mb-1",children:"No campaigns yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Build a custom drip campaign to nurture these contacts on autopilot."}),e.jsxs(K,{size:"sm",onClick:()=>y(!0),children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1.5"})," Create campaign"]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No campaigns match your search."})}):e.jsx("div",{className:"space-y-1.5",children:b.map(w=>e.jsxs("button",{onClick:()=>p(w.id),className:`w-full flex items-start gap-3 p-3 rounded-lg border text-left transition-all ${u===w.id?"border-primary bg-primary/5 ring-1 ring-primary":"border-border hover:border-primary/40 hover:bg-muted/30"}`,children:[e.jsx("div",{className:`shrink-0 h-9 w-9 rounded-lg bg-gradient-to-br ${w.cover_color} flex items-center justify-center text-lg`,children:w.icon}),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:w.name}),w.is_active&&e.jsx(Ye,{variant:"outline",className:"text-[9px] bg-emerald-500/10 text-emerald-600 border-emerald-200 px-1 py-0",children:"Active"})]}),w.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-0.5",children:w.description})]}),u===w.id&&e.jsx(ea,{className:"h-4 w-4 text-primary shrink-0 mt-1"})]},w.id))})})]}),e.jsxs(gn,{className:"gap-2 sm:gap-2",children:[_.length>0&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>y(!0),className:"mr-auto text-xs",children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"})," New campaign"]}),e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:N,disabled:!u||l.isPending,children:[l.isPending&&e.jsx(ps,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Enroll ",r.length," contact",r.length!==1?"s":""]})]})]}),e.jsx(git,{open:f,onOpenChange:y})]})}function Tme(){const t=_a();return ft({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 Bws(t){return ft({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 QSe(){const t=es(),s=_a();return Et({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 $ws(){const t=es();return Et({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 qws(){const t=es();return Et({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 yit(){const t=es();return Et({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 Uws(){const t=es();return Et({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 Vws(){const t=_a();return ft({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 Hws({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const i=br(),{data:d}=Mf(),u=fke(),p=es(),{isGmailConnected:f}=bp(),{isReady:y}=WSe(),{data:_}=Tme(),b=QSe(),N=yit(),[w,S]=k.useState(!1),[C,A]=k.useState(!1),[I,L]=k.useState(!1),[O,U]=k.useState(!1),[q,$]=k.useState(""),V=t.size;if(V===0)return null;const ee=async le=>{S(!0);try{const xe=Array.from(t).map(we=>({contact_id:we,relationship_type_id:le})),{error:he}=await G.from("innercircle_contact_tags").upsert(xe,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(he)throw he;p.invalidateQueries({queryKey:["innercircle-contacts"]}),p.invalidateQueries({queryKey:["innercircle-contact-counts"]}),cn({title:`Assigned type to ${V} contacts`}),r()}catch(fe){cn({title:"Error assigning type",description:fe.message,variant:"destructive"})}finally{S(!1)}},Z=async le=>{S(!0);try{const fe=Array.from(t);for(const xe of fe)try{await N.mutateAsync({contactId:xe,tagId:le})}catch{}p.invalidateQueries({queryKey:["all-contact-custom-tags"]}),cn({title:`Tagged ${V} contacts`}),U(!1),$("")}catch(fe){cn({title:"Error adding tags",description:fe.message,variant:"destructive"})}finally{S(!1)}},J=async()=>{if(q.trim()){S(!0);try{const le=await b.mutateAsync({name:q.trim()});await Z(le.id)}catch(le){cn({title:"Error creating tag",description:le.message,variant:"destructive"}),S(!1)}}},Y=(_==null?void 0:_.filter(le=>le.name.toLowerCase().includes(q.toLowerCase())))||[],ce=_==null?void 0:_.find(le=>le.name.toLowerCase()===q.trim().toLowerCase()),ae=()=>{const le=s.filter(Te=>t.has(Te.id)),fe=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],xe=le.map(Te=>{var Ae;return[Te.first_name,Te.last_name||"",Te.email||"",Te.phone||"",Te.address||"",Te.birthday||"",Te.home_anniversary||"",Te.notes||"",((Ae=Te.tags)==null?void 0:Ae.map(ze=>{var Ee;return(Ee=ze.relationship_type)==null?void 0:Ee.name}).join("; "))||""]}),he=[fe.join(","),...xe.map(Te=>Te.map(Ae=>`"${(Ae||"").replace(/"/g,'""')}"`).join(","))].join(` `),we=new Blob([he],{type:"text/csv"}),Ne=URL.createObjectURL(we),Ve=document.createElement("a");Ve.href=Ne,Ve.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,Ve.click(),URL.revokeObjectURL(Ne),cn({title:`Exported ${V} contacts`})},ie=async()=>{if(confirm(`Are you sure you want to delete ${V} contacts? This cannot be undone.`)){S(!0);try{const le=Array.from(t);for(const fe of le)await u.mutateAsync(fe);r()}catch(le){cn({title:"Error deleting contacts",description:le.message,variant:"destructive"})}finally{S(!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(Ye,{variant:"secondary",className:"font-semibold",children:[V," selected"]}),e.jsxs(zs,{onValueChange:ee,disabled:w,children:[e.jsx(Os,{className:"w-[180px] h-8",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(hh,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),e.jsx(Fs,{children:d==null?void 0:d.filter(le=>le.active).map(le=>e.jsx(yt,{value:le.id,children:le.name},le.id))})]}),e.jsxs(yo,{open:O,onOpenChange:U,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",disabled:w,children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(uo,{className:"w-56 p-2",align:"start",children:[e.jsx(Fe,{placeholder:"Search or create tag...",value:q,onChange:le=>$(le.target.value),onKeyDown:le=>{le.key==="Enter"&&q.trim()&&!ce?(le.preventDefault(),J()):le.key==="Enter"&&ce&&(le.preventDefault(),Z(ce.id))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[Y.map(le=>e.jsxs("button",{onClick:()=>Z(le.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:le.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:le.name})]},le.id)),q.trim()&&!ce&&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(Bs,{className:"h-3.5 w-3.5"}),'Create "',q.trim(),'"']}),Y.length===0&&!q.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:()=>A(!0),disabled:w,children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),y&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const le=Array.from(t).join(",");i(`/admin/email-campaigns/new?contactIds=${le}`)},disabled:w,children:[e.jsx(dh,{className:"h-3.5 w-3.5 mr-1"}),"Mass Email"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>L(!0),disabled:w,children:[e.jsx(qr,{className:"h-3.5 w-3.5 mr-1"}),"Enroll in Campaign"]}),a&&n&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>n(Array.from(t)),disabled:w,children:[e.jsx(Lg,{className:"h-3.5 w-3.5 mr-1"}),"Send to Lead Pond"]}),l&&o&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>o(Array.from(t)),disabled:w,children:[e.jsx(Gv,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ae,disabled:w,children:[e.jsx(Xa,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,disabled:w,className:"text-destructive hover:text-destructive",children:[e.jsx(yr,{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(Sr,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(zws,{open:I,onOpenChange:L,contactIds:Array.from(t),onSuccess:r}),e.jsx(E1,{open:C,onOpenChange:A,bulkContacts:Array.from(t).map(le=>{const fe=s.find(xe=>xe.id===le);return fe?{id:fe.id,first_name:fe.first_name,last_name:fe.last_name,email:fe.email||""}:null}).filter(le=>le!==null&&le.email!==""),onSendComplete:()=>{A(!1),r()}})]})}function X7e({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const d=br(),{isReady:u}=WSe(),p=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:f=>f.stopPropagation(),children:e.jsx(dx,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",onClick:f=>f.stopPropagation(),children:[e.jsxs(xa,{onClick:()=>d(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(Tn,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(xa,{onClick:()=>d(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(xa,{onClick:()=>d(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(La,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),u&&t.email&&e.jsxs(xa,{onClick:()=>d(`/admin/email-campaigns/new?contactIds=${t.id}`),children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Mass Email"]}),e.jsxs(xa,{onClick:()=>n(t.id,p),children:[e.jsx(uh,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(xa,{onClick:()=>a(t.id),children:[e.jsx(Lg,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(xa,{onClick:()=>l(t.id),children:[e.jsx(Gv,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(xa,{onClick:()=>s(t),children:[e.jsx(pa,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(xa,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(yr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function Gws(){const{user:t}=$s();return ft({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 Wws(){const t=es(),{user:s}=$s();return Et({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"]}),cn({title:"Smart filter saved"})},onError:r=>{cn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function Kws(){const t=es();return Et({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"]}),cn({title:"Smart filter deleted"})}})}function Zws({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=Gws(),a=Wws(),o=Kws(),[l,i]=k.useState(!1),[d,u]=k.useState(""),p=t.search||t.type&&t.type!=="all"||t.status&&t.status!=="all",f=async()=>{d.trim()&&(await a.mutateAsync({name:d.trim(),filters:t,sort_by:s}),u(""),i(!1))};return e.jsxs(e.Fragment,{children:[e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Dg,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(Ye,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(Fi,{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(xa,{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(yr,{className:"h-3 w-3 text-destructive"})})]},y.id)),e.jsx(Jb,{})]}):e.jsx(xa,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),p&&e.jsxs(xa,{onClick:()=>i(!0),children:[e.jsx(oL,{className:"h-4 w-4 mr-2"}),"Save Current Filter"]})]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ms,{className:"max-w-sm",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Save Smart Filter"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Fe,{placeholder:"e.g. Buyers in 40205",value:d,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:!d.trim()||a.isPending,children:"Save"})]})]})]})})]})}function $6(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 J7e({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=br(),i=Q7e(t,"birthday",7),d=Q7e(s,"anniversary",7);if(!i&&!d)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:Rt("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Ye,{variant:"secondary",className:Rt("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(tr,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),d&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Ye,{variant:"secondary",className:Rt("text-[10px] gap-0.5 font-medium",d.daysUntil===0?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400 animate-pulse":"bg-blue-50 text-blue-600 dark:bg-blue-900/20 dark:text-blue-400"),children:d.label}),n&&e.jsxs("button",{onClick:p=>u("home_anniversary",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors",title:"Send an anniversary card",children:[e.jsx(tr,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function eze({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(Ye,{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 tze({count:t,className:s}){return!t||t<=0?null:e.jsxs(Ye,{variant:"outline",className:Rt("text-[10px] gap-1 border-emerald-300 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400 px-1.5 py-0 h-5",s),title:`Enrolled in ${t} active drip campaign${t===1?"":"s"}`,children:[e.jsx(wS,{className:"h-2.5 w-2.5"}),t===1?"In drip":`${t} drips`]})}function Yws(){const t=_a();return ft({queryKey:["contacts-campaign-counts",t],queryFn:async()=>{if(!t)return{};const{data:s,error:r}=await G.from("drip_campaign_enrollments").select("contact_id, status").eq("owner_user_id",t).eq("status","active");if(r)throw r;const n={};return(s||[]).forEach(a=>{a.contact_id&&(n[a.contact_id]=(n[a.contact_id]||0)+1)}),n},enabled:!!t,staleTime:6e4})}function Xws(){const t=_a();return ft({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 Qws({contactId:t,compact:s=!1}){const{data:r}=Tme(),{data:n}=Bws(t),a=QSe(),o=yit(),l=Uws(),[i,d]=k.useState(!1),[u,p]=k.useState(""),f=k.useRef(null),y=new Set((n==null?void 0:n.map(S=>S.tag_id))||[]),_=(r==null?void 0:r.filter(S=>S.name.toLowerCase().includes(u.toLowerCase())))||[],b=r==null?void 0:r.find(S=>S.name.toLowerCase()===u.trim().toLowerCase()),N=async S=>{y.has(S.id)?await l.mutateAsync({contactId:t,tagId:S.id}):await o.mutateAsync({contactId:t,tagId:S.id})},w=async()=>{if(!(!u.trim()||b))try{const S=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:S.id}),p("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(S=>{var C,A,I;return e.jsxs(Ye,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((C=S.tag)==null?void 0:C.color)||"#6366F1",color:((A=S.tag)==null?void 0:A.color)||"#6366F1"},children:[e.jsx(hh,{className:"h-2.5 w-2.5"}),(I=S.tag)==null?void 0:I.name,e.jsx("button",{onClick:L=>{L.stopPropagation(),l.mutate({contactId:t,tagId:S.tag_id})},className:"ml-0.5 rounded-full hover:bg-accent p-0.5",children:e.jsx(Sr,{className:"h-2.5 w-2.5"})})]},S.id)}),e.jsxs(yo,{open:i,onOpenChange:d,children:[e.jsx(vo,{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:S=>S.stopPropagation(),children:[e.jsx(Bs,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(uo,{className:"w-56 p-2",align:"start",onClick:S=>S.stopPropagation(),children:[e.jsx(Fe,{ref:f,placeholder:"Search or create tag...",value:u,onChange:S=>p(S.target.value),onKeyDown:S=>{S.key==="Enter"&&u.trim()&&!b?(S.preventDefault(),w()):S.key==="Enter"&&b&&!y.has(b.id)&&(S.preventDefault(),N(b))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[_.map(S=>e.jsxs("button",{onClick:()=>N(S),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:S.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:S.name}),y.has(S.id)&&e.jsx(ea,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},S.id)),u.trim()&&!b&&e.jsxs("button",{onClick:w,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx(Bs,{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 sze({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(Ye,{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 b9=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function Jws({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Tme(),a=QSe(),o=qws(),l=$ws(),[i,d]=k.useState(""),[u,p]=k.useState(b9[0]),[f,y]=k.useState(null),[_,b]=k.useState(""),[N,w]=k.useState(""),S=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),d(""),p(b9[0]),cn({title:"Tag created"})}catch(L){cn({title:"Error",description:L.message,variant:"destructive"})}},C=async L=>{if(_.trim())try{await o.mutateAsync({id:L,name:_.trim(),color:N}),y(null),cn({title:"Tag updated"})}catch(O){cn({title:"Error",description:O.message,variant:"destructive"})}},A=async(L,O)=>{if(confirm(`Delete tag "${O}"? It will be removed from all contacts.`))try{await l.mutateAsync(L),cn({title:"Tag deleted"})}catch(U){cn({title:"Error",description:U.message,variant:"destructive"})}},I=L=>{y(L.id),b(L.name),w(L.color)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Manage Tags"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{placeholder:"New tag name...",value:i,onChange:L=>d(L.target.value),onKeyDown:L=>L.key==="Enter"&&S(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:S,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:b9.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:b9.map(O=>e.jsx("button",{onClick:()=>w(O),className:`h-5 w-5 rounded-full border-2 ${N===O?"border-foreground":"border-transparent"}`,style:{backgroundColor:O}},O))}),e.jsx(Fe,{value:_,onChange:O=>b(O.target.value),onKeyDown:O=>O.key==="Enter"&&C(L.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>C(L.id),children:e.jsx(ea,{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(Sr,{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(pa,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>A(L.id,L.name),children:e.jsx(yr,{className:"h-3.5 w-3.5"})})]})},L.id))]})]})})}function e2s({open:t,onOpenChange:s}){const{data:r,isLoading:n}=eE(),a=gke(),o=kDt(),l=SDt(),[i,d]=k.useState(""),[u,p]=k.useState(null),[f,y]=k.useState(""),_=async()=>{if(i.trim())try{await a.mutateAsync(i.trim()),d("")}catch(S){me.error(S.message||"Failed to add lead source")}},b=async S=>{if(f.trim())try{await o.mutateAsync({id:S,name:f.trim()}),p(null)}catch(C){me.error(C.message||"Failed to update")}},N=async(S,C)=>{if(confirm(`Remove lead source "${C}"? Contacts using it will keep the label but it won't appear in new dropdowns.`))try{await l.mutateAsync(S)}catch(A){me.error(A.message||"Failed to remove")}},w=S=>{p(S.id),y(S.name)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Manage Lead Sources"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{placeholder:"New lead source name...",value:i,onChange:S=>d(S.target.value),onKeyDown:S=>S.key==="Enter"&&_(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:_,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Bs,{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(S=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:u===S.id?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{value:f,onChange:C=>y(C.target.value),onKeyDown:C=>C.key==="Enter"&&b(S.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(S.id),children:e.jsx(ea,{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(Sr,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-sm",children:S.name}),S.owner_user_id&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>w(S),children:e.jsx(pa,{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:()=>N(S.id,S.name),children:e.jsx(yr,{className:"h-3.5 w-3.5"})})]}),!S.owner_user_id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"})]})},S.id))]})]})})}function vit({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=eE(),a=gke(),[o,l]=k.useState(!1),[i,d]=k.useState(""),u=async()=>{if(i.trim())try{const p=await a.mutateAsync(i.trim());p&&(s(p.id),d(""),l(!1))}catch{}};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:r}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(zs,{value:t||"_none",onValueChange:p=>s(p==="_none"?"":p),children:[e.jsx(Os,{className:"flex-1",children:e.jsx(qs,{placeholder:"Select lead source"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"_none",children:"No source"}),n==null?void 0:n.map(p=>e.jsx(yt,{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(Sr,{className:"h-4 w-4"}):e.jsx(Bs,{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=>d(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),u())},className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:u,disabled:!i.trim()||a.isPending,children:"Add"})]})]})}function Lwe({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=br(),[d,u]=k.useState(!1),[p,f]=k.useState(""),{data:y}=ft({queryKey:["innercircle-contact-spouse",s],queryFn:async()=>{const{data:b,error:N}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone, birthday").eq("id",s).maybeSingle();if(N)throw N;return b},enabled:!!s}),{data:_}=ft({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:N,error:w}=await b;if(w)throw w;return N},enabled:d});if(s&&y){const b=`${y.first_name} ${y.last_name||""}`.trim();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{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(Ei,{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(kS,{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(ti,{className:"h-3.5 w-3.5"})})]})]})}return!s&&(r||n)?e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{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(Ei,{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(yo,{open:d,onOpenChange:u,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"shrink-0 h-7 px-2",children:[e.jsx(Do,{className:"h-3.5 w-3.5 mr-1"}),"Link Contact"]})}),e.jsx(uo,{className:"w-72 p-2",align:"end",children:e.jsx(rze,{search:p,setSearch:f,results:_,onSelect:b=>{a(b),u(!1),f("")}})})]})]})]}):l?e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs(yo,{open:d,onOpenChange:u,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full justify-start text-muted-foreground font-normal h-10",children:[e.jsx(Do,{className:"h-4 w-4 mr-2"}),"Link an existing contact as spouse..."]})}),e.jsx(uo,{className:"w-72 p-2",align:"start",children:e.jsx(rze,{search:p,setSearch:f,results:_,onSelect:b=>{a(b),u(!1),f("")}})})]})]}):null}function rze({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(tn,{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(di,{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 t2s(){var Fn;const t=br(),[s,r]=Sc(),{user:n}=$s(),a=bE(),o=es(),l=s.get("type"),i=s.get("filter")??s.get("status"),d=s.get("new")==="true",{contactsWithScores:u,isLoading:p}=lhe(),{activeContactIds:f,hasLeadSite:y}=gws(),{data:_}=Yws(),{data:b}=Mf(),{data:N}=Xws(),{data:w}=Tme(),{data:S}=Vws(),[C,A]=k.useState(new Set),[I,L]=k.useState("any"),O=nhe(),U=pke(),q=fke(),$=LXe(),[V,ee]=k.useState(""),[Z,J]=k.useState(l||"all"),[Y,ce]=k.useState(i||"all"),[ae,ie]=k.useState("date-added"),[le,fe]=k.useState(d),[xe,he]=k.useState(null),[we,Ne]=k.useState(!1),[Ve,Te]=k.useState(!1),[Ae,ze]=k.useState(null),[Ee,ve]=k.useState(""),[Re,Ue]=k.useState(new Set),[ye,ct]=k.useState(!1),pe=Math.max(1,parseInt(s.get("page")||"1",10)||1),[Ge,tt]=k.useState(pe),st=k.useCallback(Kt=>{tt(Mr=>{const On=typeof Kt=="function"?Kt(Mr):Kt;return r(ua=>{const $t=new URLSearchParams(ua);return On<=1?$t.delete("page"):$t.set("page",String(On)),$t},{replace:!0}),On})},[]),[Ce,et]=k.useState(50),[Ct,Ot]=k.useState("my"),[ut,Oe]=k.useState(!1),[Xe,at]=k.useState(!1),{data:Ke}=Rx(),{addToLeadPond:He}=Ptt(Ke==null?void 0:Ke.teamId),gt=!!((Fn=Ke==null?void 0:Ke.team)!=null&&Fn.lead_pond_enabled&&(Ke!=null&&Ke.teamId)),Mt=!!(Ke!=null&&Ke.teamId),[Wt,xs]=k.useState([]),[Cs,Us]=k.useState(!1),Ar=Kt=>{xs([Kt]),Us(!0)},Bt=Kt=>{xs(Kt),Us(!0)},Xs=Kt=>{Ke!=null&&Ke.teamId&&He.mutate({contact_id:Kt,team_id:Ke.teamId})},Nr=Kt=>{Ke!=null&&Ke.teamId&&Kt.forEach(Mr=>{He.mutate({contact_id:Mr,team_id:Ke.teamId})})},Vs=k.useCallback(Kt=>{ct(!1),Ue(Mr=>{const On=new Set(Mr);return On.has(Kt)?On.delete(Kt):On.add(Kt),On})},[]);k.useEffect(()=>{if(!(n!=null&&n.id))return;const Kt=G.channel(`innercircle_contacts_inserts_${n.id}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"innercircle_contacts",filter:`owner_user_id=eq.${n.id}`},()=>{o.invalidateQueries({queryKey:["innercircle-contacts"]}),o.invalidateQueries({queryKey:["innercircle-contact-counts"]})}).subscribe();return()=>{G.removeChannel(Kt)}},[o,n==null?void 0:n.id]),k.useEffect(()=>{i&&ce(i)},[i]);const[ar,Or]=k.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]});k.useEffect(()=>{d&&fe(!0)},[d]),k.useEffect(()=>{var Kt;xe&&Or({first_name:xe.first_name||"",last_name:xe.last_name||"",email:xe.email||"",phone:xe.phone||"",address:xe.address||"",city:xe.city||"",state:xe.state||"",zip_code:xe.zip_code||"",birthday:xe.birthday||"",home_anniversary:xe.home_anniversary||"",spouse_name:xe.spouse_name||"",spouse_email:xe.spouse_email||"",lead_source_id:xe.lead_source_id||"",notes:xe.notes||"",tagIds:((Kt=xe.tags)==null?void 0:Kt.map(Mr=>Mr.relationship_type_id))||[]})},[xe]);const Rn=k.useMemo(()=>{if(!u)return[];let Kt=u.filter(Mr=>{var Se,De,Ze;const On=V===""||`${Mr.first_name} ${Mr.last_name}`.toLowerCase().includes(V.toLowerCase())||((Se=Mr.email)==null?void 0:Se.toLowerCase().includes(V.toLowerCase()))||((De=Mr.phone)==null?void 0:De.includes(V)),ua=Z==="all"||((Ze=Mr.tags)==null?void 0:Ze.some(xt=>xt.relationship_type_id===Z)),$t=C.size===0||(()=>{const xt=(S==null?void 0:S.filter(_t=>_t.contact_id===Mr.id).map(_t=>_t.tag_id))||[];return I==="any"?xt.some(_t=>C.has(_t)):Array.from(C).every(_t=>xt.includes(_t))})();return On&&ua&&$t});return Y==="not-touched-90"?Kt=Kt.filter(Mr=>{const On=Mr.relationshipScore.daysSinceTouch;return On===null||On>90}):Y==="at-risk"?Kt=Kt.filter(Mr=>Mr.relationshipScore.status==="at-risk"):Y==="cooling"?Kt=Kt.filter(Mr=>Mr.relationshipScore.status==="cooling"):Y==="warm"?Kt=Kt.filter(Mr=>Mr.relationshipScore.status==="warm"):Y==="has-deal"?Kt=Kt.filter(Mr=>N&&N[Mr.id]):Y==="no-deal"?Kt=Kt.filter(Mr=>!N||!N[Mr.id]):Y==="open-house"?Kt=Kt.filter(Mr=>{var ua;return(((ua=Mr.lead_source_ref)==null?void 0:ua.name)||Mr.lead_source)==="Open House"}):Y==="website-active"&&(Kt=Kt.filter(Mr=>f.has(Mr.id))),Kt=[...Kt].sort((Mr,On)=>{switch(ae){case"important-dates":{const ua=$6(Mr.birthday),$t=$6(On.birthday),Se=$6(Mr.home_anniversary),De=$6(On.home_anniversary),Ze=[ua,Se].filter(_t=>_t!==null).sort((_t,Pt)=>(_t??1/0)-(Pt??1/0))[0]??1/0,xt=[$t,De].filter(_t=>_t!==null).sort((_t,Pt)=>(_t??1/0)-(Pt??1/0))[0]??1/0;return Ze-xt}case"last-touched":{const ua=Mr.relationshipScore.lastTouchDate,$t=On.relationshipScore.lastTouchDate;return!ua&&!$t?0:ua?$t?new Date(ua).getTime()-new Date($t).getTime():1:-1}case"next-touch":{const ua=Mr.relationshipScore.daysSinceTouch,$t=On.relationshipScore.daysSinceTouch;return ua===null&&$t===null?0:ua===null?-1:$t===null?1:$t-ua}case"score":return Mr.relationshipScore.score-On.relationshipScore.score;case"date-added":{const ua=Mr.created_at,$t=On.created_at;return!ua&&!$t?0:ua?$t?new Date($t).getTime()-new Date(ua).getTime():-1:1}case"name":default:{const ua=`${Mr.first_name||""} ${Mr.last_name||""}`.toLowerCase(),$t=`${On.first_name||""} ${On.last_name||""}`.toLowerCase();return ua.localeCompare($t)}}}),Kt},[u,V,Z,C,I,Y,ae,N,S,f]),bn=Rn.length,ir=Math.max(1,Math.ceil(bn/Ce)),or=Math.min(Ge,ir),hr=k.useMemo(()=>{const Kt=(or-1)*Ce;return Rn.slice(Kt,Kt+Ce)},[Rn,or,Ce]),an=k.useRef(!1);k.useEffect(()=>{if(!an.current){an.current=!0;return}st(1)},[V,Z,C,I,Y,ae]);const Gr=k.useCallback(()=>{ct(!1),Ue(Kt=>Kt.size>0?new Set:new Set(hr.map(Mr=>Mr.id)))},[hr]),Va=k.useCallback(()=>{ct(!0),Ue(new Set(Rn.map(Kt=>Kt.id)))},[Rn]),$a=k.useCallback((Kt,Mr)=>{ee(Kt.search||""),J(Kt.type||"all"),ce(Kt.status||"all"),ie(Mr||"name")},[]),Xt=()=>{Or({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},Qa=async Kt=>{Kt.preventDefault();const Mr={...ar,lead_source_id:ar.lead_source_id||null};xe?(await U.mutateAsync({id:xe.id,...Mr}),he(null)):(await O.mutateAsync(Mr),fe(!1)),Xt()},Cr=async Kt=>{confirm("Are you sure you want to delete this contact?")&&await q.mutateAsync(Kt)};return e.jsx(Ls,{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"})]}),Ke&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsx("button",{onClick:()=>Ot("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${Ct==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(Ke.team.contact_visibility==="full_team"||Ke.team.contact_visibility==="leader_only"&&Ke.role==="team_leader")&&e.jsxs("button",{onClick:()=>Ot("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${Ct==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(cr,{className:"h-3.5 w-3.5"}),"Team"]}),Ke.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>Ot("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${Ct==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Lg,{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(wl,{className:"h-4 w-4 mr-1"}),"Back"]})}),Ct==="team"?e.jsx(k4e,{}):Ct==="lead-pond"&&Ke?e.jsx(S4e,{teamId:Ke.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{children:e.jsx(Be,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(tn,{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:V,onChange:Kt=>ee(Kt.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto pb-1",children:[e.jsxs(K,{onClick:()=>fe(!0),className:"shrink-0",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ne(!0),className:"shrink-0",children:[e.jsx(Da,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(K,{variant:"outline",onClick:()=>Te(!0),className:"shrink-0",children:[e.jsx(s0,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(lws,{})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(zs,{value:Z,onValueChange:J,children:[e.jsx(Os,{className:"w-[145px] h-9 text-sm",children:e.jsx(qs,{placeholder:"Filter by type"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Types"}),b==null?void 0:b.filter(Kt=>Kt.active).map(Kt=>e.jsx(yt,{value:Kt.id,children:Kt.name},Kt.id))]})]}),w&&w.length>0&&e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"h-9 justify-start text-sm",children:[e.jsx(hh,{className:"h-3.5 w-3.5 mr-1.5 shrink-0 text-muted-foreground"}),C.size===0?"Filter by Tags":`${C.size} tag${C.size>1?"s":""}`]})}),e.jsx(uo,{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:()=>L("any"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${I==="any"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"Any"}),e.jsx("button",{onClick:()=>L("all"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${I==="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:w.map(Kt=>{const Mr=C.has(Kt.id);return e.jsxs("button",{onClick:()=>{A(On=>{const ua=new Set(On);return ua.has(Kt.id)?ua.delete(Kt.id):ua.add(Kt.id),ua})},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(Gi,{checked:Mr,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:Kt.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:Kt.name})]},Kt.id)})}),C.size>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>A(new Set),children:"Clear tags"})]})})]}),e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",title:"Settings",children:e.jsx(So,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs(jd,{align:"end",children:[e.jsxs(xa,{onClick:()=>Oe(!0),children:[e.jsx(hh,{className:"h-4 w-4 mr-2"}),"Manage Tags"]}),e.jsxs(xa,{onClick:()=>at(!0),children:[e.jsx(Lg,{className:"h-4 w-4 mr-2"}),"Manage Lead Sources"]})]})]}),e.jsxs(zs,{value:Y,onValueChange:ce,children:[e.jsx(Os,{className:"w-[145px] h-9 text-sm",children:e.jsx(qs,{placeholder:"Filter by status"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Status"}),e.jsx(yt,{value:"warm",children:"🟢 Warm"}),e.jsx(yt,{value:"cooling",children:"🟡 Cooling Off"}),e.jsx(yt,{value:"at-risk",children:"🔴 At Risk"}),e.jsx(yt,{value:"has-deal",children:"📋 Has Deal"}),e.jsx(yt,{value:"no-deal",children:"📭 No Deal"}),e.jsx(yt,{value:"open-house",children:"🏠 Open House"}),y&&e.jsx(yt,{value:"website-active",children:"🌐 Website Active"})]})]}),e.jsxs(zs,{value:ae,onValueChange:ie,children:[e.jsx(Os,{className:"w-[165px] h-9 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(td,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(qs,{placeholder:"Sort by"})]})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"name",children:"Name (A-Z)"}),e.jsx(yt,{value:"important-dates",children:"Important Dates"}),e.jsx(yt,{value:"last-touched",children:"Last Touched"}),e.jsx(yt,{value:"next-touch",children:"Next Touch Due"}),e.jsx(yt,{value:"score",children:"Relationship Score"}),e.jsx(yt,{value:"date-added",children:"Date Added"})]})]}),e.jsx(Zws,{currentFilters:{search:V,type:Z,status:Y},currentSortBy:ae,onApplySmartList:$a})]})]})})}),e.jsx(Hws,{selectedIds:Re,contacts:Rn,onClearSelection:()=>{Ue(new Set),ct(!1)},showLeadPondAction:gt,onSendToLeadPond:Nr,showTransferAction:Mt,onTransfer:Bt}),Re.size>0&&Re.size===hr.length&&!ye&&bn>Ce&&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 ",hr.length," contacts on this page are selected."]}),e.jsxs(K,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:Va,children:["Select all ",bn.toLocaleString()," matching contacts"]})]}),ye&&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 ",bn.toLocaleString()," matching contacts are selected.",e.jsx(K,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{Ue(new Set),ct(!1)},children:"Clear selection"})]}),bn>Ce&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-2 py-1",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Showing ",(or-1)*Ce+1,"–",Math.min(or*Ce,bn)," of ",bn.toLocaleString()," contacts"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",disabled:or<=1,onClick:()=>st(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:or<=1,onClick:()=>st(Kt=>Kt-1),children:e.jsx(wl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",or," of ",ir]}),e.jsx(K,{variant:"outline",size:"sm",disabled:or>=ir,onClick:()=>st(Kt=>Kt+1),children:e.jsx(ja,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:or>=ir,onClick:()=>st(ir),children:"Last"})]})]}),a?e.jsx("div",{className:"space-y-3",children:p?e.jsx(Ie,{className:"p-6 text-center text-muted-foreground",children:"Loading contacts..."}):Rn.length===0?e.jsx(Ie,{className:"p-6 text-center text-muted-foreground",children:V||Z!=="all"||Y!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):hr.map(Kt=>{var On,ua,$t;const{relationshipScore:Mr}=Kt;return e.jsx(Ie,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const Se=new URLSearchParams;V&&Se.set("search",V),Z!=="all"&&Se.set("type",Z),Y!=="all"&&Se.set("filter",Y);const De=Se.toString();t(`/mission-control/contacts/${Kt.id}${De?`?${De}`:""}`)},children:e.jsx(Be,{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 flex-wrap",children:[e.jsxs("h3",{className:"font-semibold text-base truncate",children:[Kt.first_name," ",Kt.last_name]}),e.jsx(tze,{count:(_==null?void 0:_[Kt.id])??0}),e.jsx(ja,{className:"h-4 w-4 text-muted-foreground shrink-0 ml-auto"})]}),e.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[Kt.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(tr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:Kt.email})]}),Kt.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Tn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:Kt.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(C8,{score:Mr,size:"sm"}),e.jsx(Iwe,{contact:Kt}),(((On=Kt.lead_source_ref)==null?void 0:On.name)||Kt.lead_source)&&e.jsx(Ye,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((ua=Kt.lead_source_ref)==null?void 0:ua.name)||Kt.lead_source}),($t=Kt.tags)==null?void 0:$t.map(Se=>{var De;return e.jsx(Ye,{variant:"secondary",className:"text-xs",children:(De=Se.relationship_type)==null?void 0:De.name},Se.id)}),e.jsx(sze,{contactId:Kt.id,tags:S==null?void 0:S.filter(Se=>Se.contact_id===Kt.id)}),e.jsx(eze,{deal:N==null?void 0:N[Kt.id]})]}),e.jsx(J7e,{birthday:Kt.birthday,homeAnniversary:Kt.home_anniversary,className:"mb-2",contactId:Kt.id,contactName:`${Kt.first_name}${Kt.last_name?" "+Kt.last_name:""}`,contactAddress:[Kt.address,Kt.city,Kt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[Mr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(rn,{className:"h-3 w-3"}),gs(new Date(Mr.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),Kt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),gs(pl(Kt.birthday),"MMM d")]}),Kt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Mn,{className:"h-3 w-3"}),gs(pl(Kt.home_anniversary),"MMM d")]}),Kt.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Bs,{className:"h-3 w-3"}),"Added ",gs(new Date(Kt.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:Se=>Se.stopPropagation(),children:e.jsx(X7e,{contact:Kt,onEdit:he,onDelete:Cr,onSnooze:(Se,De)=>{ze(Se),ve(De)},showLeadPondAction:gt,onSendToLeadPond:Xs,showTransferAction:Mt,onTransfer:Ar})})]})})},Kt.id)})}):e.jsx(Ie,{children:e.jsx(Be,{className:"p-0 overflow-x-auto",children:e.jsxs(An,{className:"min-w-[800px]",children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{className:"w-[40px]",children:e.jsx(Gi,{checked:hr.length>0&&hr.every(Kt=>Re.has(Kt.id)),onCheckedChange:()=>Gr()})}),e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{children:"Score"}),e.jsx(Nt,{children:"Contact Info"}),e.jsx(Nt,{children:"Types / Pipeline"}),e.jsx(Nt,{children:"Last Contact"}),e.jsx(Nt,{className:"cursor-pointer select-none",onClick:()=>ie(ae==="date-added"?"name":"date-added"),children:e.jsxs("div",{className:"flex items-center gap-1",children:["Date Added",ae==="date-added"&&e.jsx(td,{className:"h-3 w-3"})]})}),e.jsx(Nt,{children:"Important Dates"}),e.jsx(Nt,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(Pn,{children:p?e.jsx(As,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):Rn.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:V||Z!=="all"||Y!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):hr.map(Kt=>{var ua,$t,Se;const{relationshipScore:Mr}=Kt,On=N==null?void 0:N[Kt.id];return e.jsxs(As,{className:`cursor-pointer hover:bg-accent/50 ${Re.has(Kt.id)?"bg-accent/30":""}`,onClick:()=>{const De=new URLSearchParams;V&&De.set("search",V),Z!=="all"&&De.set("type",Z),Y!=="all"&&De.set("status",Y);const Ze=De.toString();t(`/mission-control/contacts/${Kt.id}${Ze?`?${Ze}`:""}`)},children:[e.jsx(dt,{onClick:De=>De.stopPropagation(),children:e.jsx(Gi,{checked:Re.has(Kt.id),onCheckedChange:()=>Vs(Kt.id)})}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{children:[Kt.first_name," ",Kt.last_name]}),e.jsx(tze,{count:(_==null?void 0:_[Kt.id])??0})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(C8,{score:Mr,size:"sm"}),e.jsx(Iwe,{contact:Kt})]})}),e.jsx(dt,{children:e.jsx(C8,{score:Mr,size:"sm",showScore:!0})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[Kt.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(tr,{className:"h-3 w-3"}),Kt.email]}),Kt.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),Kt.phone]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((ua=Kt.lead_source_ref)==null?void 0:ua.name)||Kt.lead_source)&&e.jsx(Ye,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:(($t=Kt.lead_source_ref)==null?void 0:$t.name)||Kt.lead_source}),(Se=Kt.tags)==null?void 0:Se.map(De=>{var Ze;return e.jsx(Ye,{variant:"secondary",className:"text-xs",children:(Ze=De.relationship_type)==null?void 0:Ze.name},De.id)}),e.jsx(sze,{contactId:Kt.id,tags:S==null?void 0:S.filter(De=>De.contact_id===Kt.id)}),e.jsx(eze,{deal:On})]})}),e.jsx(dt,{children:e.jsx("div",{className:"text-sm",children:Mr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(rn,{className:"h-3 w-3"}),gs(new Date(Mr.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:Kt.created_at?gs(new Date(Kt.created_at),"MMM d, yyyy"):"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(J7e,{birthday:Kt.birthday,homeAnniversary:Kt.home_anniversary,contactId:Kt.id,contactName:`${Kt.first_name}${Kt.last_name?" "+Kt.last_name:""}`,contactAddress:[Kt.address,Kt.city,Kt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Kt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),gs(pl(Kt.birthday),"MMM d")]}),Kt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Mn,{className:"h-3 w-3"}),gs(pl(Kt.home_anniversary),"MMM d")]})]})]})}),e.jsx(dt,{children:e.jsx(X7e,{contact:Kt,onEdit:he,onDelete:Cr,onSnooze:(De,Ze)=>{ze(De),ve(Ze)},showLeadPondAction:gt,onSendToLeadPond:Xs,showTransferAction:Mt,onTransfer:Ar})})]},Kt.id)})})]})})}),bn>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 ",(or-1)*Ce+1,"–",Math.min(or*Ce,bn)," of ",bn.toLocaleString()," contacts"]}),e.jsxs(zs,{value:String(Ce),onValueChange:Kt=>{et(Number(Kt)),st(1)},children:[e.jsx(Os,{className:"w-[80px] h-8",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"50",children:"50"}),e.jsx(yt,{value:"100",children:"100"}),e.jsx(yt,{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:or<=1,onClick:()=>st(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:or<=1,onClick:()=>st(Kt=>Kt-1),children:e.jsx(wl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",or," of ",ir]}),e.jsx(K,{variant:"outline",size:"sm",disabled:or>=ir,onClick:()=>st(Kt=>Kt+1),children:e.jsx(ja,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:or>=ir,onClick:()=>st(ir),children:"Last"})]})]}),e.jsx(fs,{open:le||!!xe,onOpenChange:Kt=>{Kt||(fe(!1),he(null),Xt())},children:e.jsxs(ms,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:xe?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:Qa,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"first_name",children:"First Name *"}),e.jsx(Fe,{id:"first_name",value:ar.first_name,onChange:Kt=>Or({...ar,first_name:Kt.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Fe,{id:"last_name",value:ar.last_name,onChange:Kt=>Or({...ar,last_name:Kt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"email",children:"Email"}),e.jsx(Fe,{id:"email",type:"email",value:ar.email,onChange:Kt=>Or({...ar,email:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"phone",children:"Phone"}),e.jsx(Fe,{id:"phone",value:ar.phone,onChange:Kt=>Or({...ar,phone:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"address",children:"Address"}),e.jsx(Fe,{id:"address",value:ar.address,onChange:Kt=>Or({...ar,address:Kt.target.value}),placeholder:"Street address"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"city",children:"City"}),e.jsx(Fe,{id:"city",value:ar.city,onChange:Kt=>Or({...ar,city:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"state",children:"State"}),e.jsx(Fe,{id:"state",value:ar.state,onChange:Kt=>Or({...ar,state:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"zip_code",children:"Zip"}),e.jsx(Fe,{id:"zip_code",value:ar.zip_code,onChange:Kt=>Or({...ar,zip_code:Kt.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Fe,{id:"birthday",type:"date",value:ar.birthday,onChange:Kt=>Or({...ar,birthday:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Fe,{id:"home_anniversary",type:"date",value:ar.home_anniversary,onChange:Kt=>Or({...ar,home_anniversary:Kt.target.value})})]})]}),xe&&e.jsx(Lwe,{contactId:xe.id,currentSpouseContactId:(xe==null?void 0:xe.spouse_contact_id)||null,currentSpouseName:(xe==null?void 0:xe.spouse_name)||null,currentSpouseEmail:(xe==null?void 0:xe.spouse_email)||null,onLink:Kt=>$.mutate({contactId:xe.id,spouseContactId:Kt}),onUnlink:()=>$.mutate({contactId:xe.id,spouseContactId:null}),isEditing:!0}),e.jsx(vit,{value:ar.lead_source_id,onChange:Kt=>Or({...ar,lead_source_id:Kt})}),e.jsxs("div",{children:[e.jsx(ge,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:b==null?void 0:b.filter(Kt=>Kt.active).map(Kt=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Gi,{checked:ar.tagIds.includes(Kt.id),onCheckedChange:Mr=>{Or(Mr?{...ar,tagIds:[...ar.tagIds,Kt.id]}:{...ar,tagIds:ar.tagIds.filter(On=>On!==Kt.id)})}}),e.jsx("span",{className:"text-sm",children:Kt.name})]},Kt.id))})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"notes",children:"Notes"}),e.jsx(_r,{id:"notes",value:ar.notes,onChange:Kt=>Or({...ar,notes:Kt.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{fe(!1),he(null),Xt()},children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:O.isPending||U.isPending,children:[xe?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(bws,{open:we,onOpenChange:Ne,relationshipTypes:(b==null?void 0:b.filter(Kt=>Kt.active))||[],onSuccess:()=>{Ne(!1)}}),e.jsx(Nws,{open:Ve,onOpenChange:Te,onComplete:()=>Te(!1)}),e.jsx(kme,{open:!!Ae,onOpenChange:Kt=>{Kt||ze(null)},contactId:Ae||"",contactName:Ee}),e.jsx(Jws,{open:ut,onOpenChange:Oe}),e.jsx(e2s,{open:Xe,onOpenChange:at}),e.jsx(Itt,{open:Cs,onOpenChange:Us,contactIds:Wt,contactNames:Wt.map(Kt=>{const Mr=Rn.find(On=>On.id===Kt);return Mr?`${Mr.first_name} ${Mr.last_name||""}`.trim():""}),onComplete:()=>{xs([]),Ue(new Set),ct(!1)}})]})]})})}const s2s="9a88a47c-cb2a-4401-a2b5-111a76b19f9d";function r2s({open:t,onOpenChange:s,contact:r}){var Z;const{user:n}=$s(),a=br(),o=es(),{intakePage:l,isLoading:i}=Sme(),{isGmailConnected:d,gmailEmail:u}=bp(),p=ahe(),{data:f}=ft({queryKey:["profile-for-invite",n==null?void 0:n.id],enabled:!!(n!=null&&n.id)&&t,queryFn:async()=>{const{data:J}=await G.from("profiles").select("name, email, avatar_url").eq("id",n.id).maybeSingle();return J}}),y=(f==null?void 0:f.name)||((Z=n==null?void 0:n.email)==null?void 0:Z.split("@")[0])||"Your Agent",_=y.split(" ")[0],b=l?`https://contacts.relevelup.com/${l.slug}`:"",N=k.useMemo(()=>`Hi ${r.first_name}, I'm updating my contact list and want to make sure I have your latest info — the best phone, email, address, and a couple of dates I love to remember (like your birthday and home anniversary). It only takes about a minute, and it helps me stay in touch the right way. Thanks so much!`,[r.first_name]),[w,S]=k.useState("gmail"),[C,A]=k.useState(""),[I,L]=k.useState(""),[O,U]=k.useState(!1);k.useEffect(()=>{t&&(A(`Quick favor, ${r.first_name} — can you update your info?`),L(N),S(d?"gmail":"system"))},[t,N,r.first_name,d]);const q=k.useMemo(()=>I.split(/\n\n+/).map(J=>`

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

`).join(""),[I]),$=()=>`
${f!=null&&f.avatar_url?`${y}`:`
${_.charAt(0)}
`}

A note from ${y}

${q}

Update Your Info

Takes about a minute — promise

Share My Info →

${b}

Sent with care by ${y}

Powered by ReLevelUp

`,V=async()=>{if(!l){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>a("/mission-control/connect-page")}});return}if(!C.trim()||!I.trim()){me.error("Subject and message are required");return}U(!0);const J=$();try{if(w==="gmail"&&d){const{data:Y,error:ce}=await G.functions.invoke("gmail-send",{body:{to:r.email,subject:C,body:J,contactId:r.id}});if(ce)throw ce;if(!(Y!=null&&Y.success))throw new Error((Y==null?void 0:Y.error)||"Failed to send")}else{const{data:Y,error:ce}=await G.functions.invoke("send-connect-invite",{body:{contactEmail:r.email,subject:C,htmlBody:J,replyToEmail:(f==null?void 0:f.email)||(n==null?void 0:n.email),agentName:y}});if(ce)throw ce;if(!(Y!=null&&Y.success))throw new Error((Y==null?void 0:Y.error)||"Failed to send")}try{await p.mutateAsync({contactId:r.id,actionTypeId:s2s,notes:`Sent Connect Page invite — Subject: "${C}"`})}catch(Y){console.warn("Failed to log activity:",Y)}o.invalidateQueries({queryKey:["contact-touch-logs"]}),me.success("Connect Page invite sent!"),s(!1)}catch(Y){console.error("Send error:",Y),me.error(Y instanceof Error?Y.message:"Failed to send invite")}finally{U(!1)}},ee=$();return e.jsx(fs,{open:t,onOpenChange:J=>!O&&s(J),children:e.jsxs(ms,{className:"sm:max-w-[720px] max-h-[92vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(qr,{className:"h-5 w-5 text-primary"}),"Send Connect Page Invite"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Ask ",e.jsxs("span",{className:"font-medium",children:[r.first_name," ",r.last_name||""]})," to share their latest contact info — takes them about a minute."]})]}),i?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(ps,{className:"h-6 w-6 animate-spin text-primary"})}):l?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Send From"}),e.jsx(ta,{value:w,onValueChange:J=>S(J),className:"mt-1.5",children:e.jsxs(Qn,{className:"grid w-full grid-cols-2",children:[e.jsxs(ls,{value:"gmail",disabled:!d,children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1.5"}),d?`Gmail (${u})`:"Gmail (not connected)"]}),e.jsxs(ls,{value:"system",children:[e.jsx(qr,{className:"h-3.5 w-3.5 mr-1.5"}),"System Email"]})]})}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:w==="gmail"?"Replies go directly to your Gmail inbox.":`Sent from notifications@dashboard.relevelup.com — replies go to ${(f==null?void 0:f.email)||(n==null?void 0:n.email)||"your account email"}.`})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"invite-subject",children:"Subject"}),e.jsx(Fe,{id:"invite-subject",value:C,onChange:J=>A(J.target.value),className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"invite-message",children:"Personal Message"}),e.jsx(_r,{id:"invite-message",value:I,onChange:J=>L(J.target.value),rows:6,className:"mt-1.5 resize-none"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"The Connect Page button is added below your message automatically."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx(ge,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Preview"}),e.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline flex items-center gap-1",children:["Open Connect Page ",e.jsx(Kr,{className:"h-3 w-3"})]})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden bg-muted/30",children:e.jsx("iframe",{srcDoc:ee,title:"Email preview",sandbox:"",className:"w-full h-[420px] bg-background"})})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),disabled:O,children:"Cancel"}),e.jsx(K,{onClick:V,disabled:O,children:O?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 mr-1.5 animate-spin"})," Sending…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Nn,{className:"h-4 w-4 mr-1.5"})," Send Invite"]})})]})]}):e.jsxs("div",{className:"space-y-4 py-6 text-center",children:[e.jsx(co,{className:"h-10 w-10 text-amber-500 mx-auto"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"You haven't set up a Connect Page yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create yours in one click — it only takes a moment."})]}),e.jsxs(K,{onClick:()=>a("/mission-control/connect-page"),children:[e.jsx(Do,{className:"h-4 w-4 mr-1"})," Set Up Connect Page"]})]})]})})}function n2s(){return ft({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 a2s(t){return ft({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 i2s(){const{user:t}=$s();return ft({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 o2s(){const{user:t}=$s(),s=es();return Et({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 l2s(t){const{user:s}=$s();return ft({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 c2s(t){return ft({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 Ew(){const{user:t}=$s(),s=es();return Et({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 d2s(){const t=es();return Et({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 u2s(){const t=es();return Et({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 Ame(){const{user:t}=$s();return ft({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 _it(){const{data:t,isLoading:s}=Ame(),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 wE(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 jE(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 ow(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 h2s(){const{user:t}=$s(),s=es();return Et({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 m2s(t){return ft({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 p2s(t){return ft({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 JSe(){const t=_a(),s=es();return Et({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 bO(){const t=es();return Et({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 f2s(){const t=es();return Et({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 x2s(){const t=es();return Et({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 g2s(){const t=es();return Et({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 bit(){const t=es();return Et({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 y2s(){const t=_a();return ft({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 v2s(){const t=_a(),s=es();return Et({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 _2s(){const t=es();return Et({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 b2s(){const t=es();return Et({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 o1(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function w2s({contactId:t}){const s=br(),r=es(),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(null),N=bO(),w=bit(),{data:S,isLoading:C}=ft({queryKey:["contact-portals",t],queryFn:async()=>{const{data:q,error:$}=await G.from("deal_pipeline").select("id, deal_name, deal_type").eq("contact_id",t);if($)throw $;if(!q||q.length===0)return[];const V=q.map(J=>J.id),{data:ee,error:Z}=await G.from("client_portals").select("*").in("deal_id",V).is("archived_at",null);if(Z)throw Z;return(ee||[]).map(J=>({...J,deal:q.find(Y=>Y.id===J.deal_id)}))},enabled:!!t}),A=(S==null?void 0:S.map(q=>q.id))||[],{data:I}=ft({queryKey:["contact-portal-updates",A],queryFn:async()=>{if(A.length===0)return{};const{data:q,error:$}=await G.from("portal_updates").select("*").in("portal_id",A).order("created_at",{ascending:!1});if($)throw $;const V={};return(q||[]).forEach(ee=>{V[ee.portal_id]||(V[ee.portal_id]=ee)}),V},enabled:A.length>0}),L=q=>{navigator.clipboard.writeText(o1(q)),a(q),me.success("Portal link copied!"),setTimeout(()=>a(null),2e3)},O=async q=>{u.trim()&&(await w.mutateAsync({portal_id:q,title:u,content:f||void 0}),d(!1),p(""),y(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),me.success("Portal update posted!"))},U=async()=>{_&&(await N.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 C||!S||S.length===0?null:e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(gd,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(Be,{className:"space-y-3",children:S.map(q=>{var Z,J,Y;const $=((Z=q.stage_mapping)==null?void 0:Z.length)>0?q.stage_mapping:HNe(((J=q.deal)==null?void 0:J.deal_type)||"buyer"),V=$==null?void 0:$[q.current_stage_index??0],ee=I==null?void 0:I[q.id];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:((Y=q.deal)==null?void 0:Y.deal_name)||"Portal"}),V&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage: ",V.label||V.name]})]}),e.jsx(Ye,{variant:q.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:q.is_enabled?"Active":"Disabled"})]}),ee&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:ee.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:gs(new Date(ee.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(ea,{className:"h-3 w-3 mr-1"}):e.jsx(Ya,{className:"h-3 w-3 mr-1"}),"Copy Link"]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open(o1(q.slug),"_blank"),children:[e.jsx(Kr,{className:"h-3 w-3 mr-1"}),"View"]}),e.jsxs(fs,{open:i,onOpenChange:d,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>d(!0),children:[e.jsx(Si,{className:"h-3 w-3 mr-1"}),"Post Update"]})}),e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Title"}),e.jsx(Fe,{value:u,onChange:ce=>p(ce.target.value),placeholder:"e.g. Inspection completed!"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Details (optional)"}),e.jsx(_r,{value:f,onChange:ce=>y(ce.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(K,{onClick:()=>O(q.id),disabled:!u.trim()||w.isPending,className:"w-full",children:[e.jsx(Nn,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{b({...q}),l(!0)},children:[e.jsx(So,{className:"h-3 w-3 mr-1"}),"Settings"]})}),e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Portal Settings"})}),_&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{children:"Portal Enabled"}),e.jsx(Lr,{checked:_.is_enabled,onCheckedChange:ce=>b({..._,is_enabled:ce})})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Welcome Message"}),e.jsx(_r,{value:_.welcome_message||"",onChange:ce=>b({..._,welcome_message:ce.target.value}),placeholder:"Welcome to your home journey!",rows:2})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Next Step"}),e.jsx(Fe,{value:_.next_step_text||"",onChange:ce=>b({..._,next_step_text:ce.target.value}),placeholder:"What your client should do next..."})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Review URL"}),e.jsx(Fe,{value:_.review_url||"",onChange:ce=>b({..._,review_url:ce.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{children:"Show Post-Close Tips"}),e.jsx(Lr,{checked:_.show_post_close_tips,onCheckedChange:ce=>b({..._,show_post_close_tips:ce})})]}),e.jsx(jo,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:U,disabled:N.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${q.deal_id}`),children:[e.jsx(ti,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),S.length>1&&e.jsx(jo,{})]},q.id)})})]})}function j2s({contactId:t}){const{data:s}=ft({queryKey:["agent-lead-sites-slugs"],queryFn:async()=>{const{data:l,error:i}=await G.from("lead_sites").select("id, subdomain_slug").eq("is_active",!0);if(i)throw i;return new Map((l||[]).map(d=>[d.id,d.subdomain_slug]))},staleTime:6e5}),r=s&&s.size>0,{data:n,isLoading:a}=ft({queryKey:["contact-property-views",t],queryFn:async()=>{const{data:l,error:i}=await G.rpc("get_contact_property_views",{p_contact_id:t});if(i)throw i;return l||[]},enabled:!!t&&!!r});if(!r||a||!n||n.length===0)return null;const o=l=>{const i=s==null?void 0:s.get(l.lead_site_id);return i?`https://${i}.thelocalmove.com/listing/${l.mls_number}`:null};return e.jsxs(Ie,{className:"overflow-hidden",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(jn,{className:"h-4 w-4 text-primary"})}),"Property Activity",e.jsxs(Ye,{variant:"secondary",className:"text-xs ml-auto",children:[n.length," ",n.length===1?"property":"properties"]})]})}),e.jsx(Be,{className:"pt-0",children:e.jsx("div",{className:"space-y-1",children:n.map(l=>{const i=o(l),d=l.property_address||`MLS# ${l.mls_number}`;return e.jsxs("a",{href:i||"#",target:"_blank",rel:"noopener noreferrer",onClick:u=>{i||u.preventDefault()},className:"group flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[l.photo_url?e.jsx("div",{className:"h-10 w-10 rounded-lg overflow-hidden flex-shrink-0 bg-muted",children:e.jsx("img",{src:l.photo_url,alt:d,className:"w-full h-full object-cover"})}):e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-primary/15 to-primary/5 flex items-center justify-center flex-shrink-0",children:e.jsx(Mn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("span",{className:"font-medium text-sm truncate",children:d})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(rn,{className:"h-3 w-3"}),e.jsx("span",{title:gs(new Date(l.viewed_at),"PPp"),children:jl(new Date(l.viewed_at),{addSuffix:!0})})]})]}),i&&e.jsx(Kr,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},l.mls_number)})})})]})}const N2s=["Single Family","Condo","Townhouse","Multi-Family","Land","Commercial"];function nze({value:t,onChange:s,onAdd:r,suggestions:n,placeholder:a,icon:o}){const[l,i]=k.useState(!1),d=k.useRef(null),u=k.useRef(null);k.useEffect(()=>{const f=y=>{u.current&&!u.current.contains(y.target)&&d.current&&!d.current.contains(y.target)&&i(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const p=n.filter(f=>f.toLowerCase().includes(t.toLowerCase()));return e.jsxs("div",{className:"relative flex-1",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Fe,{ref:d,value:t,onChange:f=>{s(f.target.value),i(!0)},onFocus:()=>i(!0),placeholder:a,onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),p.length>0?r(p[0]):r(t))}}),n.length>0&&e.jsx(Fi,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>r(t),children:e.jsx(Bs,{className:"h-4 w-4"})})]}),l&&p.length>0&&e.jsx("div",{ref:u,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:p.map(f=>e.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors flex items-center gap-2",onClick:()=>{r(f),i(!1)},children:[o||e.jsx(La,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),f]},f))})]})}function k2s({contactId:t,contactName:s}){var $,V,ee;const{user:r}=$s(),n=_a(),{hasLeadSite:a}=QA(),o=es(),[l,i]=k.useState(!1),[d,u]=k.useState(""),[p,f]=k.useState(""),{data:y}=ft({queryKey:["agent-lead-site-config",n],queryFn:async()=>{const{data:Z,error:J}=await G.from("lead_sites").select("theme_config, mls_market_area").eq("agent_id",n).eq("is_active",!0).order("created_at",{ascending:!0}).limit(1).maybeSingle();if(J||!Z)return{cities:[],zipCodes:[]};const Y=Z.theme_config||{},ce=Array.isArray(Y.searchCities)?Y.searchCities:[];Z.mls_market_area&&!ce.includes(Z.mls_market_area)&&ce.unshift(Z.mls_market_area);const ae=Array.isArray(Y.searchZipCodes)?Y.searchZipCodes:[];return{cities:ce,zipCodes:ae}},enabled:!!n}),{data:_,isLoading:b}=ft({queryKey:["contact-property-alert",t],queryFn:async()=>{const{data:Z,error:J}=await G.from("contact_property_alerts").select("*").eq("contact_id",t).maybeSingle();if(J)throw J;return Z},enabled:!!t&&!!r}),[N,w]=k.useState({}),S=()=>{w({is_active:(_==null?void 0:_.is_active)??!0,min_price:(_==null?void 0:_.min_price)??null,max_price:(_==null?void 0:_.max_price)??null,min_beds:(_==null?void 0:_.min_beds)??null,min_baths:(_==null?void 0:_.min_baths)??null,min_sqft:(_==null?void 0:_.min_sqft)??null,max_sqft:(_==null?void 0:_.max_sqft)??null,cities:(_==null?void 0:_.cities)??[],zip_codes:(_==null?void 0:_.zip_codes)??[],property_types:(_==null?void 0:_.property_types)??[],frequency:(_==null?void 0:_.frequency)??"daily"}),i(!0)},C=Et({mutationFn:async()=>{const Z={contact_id:t,owner_user_id:n,is_active:N.is_active??!0,min_price:N.min_price||null,max_price:N.max_price||null,min_beds:N.min_beds||null,min_baths:N.min_baths||null,min_sqft:N.min_sqft||null,max_sqft:N.max_sqft||null,cities:N.cities||[],zip_codes:N.zip_codes||[],property_types:N.property_types||[],frequency:N.frequency||"daily"};if(_!=null&&_.id){const{error:J}=await G.from("contact_property_alerts").update(Z).eq("id",_.id);if(J)throw J}else{const{error:J}=await G.from("contact_property_alerts").insert(Z);if(J)throw J}},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-property-alert",t]}),i(!1),me.success("Property alert saved!")},onError:Z=>{me.error(Z.message||"Failed to save alert")}}),A=Et({mutationFn:async()=>{if(!(_!=null&&_.id))return;const{error:Z}=await G.from("contact_property_alerts").delete().eq("id",_.id);if(Z)throw Z},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-property-alert",t]}),i(!1),me.success("Property alert removed")}}),I=Z=>{var Y;const J=Z.trim();J&&!((Y=N.cities)!=null&&Y.includes(J))&&w(ce=>({...ce,cities:[...ce.cities||[],J]})),u("")},L=Z=>{var Y;const J=Z.trim();J&&!((Y=N.zip_codes)!=null&&Y.includes(J))&&w(ce=>({...ce,zip_codes:[...ce.zip_codes||[],J]})),f("")},O=Z=>{w(J=>{const Y=J.property_types||[];return{...J,property_types:Y.includes(Z)?Y.filter(ce=>ce!==Z):[...Y,Z]}})};if(!a||b)return null;if(_&&!l)return e.jsxs(Ie,{className:"overflow-hidden",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:`h-7 w-7 rounded-lg flex items-center justify-center ${_.is_active?"bg-green-500/10":"bg-muted"}`,children:_.is_active?e.jsx(Nm,{className:"h-4 w-4 text-green-600"}):e.jsx(Wv,{className:"h-4 w-4 text-muted-foreground"})}),"Property Alerts",e.jsxs(Ye,{variant:_.is_active?"default":"secondary",className:"text-xs ml-auto",children:[_.is_active?"Active":"Paused"," · ",_.frequency]})]})}),e.jsxs(Be,{className:"pt-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5 text-xs",children:[_.min_price||_.max_price?e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(_c,{className:"h-3 w-3"}),_.min_price?`$${(_.min_price/1e3).toFixed(0)}k`:"$0"," - ",_.max_price?`$${(_.max_price/1e3).toFixed(0)}k`:"Any"]}):null,_.min_beds?e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(Z4,{className:"h-3 w-3"}),_.min_beds,"+ beds"]}):null,_.min_baths?e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(of,{className:"h-3 w-3"}),_.min_baths,"+ baths"]}):null,($=_.cities)==null?void 0:$.map(Z=>e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(La,{className:"h-3 w-3"}),Z]},Z)),(V=_.zip_codes)==null?void 0:V.map(Z=>e.jsx(Ye,{variant:"outline",children:Z},Z)),(ee=_.property_types)==null?void 0:ee.map(Z=>e.jsx(Ye,{variant:"outline",children:Z},Z))]}),_.last_sent_at&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sent: ",new Date(_.last_sent_at).toLocaleDateString()]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:S,className:"flex-1",children:"Manage Alert"}),e.jsxs(K,{variant:"destructive",size:"sm",onClick:()=>A.mutate(),disabled:A.isPending,className:"flex-1",children:[A.isPending?e.jsx(ps,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Sr,{className:"h-4 w-4 mr-1"}),"Remove Alert"]})]})]})]});const U=((y==null?void 0:y.cities)||[]).filter(Z=>{var J;return!((J=N.cities)!=null&&J.includes(Z))}),q=((y==null?void 0:y.zipCodes)||[]).filter(Z=>{var J;return!((J=N.zip_codes)!=null&&J.includes(Z))});return l?e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Nm,{className:"h-4 w-4 text-primary"}),_?"Edit":"Setup"," Property Alert for ",s]})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{children:"Alert Active"}),e.jsx(Lr,{checked:N.is_active??!0,onCheckedChange:Z=>w(J=>({...J,is_active:Z}))})]}),e.jsxs("div",{children:[e.jsxs(ge,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(_c,{className:"h-3.5 w-3.5"})," Price Range"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Fe,{type:"number",placeholder:"Min price",value:N.min_price??"",onChange:Z=>w(J=>({...J,min_price:Z.target.value?Number(Z.target.value):null}))}),e.jsx(Fe,{type:"number",placeholder:"Max price",value:N.max_price??"",onChange:Z=>w(J=>({...J,max_price:Z.target.value?Number(Z.target.value):null}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs(ge,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Z4,{className:"h-3.5 w-3.5"})," Min Beds"]}),e.jsxs(zs,{value:N.min_beds?String(N.min_beds):"any",onValueChange:Z=>w(J=>({...J,min_beds:Z==="any"?null:Number(Z)})),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Any"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"any",children:"Any"}),[1,2,3,4,5].map(Z=>e.jsxs(yt,{value:String(Z),children:[Z,"+"]},Z))]})]})]}),e.jsxs("div",{children:[e.jsxs(ge,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(of,{className:"h-3.5 w-3.5"})," Min Baths"]}),e.jsxs(zs,{value:N.min_baths?String(N.min_baths):"any",onValueChange:Z=>w(J=>({...J,min_baths:Z==="any"?null:Number(Z)})),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Any"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"any",children:"Any"}),[1,1.5,2,2.5,3,4].map(Z=>e.jsxs(yt,{value:String(Z),children:[Z,"+"]},Z))]})]})]})]}),e.jsxs("div",{children:[e.jsxs(ge,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(yS,{className:"h-3.5 w-3.5"})," Square Feet"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Fe,{type:"number",placeholder:"Min sqft",value:N.min_sqft??"",onChange:Z=>w(J=>({...J,min_sqft:Z.target.value?Number(Z.target.value):null}))}),e.jsx(Fe,{type:"number",placeholder:"Max sqft",value:N.max_sqft??"",onChange:Z=>w(J=>({...J,max_sqft:Z.target.value?Number(Z.target.value):null}))})]})]}),e.jsxs("div",{children:[e.jsxs(ge,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(La,{className:"h-3.5 w-3.5"})," Cities"]}),e.jsx(nze,{value:d,onChange:u,onAdd:I,suggestions:U,placeholder:"Type to search cities..."}),N.cities&&N.cities.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:N.cities.map(Z=>e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[Z,e.jsx("button",{onClick:()=>w(J=>{var Y;return{...J,cities:(Y=J.cities)==null?void 0:Y.filter(ce=>ce!==Z)}}),children:e.jsx(Sr,{className:"h-3 w-3"})})]},Z))})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"mb-1.5",children:"Zip Codes"}),e.jsx(nze,{value:p,onChange:f,onAdd:L,suggestions:q,placeholder:"Type to search zip codes...",icon:e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:"#"})}),N.zip_codes&&N.zip_codes.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:N.zip_codes.map(Z=>e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[Z,e.jsx("button",{onClick:()=>w(J=>{var Y;return{...J,zip_codes:(Y=J.zip_codes)==null?void 0:Y.filter(ce=>ce!==Z)}}),children:e.jsx(Sr,{className:"h-3 w-3"})})]},Z))})]}),e.jsxs("div",{children:[e.jsxs(ge,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," Property Types"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:N2s.map(Z=>{var J;return e.jsx(Ye,{variant:(J=N.property_types)!=null&&J.includes(Z)?"default":"outline",className:"cursor-pointer",onClick:()=>O(Z),children:Z},Z)})})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"mb-1.5",children:"Frequency"}),e.jsxs(zs,{value:N.frequency||"daily",onValueChange:Z=>w(J=>({...J,frequency:Z})),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"daily",children:"Daily"}),e.jsx(yt,{value:"weekly",children:"Weekly"})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>C.mutate(),disabled:C.isPending,className:"flex-1",children:[C.isPending?e.jsx(ps,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(wc,{className:"h-4 w-4 mr-1"}),"Save Alert"]}),e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),_&&e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>A.mutate(),disabled:A.isPending,children:e.jsx(Sr,{className:"h-4 w-4"})})]})]})]}):e.jsx(Ie,{className:"overflow-hidden",children:e.jsx(Be,{className:"p-4",children:e.jsxs("button",{onClick:S,className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed border-primary/30 hover:bg-primary/5 transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Nm,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:"Set Up Property Alerts"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Automatically email ",s," new listings matching their criteria"]})]})]})})})}function S2s({contactId:t,contactName:s}){var ae;const{user:r}=$s(),n=_a(),{hasLeadSite:a}=QA(),o=es(),[l,i]=k.useState(!1),[d,u]=k.useState(""),[p,f]=k.useState([]),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState(!1),[C,A]=k.useState(""),I=k.useRef(null),L=k.useRef(null),{data:O}=ft({queryKey:["agent-lead-site-cities",n],queryFn:async()=>{const{data:ie,error:le}=await G.from("lead_sites").select("theme_config, mls_market_area").eq("agent_id",n).eq("is_active",!0).order("created_at",{ascending:!0}).limit(1).maybeSingle();if(le||!ie)return[];const fe=ie.theme_config||{},xe=Array.isArray(fe.searchCities)?fe.searchCities:[];return ie.mls_market_area&&!xe.includes(ie.mls_market_area)&&xe.unshift(ie.mls_market_area),xe},enabled:!!n}),{data:U,isLoading:q}=ft({queryKey:["contact-market-report",t],queryFn:async()=>{const{data:ie,error:le}=await G.from("innercircle_contacts").select("market_report_enabled, market_report_cities").eq("id",t).single();if(le)throw le;return ie},enabled:!!t&&!!r});k.useEffect(()=>{const ie=le=>{L.current&&!L.current.contains(le.target)&&I.current&&!I.current.contains(le.target)&&N(!1)};return document.addEventListener("mousedown",ie),()=>document.removeEventListener("mousedown",ie)},[]);const $=()=>{_((U==null?void 0:U.market_report_enabled)??!1),f((U==null?void 0:U.market_report_cities)??[]),i(!0)},V=ie=>{const le=(ie||d).trim();le&&!p.includes(le)&&f([...p,le]),u(""),N(!1)},ee=(O||[]).filter(ie=>!p.includes(ie)&&ie.toLowerCase().includes(d.toLowerCase())),Z=Et({mutationFn:async()=>{const{data:ie,error:le}=await G.functions.invoke("send-market-report",{body:{action:"preview",agentId:n,cities:(U==null?void 0:U.market_report_cities)??[]}});if(le)throw new Error(le.message||"Failed to generate preview");if(ie&&!ie.ok&&ie.error)throw new Error(ie.error);return ie},onSuccess:ie=>{A(ie.html),S(!0)},onError:ie=>{me.error(ie.message||"Failed to generate preview")}}),J=Et({mutationFn:async()=>{const{data:ie,error:le}=await G.functions.invoke("send-market-report",{body:{action:"send",agentId:n,cities:(U==null?void 0:U.market_report_cities)??[],contactIds:[t]}});if(le)throw new Error(le.message||"Failed to send report");if(ie&&!ie.ok&&ie.error)throw new Error(ie.error);return ie},onSuccess:()=>{me.success(`Market report sent to ${s}!`)},onError:ie=>{me.error(ie.message||"Failed to send report")}}),Y=Et({mutationFn:async()=>{const{error:ie}=await G.from("innercircle_contacts").update({market_report_enabled:y,market_report_cities:p}).eq("id",t);if(ie)throw ie},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-market-report",t]}),i(!1),me.success(y?"Monthly market report enabled!":"Market report disabled")},onError:ie=>{me.error(ie.message||"Failed to save")}}),ce=Et({mutationFn:async()=>{const{error:ie}=await G.from("innercircle_contacts").update({market_report_enabled:!1,market_report_cities:[]}).eq("id",t);if(ie)throw ie},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-market-report",t]}),i(!1),_(!1),f([]),me.success("Market report removed")},onError:ie=>{me.error(ie.message||"Failed to remove market report")}});return!a||q?null:U!=null&&U.market_report_enabled&&!l?e.jsxs(Ie,{className:"overflow-hidden",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg flex items-center justify-center bg-primary/10",children:e.jsx(so,{className:"h-4 w-4 text-primary"})}),"Monthly Market Report",e.jsx(Ye,{variant:"default",className:"text-xs ml-auto",children:"Active"})]})}),e.jsxs(Be,{className:"pt-0 space-y-2",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 text-xs",children:((ae=U.market_report_cities)==null?void 0:ae.length)>0?U.market_report_cities.map(ie=>e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(La,{className:"h-3 w-3"}),ie]},ie)):e.jsx("span",{className:"text-muted-foreground",children:"Using default market area"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s," receives a branded market report on the 1st of each month."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Z.mutate(),disabled:Z.isPending,className:"flex-1",children:[Z.isPending?e.jsx(ps,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(jn,{className:"h-4 w-4 mr-1"}),"Preview"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>J.mutate(),disabled:J.isPending,className:"flex-1",children:[J.isPending?e.jsx(ps,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Nn,{className:"h-4 w-4 mr-1"}),"Send Now"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:$,className:"flex-1",children:"Manage"}),e.jsxs(K,{variant:"destructive",size:"sm",onClick:()=>ce.mutate(),disabled:ce.isPending,className:"flex-1",children:[ce.isPending?e.jsx(ps,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Sr,{className:"h-4 w-4 mr-1"}),"Remove"]})]}),e.jsx(fs,{open:w,onOpenChange:S,children:e.jsxs(ms,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsx(ks,{children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5 text-primary"}),"Market Report Preview"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto -mx-6 px-6",children:e.jsx("div",{className:"border rounded-lg overflow-hidden",dangerouslySetInnerHTML:{__html:C}})}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t",children:[e.jsxs(K,{onClick:()=>{S(!1),J.mutate()},disabled:J.isPending,className:"flex-1",children:[J.isPending?e.jsx(ps,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Nn,{className:"h-4 w-4 mr-1"}),"Send to ",s]}),e.jsx(K,{variant:"outline",onClick:()=>S(!1),children:"Close"})]})]})})]})]}):l?e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(so,{className:"h-4 w-4 text-primary"}),"Market Report for ",s]})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{children:"Send Monthly Report"}),e.jsx(Lr,{checked:y,onCheckedChange:_})]}),y&&e.jsxs("div",{children:[e.jsxs(ge,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(La,{className:"h-3.5 w-3.5"})," Report Cities"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select cities from your website's configured areas."}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Fe,{ref:I,value:d,onChange:ie=>{u(ie.target.value),N(!0)},onFocus:()=>N(!0),placeholder:"Type to search cities...",onKeyDown:ie=>{ie.key==="Enter"&&(ie.preventDefault(),ee.length>0?V(ee[0]):V())}}),e.jsx(Fi,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>V(),children:e.jsx(Bs,{className:"h-4 w-4"})})]}),b&&ee.length>0&&e.jsx("div",{ref:L,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:ee.map(ie=>e.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors flex items-center gap-2",onClick:()=>V(ie),children:[e.jsx(La,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),ie]},ie))})]}),p.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:p.map(ie=>e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[ie,e.jsx("button",{onClick:()=>f(p.filter(le=>le!==ie)),children:e.jsx(Sr,{className:"h-3 w-3"})})]},ie))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>Y.mutate(),disabled:Y.isPending,className:"flex-1",children:[Y.isPending?e.jsx(ps,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(wc,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"})]})]})]}):e.jsx(Ie,{className:"overflow-hidden",children:e.jsx(Be,{className:"p-4",children:e.jsxs("button",{onClick:$,className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed border-primary/30 hover:bg-primary/5 transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(so,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:"Enable Monthly Market Report"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Auto-send ",s," a branded market report with real MLS data every month"]})]})]})})})}function C2s(t){return ft({queryKey:["contact-drip-activity",t],queryFn:async()=>{if(!t)return{enrollments:[],stepLogs:[]};const{data:s,error:r}=await G.from("drip_campaign_enrollments").select("id, campaign_id, current_step, status, next_send_at, enrolled_at, completed_at, exited_at, exit_reason").eq("contact_id",t).order("enrolled_at",{ascending:!1});if(r)throw console.error("[ContactDripActivity] enrollments error",r),r;const n=(s||[]).map(d=>d.id),a=Array.from(new Set((s||[]).map(d=>d.campaign_id)));let o=new Map;if(a.length>0){const{data:d}=await G.from("drip_campaigns").select("id, name, description, is_active").in("id",a);(d||[]).forEach(u=>o.set(u.id,u))}const l=(s||[]).map(d=>({...d,campaign:o.get(d.campaign_id)||null}));let i=[];if(n.length>0){const{data:d,error:u}=await G.from("drip_campaign_step_log").select("id, enrollment_id, campaign_id, step_order, channel, recipient_email, subject, status, error_message, sent_at").in("enrollment_id",n).order("sent_at",{ascending:!1});u?console.error("[ContactDripActivity] step log error",u):i=(d||[]).map(p=>{var f;return{...p,campaign:{name:((f=o.get(p.campaign_id))==null?void 0:f.name)??""}}})}return{enrollments:l,stepLogs:i}},enabled:!!t})}function M2s(t){switch(t){case"active":return e.jsx(Ye,{variant:"secondary",className:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20",children:"Active"});case"paused":return e.jsx(Ye,{variant:"secondary",className:"bg-amber-500/10 text-amber-600 border-amber-500/20",children:"Paused"});case"completed":return e.jsx(Ye,{variant:"secondary",className:"bg-sky-500/10 text-sky-600 border-sky-500/20",children:"Completed"});case"exited":return e.jsx(Ye,{variant:"outline",children:"Exited"});default:return e.jsx(Ye,{variant:"outline",children:t})}}function aze(t){return t==="sent"?e.jsx(Hn,{className:"h-4 w-4 text-emerald-500"}):t==="failed"?e.jsx(Qc,{className:"h-4 w-4 text-destructive"}):t==="skipped"?e.jsx(uh,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(rn,{className:"h-4 w-4 text-muted-foreground"})}function T2s({contactId:t}){const s=br(),{data:r,isLoading:n}=C2s(t),[a,o]=k.useState(null);if(n)return null;const l=(r==null?void 0:r.enrollments)||[],i=(r==null?void 0:r.stepLogs)||[];return l.length===0&&i.length===0?null:e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2 text-base",children:[e.jsx(wS,{className:"h-5 w-5 text-emerald-500"}),"Drip Campaign Activity"]})}),e.jsxs(Be,{className:"space-y-4",children:[l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Enrollments"}),l.map(d=>{var u;return e.jsxs("button",{onClick:()=>s("/mission-control/smart-drips"),className:"w-full text-left flex items-start gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-emerald-500/10 flex items-center justify-center text-emerald-600 flex-shrink-0",children:e.jsx(wS,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:((u=d.campaign)==null?void 0:u.name)||"Untitled campaign"}),M2s(d.status)]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Step ",d.current_step+1,d.next_send_at&&d.status==="active"&&e.jsxs(e.Fragment,{children:[" · Next: ",jl(new Date(d.next_send_at),{addSuffix:!0})]}),d.completed_at&&e.jsxs(e.Fragment,{children:[" · Completed ",jl(new Date(d.completed_at),{addSuffix:!0})]}),d.exited_at&&!d.completed_at&&e.jsxs(e.Fragment,{children:[" · ",d.exit_reason||"Exited"," ",jl(new Date(d.exited_at),{addSuffix:!0})]})]})]}),e.jsx(ja,{className:"h-4 w-4 text-muted-foreground mt-1 flex-shrink-0"})]},d.id)})]}),i.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:["Send History (",i.length,")"]}),e.jsxs("div",{className:"space-y-1",children:[i.slice(0,8).map(d=>{var u,p;return e.jsxs(fs,{open:(a==null?void 0:a.id)===d.id,onOpenChange:f=>!f&&o(null),children:[e.jsx(ui,{asChild:!0,children:e.jsxs("button",{onClick:()=>o(d),className:"w-full text-left flex items-start gap-3 p-2.5 rounded-lg border hover:bg-muted/50 transition-colors",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:aze(d.status)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[d.channel==="sms"?e.jsx(Si,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}):e.jsx(tr,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),e.jsx("p",{className:"text-sm truncate",children:d.subject||`${d.channel.toUpperCase()} step ${d.step_order+1}`})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:[((u=d.campaign)==null?void 0:u.name)||"Campaign"," · ",gs(new Date(d.sent_at),"MMM d, h:mm a")]}),d.status==="failed"&&d.error_message&&e.jsx("p",{className:"text-xs text-destructive mt-0.5 truncate",children:d.error_message})]})]})}),e.jsxs(ms,{className:"max-w-lg",children:[e.jsx(ks,{children:e.jsxs(bs,{className:"flex items-center gap-2",children:[aze(d.status),d.subject||"Drip step"]})}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Campaign"}),e.jsx("span",{className:"font-medium",children:((p=d.campaign)==null?void 0:p.name)||"—"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Channel"}),e.jsx("span",{className:"font-medium uppercase",children:d.channel})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Step"}),e.jsxs("span",{className:"font-medium",children:["#",d.step_order+1]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Recipient"}),e.jsx("span",{className:"font-medium",children:d.recipient_email||"—"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Status"}),e.jsx("span",{className:"font-medium capitalize",children:d.status})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Sent"}),e.jsx("span",{className:"font-medium",children:gs(new Date(d.sent_at),"MMM d, yyyy h:mm a")})]}),d.error_message&&e.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-2 text-destructive text-xs",children:d.error_message})]})]})]},d.id)}),i.length>8&&e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>s("/mission-control/smart-drips"),children:"View all in Smart Drips"})]})]})]})]})}function A2s({videoId:t}){var l;const{data:s,isLoading:r,error:n}=c2s(t);if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ss,{className:"w-full aspect-video rounded-lg"}),e.jsx(Ss,{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(Qc,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-medium",children:"Video Unavailable"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"This video has been deleted or is no longer available."})]});const a=i=>{let d=i;return d.includes("iframe.mediadelivery.net/play/")&&(d=d.replace("/play/","/embed/"),d+=(d.includes("?")?"&":"?")+"autoplay=true&responsive=true"),d},o=(l=s.playback_url)==null?void 0:l.includes("iframe.mediadelivery.net");return e.jsxs("div",{className:"space-y-4",children:[s.playback_url?e.jsx("div",{className:"relative w-full aspect-video bg-black rounded-lg overflow-hidden",children:o?e.jsx("iframe",{src:a(s.playback_url),title:s.title||"Video preview",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsx("video",{src:s.playback_url,controls:!0,autoPlay:!0,className:"absolute top-0 left-0 w-full h-full object-contain"})}):e.jsx("div",{className:"w-full aspect-video bg-muted rounded-lg flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Video is still processing..."})}),s.title&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:s.title}),s.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.notes})]})]})}function E2s({contactId:t}){const s=br(),[r,n]=k.useState(!1),{data:a,isLoading:o}=ft({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}=ft({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}),d={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"},u=(a==null?void 0:a.filter(f=>f.status!=="done"))||[],p=(a==null?void 0:a.filter(f=>f.status==="done"))||[];return e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(ea,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(Ye,{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(Bs,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(Be,{className:"space-y-1",children:o?e.jsx(Ss,{className:"h-8 w-full"}):u.length===0&&p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tasks yet"}):e.jsxs(e.Fragment,{children:[u.map(f=>e.jsxs("button",{onClick:async()=>{await l(f.id,f.status),i()},className:"w-full text-left flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 transition-colors group",children:[e.jsx("div",{className:"h-4 w-4 rounded-full border-2 border-muted-foreground/30 shrink-0 group-hover:border-primary"}),e.jsxs("span",{className:"text-sm flex-1 truncate",children:[d[f.priority]," ",f.title]}),f.due_date&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:gs(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(P2s,{contactId:t,open:r,onOpenChange:f=>{n(f),f||i()}})]})}function P2s({contactId:t,open:s,onOpenChange:r}){const[n,a]=k.useState(""),[o,l]=k.useState("medium"),[i,d]=k.useState(),{data:u}=ft({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?gs(i,"yyyy-MM-dd"):null}]);if(f){console.error("Task create error:",f);return}r(!1)};return e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(ms,{className:"sm:max-w-[400px]",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Add Task"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ge,{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(ge,{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(ge,{children:"Due Date"}),e.jsx(Fe,{type:"date",value:i?gs(i,"yyyy-MM-dd"):"",onChange:f=>d(f.target.value?new Date(f.target.value+"T00:00:00"):void 0)})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{onClick:p,disabled:!n.trim(),children:"Create Task"})]})]})]})})}function I2s({contactId:t}){const s=br(),{data:r,isLoading:n}=ft({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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Lh,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(Be,{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(Ye,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(Ye,{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(ti,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function L2s(){var ut,Oe,Xe,at,Ke;const{contactId:t}=ho(),s=br(),[r]=Sc(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=A8t(t||""),{data:d}=Mf(),{data:u}=KR(),{data:p}=ZR(3650),{data:f}=Cme(365),{data:y}=m2s(t),{contactsWithScores:_}=lhe(),b=pke(),N=fke(),w=ahe(),S=LXe(),[C,A]=k.useState(!1),[I,L]=k.useState({}),[O,U]=k.useState(!1),[q,$]=k.useState(null),[V,ee]=k.useState(""),[Z,J]=k.useState(void 0),[Y,ce]=k.useState(""),[ae,ie]=k.useState(null),[le,fe]=k.useState(!1),[xe,he]=k.useState(null),[we,Ne]=k.useState(!1),{isGmailConnected:Ve,gmailEmail:Te}=bp(),{data:Ae}=ft({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:He,error:gt}=await G.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(gt)throw gt;return He},enabled:!!t}),ze=He=>{if(!He)return null;const gt=He.match(/Video ID:\s*([a-f0-9-]+)/i);return gt?gt[1]:null},Ee=k.useMemo(()=>{if(!_)return[];let He=_.filter(gt=>{var xs,Cs,Us;const Mt=n===""||`${gt.first_name} ${gt.last_name}`.toLowerCase().includes(n.toLowerCase())||((xs=gt.email)==null?void 0:xs.toLowerCase().includes(n.toLowerCase()))||((Cs=gt.phone)==null?void 0:Cs.includes(n)),Wt=a==="all"||((Us=gt.tags)==null?void 0:Us.some(Ar=>Ar.relationship_type_id===a));return Mt&&Wt});return o==="not-touched-90"?He=He.filter(gt=>{const Mt=gt.relationshipScore.daysSinceTouch;return Mt===null||Mt>90}):o==="at-risk"?He=He.filter(gt=>gt.relationshipScore.status==="at-risk"):o==="cooling"?He=He.filter(gt=>gt.relationshipScore.status==="cooling"):o==="warm"&&(He=He.filter(gt=>gt.relationshipScore.status==="warm")),He.map(gt=>gt.id)},[_,n,a,o]),ve=Ee.indexOf(t||""),Re=ve>0?Ee[ve-1]:null,Ue=ve1&&ve!==-1,ct=He=>{const gt=new URLSearchParams;n&>.set("search",n),a!=="all"&>.set("type",a),o!=="all"&>.set("status",o);const Mt=gt.toString();return`/mission-control/contacts/${He}${Mt?`?${Mt}`:""}`},pe=k.useMemo(()=>{const He=((p==null?void 0:p.filter(Mt=>Mt.contact_id===t))||[]).map(Mt=>{var Us,Ar,Bt;const Wt=ze(Mt.notes);let xs=((Us=Mt.action_type)==null?void 0:Us.name)||"Touch",Cs=Mt.notes;if(xs==="Other"&&((Ar=Mt.notes)!=null&&Ar.startsWith("["))){const Xs=Mt.notes.indexOf("]");Xs>0&&(xs=Mt.notes.substring(1,Xs),Cs=Mt.notes.substring(Xs+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:Mt.id,type:"touch",completed_at:Mt.completed_at,name:xs,color:((Bt=Mt.action_type)==null?void 0:Bt.color)||"#3B82F6",notes:Cs,videoId:Wt}}),gt=((f==null?void 0:f.filter(Mt=>Mt.contact_id===t))||[]).map(Mt=>({id:Mt.id,type:"popby",completed_at:Mt.completed_at,name:"Pop-by",color:"#F97316",notes:Mt.notes,videoId:null}));return[...He,...gt].sort((Mt,Wt)=>new Date(Wt.completed_at).getTime()-new Date(Mt.completed_at).getTime())},[p,f,t]),Ge=()=>{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(gt=>gt.relationship_type_id))||[]}),A(!0))},tt=async()=>{await b.mutateAsync({id:t,...I,lead_source_id:I.lead_source_id||null}),A(!1)},st=async()=>{confirm("Are you sure you want to delete this contact?")&&(await N.mutateAsync(t),s("/mission-control/contacts"))},et=((ut=u==null?void 0:u.find(He=>He.id===q))==null?void 0:ut.name)==="Other",Ct=async()=>{if(!q||et&&!Y.trim())return;const He=Z?new Date(Z.getFullYear(),Z.getMonth(),Z.getDate(),12,0,0).toISOString():void 0,gt=et?`[${Y.trim()}]${V?" — "+V:""}`:V;await w.mutateAsync({contactId:t,actionTypeId:q,notes:gt,completedAt:He}),U(!1),$(null),ee(""),J(void 0),ce("")},Ot=(He,gt)=>{Ve&&l?(he({email:He,name:gt||`${l.first_name} ${l.last_name||""}`.trim()}),fe(!0)):window.location.href=`mailto:${He}`};return i?e.jsx(Ls,{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(Ls,{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:()=>{window.history.length>1?s(-1):s("/mission-control/contacts")},children:[e.jsx(wl,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),ye&&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(wl,{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:[ve+1," of ",Ee.length]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Ue&&s(ct(Ue)),disabled:!Ue,className:"px-2",children:[e.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),e.jsx(ja,{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:()=>Ot(l.email,`${l.first_name} ${l.last_name||""}`.trim()),children:[e.jsx(tr,{className:"h-4 w-4 mr-1"}),"Email"]}),l.email&&e.jsxs(K,{variant:"outline",onClick:()=>Ne(!0),className:"border-primary/40 text-primary hover:bg-primary/10",children:[e.jsx(qr,{className:"h-4 w-4 mr-1"}),"Send Connect Page"]}),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(hn,{className:"h-4 w-4 mr-1"}),"Quick Video Touch"]}),e.jsxs(fs,{open:O,onOpenChange:U,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),e.jsxs(ms,{className:"max-h-[85vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Log an Action"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{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:()=>$(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))}),et&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ge,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(Fe,{id:"custom-action-name",value:Y,onChange:He=>ce(He.target.value),placeholder:"e.g. Met a client for lunch, Dropped off a gift...",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Date (optional — backdate if needed)"}),e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Rt("w-full justify-start text-left font-normal mt-2",!Z&&"text-muted-foreground"),children:[e.jsx(nn,{className:"h-4 w-4 mr-2"}),Z?gs(Z,"PPP"):"Today (default)"]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(ff,{mode:"single",selected:Z,onSelect:J,disabled:He=>He>new Date,initialFocus:!0,className:Rt("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(_r,{id:"action-notes",value:V,onChange:He=>ee(He.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(K,{onClick:Ct,disabled:!q||et&&!Y.trim()||w.isPending,className:"w-full",children:[e.jsx(ea,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(K,{variant:"outline",onClick:Ge,children:[e.jsx(Gc,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:st,children:e.jsx(yr,{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||""]}),(((Oe=l.lead_source_ref)==null?void 0:Oe.name)||l.lead_source)&&e.jsx(Ye,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((Xe=l.lead_source_ref)==null?void 0:Xe.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:()=>Ot(l.email),className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(tr,{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(Tn,{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(Iwe,{contact:l}),(at=l.tags)==null?void 0:at.map(He=>{const gt=d==null?void 0:d.find(Mt=>Mt.id===He.relationship_type_id);return gt?e.jsx(Ye,{variant:"secondary",className:"text-xs",children:gt.name},He.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(Qws,{contactId:t})})]})}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(Ie,{className:"md:col-span-2",children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Contact Information"})}),e.jsx(Be,{children:C?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ge,{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(ge,{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(ge,{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(ge,{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(ge,{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(ge,{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(ge,{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(ge,{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(ge,{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(ge,{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(jo,{}),e.jsx(Lwe,{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=>S.mutate({contactId:t,spouseContactId:He}),onUnlink:()=>S.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(ge,{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(ge,{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(vit,{value:I.lead_source_id||"",onChange:He=>L({...I,lead_source_id:He})}),e.jsxs("div",{children:[e.jsx(ge,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:d==null?void 0:d.filter(He=>He.active).map(He=>{var gt;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Gi,{checked:(gt=I.tagIds)==null?void 0:gt.includes(He.id),onCheckedChange:Mt=>{var Wt;L(Mt?{...I,tagIds:[...I.tagIds||[],He.id]}:{...I,tagIds:(Wt=I.tagIds)==null?void 0:Wt.filter(xs=>xs!==He.id)})}}),e.jsx("span",{className:"text-sm",children:He.name})]},He.id)})})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"notes",children:"Notes"}),e.jsx(_r,{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:tt,disabled:b.isPending,children:"Save Changes"}),e.jsx(K,{variant:"outline",onClick:()=>A(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[pe.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",gs(new Date(pe[0].completed_at),"MMM d, yyyy")," ","(",pe[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(tr,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("button",{onClick:()=>Ot(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(Tn,{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(La,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{className:"flex flex-col",children:[l.address&&e.jsx("span",{children:l.address}),(l.city||l.state||l.zip_code)&&e.jsxs("span",{className:"text-muted-foreground",children:[[l.city,l.state].filter(Boolean).join(", "),l.zip_code&&` ${l.zip_code}`]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[l.birthday&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",gs(pl(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",gs(pl(l.home_anniversary),"MMMM d")]})]}),l.created_at&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bs,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Date Added: ",gs(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(jo,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(Lwe,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:He=>S.mutate({contactId:t,spouseContactId:He}),onUnlink:()=>S.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(ma,{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(jo,{}),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:(Ke=l.tags)!=null&&Ke.length?l.tags.map(He=>{var gt;return e.jsx(Ye,{variant:"secondary",children:(gt=He.relationship_type)==null?void 0:gt.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(jo,{}),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(xws,{contact:l,onLogTouch:()=>U(!0)}),e.jsx(I2s,{contactId:t}),e.jsx(w2s,{contactId:t}),e.jsx(j2s,{contactId:t}),e.jsx(k2s,{contactId:t,contactName:l.first_name}),e.jsx(S2s,{contactId:t,contactName:l.first_name}),e.jsx(E2s,{contactId:t}),e.jsx(T2s,{contactId:t}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Activity Log"})}),e.jsx(Be,{children:pe.length>0?e.jsx("div",{className:"space-y-4",children:pe.map(He=>{var gt;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(Vi,{className:"h-4 w-4"}):(gt=He.name)==null?void 0:gt.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:()=>ie(He.videoId),children:[e.jsx(Co,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:gs(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(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Si,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(Be,{children:e.jsx("div",{className:"space-y-4",children:y.map(He=>{var gt,Mt;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(gt=He.video)!=null&>.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:()=>ie(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:()=>ie(He.video_id),children:e.jsx(hn,{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: ",((Mt=He.video)==null?void 0:Mt.title)||"Untitled Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>ie(He.video_id),children:[e.jsx(Co,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:gs(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)})})})]}),Ae&&Ae.length>0&&e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Nn,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(Be,{children:e.jsx("div",{className:"space-y-3",children:Ae.map(He=>e.jsxs(fs,{children:[e.jsx(ui,{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(tr,{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," · ",gs(new Date(He.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx(ja,{className:"h-4 w-4 text-muted-foreground mt-1 flex-shrink-0"})]})}),e.jsxs(ms,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5 text-sky-500"}),He.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",He.to_email," · ",gs(new Date(He.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden rounded-lg border bg-white",children:e.jsx("iframe",{srcDoc:He.body,className:"w-full h-[400px] border-0",sandbox:"",title:`Email: ${He.subject}`})})]})]},He.id))})})]})]}),e.jsx(fs,{open:!!ae,onOpenChange:He=>!He&&ie(null),children:e.jsxs(ms,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Video Preview"})}),ae&&e.jsx(A2s,{videoId:ae})]})})]})]})}),Ve&&l&&xe&&e.jsx(E1,{open:le,onOpenChange:fe,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:xe.email},gmailEmail:Te}),l&&l.email&&e.jsx(r2s,{open:we,onOpenChange:Ne,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:l.email}})]}):e.jsx(Ls,{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 ize={Crown:km,FileText:mn,Users:cr,Globe:gd,Star:Gn,Phone:Tn,MessageSquare:Si,PenTool:Pb,Video:hn,Gift:Vi},u0e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function D2s(){var Xe,at;const t=br(),{user:s}=$s(),{data:r}=Mf(),{data:n}=P8t(),{data:a}=z8t(),{data:o}=IXe(),{data:l}=KR(),{data:i}=E8t(),d=B8t(),u=I8t(),p=D8t(),f=R8t(),y=O8t(),_=F8t(),b=L8t(),[N,w]=k.useState(null),[S,C]=k.useState(!1),[A,I]=k.useState(null),[L,O]=k.useState(""),[U,q]=k.useState(""),[$,V]=k.useState([]),[ee,Z]=k.useState(null),[J,Y]=k.useState(null),[ce,ae]=k.useState(!1),[ie,le]=k.useState(""),[fe,xe]=k.useState(""),[he,we]=k.useState(""),[Ne,Ve]=k.useState(""),Te=(Ke,He)=>a==null?void 0:a.some(gt=>gt.plan_id===Ke&>.relationship_type_id===He&>.active),Ae=Ke=>a==null?void 0:a.find(He=>He.relationship_type_id===Ke&&He.active),ze=async(Ke,He)=>{const gt=Te(Ke,He);await d.mutateAsync({planId:Ke,relationshipTypeId:He,active:!gt})},Ee=(n==null?void 0:n.filter(Ke=>Ke.active&&!Ke.owner_user_id))||[],ve=(n==null?void 0:n.filter(Ke=>Ke.owner_user_id===(s==null?void 0:s.id)))||[],Re=r==null?void 0:r.find(Ke=>Ke.id===N),Ue=N?Ae(N):null,ye=n==null?void 0:n.find(Ke=>Ke.id===(Ue==null?void 0:Ue.plan_id)),ct=async()=>{if(!L.trim())return;const Ke=await u.mutateAsync({name:L,description:U});Ke&&$.length>0&&await y.mutateAsync({planId:Ke.id,items:$}),tt()},pe=async()=>{!L.trim()||!A||(await p.mutateAsync({id:A,name:L,description:U}),await y.mutateAsync({planId:A,items:$}),tt())},Ge=Ke=>{var He;I(Ke.id),O(Ke.name),q(Ke.description||""),V(((He=Ke.items)==null?void 0:He.map(gt=>({month_number:gt.month_number,action_type_id:gt.action_type_id,default_script_id:gt.default_script_id||void 0,notes:gt.notes||void 0})))||[]),C(!0)},tt=()=>{C(!1),I(null),O(""),q(""),V([])},st=(Ke,He)=>{Y(He)},Ce=(Ke,He,gt)=>{V(Mt=>[...Mt.filter(xs=>xs.month_number!==Ke),{month_number:Ke,action_type_id:He,default_script_id:gt}]),Z(null),Y(null)},et=Ke=>{V(He=>He.filter(gt=>gt.month_number!==Ke))},Ct=async()=>{if(!ie.trim()||!fe.trim()||!J)return;const Ke=await _.mutateAsync({actionTypeId:J,title:ie,scriptBody:fe,emailSubject:he||void 0,tone:Ne||void 0});Ke&&ee!==null&&Ce(ee,J,Ke.id),ae(!1),le(""),xe(""),we(""),Ve("")},Ot=J?i==null?void 0:i.filter(Ke=>Ke.action_type_id===J&&Ke.active):[],ut=Ke=>ize[Ke||"Phone"]||Tn,Oe=Ke=>ize[Ke||"Users"]||cr;return e.jsxs(Ls,{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(wl,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(K,{onClick:()=>C(!0),className:"w-full sm:w-auto",children:[e.jsx(Bs,{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(Ke=>Ke.active).map(Ke=>{const He=Oe(Ke.icon),gt=(o==null?void 0:o[Ke.id])||0,Mt=Ae(Ke.id),Wt=n==null?void 0:n.find(Cs=>Cs.id===(Mt==null?void 0:Mt.plan_id)),xs=N===Ke.id;return e.jsxs("button",{onClick:()=>w(Ke.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${xs?"border-primary bg-primary/5 ring-2 ring-primary":"hover:bg-accent"} `,children:[e.jsx(He,{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:Ke.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[gt," contacts"]})]}),Wt?e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:[e.jsx(si,{className:"h-3 w-3 mr-1"}),Wt.name.split(" ")[0]]}):e.jsx(Ye,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},Ke.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:N&&Re?e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[(()=>{const Ke=Oe(Re.icon);return e.jsx(Ke,{className:"h-5 w-5"})})(),Re.name," Touchpoint Plan"]}),e.jsxs(mr,{children:["Choose a plan for your ",Re.name," contacts"]})]}),e.jsxs(Be,{className:"space-y-6",children:[ye&&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(si,{className:"h-4 w-4 text-green-500"}),"Currently using: ",ye.name]}),ye.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:ye.description})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>ze(ye.id,N),children:"Disable"})]}),ye.items&&ye.items.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:u0e.map((Ke,He)=>{var xs,Cs;const gt=((xs=ye.items)==null?void 0:xs.filter(Us=>Us.month_number===He+1))||[],Mt=(Cs=gt[0])==null?void 0:Cs.action_type,Wt=Mt?ut(Mt.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${gt.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:Ke}),Wt&&e.jsx(Wt,{className:"h-4 w-4 mx-auto mt-1",style:{color:(Mt==null?void 0:Mt.color)||"#3B82F6"}})]},He)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:ye?"Switch to a Different Plan":"Choose a Plan"}),Ee.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"}),Ee.map(Ke=>{var gt;const He=(ye==null?void 0:ye.id)===Ke.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${He?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ke.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((gt=Ke.items)==null?void 0:gt.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 Mt=`${Ke.name} (Copy)`;b.mutate({sourcePlanId:Ke.id,newName:Mt})},children:e.jsx(Ya,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:He?"outline":"default",disabled:He||d.isPending,onClick:()=>ze(Ke.id,N),children:He?"Active":"Use This"})]})]},Ke.id)})]}),ve.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),ve.map(Ke=>{var gt;const He=(ye==null?void 0:ye.id)===Ke.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${He?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ke.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((gt=Ke.items)==null?void 0:gt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>Ge(Ke),children:e.jsx(Ry,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>f.mutate(Ke.id),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})}),e.jsx(K,{size:"sm",variant:He?"outline":"default",disabled:He||d.isPending,onClick:()=>ze(Ke.id,N),children:He?"Active":"Use This"})]})]},Ke.id)})]}),Ee.length===0&&ve.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(Ie,{children:e.jsxs(Be,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(nn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"Select a contact group to view and assign plans"})]})})})]}),e.jsx(Ie,{className:"bg-muted/50",children:e.jsx(Be,{className:"py-4",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"How it works:"})," When you assign a plan to a contact group, those contacts will appear in your daily suggested actions based on the plan's schedule."]})})})]}),e.jsx(fs,{open:S,onOpenChange:Ke=>{Ke?C(!0):tt()},children:e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:A?"Edit Touchpoint Plan":"Create Custom Touchpoint Plan"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(Fe,{id:"plan-name",value:L,onChange:Ke=>O(Ke.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(_r,{id:"plan-description",value:U,onChange:Ke=>q(Ke.target.value),placeholder:"Describe your plan...",rows:2})]})]}),e.jsxs("div",{children:[e.jsx(ge,{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:u0e.map((Ke,He)=>{const gt=He+1,Mt=$.find(Cs=>Cs.month_number===gt),Wt=Mt?l==null?void 0:l.find(Cs=>Cs.id===Mt.action_type_id):null,xs=Wt?ut(Wt.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>Z(ee===gt?null:gt),className:` w-full p-3 rounded-lg border text-center transition-all ${Mt?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${ee===gt?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:Ke}),xs?e.jsx(xs,{className:"h-5 w-5 mx-auto mt-1",style:{color:(Wt==null?void 0:Wt.color)||"#3B82F6"}}):e.jsx(Bs,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),Mt&&e.jsx("button",{type:"button",onClick:Cs=>{Cs.stopPropagation(),et(gt)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(Sr,{className:"h-3 w-3"})})]},He)})}),ee!==null&&!J&&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 ",u0e[ee-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(Ke=>Ke.active).map(Ke=>{const He=ut(Ke.icon);return e.jsxs("button",{type:"button",onClick:()=>st(ee,Ke.id),className:"flex items-center gap-2 px-3 py-2 rounded-lg border bg-background hover:bg-accent transition-colors",children:[e.jsx(He,{className:"h-4 w-4",style:{color:Ke.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:Ke.name})]},Ke.id)})})]}),ee!==null&&J&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm font-medium",children:"Step 2: Select a script (optional)"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Y(null),children:[e.jsx(wl,{className:"h-4 w-4 mr-1"})," Back"]})]}),e.jsxs("div",{className:"space-y-2 max-h-[300px] overflow-y-auto pr-1",children:[e.jsx("button",{type:"button",onClick:()=>Ce(ee,J),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(Ke=>e.jsx("button",{type:"button",onClick:()=>Ce(ee,J,Ke.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:Ke.title}),Ke.tone&&e.jsx(Ye,{variant:"secondary",className:"text-xs mt-1",children:Ke.tone}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[Ke.script_body.substring(0,100),"..."]})]})},Ke.id)),e.jsxs("button",{type:"button",onClick:()=>ae(!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(Bs,{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"})]})]})]})]})]}),$.length>0&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[$.length," touchpoint",$.length!==1?"s":""," per year"]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:tt,children:"Cancel"}),e.jsxs(K,{onClick:A?pe:ct,disabled:!L.trim()||u.isPending||p.isPending,children:[e.jsx(wc,{className:"h-4 w-4 mr-2"}),A?"Save Changes":"Create Plan"]})]})]})}),e.jsx(fs,{open:ce,onOpenChange:ae,children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Create Custom Script"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"script-title",children:"Script Title"}),e.jsx(Fe,{id:"script-title",value:ie,onChange:Ke=>le(Ke.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(zs,{value:Ne,onValueChange:Ve,children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select tone..."})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"friendly",children:"Friendly"}),e.jsx(yt,{value:"professional",children:"Professional"}),e.jsx(yt,{value:"casual",children:"Casual"}),e.jsx(yt,{value:"formal",children:"Formal"})]})]})]}),((at=(Xe=l==null?void 0:l.find(Ke=>Ke.id===J))==null?void 0:Xe.name)==null?void 0:at.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(Fe,{id:"script-email-subject",value:he,onChange:Ke=>we(Ke.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(ge,{htmlFor:"script-body",children:"Script Content"}),e.jsx(_r,{id:"script-body",value:fe,onChange:Ke=>xe(Ke.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(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>ae(!1),children:"Cancel"}),e.jsxs(K,{onClick:Ct,disabled:!ie.trim()||!fe.trim()||_.isPending,children:[e.jsx(wc,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}function R2s(t,s,r,n){const a=u=>u*Math.PI/180,l=a(r-t),i=a(n-s),d=Math.sin(l/2)**2+Math.cos(a(t))*Math.cos(a(r))*Math.sin(i/2)**2;return 2*3958.8*Math.asin(Math.sqrt(d))}const wit="popby_geocode_cache_v1";function O2s(){try{return JSON.parse(localStorage.getItem(wit)||"{}")}catch{return{}}}function F2s(t){try{localStorage.setItem(wit,JSON.stringify(t))}catch{}}function z2s({contacts:t,onLogPopby:s}){const[r,n]=k.useState(null),[a,o]=k.useState("idle"),[l,i]=k.useState(5),[d,u]=k.useState(""),[p,f]=k.useState(new Map),[y,_]=k.useState(!1);k.useEffect(()=>{(async()=>{const{data:C}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();C!=null&&C.value&&u(C.value)})()},[]);const b=k.useMemo(()=>t.filter(C=>C.isDue&&(C.address||C.city&&C.state||C.zip)),[t]),N=()=>{if(!("geolocation"in navigator)){o("unavailable");return}o("loading"),navigator.geolocation.getCurrentPosition(C=>{n({lat:C.coords.latitude,lng:C.coords.longitude}),o("ok")},()=>{o("denied")},{enableHighAccuracy:!0,timeout:1e4,maximumAge:6e4})};k.useEffect(()=>{if(!d||!r||b.length===0)return;let C=!1;const A=O2s(),I=new Map;b.forEach(O=>{const U=[O.address,O.city,O.state,O.zip].filter(Boolean).join("|").toLowerCase();A[U]&&I.set(O.id,A[U])}),f(new Map(I));const L=b.filter(O=>!([O.address,O.city,O.state,O.zip].filter(Boolean).join("|").toLowerCase()in A));if(L.length!==0)return _(!0),(async()=>{const O=[...L],U=async()=>{var q,$;for(;O.length&&!C;){const V=O.shift(),ee=[V.address,V.city,V.state,V.zip].filter(Boolean),Z=ee.join("|").toLowerCase(),J=ee.join(", ");try{const ce=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(J)}.json?limit=1&access_token=${d}`)).json();if(($=(q=ce==null?void 0:ce.features)==null?void 0:q[0])!=null&&$.center){const[ae,ie]=ce.features[0].center;A[Z]={lat:ie,lng:ae},I.set(V.id,{lat:ie,lng:ae})}else A[Z]=null}catch{}}};await Promise.all([U(),U(),U(),U()]),C||(F2s(A),f(new Map(I)),_(!1))})(),()=>{C=!0}},[d,r,b]);const w=k.useMemo(()=>{if(!r)return[];const C=[];return b.forEach(A=>{const I=p.get(A.id);if(!I)return;const L=R2s(r.lat,r.lng,I.lat,I.lng);L<=l&&C.push({...A,distanceMiles:L,lat:I.lat,lng:I.lng})}),C.sort((A,I)=>A.distanceMiles-I.distanceMiles)},[r,b,p,l]),S=C=>{const I=/iPad|iPhone|iPod/.test(navigator.userAgent)?`https://maps.apple.com/?daddr=${C.lat},${C.lng}`:`https://www.google.com/maps/dir/?api=1&destination=${C.lat},${C.lng}`;window.open(I,"_blank","noopener")};return e.jsxs(Ie,{className:"border-primary/30 bg-gradient-to-br from-primary/5 to-transparent",children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2 text-lg",children:[e.jsx(PM,{className:"h-5 w-5 text-primary"}),"Nearby Now"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Due contacts within driving distance — perfect for errand-day pop-bys."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(zs,{value:String(l),onValueChange:C=>i(Number(C)),children:[e.jsx(Os,{className:"w-[110px] h-9",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"2",children:"2 miles"}),e.jsx(yt,{value:"5",children:"5 miles"}),e.jsx(yt,{value:"10",children:"10 miles"}),e.jsx(yt,{value:"25",children:"25 miles"})]})]}),e.jsxs(K,{size:"sm",variant:a==="ok"?"outline":"default",onClick:N,disabled:a==="loading",children:[a==="loading"?e.jsx(to,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(PM,{className:"h-4 w-4 mr-1"}),a==="ok"?"Refresh":"Use my location"]})]})]})}),e.jsxs(Be,{className:"space-y-3",children:[a==="idle"&&e.jsxs("div",{className:"text-center py-6 text-sm text-muted-foreground",children:[e.jsx(La,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"Tap ",e.jsx("span",{className:"font-medium text-foreground",children:'"Use my location"'})," to see who's close by right now."]}),a==="denied"&&e.jsxs("div",{className:"text-center py-6 text-sm text-destructive flex flex-col items-center gap-2",children:[e.jsx(co,{className:"h-6 w-6"}),"Location access was blocked. Enable it in your browser to use Nearby Now."]}),a==="unavailable"&&e.jsx("div",{className:"text-center py-6 text-sm text-muted-foreground",children:"Geolocation isn't available on this device."}),a==="ok"&&!d&&e.jsx("div",{className:"text-center py-6 text-sm text-muted-foreground",children:"Mapping isn't configured yet — ask an admin to add the Mapbox token."}),a==="ok"&&d&&b.length===0&&e.jsx("div",{className:"text-center py-6 text-sm text-muted-foreground",children:"No due contacts have addresses yet. Add street addresses to your sphere to power this."}),a==="ok"&&d&&b.length>0&&y&&w.length===0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ss,{className:"h-14 w-full"}),e.jsx(Ss,{className:"h-14 w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Locating contacts…"})]}),a==="ok"&&d&&!y&&w.length===0&&b.length>0&&e.jsxs("div",{className:"text-center py-6 text-sm text-muted-foreground",children:["No due contacts within ",l," miles. Try widening the radius."]}),w.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ye,{variant:"secondary",className:"font-medium",children:[w.length," nearby"]}),y&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(to,{className:"h-3 w-3 animate-spin"})," still locating…"]})]}),e.jsx("div",{className:"space-y-2",children:w.map(C=>e.jsxs("div",{className:"flex items-center justify-between gap-3 p-3 rounded-lg bg-card border hover:border-primary/40 transition-colors",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"font-medium truncate",children:[C.first_name," ",C.last_name]}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:C.distanceMiles<1?`${(C.distanceMiles*5280).toFixed(0)} ft`:`${C.distanceMiles.toFixed(1)} mi`}),C.daysOverdue>0&&e.jsxs(Ye,{variant:"destructive",className:"text-xs",children:[C.daysOverdue,"d overdue"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:[C.address,C.city,C.state].filter(Boolean).join(", ")})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[C.phone&&e.jsx(K,{size:"icon",variant:"ghost",asChild:!0,className:"h-9 w-9",title:"Call",children:e.jsx("a",{href:`tel:${C.phone}`,children:e.jsx(Tn,{className:"h-4 w-4"})})}),e.jsx(K,{size:"icon",variant:"ghost",onClick:()=>S(C),className:"h-9 w-9",title:"Directions",children:e.jsx(CL,{className:"h-4 w-4"})}),e.jsxs(K,{size:"sm",onClick:()=>s(C),children:[e.jsx(Vi,{className:"h-4 w-4 mr-1"}),"Log"]})]})]},C.id))})]})]})]})}const B2s="0dde5abb-0005-4c8c-a471-30d0cbc9e280",$2s=[{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 q2s(){const t=br(),s=hit(),{data:r}=cws(),{data:n}=Mf(),{data:a}=YSe(),{data:o}=Cme(90),{data:l}=Uh(),i=pws(),d=hws(),u=uws(),p=mws(),{data:f=[],isLoading:y}=ft({queryKey:["popby-templates"],queryFn:async()=>{const{data:ce,error:ae}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",B2s).order("publish_date",{ascending:!1});if(ae)throw ae;const{data:ie}=await G.from("template_likes").select("template_id"),{data:le}=await G.from("template_comments").select("template_id"),fe=new Map;ie==null||ie.forEach(he=>{fe.set(he.template_id,(fe.get(he.template_id)||0)+1)});const xe=new Map;return le==null||le.forEach(he=>{xe.set(he.template_id,(xe.get(he.template_id)||0)+1)}),(ce||[]).map(he=>({...he,likesCount:fe.get(he.id)||0,commentsCount:xe.get(he.id)||0}))}}),_=ce=>{const ae=l==null?void 0:l.find(ie=>ie.id===ce);return ae?`${ae.first_name} ${ae.last_name||""}`.trim():"Unknown"},b=ce=>{if(!ce)return null;const ae=r==null?void 0:r.find(ie=>ie.id===ce);return(ae==null?void 0:ae.name)||null},[N,w]=k.useState(null),[S,C]=k.useState(!1),[A,I]=k.useState(!1),[L,O]=k.useState(!1),[U,q]=k.useState({popby_item_id:"",notes:""}),[$,V]=k.useState({name:"",description:""}),ee=async()=>{N&&(await d.mutateAsync({contact_id:N.id,popby_item_id:U.popby_item_id||void 0,notes:U.notes||void 0}),C(!1),w(null),q({popby_item_id:"",notes:""}))},Z=async()=>{$.name.trim()&&(await u.mutateAsync({name:$.name.trim(),description:$.description.trim()||void 0}),O(!1),V({name:"",description:""}))},J=async(ce,ae)=>{await p.mutateAsync({relationship_type_id:ce,frequency_days:parseInt(ae)})},Y=ce=>{var ie;const ae=a==null?void 0:a.find(le=>le.relationship_type_id===ce);return((ie=ae==null?void 0:ae.frequency_days)==null?void 0:ie.toString())||"90"};return e.jsx(Ls,{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(Ie,{children:e.jsxs(Be,{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(Ie,{children:e.jsxs(Be,{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(Ie,{children:e.jsxs(Be,{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(La,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(K,{variant:"outline",onClick:()=>I(!0),children:[e.jsx(So,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(K,{variant:"outline",onClick:()=>O(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(ta,{defaultValue:"due",children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"due",children:"Due for Popby"}),e.jsx(ls,{value:"activity",children:"Recent Activity"}),e.jsx(ls,{value:"library",children:"Popby Library"}),e.jsx(ls,{value:"templates",children:"Popby Templates"})]}),e.jsxs(js,{value:"due",className:"space-y-4 mt-4",children:[e.jsx(z2s,{contacts:s||[],onLogPopby:ce=>{w(ce),C(!0)}}),!s||s.length===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(Vi,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No contacts due for a popby right now!"}),e.jsx("p",{className:"text-sm mt-1",children:"Great job staying connected."})]})}):e.jsx("div",{className:"space-y-3",children:s.map(ce=>e.jsx(Ie,{className:"hover:shadow-md transition-shadow",children:e.jsx(Be,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium",children:[ce.first_name," ",ce.last_name]}),ce.daysOverdue>0&&e.jsxs(Ye,{variant:"destructive",className:"text-xs",children:[ce.daysOverdue,"+ days overdue"]}),ce.daysSinceLastPopby===null&&e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Never visited"})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-1 text-sm text-muted-foreground",children:[ce.address&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(La,{className:"h-3 w-3"}),ce.city||ce.address]}),ce.tags&&ce.tags.length>0&&e.jsx("span",{children:ce.tags.map(ae=>{var ie;return(ie=ae.relationship_type)==null?void 0:ie.name}).join(", ")})]}),ce.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",gs(new Date(ce.lastPopby),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ce.phone&&e.jsx(K,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx("a",{href:`tel:${ce.phone}`,children:e.jsx(Tn,{className:"h-4 w-4"})})}),e.jsxs(K,{size:"sm",onClick:()=>{w(ce),C(!0)},children:[e.jsx(si,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},ce.id))})]}),e.jsx(js,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(rn,{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(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(Be,{className:"space-y-3",children:o.map(ce=>e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0 last:pb-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/10 flex items-center justify-center",children:e.jsx(Vi,{className:"h-5 w-5 text-orange-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium",children:_(ce.contact_id)}),b(ce.popby_item_id)&&e.jsx(Ye,{variant:"secondary",className:"text-xs",children:b(ce.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:gs(new Date(ce.completed_at),"MMM d, yyyy h:mm a")}),ce.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ce.notes})]})]},ce.id))})]})}),e.jsx(js,{value:"library",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[r==null?void 0:r.map(ce=>e.jsx(Ie,{children:e.jsx(Be,{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(Vi,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-medium",children:ce.name}),ce.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:ce.description}),!ce.owner_user_id&&e.jsx(Ye,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},ce.id)),e.jsx(Ie,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>O(!0),children:e.jsx(Be,{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(Bs,{className:"h-8 w-8 mx-auto mb-2"}),e.jsx("p",{children:"Add New Popby Idea"})]})})})]})}),e.jsxs(js,{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((ce,ae)=>e.jsx(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsx(Ss,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(Ss,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ss,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ss,{className:"h-5 w-16"}),e.jsx(Ss,{className:"h-5 w-20"})]})]})},ae))}),!y&&f.length===0&&e.jsx(Ie,{children:e.jsxs(Be,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(al,{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(ce=>e.jsxs(Ie,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer",onClick:()=>t(`/templates/${ce.id}`),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:ce.preview_image_url?e.jsx("img",{src:ce.preview_image_url,alt:ce.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"})}),e.jsxs(Be,{className:"p-4 flex flex-col",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:ce.name}),ce.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:Jde(ce.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(Ye,{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(Ou,{className:"h-3.5 w-3.5"}),ce.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(bc,{className:"h-3.5 w-3.5"}),ce.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:ae=>{ae.stopPropagation(),t(`/templates/${ce.id}`)},children:[e.jsx(Kr,{className:"h-4 w-4"}),"View Template"]})]})]},ce.id))})]})]}),e.jsx(fs,{open:S,onOpenChange:C,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsxs(bs,{children:["Log Popby for ",N==null?void 0:N.first_name," ",N==null?void 0:N.last_name]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Popby Item (optional)"}),e.jsxs(zs,{value:U.popby_item_id,onValueChange:ce=>q(ae=>({...ae,popby_item_id:ce})),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select a popby item..."})}),e.jsx(Fs,{children:r==null?void 0:r.map(ce=>e.jsx(yt,{value:ce.id,children:ce.name},ce.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Notes (optional)"}),e.jsx(_r,{placeholder:"Any notes about this popby...",value:U.notes,onChange:ce=>q(ae=>({...ae,notes:ce.target.value}))})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(K,{onClick:ee,disabled:d.isPending,children:"Log Popby"})]})]})}),e.jsx(fs,{open:A,onOpenChange:I,children:e.jsxs(ms,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Popby Frequency Settings"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set default popby frequency for each relationship type. You can override these per-contact."}),n==null?void 0:n.map(ce=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx(ge,{className:"font-medium",children:ce.name}),e.jsxs(zs,{value:Y(ce.id),onValueChange:ae=>J(ce.id,ae),children:[e.jsx(Os,{className:"w-[180px]",children:e.jsx(qs,{})}),e.jsx(Fs,{children:$2s.map(ae=>e.jsx(yt,{value:ae.value,children:ae.label},ae.value))})]})]},ce.id))]}),e.jsx(gn,{children:e.jsx(K,{onClick:()=>I(!1),children:"Done"})})]})}),e.jsx(fs,{open:L,onOpenChange:O,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Add Popby Idea"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Name *"}),e.jsx(Fe,{placeholder:"e.g., Homemade cookies",value:$.name,onChange:ce=>V(ae=>({...ae,name:ce.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Description"}),e.jsx(_r,{placeholder:"Optional description...",value:$.description,onChange:ce=>V(ae=>({...ae,description:ce.target.value}))})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(K,{onClick:Z,disabled:!$.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}const U2s=SC({property_address:Yl().min(1,"Property address is required"),city:Yl().optional(),state:Yl().optional(),zip:Yl().optional(),transaction_type:lKe(["buyer","seller"]),close_date:Yl().min(1,"Close date is required"),sale_price:JL().min(0,"Sale price must be positive"),commission_amount:JL().optional(),lead_source_id:Yl().optional(),client_type_id:Yl().optional(),contact_id:Yl().optional(),notes:Yl().optional(),is_win:N5t()});function jit({open:t,onOpenChange:s,transaction:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,d]=k.useState(!1),[u,p]=k.useState(""),f=ihe(),y=CDt(),{data:_}=eE(),{data:b}=Mf(),{data:N}=Uh(),w=nhe(),S=gke(),{data:C}=ohe(),A=(C==null?void 0:C.show_commission)??!0,I=Zue({resolver:Yue(U2s),defaultValues:{property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1}});k.useEffect(()=>{r?I.reset({property_address:r.property_address,city:r.city||"",state:r.state||"",zip:r.zip||"",transaction_type:r.transaction_type,close_date:r.close_date,sale_price:Number(r.sale_price),commission_amount:r.commission_amount?Number(r.commission_amount):void 0,lead_source_id:r.lead_source_id||void 0,client_type_id:r.client_type_id||void 0,contact_id:r.contact_id||void 0,notes:r.notes||"",is_win:r.is_win}):I.reset({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1})},[r,I]);const L=async $=>{const V={property_address:$.property_address,transaction_type:$.transaction_type,close_date:$.close_date,sale_price:$.sale_price,is_win:$.is_win,commission_amount:$.commission_amount||null,lead_source_id:$.lead_source_id||null,client_type_id:$.client_type_id||null,contact_id:$.contact_id||null,city:$.city||null,state:$.state||null,zip:$.zip||null,notes:$.notes||null};r?await y.mutateAsync({id:r.id,...V}):await f.mutateAsync(V),s(!1)},O=async()=>{if(!o.trim())return;const[$,...V]=o.trim().split(" "),ee=V.join(" ")||null,Z=await w.mutateAsync({first_name:$,last_name:ee,tagIds:[]});Z&&(I.setValue("contact_id",Z.id),l(""),d(!1),a(!1))},U=async()=>{if(!u.trim())return;const $=await S.mutateAsync(u.trim());$&&(I.setValue("lead_source_id",$.id),p(""))},q=N==null?void 0:N.find($=>$.id===I.watch("contact_id"));return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-lg max-h-[90vh]",children:[e.jsx(ks,{children:e.jsx(bs,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(di,{className:"max-h-[70vh] pr-4",children:e.jsx(Xue,{...I,children:e.jsxs("form",{onSubmit:I.handleSubmit(L),className:"space-y-4",children:[e.jsx(Ic,{control:I.control,name:"property_address",render:({field:$})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Property Address *"}),e.jsx(mc,{children:e.jsx(Fe,{placeholder:"123 Main St",...$})}),e.jsx(gm,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Ic,{control:I.control,name:"city",render:({field:$})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"City"}),e.jsx(mc,{children:e.jsx(Fe,{placeholder:"City",...$})})]})}),e.jsx(Ic,{control:I.control,name:"state",render:({field:$})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"State"}),e.jsx(mc,{children:e.jsx(Fe,{placeholder:"TX",...$})})]})}),e.jsx(Ic,{control:I.control,name:"zip",render:({field:$})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Zip"}),e.jsx(mc,{children:e.jsx(Fe,{placeholder:"75001",...$})})]})})]}),e.jsx(Ic,{control:I.control,name:"transaction_type",render:({field:$})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Transaction Type *"}),e.jsxs(zs,{onValueChange:$.onChange,value:$.value,children:[e.jsx(mc,{children:e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select type"})})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"buyer",children:"Buyer"}),e.jsx(yt,{value:"seller",children:"Seller"})]})]}),e.jsx(gm,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Ic,{control:I.control,name:"close_date",render:({field:$})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Close Date *"}),e.jsx(mc,{children:e.jsx(Fe,{type:"date",...$})}),e.jsx(gm,{})]})}),e.jsx(Ic,{control:I.control,name:"sale_price",render:({field:$})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Sale Price *"}),e.jsx(mc,{children:e.jsx(Fe,{type:"number",placeholder:"0",...$,onChange:V=>$.onChange(Number(V.target.value))})}),e.jsx(gm,{})]})})]}),A&&e.jsx(Ic,{control:I.control,name:"commission_amount",render:({field:$})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Commission"}),e.jsx(mc,{children:e.jsx(Fe,{type:"number",placeholder:"0",...$,value:$.value??"",onChange:V=>$.onChange(V.target.value?Number(V.target.value):void 0)})})]})}),e.jsx(Ic,{control:I.control,name:"lead_source_id",render:({field:$})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Lead Source"}),e.jsxs(zs,{onValueChange:$.onChange,value:$.value||"",children:[e.jsx(mc,{children:e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select source"})})}),e.jsx(Fs,{children:_==null?void 0:_.map(V=>e.jsx(yt,{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:$=>p($.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:U,disabled:!u.trim(),children:e.jsx(Bs,{className:"h-4 w-4"})})]}),e.jsx(Ic,{control:I.control,name:"client_type_id",render:({field:$})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Client Type"}),e.jsxs(zs,{onValueChange:$.onChange,value:$.value||"",children:[e.jsx(mc,{children:e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select client type"})})}),e.jsx(Fs,{children:b==null?void 0:b.map(V=>e.jsx(yt,{value:V.id,children:V.name},V.id))})]})]})}),e.jsx(Ic,{control:I.control,name:"contact_id",render:({field:$})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Client Contact"}),e.jsxs(yo,{open:n,onOpenChange:a,children:[e.jsx(vo,{asChild:!0,children:e.jsx(mc,{children:e.jsxs(K,{variant:"outline",role:"combobox",className:Rt("w-full justify-between",!$.value&&"text-muted-foreground"),children:[q?`${q.first_name} ${q.last_name||""}`.trim():"Select contact",e.jsx(wx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(uo,{className:"w-full p-0",align:"start",children:[e.jsxs(Ax,{children:[e.jsx(Ex,{placeholder:"Search contacts..."}),e.jsxs(Px,{children:[e.jsx(Ix,{children:e.jsxs("div",{className:"p-2 space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"No contact found."}),!i&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>d(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx(Lx,{children:N==null?void 0:N.map(V=>e.jsxs(op,{value:`${V.first_name} ${V.last_name||""}`,onSelect:()=>{$.onChange(V.id),a(!1)},children:[e.jsx(ea,{className:Rt("mr-2 h-4 w-4",V.id===$.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:O,disabled:!o.trim()||w.isPending,children:"Add Contact"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{d(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(Ic,{control:I.control,name:"notes",render:({field:$})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Notes"}),e.jsx(mc,{children:e.jsx(_r,{placeholder:"Any notes about this transaction...",...$})})]})}),e.jsx(Ic,{control:I.control,name:"is_win",render:({field:$})=>e.jsxs(uc,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(hc,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx(mc,{children:e.jsx(Lr,{checked:$.value,onCheckedChange:$.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 eCe({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=k.useState(null),[i,d]=k.useState(null),[u,p]=k.useState(""),[f,y]=k.useState("all"),[_,b]=k.useState("all"),[N,w]=k.useState("all"),[S,C]=k.useState(!1),A=MDt(),I=ihe(),{data:L}=eE(),{data:O}=Mf(),U=bE(),q=ee=>{const{id:Z,created_at:J,updated_at:Y,lead_source:ce,client_type:ae,contact:ie,...le}=ee;I.mutate(le)},$=()=>{i&&(A.mutate(i),d(null))},V=t.filter(ee=>{var ie,le,fe,xe;const Z=u===""||ee.property_address.toLowerCase().includes(u.toLowerCase())||((le=(ie=ee.contact)==null?void 0:ie.first_name)==null?void 0:le.toLowerCase().includes(u.toLowerCase()))||((xe=(fe=ee.contact)==null?void 0:fe.last_name)==null?void 0:xe.toLowerCase().includes(u.toLowerCase())),J=f==="all"||ee.transaction_type===f,Y=_==="all"||ee.lead_source_id===_,ce=N==="all"||ee.client_type_id===N,ae=!S||ee.is_win;return Z&&J&&Y&&ce&&ae});return r?e.jsx(Ie,{children:e.jsx(Be,{className:"p-6 space-y-4",children:[1,2,3].map(ee=>e.jsx(Ss,{className:"h-16 w-full"},ee))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs(Ft,{children:["Transactions (",V.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(tn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search...",value:u,onChange:ee=>p(ee.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(zs,{value:f,onValueChange:y,children:[e.jsx(Os,{className:"w-[100px]",children:e.jsx(qs,{placeholder:"Type"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Types"}),e.jsx(yt,{value:"buyer",children:"Buyer"}),e.jsx(yt,{value:"seller",children:"Seller"})]})]}),e.jsxs(zs,{value:_,onValueChange:b,children:[e.jsx(Os,{className:"w-[130px]",children:e.jsx(qs,{placeholder:"Lead Source"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Sources"}),L==null?void 0:L.map(ee=>e.jsx(yt,{value:ee.id,children:ee.name},ee.id))]})]}),e.jsxs(K,{variant:S?"default":"outline",size:"sm",onClick:()=>C(!S),children:[e.jsx(rc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(Be,{children:V.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):U?e.jsx("div",{className:"space-y-3",children:V.map(ee=>e.jsxs(Ie,{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:ee.property_address}),ee.is_win&&e.jsx(rc,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[ee.city,ee.state?`, ${ee.state}`:""]})]}),e.jsx(Ye,{variant:ee.transaction_type==="buyer"?"default":"secondary",children:ee.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: "}),VEe(ee.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),El(ee.sale_price)]}),s&&ee.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),El(ee.commission_amount)]}),ee.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),ee.lead_source.name]}),ee.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),ee.contact.first_name," ",ee.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[ee.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(ee),children:e.jsx(Gc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>q(ee),children:e.jsx(Ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(ee.id),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})]},ee.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[n&&e.jsx(Nt,{children:"Agent"}),e.jsx(Nt,{children:"Property"}),e.jsx(Nt,{children:"Type"}),e.jsx(Nt,{children:"Close Date"}),e.jsx(Nt,{children:"Sale Price"}),s&&e.jsx(Nt,{children:"Commission"}),e.jsx(Nt,{children:"Lead Source"}),e.jsx(Nt,{children:"Client"}),!a&&e.jsx(Nt,{className:"w-[50px]"})]})}),e.jsx(Pn,{children:V.map(ee=>{var Z;return e.jsxs(As,{children:[n&&e.jsx(dt,{className:"font-medium text-sm",children:n[ee.owner_user_id]||"Unknown"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[ee.is_win&&e.jsx(rc,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ee.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[ee.city,ee.state?`, ${ee.state}`:""]})]})]})}),e.jsx(dt,{children:e.jsx(Ye,{variant:ee.transaction_type==="buyer"?"default":"secondary",children:ee.transaction_type})}),e.jsx(dt,{children:VEe(ee.close_date)}),e.jsx(dt,{children:El(ee.sale_price)}),s&&e.jsx(dt,{children:ee.commission_amount?El(ee.commission_amount):"-"}),e.jsx(dt,{children:((Z=ee.lead_source)==null?void 0:Z.name)||"-"}),e.jsx(dt,{children:ee.contact?`${ee.contact.first_name} ${ee.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(dt,{children:e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(cx,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",children:[e.jsxs(xa,{onClick:()=>l(ee),children:[e.jsx(Gc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(xa,{onClick:()=>q(ee),children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(xa,{onClick:()=>d(ee.id),className:"text-destructive",children:[e.jsx(yr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},ee.id)})})]})})})]}),e.jsx(jit,{open:!!o,onOpenChange:ee=>!ee&&l(null),transaction:o||void 0}),e.jsx(Ll,{open:!!i,onOpenChange:ee=>!ee&&d(null),children:e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Delete Transaction?"}),e.jsx(vl,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:$,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function Nit({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),N=Math.max(_-y,0),w=l>0?N/l:0,S=o/12*100,C=b>=S?"ahead":b>=S*.8?"on-track":"behind";return{percent:b,remaining:N,pace:w,status:C}},d=i(s.totalTransactions,t.transactions_goal),u=i(s.totalVolume,t.volume_goal),p=n?i(s.totalCommission,t.gci_goal):null,f=y=>{switch(y){case"ahead":return e.jsxs(Ye,{className:"bg-green-500 text-white",children:[e.jsx(Yo,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(Ye,{variant:"secondary",children:[e.jsx(Xy,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(Ye,{variant:"destructive",children:[e.jsx(jS,{className:"h-3 w-3 mr-1"}),"Behind"]});default:return null}};return!t.transactions_goal&&!t.volume_goal&&!t.gci_goal?null:e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oh,{className:"h-5 w-5 text-primary"}),e.jsxs(Ft,{children:[r," Goals Progress"]})]})}),e.jsx(Be,{children:e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[t.transactions_goal&&d&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Transactions"}),f(d.status)]}),e.jsx(pi,{value:d.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[s.totalTransactions," of ",t.transactions_goal]}),e.jsxs("span",{children:[Math.round(d.percent),"%"]})]}),d.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Math.ceil(d.pace),"/month to hit goal"]})]}),t.volume_goal&&u&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Volume"}),f(u.status)]}),e.jsx(pi,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[El(s.totalVolume,!0)," of ",El(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 ",El(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(pi,{value:p.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[El(s.totalCommission,!0)," of ",El(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 ",El(p.pace,!0),"/month"]})]})]})})]})}const V2s={light:"",dark:".dark"},kit=k.createContext(null);function Sit(){const t=k.useContext(kit);if(!t)throw new Error("useChart must be used within a ");return t}const Cit=k.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=k.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(kit.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:Rt("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(H2s,{id:i,config:n}),e.jsx(sT,{children:r})]})})});Cit.displayName="Chart";const H2s=({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(V2s).map(([n,a])=>` ${a} [data-chart=${t}] { ${r.map(([o,l])=>{var d;const i=((d=l.theme)==null?void 0:d[n])||l.color;return i?` --color-${o}: ${i};`:null}).join(` `)} } `).join(` `)}}):null},Mit=k.forwardRef(({active:t,payload:s,className:r,indicator:n="dot",hideLabel:a=!1,hideIndicator:o=!1,label:l,labelFormatter:i,labelClassName:d,formatter:u,color:p,nameKey:f,labelKey:y},_)=>{const{config:b}=Sit(),N=k.useMemo(()=>{var L;if(a||!(s!=null&&s.length))return null;const[S]=s,C=`${y||S.dataKey||S.name||"value"}`,A=Dwe(b,S,C),I=!y&&typeof l=="string"?((L=b[l])==null?void 0:L.label)||l:A==null?void 0:A.label;return i?e.jsx("div",{className:Rt("font-medium",d),children:i(I,s)}):I?e.jsx("div",{className:Rt("font-medium",d),children:I}):null},[l,i,s,a,d,b,y]);if(!t||!(s!=null&&s.length))return null;const w=s.length===1&&n!=="dot";return e.jsxs("div",{ref:_,className:Rt("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[w?null:N,e.jsx("div",{className:"grid gap-1.5",children:s.map((S,C)=>{const A=`${f||S.name||S.dataKey||"value"}`,I=Dwe(b,S,A),L=p||S.payload.fill||S.color;return e.jsx("div",{className:Rt("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&&(S==null?void 0:S.value)!==void 0&&S.name?u(S.value,S.name,S,C,S.payload):e.jsxs(e.Fragment,{children:[I!=null&&I.icon?e.jsx(I.icon,{}):!o&&e.jsx("div",{className:Rt("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":w&&n==="dashed"}),style:{"--color-bg":L,"--color-border":L}}),e.jsxs("div",{className:Rt("flex flex-1 justify-between leading-none",w?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[w?N:null,e.jsx("span",{className:"text-muted-foreground",children:(I==null?void 0:I.label)||S.name})]}),S.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:S.value.toLocaleString()})]})]})},S.dataKey)})})]})});Mit.displayName="ChartTooltip";const G2s=k.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=Sit();return r!=null&&r.length?e.jsx("div",{ref:o,className:Rt("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",t),children:r.map(i=>{const d=`${a||i.dataKey||"value"}`,u=Dwe(l,i,d);return e.jsxs("div",{className:Rt("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});G2s.displayName="ChartLegend";function Dwe(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 w9=["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 tCe({stats:t,year:s}){const r=t.transactionsByMonth.some(a=>a.count>0),n=t.leadSourceBreakdown.length>0;return!r&&!n?e.jsx(Ie,{children:e.jsx(Be,{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(Ie,{className:"overflow-hidden",children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Transactions by Month"})}),e.jsx(Be,{className:"overflow-hidden",children:e.jsx(Cit,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(sT,{width:"100%",height:"100%",children:e.jsxs(Wat,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(Aat,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(pC,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(fC,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(Jm,{content:e.jsx(Mit,{})}),e.jsx(v1,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Be,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(sT,{width:"100%",height:"100%",children:e.jsxs(Kat,{children:[e.jsx(S0,{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(mO,{fill:w9[o%w9.length]},`cell-${o}`))}),e.jsx(Jm,{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:w9[o%w9.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function W2s(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=lNe(s,n,new Date);if(j1e(a))return gs(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(j1e(n))return gs(n,"yyyy-MM-dd")}catch{}return null}const K2s=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function Z2s({open:t,onOpenChange:s}){const[r,n]=k.useState([]),[a,o]=k.useState(!1),[l,i]=k.useState(0),{data:d}=eE(),{data:u}=Mf(),p=ihe(),f=()=>{const S=K2s.join(","),C=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),A=`${S} ${C}`,I=new Blob([A],{type:"text/csv"}),L=URL.createObjectURL(I),O=document.createElement("a");O.href=L,O.download="transaction-import-template.csv",O.click(),URL.revokeObjectURL(L)},y=S=>{const C=S.split(` `).filter(I=>I.trim());if(C.length<2)return[];const A=C[0].split(",").map(I=>I.trim().toLowerCase().replace(/['"]/g,""));return C.slice(1).map((I,L)=>{var ie,le,fe,xe;const O=[];let U="",q=!1;for(const he of I)he==='"'?q=!q:he===","&&!q?(O.push(U.trim()),U=""):U+=he;O.push(U.trim());const $=he=>{var Ne;const we=A.indexOf(he);return we>=0?(Ne=O[we])==null?void 0:Ne.replace(/^["']|["']$/g,"").trim():""},V=(ie=$("transaction_type"))==null?void 0:ie.toLowerCase(),ee=(le=$("sale_price"))==null?void 0:le.replace(/[$,]/g,""),Z=(fe=$("commission_amount"))==null?void 0:fe.replace(/[$,]/g,""),J=(xe=$("is_win"))==null?void 0:xe.toLowerCase(),Y=$("close_date"),ce=W2s(Y);let ae;return $("property_address")?["buyer","seller"].includes(V)?ce?(!ee||isNaN(Number(ee)))&&(ae="Invalid sale price"):ae=`Invalid date format: "${Y}" - use MM/DD/YYYY or YYYY-MM-DD`:ae='Transaction type must be "buyer" or "seller"':ae="Missing property address",{property_address:$("property_address"),city:$("city"),state:$("state"),zip:$("zip"),transaction_type:V==="seller"?"seller":"buyer",close_date:ce||"",sale_price:Number(ee)||0,commission_amount:Z?Number(Z):null,lead_source_name:$("lead_source"),client_type_name:$("client_type"),is_win:["yes","true","1"].includes(J),notes:$("notes"),error:ae}})},_=S=>{var I;const C=(I=S.target.files)==null?void 0:I[0];if(!C)return;const A=new FileReader;A.onload=L=>{var q;const O=(q=L.target)==null?void 0:q.result,U=y(O);n(U)},A.readAsText(C)},b=async()=>{const S=r.filter(I=>!I.error);if(S.length===0){me.error("No valid transactions to import");return}o(!0),i(0);let C=0,A=0;for(let I=0;Iq.name.toLowerCase()===L.lead_source_name.toLowerCase()),U=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:(O==null?void 0:O.id)||null,client_type_id:(U==null?void 0:U.id)||null,contact_id:null,notes:L.notes||null,is_win:L.is_win}),C++}catch(O){A++,console.error("Failed to import transaction:",O)}i(Math.round((I+1)/S.length*100))}o(!1),C>0&&me.success(`Imported ${C} transaction${C>1?"s":""}`),A>0&&me.error(`Failed to import ${A} transaction${A>1?"s":""}`),n([]),s(!1)},N=r.filter(S=>!S.error).length,w=r.filter(S=>S.error).length;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Import Transactions"}),e.jsx(Rr,{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(Xa,{className:"h-4 w-4 mr-2"}),"Template"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(Ye,{variant:"outline",children:[r.length," rows found"]}),N>0&&e.jsxs(Ye,{className:"bg-green-500 text-white",children:[e.jsx(ea,{className:"h-3 w-3 mr-1"}),N," valid"]}),w>0&&e.jsxs(Ye,{variant:"destructive",children:[e.jsx(co,{className:"h-3 w-3 mr-1"}),w," errors"]})]}),e.jsx(di,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((S,C)=>e.jsxs("div",{className:`p-2 rounded text-sm ${S.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:S.property_address||"(no address)"}),e.jsx(Ye,{variant:S.transaction_type==="buyer"?"default":"secondary",children:S.transaction_type})]}),e.jsxs("div",{className:"text-muted-foreground",children:[S.close_date," • $",S.sale_price.toLocaleString()]}),S.error&&e.jsx(b4e,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(w4e,{className:"text-xs",children:S.error})})]},C)),r.length>10&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["...and ",r.length-10," more"]})]})}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${l}%`}})}),e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:["Importing... ",l,"%"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:b,disabled:N===0||a,children:[e.jsx(Da,{className:"h-4 w-4 mr-2"}),"Import ",N," Transaction",N!==1?"s":""]})]})]})]})})}const Y2s=SC({transactions_goal:JL().min(0).optional(),volume_goal:JL().min(0).optional(),gci_goal:JL().min(0).optional()});function X2s({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=TDt(),{data:o}=ohe(),l=(o==null?void 0:o.show_commission)??!0,i=Zue({resolver:Yue(Y2s),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});k.useEffect(()=>{n?i.reset({transactions_goal:n.transactions_goal??void 0,volume_goal:n.volume_goal?Number(n.volume_goal):void 0,gci_goal:n.gci_goal?Number(n.gci_goal):void 0}):i.reset({transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0})},[n,i,t]);const d=async u=>{await a.mutateAsync({year:r,transactions_goal:u.transactions_goal??null,volume_goal:u.volume_goal??null,gci_goal:l?u.gci_goal??null:null}),s(!1)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(bs,{children:[r," Goals"]}),e.jsx(Rr,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(Xue,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(d),className:"space-y-4",children:[e.jsx(Ic,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Transactions Goal"}),e.jsx(mc,{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(Qie,{children:"Total number of deals you want to close"}),e.jsx(gm,{})]})}),e.jsx(Ic,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Volume Goal ($)"}),e.jsx(mc,{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(Qie,{children:"Total sales volume you want to achieve"}),e.jsx(gm,{})]})}),l&&e.jsx(Ic,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"GCI Goal ($)"}),e.jsx(mc,{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(Qie,{children:"Gross commission income target"}),e.jsx(gm,{})]})}),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 sCe({transactions:t,isLoading:s}){const r=k.useRef(null),n=k.useRef(null),a=k.useRef([]),o=k.useRef(null),{isAdmin:l}=$s(),[i,d]=k.useState(""),[u,p]=k.useState(!0),[f,y]=k.useState(0),[_,b]=k.useState(!1),N=t.filter(S=>S.latitude!=null&&S.longitude!=null),w=t.filter(S=>S.latitude==null||S.longitude==null);return k.useEffect(()=>{(async()=>{p(!0);try{const{data:C}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();C!=null&&C.value&&d(C.value)}catch(C){console.error("Error fetching mapbox token:",C)}p(!1)})()},[]),k.useEffect(()=>{if(!i||w.length===0||_)return;(async()=>{var A;b(!0);let C=0;for(const I of w){const L=[I.property_address,I.city,I.state,I.zip].filter(Boolean).join(", ");if(L)try{const U=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(L)}.json?access_token=${i}&limit=1`)).json();if((A=U.features)!=null&&A[0]){const[q,$]=U.features[0].center;await G.from("scorecard_transactions").update({latitude:$,longitude:q}).eq("id",I.id),I.latitude=$,I.longitude=q,C++}}catch(O){console.error("Geocode error:",O)}}y(C),b(!1)})()},[i,t]),k.useEffect(()=>{if(!r.current||!i||n.current)return;yc.accessToken=i;const S=t.filter(I=>I.latitude!=null&&I.longitude!=null);let C=[-98.5795,39.8283],A=4;if(S.length>0){const I=S.reduce((O,U)=>O+U.longitude,0)/S.length,L=S.reduce((O,U)=>O+U.latitude,0)/S.length;C=[I,L],A=S.length===1?12:10}return n.current=new yc.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:A,center:C}),n.current.addControl(new yc.NavigationControl,"top-right"),()=>{var I;(I=n.current)==null||I.remove(),n.current=null}},[i]),k.useEffect(()=>{var C;if(!n.current||!i)return;a.current.forEach(A=>A.remove()),a.current=[],(C=o.current)==null||C.remove();const S=t.filter(A=>A.latitude!=null&&A.longitude!=null);if(S.forEach(A=>{var $;const I=A.transaction_type==="buyer",L=I?"#3B82F6":"#10B981",O=document.createElement("div");O.className="cursor-pointer",O.innerHTML=`
${I?'':''}
`;const U=new yc.Popup({offset:25,closeButton:!0}).setHTML(`
${A.property_address}
${A.city?`
${A.city}${A.state?", "+A.state:""} ${A.zip||""}
`:""}
${I?"Buyer":"Seller"} $${Number(A.sale_price).toLocaleString()}
Closed: ${pl(A.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${($=A.lead_source)!=null&&$.name?" · "+A.lead_source.name:""}
${A.contact?`
Client: ${A.contact.first_name} ${A.contact.last_name||""}
`:""}
`),q=new yc.Marker(O).setLngLat([A.longitude,A.latitude]).setPopup(U).addTo(n.current);a.current.push(q)}),S.length>1){const A=new yc.LngLatBounds;S.forEach(I=>A.extend([I.longitude,I.latitude])),n.current.fitBounds(A,{padding:60,maxZoom:13})}else S.length===1&&n.current.flyTo({center:[S[0].longitude,S[0].latitude],zoom:12})},[t,i,_]),u||s?e.jsx(Ie,{children:e.jsx(Be,{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(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(La,{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:[N.length," of ",t.length," mapped",_&&" · Geocoding..."]})]}),e.jsx("div",{ref:r,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):e.jsx(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(co,{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 Tit=()=>{const{data:t}=Rx();return ft({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"})},Q2s=t=>{const{data:s}=Rx(),{data:r}=Tit();return ft({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 J2s(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 ejs(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function tjs({year:t}){var y;const{data:s,isLoading:r}=Tit(),{data:n,isLoading:a}=Q2s(t),o=br(),l=r||a,{aggregate:i,memberStats:d,topPerformer:u,agentNameMap:p,teamChartStats:f}=k.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const _=s.map(V=>J2s(V,n));_.sort((V,ee)=>ee.totalVolume-V.totalVolume);const b={};s.forEach(V=>{b[V.id]=V.name||V.email});const N=n.length,w=n.reduce((V,ee)=>V+Number(ee.sale_price),0),S=n.reduce((V,ee)=>V+(Number(ee.commission_amount)||0),0),C=n.filter(V=>V.transaction_type==="buyer").length,A=n.filter(V=>V.transaction_type==="seller").length,I={};n.forEach(V=>{var Z;const ee=((Z=V.lead_source)==null?void 0:Z.name)||"Unknown";I[ee]=(I[ee]||0)+1});const L=Object.entries(I).sort((V,ee)=>ee[1]-V[1])[0],O={};n.forEach(V=>{const ee=pl(V.close_date).toLocaleString("default",{month:"short"});O[ee]=(O[ee]||0)+1});const q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(V=>({month:V,count:O[V]||0})),$=Object.entries(I).map(([V,ee])=>({name:V,count:ee})).sort((V,ee)=>ee.count-V.count);return{aggregate:{totalTxns:N,buyerCount:C,sellerCount:A,totalVolume:w,avgPrice:N>0?w/N:0,totalGCI:S,topSource:L?{name:L[0],count:L[1]}:null,memberCount:s.length},memberStats:_,topPerformer:_[0]||null,agentNameMap:b,teamChartStats:{transactionsByMonth:q,leadSourceBreakdown:$}}},[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(Ss,{className:"h-24"},_))}),e.jsx(Ss,{className:"h-64"})]}):!i||d.length===0?e.jsx(Ie,{className:"py-12",children:e.jsxs(Be,{className:"text-center space-y-2",children:[e.jsx(cr,{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(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(cr,{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(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Mn,{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(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(_c,{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:El(i.totalVolume,!0)})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Yo,{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:El(i.avgPrice,!0)})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(_c,{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:El(i.totalGCI,!0)})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((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(Ie,{className:"border-primary/30 bg-primary/5",children:e.jsxs(Be,{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(Hi,{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:El(u.totalVolume,!0)})]})]})}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Member Performance"})}),e.jsx(Be,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Agent"}),e.jsx(Nt,{className:"text-center",children:"Transactions"}),e.jsx(Nt,{className:"text-center",children:"B / S"}),e.jsx(Nt,{className:"text-right",children:"Volume"}),e.jsx(Nt,{className:"text-right",children:"Avg Price"}),e.jsx(Nt,{className:"text-right",children:"GCI"}),e.jsx(Nt,{className:"text-right"})]})}),e.jsx(Pn,{children:d.map((_,b)=>e.jsxs(As,{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(Hi,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ca,{src:_.member.avatar_url||void 0}),e.jsx(_n,{className:"text-xs",children:ejs(_.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:El(_.totalVolume,!0)}),e.jsx(dt,{className:"text-right text-sm",children:El(_.averagePrice,!0)}),e.jsx(dt,{className:"text-right font-medium",children:El(_.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(jn,{className:"h-4 w-4"})})})]},_.member.id))})]})})})]}),e.jsxs(ta,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Qn,{children:[e.jsxs(ls,{value:"transactions",children:[e.jsx(Rh,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(ls,{value:"charts",children:[e.jsx(so,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(ls,{value:"map",children:[e.jsx(La,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(js,{value:"transactions",children:e.jsx(eCe,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:p,readOnly:!0})}),e.jsx(js,{value:"charts",children:f&&e.jsx(tCe,{stats:f,year:t})}),e.jsx(js,{value:"map",children:e.jsx(sCe,{transactions:n||[],isLoading:a})})]})]})}const Ait=new Date().getFullYear(),oze=Array.from({length:10},(t,s)=>Ait-s);function sjs(){var $;const[t,s]=k.useState(Ait),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[d,u]=k.useState(!1),[p,f]=k.useState("my"),{data:y}=Rx(),_=(y==null?void 0:y.role)==="team_leader",{data:b,isLoading:N}=yke(t),{yearStats:w,lifetimeStats:S,showCommission:C}=QXe(t),{data:A,isLoading:I}=XXe(t),{data:L}=ohe(),O=ADt(),U=()=>{if(!b||b.length===0)return;const V=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...C?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],ee=b.map(ae=>{var ie,le;return[ae.property_address,ae.city||"",ae.state||"",ae.zip||"",ae.transaction_type,ae.close_date,ae.sale_price,...C?[ae.commission_amount||""]:[],((ie=ae.lead_source)==null?void 0:ie.name)||"",((le=ae.client_type)==null?void 0:le.name)||"",ae.contact?`${ae.contact.first_name} ${ae.contact.last_name||""}`.trim():"",ae.is_win?"Yes":"No",ae.notes||""]}),Z=[V,...ee].map(ae=>ae.map(ie=>`"${String(ie).replace(/"/g,'""')}"`).join(",")).join(` `),J=new Blob([Z],{type:"text/csv"}),Y=URL.createObjectURL(J),ce=document.createElement("a");ce.href=Y,ce.download=`transactions-${t}.csv`,ce.click(),URL.revokeObjectURL(Y)},q=!b||b.length===0;return e.jsxs(Ls,{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(cr,{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(zs,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Os,{className:"w-[120px]",children:e.jsx(qs,{})}),e.jsx(Fs,{children:oze.map(V=>e.jsx(yt,{value:String(V),children:V},V))})]})]}),e.jsx(tjs,{year:t})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Business Scorecard"}),e.jsx("p",{className:"text-muted-foreground",children:"Track your transactions, goals, and performance"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(zs,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Os,{className:"w-[120px]",children:e.jsx(qs,{})}),e.jsx(Fs,{children:oze.map(V=>e.jsx(yt,{value:String(V),children:V},V))})]}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(!d),children:e.jsx(So,{className:"h-4 w-4"})})]})]}),d&&e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(Ft,{className:"text-lg",children:"Settings"})}),e.jsx(Be,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ge,{children:"Show Commission"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),e.jsx(Lr,{checked:(L==null?void 0:L.show_commission)??!0,onCheckedChange:V=>O.mutate({show_commission:V})})]})})]}),q&&!N?e.jsx(Ie,{className:"py-12",children:e.jsxs(Be,{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(so,{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(Bs,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(Da,{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(Xa,{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(Bs,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(Oh,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(Da,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(K,{variant:"outline",onClick:U,disabled:q,children:[e.jsx(Xa,{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(Xa,{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(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Mn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:w.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[S.totalTransactions," lifetime"]})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(cr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[w.buyerCount,"/",w.sellerCount]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"B/S split"})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(_c,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:El(w.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[El(S.totalVolume,!0)," lifetime"]})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Yo,{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:El(w.averagePrice,!0)})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:(($=w.topLeadSource)==null?void 0:$.name)||"-"}),w.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.topLeadSource.count," deals"]})]})}),C&&e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(_c,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:El(w.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[El(S.totalCommission,!0)," lifetime"]})]})}),C&&w.totalNetToAgent>0&&w.totalNetToAgent!==w.totalCommission&&e.jsx(Ie,{children:e.jsxs(Be,{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(_c,{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:El(w.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[El(S.totalNetToAgent,!0)," lifetime"]})]})})]}),A&&e.jsx(Nit,{goals:A,stats:w,year:t,showCommission:C}),e.jsxs(ta,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"transactions",children:"Transactions"}),e.jsx(ls,{value:"charts",children:"Charts"}),e.jsxs(ls,{value:"map",children:[e.jsx(La,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(js,{value:"transactions",children:e.jsx(eCe,{transactions:b||[],showCommission:C,isLoading:N})}),e.jsx(js,{value:"charts",children:e.jsx(tCe,{stats:w,year:t})}),e.jsx(js,{value:"map",children:e.jsx(sCe,{transactions:b||[],isLoading:N})})]})]})]})]}),e.jsx(jit,{open:r,onOpenChange:n}),e.jsx(Z2s,{open:a,onOpenChange:o}),e.jsx(X2s,{open:l,onOpenChange:i,year:t,existingGoals:A})]})}function Eit({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=$s(),[l,i]=k.useState(null),[d,u]=k.useState(!1),[p,f]=k.useState(!1);k.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:w,error:S}=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(S)throw S;if(w&&w.share_token)i(w);else if(w&&!w.share_token){const{data:C,error:A}=await G.from("listing_shares").update({share_type:"referral_link"}).eq("id",w.id).select("id, share_token, click_count, lead_count").single();if(A)throw A;i(C)}else{const{data:C,error:A}=await G.from("listing_shares").insert({listing_id:r,sharing_agent_id:o.id,share_type:"referral_link"}).select("id, share_token, click_count, lead_count").single();if(A)throw A;i(C)}}catch(w){console.error("Error creating share link:",w),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=N=>{const w=encodeURIComponent(y),S=encodeURIComponent(`Check out this listing: ${a}`);switch(N){case"email":window.open(`mailto:?subject=${S}&body=${w}`);break;case"text":window.open(`sms:?body=${S}%20${w}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${w}`,"_blank");break}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(qr,{className:"h-5 w-5 text-amber-500"}),"Share & Earn Leads"]}),e.jsx(Rr,{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(ge,{children:"Your Referral Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:d?"Generating...":y,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:_,disabled:d||!y,variant:p?"default":"outline",children:p?e.jsx(ea,{className:"h-4 w-4"}):e.jsx(Ya,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Share via"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("email"),disabled:d,children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("text"),disabled:d,children:[e.jsx(Si,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("facebook"),disabled:d,children:[e.jsx(du,{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(ge,{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(jn,{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(cr,{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 rjs={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},njs={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},ajs={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function j9({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var N,w;const{user:o}=$s(),{data:l}=HXe(t.id),i=VXe(),[d,u]=k.useState(!1),p=S=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(S),f=((N=t.photos)==null?void 0:N.find(S=>S.is_primary))||((w=t.photos)==null?void 0:w[0]),y=(o==null?void 0:o.id)===t.agent_id,_=async S=>{S.stopPropagation();try{const C=await i.mutateAsync(t.id);me.success(C.saved?"Listing saved!":"Listing removed from saved")}catch{me.error("Failed to save listing")}},b=S=>{if(S.stopPropagation(),o)u(!0);else{const C=`https://listings.relevelup.com/${t.slug||t.id}`;navigator.clipboard.writeText(C),me.success("Link copied to clipboard!")}};return e.jsxs(Ie,{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(r0,{className:"h-12 w-12"})}),e.jsx(Ye,{className:`absolute top-2 left-2 ${rjs[t.status]} text-white border-0`,children:njs[t.status]}),t.is_featured&&e.jsx("div",{className:"absolute top-2 right-2 p-1.5 bg-amber-500 rounded-full",children:e.jsx(Gn,{className:"h-4 w-4 text-white fill-white"})}),e.jsxs("div",{className:"absolute bottom-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:_,children:e.jsx(Za,{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(vd,{className:"h-4 w-4"}):e.jsx(qr,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(Eit,{open:d,onOpenChange:u,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs(Be,{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(Ye,{variant:"outline",className:"text-xs",children:[e.jsx(cr,{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(La,{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(Ky,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(of,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(r0,{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(Ye,{variant:"secondary",className:"text-xs",children:ajs[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(jn,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vd,{className:"h-3 w-3"}),t.share_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Za,{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:S=>{S.stopPropagation(),r()},children:[e.jsx(Gc,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(K,{variant:"destructive",size:"sm",onClick:S=>{S.stopPropagation(),n()},children:e.jsx(yr,{className:"h-4 w-4"})})]})]})]})}const ijs=[{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"}],ojs=[{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 ljs({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(Ft,{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(Sr,{className:"h-4 w-4"})})]})]}),e.jsxs(Be,{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(ge,{children:"Status"}),e.jsxs(zs,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"All statuses"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Statuses"}),ijs.map(a=>e.jsx(yt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Property Type"}),e.jsxs(zs,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"All types"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Types"}),ojs.map(a=>e.jsx(yt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(ge,{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(ge,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx(Lr,{checked:t.openToReferrals||!1,onCheckedChange:a=>s({...t,openToReferrals:a||void 0})})]})]})]})}function cjs({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(Hi,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(Qv,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(rc,{className:"h-5 w-5 text-amber-700"});default:return e.jsx("span",{className:"text-sm font-medium text-muted-foreground w-5 text-center",children:n+1})}},r=(n,a)=>!n||n.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"No data yet. Start sharing to climb the leaderboard!"}):e.jsx("div",{className:"space-y-2",children:n.map((o,l)=>e.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${l===0?"bg-gradient-to-r from-amber-500/10 to-amber-500/5 border border-amber-500/20":"bg-muted/50"}`,children:[e.jsx("div",{className:"flex items-center justify-center w-8",children:s(l)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:o.name})}),e.jsxs(Ye,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Hi,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx(Be,{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(vd,{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(Mn,{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(Qv,{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(Hi,{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(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Community Leaderboard"})}),e.jsx(Be,{children:e.jsxs(ta,{defaultValue:"sharers",children:[e.jsxs(Qn,{className:"w-full",children:[e.jsxs(ls,{value:"sharers",className:"flex-1",children:[e.jsx(vd,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(ls,{value:"listers",className:"flex-1",children:[e.jsx(Mn,{className:"h-4 w-4 mr-2"}),"Top Contributors"]})]}),e.jsx(js,{value:"sharers",className:"mt-4",children:r(t==null?void 0:t.topSharers,"shares")}),e.jsx(js,{value:"listers",className:"mt-4",children:r(t==null?void 0:t.topListers,"listings")})]})})]})]})}const lze={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},cze={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function djs(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function ujs({listings:t,isLoading:s}){const r=br(),n=k.useRef(null),a=k.useRef(null),o=k.useRef([]),{isAdmin:l}=$s(),[i,d]=k.useState(""),[u,p]=k.useState(!0),[f,y]=k.useState(!1),_=t.filter(N=>N.latitude!=null&&N.longitude!=null),b=t.filter(N=>(N.latitude==null||N.longitude==null)&&(N.property_address||N.city));return k.useEffect(()=>{(async()=>{p(!0);try{const{data:w}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();w!=null&&w.value&&d(w.value)}catch(w){console.error("Error fetching mapbox token:",w)}p(!1)})()},[]),k.useEffect(()=>{if(!i||b.length===0||f)return;(async()=>{var w;y(!0);for(const S of b){const C=[S.property_address,S.city,S.state].filter(Boolean).join(", ");if(C)try{const I=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(C)}.json?access_token=${i}&limit=1`)).json();if((w=I.features)!=null&&w[0]){const[L,O]=I.features[0].center;await G.from("listings").update({latitude:O,longitude:L}).eq("id",S.id),S.latitude=O,S.longitude=L}}catch(A){console.error("Geocode error:",A)}}y(!1)})()},[i,t]),k.useEffect(()=>{if(!n.current||!i||a.current)return;yc.accessToken=i;const N=t.filter(C=>C.latitude!=null&&C.longitude!=null);let w=[-98.5795,39.8283],S=4;if(N.length>0){const C=N.reduce((I,L)=>I+L.longitude,0)/N.length,A=N.reduce((I,L)=>I+L.latitude,0)/N.length;w=[C,A],S=N.length===1?12:10}return a.current=new yc.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:S,center:w}),a.current.addControl(new yc.NavigationControl,"top-right"),()=>{var C;(C=a.current)==null||C.remove(),a.current=null}},[i]),k.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(w=>w.remove()),o.current=[];const N=t.filter(w=>w.latitude!=null&&w.longitude!=null);if(N.forEach(w=>{var O,U,q;const S=lze[w.status]||"#10B981",C=((O=w.photos)==null?void 0:O.find($=>$.is_primary))||((U=w.photos)==null?void 0:U[0]),A=document.createElement("div");A.className="cursor-pointer",A.innerHTML=`
`;const I=new yc.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${C!=null&&C.photo_url?``:""}
${djs(w.price)}
${w.property_address||""}
${w.city}, ${w.state}
${cze[w.status]||w.status} ${w.bedrooms?`${w.bedrooms} bed`:""} ${w.bathrooms?`${w.bathrooms} bath`:""}
${(q=w.agent)!=null&&q.name?`
Listed by ${w.agent.name}
`:""}
Click to view details →
`),L=new yc.Marker(A).setLngLat([w.longitude,w.latitude]).setPopup(I).addTo(a.current);o.current.push(L)}),N.length>1){const w=new yc.LngLatBounds;N.forEach(S=>w.extend([S.longitude,S.latitude])),a.current.fitBounds(w,{padding:60,maxZoom:13})}else N.length===1&&a.current.flyTo({center:[N[0].longitude,N[0].latitude],zoom:12})},[t,i,f]),k.useEffect(()=>(window.__navigateToListing__=N=>{r(`/mission-control/listings/${N}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(Ie,{children:e.jsx(Be,{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(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(La,{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(lze).map(([N,w])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:w}}),e.jsx("span",{className:"text-xs",children:cze[N]})]},N)),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(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(co,{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 hjs(){var $,V,ee,Z,J,Y,ce,ae;const t=br(),{brokerageId:s}=$s(),{data:r,isLoading:n}=zXe(),[a,o]=k.useState("feed"),[l,i]=k.useState(!1),[d,u]=k.useState(""),[p,f]=k.useState({sortBy:"newest"}),{data:y,isLoading:_}=BXe({...p,city:d||p.city}),{data:b,isLoading:N}=hDt(),{data:w,isLoading:S}=$Xe(),{data:C,isLoading:A}=xDt(),{data:I,isLoading:L}=vDt(),{data:O}=yDt(),U=UXe(),q=async ie=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await U.mutateAsync(ie),me.success("Listing deleted successfully")}catch{me.error("Failed to delete listing")}};return n?e.jsx(Ls,{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(Ls,{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(Bs,{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(Ie,{children:e.jsxs(Be,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Mn,{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(Ie,{children:e.jsxs(Be,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:e.jsx(Za,{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(Ie,{children:e.jsxs(Be,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:e.jsx(X4,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(w==null?void 0:w.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"My Listings"})]})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(cr,{className:"h-5 w-5 text-sky-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:((($=C==null?void 0:C.sent)==null?void 0:$.length)||0)+(((V=C==null?void 0:C.received)==null?void 0:V.length)||0)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),e.jsxs(ta,{value:a,onValueChange:o,children:[e.jsxs(Qn,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(ls,{value:"feed",children:"Community Feed"}),s&&e.jsx(ls,{value:"brokerage",children:"Brokerage"}),e.jsx(ls,{value:"my-listings",children:"My Listings"}),e.jsx(ls,{value:"saved",children:"Saved"}),e.jsx(ls,{value:"referrals",children:"Referrals"}),e.jsx(ls,{value:"map",children:"Map"}),e.jsx(ls,{value:"leaderboard",children:"Leaderboard"})]}),e.jsxs(js,{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(tn,{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:d,onChange:ie=>u(ie.target.value),className:"pl-9"})]}),e.jsxs(zs,{value:p.sortBy,onValueChange:ie=>f({...p,sortBy:ie}),children:[e.jsx(Os,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"Sort by"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"newest",children:"Newest First"}),e.jsx(yt,{value:"updated",children:"Recently Updated"}),e.jsx(yt,{value:"price_asc",children:"Price: Low to High"}),e.jsx(yt,{value:"price_desc",children:"Price: High to Low"})]})]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!l),children:[e.jsx(Dg,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(ljs,{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((ie,le)=>e.jsxs(Ie,{children:[e.jsx(Ss,{className:"h-48 w-full"}),e.jsxs(Be,{className:"p-4 space-y-2",children:[e.jsx(Ss,{className:"h-5 w-3/4"}),e.jsx(Ss,{className:"h-4 w-1/2"}),e.jsx(Ss,{className:"h-4 w-1/4"})]})]},le))}):(y==null?void 0:y.length)===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"py-12 text-center",children:[e.jsx(Mn,{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(Bs,{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(ie=>e.jsx(j9,{listing:ie,onClick:()=>t(`/mission-control/listings/${ie.id}`)},ie.id))})]}),e.jsx(js,{value:"my-listings",className:"space-y-4",children:S?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ie,le)=>e.jsxs(Ie,{children:[e.jsx(Ss,{className:"h-48 w-full"}),e.jsxs(Be,{className:"p-4 space-y-2",children:[e.jsx(Ss,{className:"h-5 w-3/4"}),e.jsx(Ss,{className:"h-4 w-1/2"})]})]},le))}):(w==null?void 0:w.length)===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"py-12 text-center",children:[e.jsx(X4,{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(Bs,{className:"h-4 w-4 mr-2"}),"Add Your First Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w==null?void 0:w.map(ie=>e.jsx(j9,{listing:ie,showActions:!0,onClick:()=>t(`/mission-control/listings/${ie.id}`),onEdit:()=>t(`/mission-control/listings/${ie.id}/edit`),onDelete:()=>q(ie.id)},ie.id))})}),e.jsx(js,{value:"saved",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((ie,le)=>e.jsxs(Ie,{children:[e.jsx(Ss,{className:"h-48 w-full"}),e.jsxs(Be,{className:"p-4 space-y-2",children:[e.jsx(Ss,{className:"h-5 w-3/4"}),e.jsx(Ss,{className:"h-4 w-1/2"})]})]},le))}):(b==null?void 0:b.length)===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"py-12 text-center",children:[e.jsx(Za,{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(ie=>e.jsx(j9,{listing:ie.listing,onClick:()=>t(`/mission-control/listings/${ie.listing.id}`)},ie.id))})}),e.jsx(js,{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(vd,{className:"h-4 w-4"}),"Referrals Sent (",((ee=C==null?void 0:C.sent)==null?void 0:ee.length)||0,")"]}),((Z=C==null?void 0:C.sent)==null?void 0:Z.length)===0?e.jsx(Ie,{children:e.jsx(Be,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):e.jsx("div",{className:"space-y-3",children:(J=C==null?void 0:C.sent)==null?void 0:J.map(ie=>{var le,fe;return e.jsx(Ie,{children:e.jsx(Be,{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:ie.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((le=ie.listing)==null?void 0:le.property_address)||((fe=ie.listing)==null?void 0:fe.city)})]}),e.jsx(Ye,{variant:ie.status==="closed"?"default":"secondary",children:ie.status.replace("_"," ")})]})})},ie.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4"}),"Referrals Received (",((Y=C==null?void 0:C.received)==null?void 0:Y.length)||0,")"]}),((ce=C==null?void 0:C.received)==null?void 0:ce.length)===0?e.jsx(Ie,{children:e.jsx(Be,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(ae=C==null?void 0:C.received)==null?void 0:ae.map(ie=>{var le;return e.jsx(Ie,{children:e.jsxs(Be,{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:ie.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(le=ie.sender)==null?void 0:le.name]})]}),e.jsx(Ye,{variant:ie.status==="closed"?"default":"secondary",children:ie.status.replace("_"," ")})]}),e.jsx(K,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${ie.listing_id}`),children:"View Listing"})]})},ie.id)})})]})]})}),s&&e.jsx(js,{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((ie,le)=>e.jsxs(Ie,{children:[e.jsx(Ss,{className:"h-48 w-full"}),e.jsxs(Be,{className:"p-4 space-y-2",children:[e.jsx(Ss,{className:"h-5 w-3/4"}),e.jsx(Ss,{className:"h-4 w-1/2"})]})]},le))}):(I==null?void 0:I.length)===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"py-12 text-center",children:[e.jsx(X4,{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(Bs,{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(ie=>e.jsx(j9,{listing:ie,onClick:()=>t(`/mission-control/listings/${ie.id}`)},ie.id))})}),e.jsx(js,{value:"map",children:e.jsx(ujs,{listings:y||[],isLoading:_})}),e.jsx(js,{value:"leaderboard",children:e.jsx(cjs,{leaderboard:O})})]})]})}):e.jsx(Ls,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Ie,{children:e.jsxs(Be,{className:"py-12 text-center",children:[e.jsx(Mn,{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 mjs(t){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}const pjs={single_family:"Single Family Home",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury Home",commercial:"Commercial",other:"Property"};function fjs({open:t,onOpenChange:s,listing:r}){const{user:n}=$s(),{data:a=[],isLoading:o}=Uh(),{data:l=[]}=Mf(),[i,d]=k.useState(""),[u,p]=k.useState("all"),[f,y]=k.useState(new Set),[_,b]=k.useState(!1),[N,w]=k.useState(null);k.useEffect(()=>{t||(d(""),p("all"),y(new Set),b(!1))},[t]),k.useEffect(()=>{!t||!n||(async()=>{const{data:q}=await G.from("gmail_integrations").select("gmail_email").eq("user_id",n.id).maybeSingle();w((q==null?void 0:q.gmail_email)||null)})()},[t,n]);const S=k.useMemo(()=>a.filter(q=>q.email),[a]),C=k.useMemo(()=>{let q=S;if(u!=="all"&&(q=q.filter($=>{var V;return(V=$.tags)==null?void 0:V.some(ee=>ee.relationship_type_id===u)})),i.trim()){const $=i.toLowerCase();q=q.filter(V=>`${V.first_name||""} ${V.last_name||""}`.toLowerCase().includes($)||(V.email||"").toLowerCase().includes($))}return q},[S,i,u]),A=()=>{f.size===C.length?y(new Set):y(new Set(C.map(q=>q.id)))},I=q=>{const $=new Set(f);$.has(q)?$.delete(q):$.add(q),y($)},L=k.useMemo(()=>S.filter(q=>f.has(q.id)).map(q=>({id:q.id,first_name:q.first_name||"there",last_name:q.last_name,email:q.email})),[S,f]),{defaultSubject:O,defaultBody:U}=k.useMemo(()=>{var he,we,Ne,Ve;const q=r.property_address||`${r.city}, ${r.state}`,$=mjs(r.price),V=pjs[r.property_type]||"home",ee=r.bedrooms?`${r.bedrooms} bed`:"",Z=r.bathrooms?`${r.bathrooms} bath`:"",J=r.square_footage?`${r.square_footage.toLocaleString()} sqft`:"",Y=[ee,Z,J].filter(Boolean).join(" • "),ce=`https://listings.relevelup.com/${r.slug||r.id}`,ae=((we=(he=r.photos)==null?void 0:he.find(Te=>Te.is_primary))==null?void 0:we.photo_url)||((Ve=(Ne=r.photos)==null?void 0:Ne[0])==null?void 0:Ve.photo_url)||"",le={active:"Just Listed",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"}[r.status]||"New Listing",fe=`${le}: ${q} — ${$}`,xe=`

Hi {{first_name}},

I wanted to share a property I think you might love. Take a look:

${ae?` ${q} `:""}
${le}

${$}

${q}

${r.city}, ${r.state}

${Y?`

${Y} • ${V}

`:""} View Photos & Details →

If this catches your eye — or you know someone who'd love it — just hit reply. I'd be happy to set up a private showing.

Talk soon,

`;return{defaultSubject:fe,defaultBody:xe}},[r]);return _?e.jsx(E1,{open:_,onOpenChange:q=>{b(q),q||s(!1)},bulkContacts:L,defaultSubject:O,defaultBody:U,gmailEmail:N}):e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-[640px] max-h-[90vh] flex flex-col",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(qr,{className:"h-5 w-5 text-amber-500"}),"Email this listing to your sphere"]}),e.jsx(Rr,{children:"Pick which contacts should hear about this property. We'll personalize each email with their name."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(tn,{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:i,onChange:q=>d(q.target.value),className:"pl-9"})]}),e.jsxs(zs,{value:u,onValueChange:p,children:[e.jsx(Os,{className:"sm:w-[180px]",children:e.jsx(qs,{placeholder:"Filter by tag"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All contacts"}),l.map(q=>e.jsx(yt,{value:q.id,children:q.name},q.id))]})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm border-y py-2",children:[e.jsxs("button",{type:"button",onClick:A,className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(Gi,{checked:C.length>0&&f.size===C.length,className:"pointer-events-none"}),e.jsx("span",{children:f.size===C.length&&C.length>0?"Deselect all":`Select all (${C.length})`})]}),e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(cr,{className:"h-3 w-3"}),f.size," selected"]})]}),e.jsx(di,{className:"flex-1 -mx-6 px-6",children:o?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(ps,{className:"h-5 w-5 animate-spin mr-2"}),"Loading your contacts..."]}):C.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground text-sm",children:S.length===0?"No contacts with email addresses yet.":"No contacts match your search."}):e.jsx("div",{className:"space-y-1 py-2",children:C.map(q=>e.jsxs("label",{className:"flex items-center gap-3 p-2 rounded-md hover:bg-muted/50 cursor-pointer",children:[e.jsx(Gi,{checked:f.has(q.id),onCheckedChange:()=>I(q.id)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[q.first_name," ",q.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:q.email})]}),q.tags&&q.tags.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap justify-end max-w-[40%]",children:q.tags.slice(0,2).map($=>{var V;return e.jsx(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:(V=$.relationship_type)==null?void 0:V.name},$.id)})})]},q.id))})}),e.jsx(jo,{}),e.jsxs("div",{className:"flex justify-between items-center gap-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:N?`Sending from ${N}`:"Connect Gmail in Settings to send"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>b(!0),disabled:f.size===0,className:"gap-2",children:[e.jsx(tr,{className:"h-4 w-4"}),"Compose Email (",f.size,")"]})]})]})]})})}function px(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 Eme(){const t=_a();return ft({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 Pit(){const t=_a(),s=es();return Et({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 Pme(){const t=_a();return ft({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 Iit(){const t=_a(),s=es();return Et({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 Lit(){const t=es();return Et({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 xjs(){const t=es();return Et({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 gjs(){const t=es();return Et({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 yjs(t){return ft({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 vjs(){const t=es();return Et({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 _js(t){return ft({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 bjs(){const t=es();return Et({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 wjs(){const t=es();return Et({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 jjs(){const t=_a();return ft({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 d,u,p;return!((d=i.deal_pipeline_stages)!=null&&d.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 d;return(d=i.deal_pipeline_stages)==null?void 0:d.is_won_stage}))||[],o=new Date().getFullYear(),l=a.filter(i=>{const d=i.actual_close_date;return d?new Date(d).getFullYear()===o:!0});return{totalDeals:(s==null?void 0:s.length)||0,activeDeals:n.length,wonDeals:a.length,pipelineValue:n.reduce((i,d)=>i+(d.expected_price||0),0),expectedCommission:n.reduce((i,d)=>i+(d.expected_commission||0),0),expectedNetToAgent:n.reduce((i,d)=>i+(px(d)||0),0),wonValue:a.reduce((i,d)=>i+(d.expected_price||0),0),weightedGCI:n.reduce((i,d)=>{const u=(d.probability??50)/100;return i+(d.expected_commission||0)*u},0),weightedNet:n.reduce((i,d)=>{const u=(d.probability??50)/100;return i+(px(d)||0)*u},0),ytdWonDeals:l.length,ytdWonGCI:l.reduce((i,d)=>i+(d.expected_commission||0),0),ytdWonNet:l.reduce((i,d)=>i+(px(d)||0),0),projectedAnnualNet:l.reduce((i,d)=>i+(px(d)||0),0)+n.reduce((i,d)=>{const u=(d.probability??50)/100;return i+(px(d)||0)*u},0)}},enabled:!!t})}function Njs(t){const s=_a();return ft({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 kjs(){const t=es();return Et({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 Sjs(){const t=es();return Et({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 Cjs({listing:t}){const s=br(),[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l,isLoading:i}=Njs(t.id),{data:d,isLoading:u}=Eme(),{data:p,isLoading:f}=Pme(),y=Pit(),_=kjs(),b=Sjs(),N=Iit(),w=(p==null?void 0:p.filter(L=>!L.listing_id))||[],S=L=>{if(!(d!=null&&d.length))return null;switch(L){case"coming_soon":case"active":case"price_improvement":return d.find(O=>O.name==="Active");case"under_contract":return d.find(O=>O.name==="Under Contract");case"sold":return d.find(O=>O.is_won_stage);default:return d.find(O=>O.name==="Active")}},C=async()=>{o(!0);try{d!=null&&d.length||await y.mutateAsync();const L=S(t.status);await N.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)}},A=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(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2 text-base",children:[e.jsx(Zy,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx(Be,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ps,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Ie,{className:"border-primary/20 bg-primary/5",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"flex items-center gap-2 text-base",children:[e.jsx(Do,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs(Be,{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(Ye,{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(ti,{className:"h-3 w-3 ml-1"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:I,disabled:b.isPending,children:b.isPending?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(kS,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"flex items-center gap-2 text-base",children:[e.jsx(Zy,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link this listing to your pipeline to track the deal and sync status changes."}),e.jsxs(K,{onClick:C,disabled:a||N.isPending,className:"w-full",size:"sm",children:[a||N.isPending?e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),w.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(zs,{value:r,onValueChange:n,children:[e.jsx(Os,{className:"flex-1 text-sm",children:e.jsx(qs,{placeholder:"Link to existing deal..."})}),e.jsx(Fs,{children:w.map(L=>e.jsx(yt,{value:L.id,children:L.deal_name},L.id))})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:A,disabled:!r||_.isPending,children:_.isPending?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(Do,{className:"h-4 w-4"})})]})]})]})]})}const Mjs={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Tjs={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},dze={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Ajs(){var ce,ae,ie,le,fe,xe,he,we,Ne;const{listingId:t}=ho(),s=br(),{user:r}=$s(),{data:n,isLoading:a}=qXe(t||""),{data:o}=HXe(t||""),{data:l}=pDt(t||""),i=VXe(),d=mDt(),u=fDt(),p=UXe(),f=gDt(),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState(!1),[C,A]=k.useState(!1),[I,L]=k.useState(null),[O,U]=k.useState({buyerName:"",buyerType:"",notes:""}),q=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),$=Ve=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Ve),V=async Ve=>{const Te=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,Ae=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:Ve});try{switch(Ve){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(Te)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(Te),me.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${Ae} ${Te}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(Ae)}&body=${encodeURIComponent(`Check out this listing: ${Te}`)}`);break}}catch(ze){console.error("Share error:",ze),me.error("Failed to share")}},ee=async()=>{try{await p.mutateAsync(n.id),me.success("Listing deleted"),s("/mission-control/listings")}catch{me.error("Failed to delete listing")}},Z=async()=>{if(!O.buyerName.trim()){me.error("Please enter buyer name");return}try{await f.mutateAsync({listingId:n.id,listingAgentId:n.agent_id,buyerName:O.buyerName,buyerType:O.buyerType||void 0,notes:O.notes||void 0}),me.success("Referral sent successfully!"),N(!1),U({buyerName:"",buyerType:"",notes:""})}catch{me.error("Failed to send referral")}},J=Ve=>{var Ue,ye;const Te=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,Ae=$((n==null?void 0:n.price)||0),ze=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Ee=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",ve=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",Re=[ze,Ee,ve].filter(Boolean).join(" | ");switch(Ve){case"just_listed":return`🏡 JUST LISTED! ${Te} ${Ae} ${Re} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(Ue=n==null?void 0:n.city)==null?void 0:Ue.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${Te} Now ${Ae}! ${Re} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${dze[(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 #${(ye=n==null?void 0:n.city)==null?void 0:ye.replace(/\s/g,"")}`;default:return""}};if(a)return e.jsx(Ls,{title:"Listing",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ss,{className:"h-10 w-32"}),e.jsx(Ss,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(Ss,{className:"h-48"}),e.jsx(Ss,{className:"h-48"}),e.jsx(Ss,{className:"h-48"})]})]})});if(!n)return e.jsx(Ls,{title:"Listing Not Found",description:"",children:e.jsx(Ie,{children:e.jsxs(Be,{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 Y=((ce=n.photos)==null?void 0:ce.find(Ve=>Ve.is_primary))||((ae=n.photos)==null?void 0:ae[0]);return e.jsxs(Ls,{title:"",description:"",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/mission-control/listings"),children:[e.jsx(Ra,{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:()=>Y&&L(Y.photo_url),children:Y?e.jsx("img",{src:Y.photo_url,alt:"Primary",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No photos"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:(ie=n.photos)==null?void 0:ie.slice(1,5).map((Ve,Te)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>L(Ve.photo_url),children:e.jsx("img",{src:Ve.photo_url,alt:`Photo ${Te+2}`,className:"w-full h-full object-cover"})},Ve.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsx(Ie,{children:e.jsxs(Be,{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(Ye,{className:`${Mjs[n.status]} text-white border-0`,children:Tjs[n.status]}),n.is_featured&&e.jsxs(Ye,{variant:"outline",className:"border-amber-500 text-amber-500",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1 fill-amber-500"}),"Featured"]}),n.open_to_referrals&&e.jsxs(Ye,{variant:"outline",children:[e.jsx(cr,{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(La,{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(Za,{className:`h-4 w-4 ${o?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>d.mutate(n.id),children:l?e.jsx(Wv,{className:"h-4 w-4"}):e.jsx(Nm,{className:"h-4 w-4"})}),!q&&e.jsxs(K,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>S(!0),children:[e.jsx(qr,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(vd,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(jd,{children:[e.jsxs(xa,{onClick:()=>V("copy"),children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(xa,{onClick:()=>V("facebook"),children:[e.jsx(du,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(xa,{onClick:()=>V("text"),children:[e.jsx(Si,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(xa,{onClick:()=>V("email"),children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),q&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>A(!0),className:"gap-2",children:[e.jsx(tr,{className:"h-4 w-4"}),"Email My Sphere"]}),e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(Gc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>_(!0),children:e.jsx(yr,{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(Ky,{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(of,{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(r0,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.square_footage.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sq Ft"})]}),n.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(nn,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.year_built}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"pt-4 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Ye,{variant:"secondary",children:[e.jsx(ma,{className:"h-3 w-3 mr-1"}),dze[n.property_type]]}),n.lot_size&&e.jsxs(Ye,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(Ye,{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(Kr,{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(jn,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vd,{className:"h-4 w-4"}),n.share_count," shares"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Za,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Share Content"})}),e.jsx(Be,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(Ve=>e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("p",{className:"font-medium text-sm capitalize",children:[Ve.replace("_"," ")," Caption"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(J(Ve)),me.success("Caption copied!")},children:e.jsx(Ya,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:J(Ve)})]},Ve))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Listing Agent"})}),e.jsxs(Be,{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:((fe=(le=n.agent)==null?void 0:le.name)==null?void 0:fe.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((xe=n.agent)==null?void 0:xe.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})]})]}),!q&&e.jsx("div",{className:"space-y-2",children:((Ne=n.agent)==null?void 0:Ne.email)&&e.jsx(K,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),q&&e.jsx(Cjs,{listing:n}),!q&&n.open_to_referrals&&e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(Be,{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:()=>N(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(fs,{open:!!I,onOpenChange:()=>L(null),children:e.jsx(ms,{className:"max-w-4xl",children:e.jsx("img",{src:I||"",alt:"Full size",className:"w-full h-auto"})})}),e.jsx(fs,{open:y,onOpenChange:_,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Delete Listing"}),e.jsx(Rr,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:ee,disabled:p.isPending,children:p.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(fs,{open:b,onOpenChange:N,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Send Buyer Referral"}),e.jsx(Rr,{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(ge,{children:"Buyer Name *"}),e.jsx(Fe,{value:O.buyerName,onChange:Ve=>U({...O,buyerName:Ve.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Buyer Type"}),e.jsxs(zs,{value:O.buyerType,onValueChange:Ve=>U({...O,buyerType:Ve}),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select type"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"first_time",children:"First-Time Buyer"}),e.jsx(yt,{value:"investor",children:"Investor"}),e.jsx(yt,{value:"relocating",children:"Relocating"}),e.jsx(yt,{value:"upgrade",children:"Upgrading"}),e.jsx(yt,{value:"downsize",children:"Downsizing"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Notes"}),e.jsx(_r,{value:O.notes,onChange:Ve=>U({...O,notes:Ve.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>N(!1),children:"Cancel"}),e.jsx(K,{onClick:Z,disabled:f.isPending,children:f.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(Eit,{open:w,onOpenChange:S,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}`}),n&&e.jsx(fjs,{open:C,onOpenChange:A,listing:n})]})}function Ejs({onImport:t}){const[s,r]=k.useState(""),[n,a]=k.useState([]),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState(null),f=k.useRef(),y=k.useRef(null);k.useEffect(()=>{const C=A=>{y.current&&!y.current.contains(A.target)&&d(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]);const _=async C=>{if(C.trim().length<3){a([]),d(!1);return}l(!0);try{const{data:A,error:I}=await G.functions.invoke("mls-listing-search",{body:{query:C}});if(I)throw I;a((A==null?void 0:A.listings)||[]),d(!0)}catch(A){console.error("MLS search error:",A),a([])}finally{l(!1)}},b=C=>{r(C),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>_(C),400)},N=C=>{p(C.mlsNumber),t(C),d(!1),r(`${C.address}, ${C.city}`),me.success(`Imported: ${C.address}`,{description:"Property details and photos have been auto-filled."}),p(null)},w=C=>C?`$${C.toLocaleString()}`:"",S=C=>{const A=(C||"").toLowerCase();return A.includes("single")||A.includes("detached")?"Single Family":A.includes("condo")?"Condo":A.includes("town")?"Townhouse":A.includes("land")||A.includes("lot")?"Land":A.includes("multi")?"Multi-Family":A.includes("commercial")?"Commercial":C||"Other"};return e.jsxs(Ie,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Xa,{className:"h-4 w-4 text-primary"}),"Import from MLS"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Search by address to auto-fill property details and photos from MLS"})]}),e.jsx(Be,{children:e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(tn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{value:s,onChange:C=>b(C.target.value),onFocus:()=>n.length>0&&d(!0),placeholder:"Start typing a property address...",className:"pl-9 pr-9"}),o&&e.jsx(ps,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 animate-spin text-muted-foreground"}),s&&!o&&e.jsx("button",{type:"button",onClick:()=>{r(""),a([]),d(!1)},className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Sr,{className:"h-4 w-4"})})]}),i&&e.jsx("div",{className:"absolute z-50 w-full mt-1 bg-popover border rounded-lg shadow-lg max-h-[400px] overflow-y-auto",children:n.length===0&&!o?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No properties found. Try a different address."}):n.map(C=>e.jsxs("button",{type:"button",onClick:()=>N(C),disabled:u===C.mlsNumber,className:"w-full text-left p-3 hover:bg-accent/50 transition-colors border-b last:border-0 flex items-start gap-3",children:[C.photos[0]?e.jsx("img",{src:C.photos[0],alt:"",className:"w-16 h-12 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-16 h-12 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(La,{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.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[C.city,", ",C.state," ",C.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:w(C.price)}),C.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ky,{className:"h-3 w-3"})," ",C.bedrooms]}),C.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(of,{className:"h-3 w-3"})," ",C.bathrooms]}),C.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(yS,{className:"h-3 w-3"})," ",C.sqft.toLocaleString()]})]})]}),e.jsxs("div",{className:"flex-shrink-0 flex flex-col items-end gap-1",children:[e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:S(C.propertyType)}),C.photos.length>0&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[C.photos.length," photos"]})]})]},C.mlsNumber))})]})})]})}function Pjs({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:d}=z4e({id:t.id}),u={transform:oC.Transform.toString(l),transition:i};return e.jsxs("div",{ref:o,style:u,className:Rt("relative aspect-square rounded-lg overflow-hidden bg-muted group",d&&"opacity-50 ring-2 ring-primary z-50"),children:[e.jsx("img",{src:t.photo_url,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",...n,...a,className:"absolute top-1 left-1 p-1 bg-black/60 text-white rounded cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(uu,{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(Sr,{className:"h-3 w-3"})}),t.is_primary?e.jsxs("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded flex items-center gap-0.5",children:[e.jsx(Gn,{className:"h-2.5 w-2.5 fill-current"})," Primary"]}):e.jsx("button",{type:"button",onClick:()=>r(t.id),className:"absolute bottom-1 left-1 text-[10px] bg-black/60 text-white px-1.5 py-0.5 rounded opacity-0 group-hover:opacity-100 transition-opacity hover:bg-black/80",children:"Set as Primary"})]})}function Ijs({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=E4e(xce(lO,{activationConstraint:{distance:5}})),i=[...t].sort((u,p)=>(u.sort_order??0)-(p.sort_order??0)),d=u=>{const{active:p,over:f}=u;if(!f||p.id===f.id)return;const y=i.findIndex(S=>S.id===p.id),_=i.findIndex(S=>S.id===f.id),b=[...i],[N]=b.splice(y,1);b.splice(_,0,N);const w=b.map((S,C)=>({...S,sort_order:C}));a(w)};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. Hover to set primary."}),e.jsx(R4e,{sensors:l,collisionDetection:P4e,onDragEnd:d,children:e.jsx(F4e,{items:i.map(u=>u.id),strategy:cO,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(Pjs,{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(ps,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Da,{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 Ljs({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=br(),{user:a}=$s(),[o,l]=k.useState(!1),[i,d]=k.useState([]),[u,p]=k.useState(!1),[f,y]=k.useState(null),[_,b]=k.useState({});k.useEffect(()=>{t&&a?N():y(null)},[t,a]);const N=async()=>{if(!t)return;const{data:$,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&&$&&(y($),w($))},w=async $=>{try{const{data:V,error:ee}=await G.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:$.bunny_video_id,isAgentVideo:!0}});!ee&&(V!=null&&V.thumbnailUrl)&&b(Z=>({...Z,[$.id]:{thumbnailUrl:V.thumbnailUrl}}))}catch(V){console.warn("Failed to get signed URL",V)}},S=async()=>{if(a){p(!0);try{const{data:$,error:V}=await G.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("owner_user_id",a.id).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(V)throw V;d($||[]),$!=null&&$.length&&C($)}catch($){console.error("Error fetching videos:",$),me.error("Failed to load videos")}finally{p(!1)}}},C=async $=>{var V;try{const ee=$.map(ae=>ae.bunny_video_id),{data:Z,error:J}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:ee,isAgentVideo:!0}});if(J)throw J;const Y=(Z==null?void 0:Z.assets)||{},ce={};for(const ae of $)(V=Y[ae.bunny_video_id])!=null&&V.thumbnailUrl&&(ce[ae.id]={thumbnailUrl:Y[ae.bunny_video_id].thumbnailUrl});b(ae=>({...ae,...ce}))}catch(ee){console.warn("Failed to bulk-fetch signed URLs",ee)}},A=()=>{l(!0),S()},I=$=>{s($.id),y($),l(!1),me.success("Video selected")},L=()=>{s(null),y(null)},O=()=>{const $=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent($)}`)},U=$=>{if(!$)return"0:00";const V=Math.floor($/60),ee=$%60;return`${V}:${ee.toString().padStart(2,"0")}`},q=$=>{var V;return((V=_[$.id])==null?void 0:V.thumbnailUrl)||$.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[f?e.jsx(Ie,{className:"overflow-hidden",children:e.jsx(Be,{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(hn,{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(Co,{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:U(f.duration_seconds)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:f.title||"Untitled Video"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Property Video Tour"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:A,children:"Change"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:L,className:"text-destructive hover:text-destructive",children:e.jsx(Sr,{className:"h-4 w-4"})})]})]})})}):e.jsx(Ie,{className:"border-dashed",children:e.jsx(Be,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add a video walkthrough to showcase this property"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 justify-center",children:[e.jsxs(K,{type:"button",variant:"outline",onClick:A,className:"gap-2",children:[e.jsx(cS,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(K,{type:"button",variant:"outline",onClick:O,className:"gap-2",children:[e.jsx(bx,{className:"h-4 w-4"}),"Record New Video"]})]})]})})}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ms,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(ks,{children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(cS,{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(ps,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(hn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No videos in your library yet"}),e.jsxs(K,{onClick:O,className:"gap-2",children:[e.jsx(bx,{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($=>e.jsxs("button",{type:"button",onClick:()=>I($),className:`group relative rounded-lg overflow-hidden border-2 transition-all text-left ${t===$.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($)?e.jsx("img",{src:q($),alt:$.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(hn,{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(Co,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity"})}),$.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:$.title||"Untitled Video"})})]},$.id))})}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:O,className:"gap-2",children:[e.jsx(bx,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const Djs=[{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"}],Rjs=[{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 Ojs({id:t,url:s,index:r,onRemove:n}){const{attributes:a,listeners:o,setNodeRef:l,transform:i,transition:d,isDragging:u}=z4e({id:t}),p={transform:oC.Transform.toString(i),transition:d};return e.jsxs("div",{ref:l,style:p,className:`relative aspect-square rounded-lg overflow-hidden bg-muted group ${u?"opacity-50 ring-2 ring-primary z-50":""}`,children:[e.jsx("img",{src:s,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",...a,...o,className:"absolute top-1 left-1 p-1 bg-black/60 text-white rounded cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(uu,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>n(r),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Sr,{className:"h-3 w-3"})}),r===0&&e.jsxs("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded flex items-center gap-0.5",children:[e.jsx(Gn,{className:"h-2.5 w-2.5 fill-current"})," Primary"]})]})}function Fjs({photoUrls:t,pendingPhotos:s,onRemove:r,onReorder:n,uploading:a,onUpload:o}){const l=E4e(xce(lO,{activationConstraint:{distance:5}})),i=t.map((u,p)=>`pending-${p}`),d=u=>{const{active:p,over:f}=u;if(!f||p.id===f.id)return;const y=i.indexOf(p.id),_=i.indexOf(f.id),b=[...t],N=[...s],[w]=b.splice(y,1),[S]=N.splice(y,1);b.splice(_,0,w),N.splice(_,0,S),n(b,N)};return e.jsxs("div",{className:"space-y-2",children:[t.length>1&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. First photo will be primary."}),e.jsx(R4e,{sensors:l,collisionDetection:P4e,onDragEnd:d,children:e.jsx(F4e,{items:i,strategy:cO,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[t.map((u,p)=>e.jsx(Ojs,{id:i[p],url:u,index:p,onRemove:r},i[p])),e.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 cursor-pointer flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[a?e.jsx(ps,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Da,{className:"h-8 w-8"}),e.jsx("span",{className:"text-xs",children:"Upload"})]}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:u=>o(u.target.files),disabled:a})]})]})})}),s.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-4",children:[s.length," photo",s.length!==1?"s":""," will be uploaded when you save."]})]})}function uze(){const{listingId:t}=ho(),[s]=Sc(),r=s.get("brokerage"),n=br(),{user:a}=$s(),{hasLeadSite:o}=QA(),l=!!t&&t!=="new",i=!!r&&!l,[d,u]=k.useState([]),{data:p,isLoading:f}=qXe(l?t:""),y=aDt(),_=iDt(),b=oDt(),N=lDt(),w=cDt(),S=dDt(),C=uDt(),{data:A=[]}=ft({queryKey:["brokerage-agents",r],queryFn:async()=>{if(!r)return[];const{data:he,error:we}=await G.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name");if(we)throw we;return he||[]},enabled:i}),[I,L]=k.useState(""),[O,U]=k.useState(!1),[q,$]=k.useState([]),[V,ee]=k.useState([]),[Z,J]=k.useState({property_address:"",city:"",state:"",neighborhood:"",price:"",property_type:"single_family",status:"active",bedrooms:"",bathrooms:"",square_footage:"",lot_size:"",year_built:"",has_hoa:!1,description:"",agent_notes:"",agent_notes_public:!1,mls_link:"",video_link:"",video_id:null,allow_sharing:!0,open_to_referrals:!0,open_to_social_promotion:!0,share_with_brokerage:!1,is_public:!0});k.useEffect(()=>{var he,we,Ne,Ve,Te;p&&l&&J({property_address:p.property_address||"",city:p.city||"",state:p.state||"",neighborhood:p.neighborhood||"",price:((he=p.price)==null?void 0:he.toString())||"",property_type:p.property_type,status:p.status,bedrooms:((we=p.bedrooms)==null?void 0:we.toString())||"",bathrooms:((Ne=p.bathrooms)==null?void 0:Ne.toString())||"",square_footage:((Ve=p.square_footage)==null?void 0:Ve.toString())||"",lot_size:p.lot_size||"",year_built:((Te=p.year_built)==null?void 0:Te.toString())||"",has_hoa:p.has_hoa,description:p.description||"",agent_notes:p.agent_notes||"",agent_notes_public:p.agent_notes_public,mls_link:p.mls_link||"",video_link:p.video_link||"",video_id:p.video_id||null,allow_sharing:p.allow_sharing,open_to_referrals:p.open_to_referrals,open_to_social_promotion:p.open_to_social_promotion,share_with_brokerage:p.share_with_brokerage??!1,is_public:p.is_public})},[p,l]);const Y=he=>{var Te,Ae;const we={"single family":"single_family",detached:"single_family",residential:"single_family",condo:"condo",condominium:"condo",apartment:"condo",townhouse:"townhouse",townhome:"townhouse",land:"land",lot:"land","lots and land":"land","multi-family":"multi_family","multi family":"multi_family",duplex:"multi_family",commercial:"commercial"},Ne=(he.propertyType||"").toLowerCase(),Ve=((Te=Object.entries(we).find(([ze])=>Ne.includes(ze)))==null?void 0:Te[1])||"other";J(ze=>({...ze,property_address:he.address||ze.property_address,city:he.city||ze.city,state:he.state||ze.state,price:he.price?String(he.price):ze.price,property_type:Ve,bedrooms:he.bedrooms?String(he.bedrooms):ze.bedrooms,bathrooms:he.bathrooms?String(he.bathrooms):ze.bathrooms,square_footage:he.sqft?String(he.sqft):ze.square_footage,lot_size:he.lotSize?String(he.lotSize):ze.lot_size,year_built:he.yearBuilt?String(he.yearBuilt):ze.year_built,description:he.description||ze.description})),((Ae=he.photos)==null?void 0:Ae.length)>0&&(u(he.photos),V.forEach(ze=>URL.revokeObjectURL(ze)),$([]),ee([]))},ce=he=>{if(!he)return;const we=Array.from(he);$(Ve=>[...Ve,...we]);const Ne=we.map(Ve=>URL.createObjectURL(Ve));ee(Ve=>[...Ve,...Ne])},ae=he=>{URL.revokeObjectURL(V[he]),$(we=>we.filter((Ne,Ve)=>Ve!==he)),ee(we=>we.filter((Ne,Ve)=>Ve!==he))},ie=async he=>{var we;if(!(!he||!p)){U(!0);try{for(const Ne of Array.from(he)){const Ve=Ne.name.split(".").pop(),Te=`${a==null?void 0:a.id}/${p.id}/${Date.now()}.${Ve}`,{error:Ae}=await G.storage.from("listing-photos").upload(Te,Ne);if(Ae)throw Ae;const{data:{publicUrl:ze}}=G.storage.from("listing-photos").getPublicUrl(Te);await N.mutateAsync({listingId:p.id,photoUrl:ze,isPrimary:!((we=p.photos)!=null&&we.length)})}me.success("Photos uploaded!")}catch(Ne){console.error("Upload error:",Ne),me.error("Failed to upload photos")}finally{U(!1)}}},le=async he=>{for(let we=0;we{if(p)try{await w.mutateAsync({photoId:he,listingId:p.id}),me.success("Photo removed")}catch{me.error("Failed to remove photo")}},xe=async he=>{if(he.preventDefault(),!Z.city.trim()||!Z.state.trim()||!Z.price){me.error("Please fill in required fields (City, State, Price)");return}if(i&&!I){me.error("Please select an agent to assign this listing to");return}try{const we={property_address:Z.property_address||null,city:Z.city,state:Z.state,neighborhood:Z.neighborhood||null,price:Number(Z.price),property_type:Z.property_type,status:Z.status,bedrooms:Z.bedrooms?Number(Z.bedrooms):null,bathrooms:Z.bathrooms?Number(Z.bathrooms):null,square_footage:Z.square_footage?Number(Z.square_footage):null,lot_size:Z.lot_size||null,year_built:Z.year_built?Number(Z.year_built):null,has_hoa:Z.has_hoa,description:Z.description||null,agent_notes:Z.agent_notes||null,agent_notes_public:Z.agent_notes_public,mls_link:Z.mls_link||null,video_link:Z.video_link||null,video_id:Z.video_id||null,allow_sharing:Z.allow_sharing,open_to_referrals:Z.open_to_referrals,open_to_social_promotion:Z.open_to_social_promotion,share_with_brokerage:Z.share_with_brokerage,is_public:Z.is_public};if(l)await b.mutateAsync({id:t,...we}),me.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{U(!0);let Ne;if(i&&I?Ne=await _.mutateAsync({agentId:I,...we}):Ne=await y.mutateAsync(we),q.length>0)try{await le(Ne.id),V.forEach(Ve=>URL.revokeObjectURL(Ve)),$([]),ee([])}catch(Ve){console.error("Photo upload error:",Ve),me.error("Listing created but some photos failed to upload")}if(d.length>0)try{for(let Ve=0;Ven(i?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),i?"Back to Brokerage":"Back to Listings"]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[i&&e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Assign to Agent *"})}),e.jsxs(Be,{children:[e.jsxs(zs,{value:I,onValueChange:L,children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select an agent..."})}),e.jsx(Fs,{children:A.map(he=>e.jsx(yt,{value:he.id,children:he.name||he.email},he.id))})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"This listing will appear on the selected agent's Listing Exchange."})]})]}),!l&&o&&!i&&e.jsx(Ejs,{onImport:Y}),d.length>0&&e.jsxs(Ie,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Xa,{className:"h-4 w-4 text-primary"}),"MLS Photos (",d.length,")"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"These photos will be imported when you save the listing."})]}),e.jsxs(Be,{children:[e.jsxs("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:[d.slice(0,12).map((he,we)=>e.jsx("div",{className:"aspect-square rounded overflow-hidden bg-muted",children:e.jsx("img",{src:he,alt:"",className:"w-full h-full object-cover"})},we)),d.length>12&&e.jsxs("div",{className:"aspect-square rounded bg-muted flex items-center justify-center text-sm text-muted-foreground font-medium",children:["+",d.length-12]})]}),e.jsxs(K,{type:"button",variant:"ghost",size:"sm",className:"mt-2 text-destructive",onClick:()=>u([]),children:[e.jsx(Sr,{className:"h-3 w-3 mr-1"})," Clear MLS photos"]})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Property Details"})}),e.jsx(Be,{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(ge,{children:"Property Address"}),e.jsx(Fe,{value:Z.property_address,onChange:he=>J({...Z,property_address:he.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"City *"}),e.jsx(Fe,{value:Z.city,onChange:he=>J({...Z,city:he.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"State *"}),e.jsx(Fe,{value:Z.state,onChange:he=>J({...Z,state:he.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Neighborhood"}),e.jsx(Fe,{value:Z.neighborhood,onChange:he=>J({...Z,neighborhood:he.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Price *"}),e.jsx(Fe,{type:"number",value:Z.price,onChange:he=>J({...Z,price:he.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Property Type"}),e.jsxs(zs,{value:Z.property_type,onValueChange:he=>J({...Z,property_type:he}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:Rjs.map(he=>e.jsx(yt,{value:he.value,children:he.label},he.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Status"}),e.jsxs(zs,{value:Z.status,onValueChange:he=>J({...Z,status:he}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:Djs.map(he=>e.jsx(yt,{value:he.value,children:he.label},he.value))})]})]})]})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Property Specs (Optional)"})}),e.jsx(Be,{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(ge,{children:"Bedrooms"}),e.jsx(Fe,{type:"number",value:Z.bedrooms,onChange:he=>J({...Z,bedrooms:he.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Bathrooms"}),e.jsx(Fe,{type:"number",step:"0.5",value:Z.bathrooms,onChange:he=>J({...Z,bathrooms:he.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Sq Ft"}),e.jsx(Fe,{type:"number",value:Z.square_footage,onChange:he=>J({...Z,square_footage:he.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Lot Size"}),e.jsx(Fe,{value:Z.lot_size,onChange:he=>J({...Z,lot_size:he.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Year Built"}),e.jsx(Fe,{type:"number",value:Z.year_built,onChange:he=>J({...Z,year_built:he.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(Lr,{checked:Z.has_hoa,onCheckedChange:he=>J({...Z,has_hoa:he})}),e.jsx(ge,{children:"Has HOA"})]})]})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Description & Links"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Description"}),e.jsx(_r,{value:Z.description,onChange:he=>J({...Z,description:he.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Agent Notes"}),e.jsx(_r,{value:Z.agent_notes,onChange:he=>J({...Z,agent_notes:he.target.value}),placeholder:"Notes for other agents...",rows:2}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{checked:Z.agent_notes_public,onCheckedChange:he=>J({...Z,agent_notes_public:he})}),e.jsx(ge,{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(ge,{children:"MLS Link"}),e.jsx(Fe,{value:Z.mls_link,onChange:he=>J({...Z,mls_link:he.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Video Link"}),e.jsx(Fe,{value:Z.video_link,onChange:he=>J({...Z,video_link:he.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(Be,{children:e.jsx(Ljs,{selectedVideoId:Z.video_id,onVideoSelect:he=>J({...Z,video_id:he}),listingId:l?t:void 0})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Photos"})}),e.jsx(Be,{children:l&&(p!=null&&p.photos)?e.jsx(Ijs,{photos:p.photos,uploading:O,onUpload:he=>ie(he),onRemove:he=>fe(he),onReorder:he=>{S.mutate({photos:he.map(we=>({id:we.id,sort_order:we.sort_order,is_primary:we.is_primary}))})},onSetPrimary:he=>{p&&C.mutate({photoId:he,listingId:p.id})}}):e.jsx(Fjs,{photoUrls:V,onRemove:ae,onReorder:(he,we)=>{ee(he),$(we)},pendingPhotos:q,uploading:O,onUpload:ce})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Sharing & Collaboration"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Allow Sharing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),e.jsx(Lr,{checked:Z.allow_sharing,onCheckedChange:he=>J({...Z,allow_sharing:he})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Open to Referrals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),e.jsx(Lr,{checked:Z.open_to_referrals,onCheckedChange:he=>J({...Z,open_to_referrals:he})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Social Promotion"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),e.jsx(Lr,{checked:Z.open_to_social_promotion,onCheckedChange:he=>J({...Z,open_to_social_promotion:he})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx(Lr,{checked:Z.share_with_brokerage,onCheckedChange:he=>J({...Z,share_with_brokerage:he})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Make Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Publish on listings.relevelup.com to get leads"})]}),e.jsx(Lr,{checked:Z.is_public,onCheckedChange:he=>J({...Z,is_public:he})})]})]})]}),e.jsx(K,{type:"submit",className:"w-full",size:"lg",disabled:y.isPending||b.isPending,children:y.isPending||b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):l?"Update Listing":"Create Listing"})]})]})]})})}let Km=null;function zjs(){if(Km)return Km;try{const t=document.createElement("canvas"),s=t.getContext("webgl2")||t.getContext("webgl");if(!s)return Km={canRunVirtualBg:!1,reason:"WebGL is not supported on this device"},Km;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(d=>o.includes(d)))return Km={canRunVirtualBg:!1,reason:"Your device uses a software renderer which may cause lag",renderer:n},Km;const i=performance;return i.memory&&i.memory.jsHeapSizeLimit<256*1024*1024?(Km={canRunVirtualBg:!1,reason:"Limited device memory detected",renderer:n},Km):navigator.hardwareConcurrency&&navigator.hardwareConcurrency<2?(Km={canRunVirtualBg:!1,reason:"Single-core device detected — virtual backgrounds may cause lag",renderer:n},Km):(Km={canRunVirtualBg:!0,renderer:n},Km)}catch{return Km={canRunVirtualBg:!0},Km}}const Bjs=[{type:"none",label:"Off"},{type:"blur",label:"Blur"}];function $js({value:t,onChange:s,isLoading:r=!1,disabled:n=!1,className:a}){const o=k.useRef(null),[l,i]=k.useState(!1),[d]=k.useState(()=>zjs()),u=!d.canRunVirtualBg,{data:p=[],refetch:f}=ft({queryKey:["video-backgrounds"],queryFn:async()=>{const{data:{user:w}}=await G.auth.getUser();if(!w)return[];const{data:S,error:C}=await G.from("video_backgrounds").select("*").eq("is_active",!0).order("sort_order",{ascending:!0});return C?(console.error("Failed to load backgrounds:",C),[]):S||[]}}),y=p.map(w=>({type:"image",label:w.name,imageUrl:w.image_url,thumbnail:w.thumbnail_url||w.image_url})),_=[...Bjs,...y],b=w=>w.type!==t.type?!1:w.type==="image"?w.imageUrl===t.imageUrl:!0,N=async w=>{var C;const S=(C=w.target.files)==null?void 0:C[0];if(S){if(!S.type.startsWith("image/")){me.error("Please select an image file");return}if(S.size>5*1024*1024){me.error("Image must be under 5MB");return}i(!0);try{const{data:{user:A}}=await G.auth.getUser();if(!A)throw new Error("Not authenticated");const I=S.name.split(".").pop()||"jpg",L=`${A.id}/${crypto.randomUUID()}.${I}`,{error:O}=await G.storage.from("video-backgrounds").upload(L,S,{contentType:S.type});if(O)throw O;const{data:U}=G.storage.from("video-backgrounds").getPublicUrl(L),q=U.publicUrl,{error:$}=await G.from("video_backgrounds").insert({name:S.name.replace(/\.[^.]+$/,""),image_url:q,thumbnail_url:q,category:"custom",is_stock:!1,user_id:A.id});if($)throw $;await f(),s({type:"image",imageUrl:q,blurRadius:15}),me.success("Background uploaded!")}catch(A){console.error("Upload error:",A),me.error("Failed to upload background")}finally{i(!1),o.current&&(o.current.value="")}}};return e.jsxs("div",{className:Rt("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(Qc,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{children:d.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(ps,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Loading…"})]}),_.map((w,S)=>{const C=b(w);return e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({type:w.type,imageUrl:w.imageUrl,blurRadius:15}),className:Rt("flex-shrink-0 flex flex-col items-center gap-0.5 rounded-lg border-2 p-1 transition-all","hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-primary/30",C?"border-primary bg-primary/10":"border-transparent bg-muted/50",n&&"opacity-50 cursor-not-allowed"),children:[e.jsxs("div",{className:"w-12 h-8 rounded flex items-center justify-center overflow-hidden bg-muted",children:[w.type==="none"&&e.jsx(iL,{className:"h-4 w-4 text-muted-foreground"}),w.type==="blur"&&e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-primary/20 to-primary/40 flex items-center justify-center",children:e.jsx("span",{className:"text-[10px] font-medium text-primary",children:"Blur"})}),w.type==="image"&&w.thumbnail&&e.jsx("img",{src:w.thumbnail,alt:w.label,className:"w-full h-full object-cover"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-14",children:w.label})]},`${w.type}-${w.imageUrl||S}`)}),e.jsxs("button",{type:"button",disabled:n||l,onClick:()=>{var w;return(w=o.current)==null?void 0:w.click()},className:Rt("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(ps,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(Bs,{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:N}),e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({...t,mirror:!t.mirror}),className:Rt("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(fL,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Mirror"})]})]})]})}var gA=typeof self<"u"?self:{};function Dit(t,s){e:{for(var r=["CLOSURE_FLAGS"],n=gA,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 Oit(t){gA.setTimeout(()=>{throw t},0)}var Rwe,Hjs=Dit(610401301,!1),mze=Dit(748402147,!0);function pze(){var t=gA.navigator;return t&&(t=t.userAgent)?t:""}const fze=gA.navigator;function Ime(t){return Ime[" "](t),t}Rwe=fze&&fze.userAgentData||null,Ime[" "]=function(){};const Fit={};let q6=null;function Gjs(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(;d>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 zit(){if(!q6){q6={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),s=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const n=t.concat(s[r].split(""));Fit[r]=n;for(let a=0;a0)&&(pze().indexOf("Trident")!=-1||pze().indexOf("MSIE")!=-1))&&typeof btoa=="function";const xze=/[-_.]/g,Kjs={"-":"+",_:"/",".":"="};function Zjs(t){return Kjs[t]||""}function $it(t){if(!Bit)return Gjs(t);t=xze.test(t)?t.replace(xze,Zjs):t,t=atob(t);const s=new Uint8Array(t.length);for(let r=0;r=s||(r[t]=n+1,Uit(t=Error(),"incident"),Oit(t))}}function NE(){return typeof BigInt=="function"}var kE=typeof Symbol=="function"&&typeof Symbol()=="symbol";function C0(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 Qjs=C0("jas",void 0,!0),gze=C0(void 0,"0di"),v6=C0(void 0,"1oa"),yf=C0(void 0,Symbol()),Jjs=C0(void 0,"0ub"),eNs=C0(void 0,"0ubs"),Fwe=C0(void 0,"0ubsb"),tNs=C0(void 0,"0actk"),_A=C0("m_m","Pa",!0),yze=C0();const Vit={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},Hit=Object.defineProperties,ga=kE?Qjs:"Ga";var DC;const vze=[];function wO(t,s){kE||ga in t||Hit(t,Vit),t[ga]|=s}function xu(t,s){kE||ga in t||Hit(t,Vit),t[ga]=s}function jO(t){return wO(t,34),t}function cR(t){return wO(t,8192),t}xu(vze,7),DC=Object.freeze(vze);var bA={};function wf(t,s){return s===void 0?t.h!==gC&&!!(2&(0|t.v[ga])):!!(2&s)&&t.h!==gC}const gC={};function aCe(t,s){if(t!=null){if(typeof t=="string")t=t?new d0(t,yA):xC();else if(t.constructor!==d0)if(rCe(t))t=t.length?new d0(new Uint8Array(t),yA):xC();else{if(!s)throw Error();t=void 0}}return t}class _ze{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 sNs=Object.freeze({});function Git(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"),bze=Lme(t=>typeof t=="string"),nNs=Lme(t=>typeof t=="boolean"),Dme=typeof gA.BigInt=="function"&&typeof gA.BigInt(0)=="bigint";function vf(t){var s=t;if(bze(s)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(s))throw Error(String(s))}else if(rNs(s)&&!Number.isSafeInteger(s))throw Error(String(s));return Dme?BigInt(t):t=nNs(t)?t?"1":"0":bze(t)?t.trim()||"0":String(t)}var zwe=Lme(t=>Dme?t>=iNs&&t<=lNs:t[0]==="-"?wze(t,aNs):wze(t,oNs));const aNs=Number.MIN_SAFE_INTEGER.toString(),iNs=Dme?BigInt(Number.MIN_SAFE_INTEGER):void 0,oNs=Number.MAX_SAFE_INTEGER.toString(),lNs=Dme?BigInt(Number.MAX_SAFE_INTEGER):void 0;function wze(t,s){if(t.length>s.length)return!1;if(t.lengtha)return!1;if(n>>0;Lc=s,Rd=(t-s)/4294967296>>>0}function wA(t){if(t<0){jze(-t);const[s,r]=lCe(Lc,Rd);Lc=s>>>0,Rd=r>>>0}else jze(t)}function iCe(t){const s=dNs||(dNs=new DataView(new ArrayBuffer(8)));s.setFloat32(0,+t,!0),Rd=0,Lc=s.getUint32(0,!0)}function Kit(t,s){const r=4294967296*s+(t>>>0);return Number.isSafeInteger(r)?r:dR(t,s)}function uNs(t,s){return vf(NE()?BigInt.asUintN(64,(BigInt(s>>>0)<>>0)):dR(t,s))}function Zit(t,s){return NE()?vf(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(s))<>>=0,(s>>>=0)<=2097151)var r=""+(4294967296*s+t);else NE()?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+Nze(r)+Nze(t));return r}function Nze(t){return t=String(t),"0000000".slice(t.length)+t}function oCe(t,s){if(2147483648&s)if(NE())t=""+(BigInt(0|s)<>>0));else{const[r,n]=lCe(t,s);t="-"+dR(r,n)}else t=dR(t,s);return t}function Rme(t){if(t.length<16)wA(Number(t));else if(NE())t=BigInt(t),Lc=Number(t&BigInt(4294967295))>>>0,Rd=Number(t>>BigInt(32)&BigInt(4294967295));else{const s=+(t[0]==="-");Rd=Lc=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));Rd*=1e6,Lc=1e6*Lc+o,Lc>=4294967296&&(Rd+=Math.trunc(Lc/4294967296),Rd>>>=0,Lc>>>=0)}if(s){const[n,a]=lCe(Lc,Rd);Lc=n,Rd=a}}}function lCe(t,s){return s=~s,t?t=1+~t:s+=1,[t,s]}function Bg(t){return Array.prototype.slice.call(t)}const NO=typeof BigInt=="function"?BigInt.asIntN:void 0,hNs=typeof BigInt=="function"?BigInt.asUintN:void 0,yC=Number.isSafeInteger,Ome=Number.isFinite,jA=Math.trunc,mNs=vf(0);function U6(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 Hy(t){return t==null||typeof t=="number"?t:t==="NaN"||t==="Infinity"||t==="-Infinity"?Number(t):void 0}function uR(t){if(t!=null&&typeof t!="boolean"){var s=typeof t;throw Error(`Expected boolean but got ${s!="object"?s:t?Array.isArray(t)?"array":s:"null"}: ${t}`)}return t}function Yit(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0}const pNs=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function kO(t){switch(typeof t){case"bigint":return!0;case"number":return Ome(t);case"string":return pNs.test(t);default:return!1}}function CE(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Ome(t)?0|t:void 0}function Xit(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Ome(t)?t>>>0:void 0}function Qit(t){const s=t.length;return(t[0]==="-"?s<20||s===20&&t<="-9223372036854775808":s<19||s===19&&t<="9223372036854775807")?t:(Rme(t),oCe(Lc,Rd))}function cCe(t){if(t=jA(t),!yC(t)){wA(t);var s=Lc,r=Rd;(t=2147483648&r)&&(r=~r>>>0,(s=1+~s>>>0)==0&&(r=r+1>>>0)),t=typeof(s=Kit(s,r))=="number"?t?-s:s:t?"-"+s:s}return t}function Jit(t){var s=jA(Number(t));return yC(s)?String(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),Qit(t))}function eot(t){var s=jA(Number(t));return yC(s)?vf(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),NE()?vf(NO(64,BigInt(t))):vf(Qit(t)))}function tot(t){return yC(t)?t=vf(cCe(t)):(t=jA(t),yC(t)?t=String(t):(wA(t),t=oCe(Lc,Rd)),t=vf(t)),t}function jde(t){const s=typeof t;return t==null?t:s==="bigint"?vf(NO(64,t)):kO(t)?s==="string"?eot(t):tot(t):void 0}function sot(t){if(typeof t!="string")throw Error();return t}function SO(t){if(t!=null&&typeof t!="string")throw Error();return t}function mh(t){return t==null||typeof t=="string"?t:void 0}function dCe(t,s,r,n){return t!=null&&t[_A]===bA?t:Array.isArray(t)?((n=(r=0|t[ga])|32&n|2&n)!==r&&xu(t,n),new s(t)):(r?2&n?((t=s[gze])||(jO((t=new s).v),t=s[gze]=t),s=t):s=new s:s=void 0,s)}function fNs(t,s,r){if(s)e:{if(!kO(s=t))throw Owe("int64");switch(typeof s){case"string":s=eot(s);break e;case"bigint":s=vf(NO(64,s));break e;default:s=tot(s)}}else s=jde(t);return(t=s)==null?r?mNs:void 0:t}const xNs={};let gNs=function(){try{return Ime(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class m0e{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 yNs=gNs?(Object.setPrototypeOf(m0e.prototype,Map.prototype),Object.defineProperties(m0e.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),m0e):class extends Map{constructor(){super()}};function kze(t){return t}function p0e(t){if(2&t.J)throw Error("Cannot mutate an immutable Map")}var _1=class extends yNs{constructor(t,s,r=kze,n=kze){super(),this.J=0|t[ga],this.K=s,this.S=r,this.fa=this.K?vNs:n;for(let a=0;a{t.call(s,a.get(n),n,a)}):super.forEach(t,s)}set(t,s){return p0e(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 vNs(t,s,r,n,a,o){return t=dCe(t,n,r,o),a&&(t=hCe(t)),t}function _Ns(t){return[t,this.get(t)]}let bNs;function Sze(){return bNs||(bNs=new _1(jO([]),void 0,void 0,void 0,xNs))}function Fme(t){return yf?t[yf]:void 0}function Nde(t,s){for(const r in t)!isNaN(r)&&s(t,+r,t[r])}_1.prototype.toJSON=void 0;var Bwe=class{};const wNs={Ka:!0};function jNs(t,s){s<100||vA(eNs,1)}function zme(t,s,r,n){const a=n!==void 0;n=!!n;var o,l=yf;!a&&kE&&l&&(o=t[l])&&Nde(o,jNs),l=[];var i=t.length;let d;o=4294967295;let u=!1;const p=!!(64&s),f=p?128&s?0:-1:void 0;1&s||(d=i&&t[i-1],d!=null&&typeof d=="object"&&d.constructor===Object?o=--i:d=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(d)for(let _ in d){if((i=d[_])==null||(i=r(i,n))==null)continue;let b;y=+_,p&&!Number.isNaN(y)&&(b=y+f){b[w]=Bg(S)}),b.da=_.da,b}(t)),l}function NNs(t){return t[0]=hR(t[0]),t[1]=hR(t[1]),t}function hR(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return zwe(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var s=0|t[ga];return t.length===0&&1&s?void 0:zme(t,s,hR)}if(t!=null&&t[_A]===bA)return rot(t);if(t instanceof d0){if((s=t.g)==null)t="";else if(typeof s=="string")t=s;else{if(Bit){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++]=d+o+l+i}switch(d=0,i=a,s.length-u){case 2:i=r[(15&(d=s[u+1]))<<2]||a;case 1:s=s[u],n[p]=r[s>>2]+r[(3&s)<<4|d>>4]+i+a}s=n.join("")}t=t.g=s}return t}return t instanceof _1?t=t.size!==0?t.V(NNs):void 0:void 0}return t}let kNs,SNs;function rot(t){return zme(t=t.v,0|t[ga],hR)}function DS(t,s){return not(t,s[0],s[1])}function not(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[ga],mze&&1&a)throw Error("rfarr");if(2048&a&&!(2&a)&&function(){if(mze)throw Error("carr");vA(tNs,5)}(),256&a)throw Error("farr");if(64&a)return(a|n)!==a&&xu(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 d=r[l];if(d!=null&&typeof d=="object"&&d.constructor===Object){if((l-=s=128&a?0:-1)>=1024)throw Error("pvtlmt");for(var i in d)(o=+i)1024)throw Error("spvt");a=-16760833&a|(1023&i)<<14}}}return xu(t,64|a|n),t}function CNs(t,s){if(typeof t!="object")return t;if(Array.isArray(t)){var r=0|t[ga];return t.length===0&&1&r?void 0:Cze(t,r,s)}if(t!=null&&t[_A]===bA)return Mze(t);if(t instanceof _1){if(2&(s=t.J))return t;if(!t.size)return;if(r=jO(t.V()),t.K)for(t=0;t=o)if(l=t[o],l!=null&&typeof l=="object"&&l.constructor===Object)r=l[s],i=!0;else{if(a!==o)return;r=l}else r=t[a];if(n&&r!=null){if((n=n(r))==null)return n;if(!Object.is(n,r))return i?l[s]=n:t[a]=n,n}return r}}function sl(t,s,r,n){AE(t),pu(t=t.v,0|t[ga],s,r,n)}function pu(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[ga]))>>14&1023||536870912)?n!=null&&(t[l+(a?0:-1)]={[r]:n}):t[o]=n),s)}function E4(){return sNs===void 0?2:4}function P4(t,s,r,n,a){let o=t.v,l=0|o[ga];n=wf(t,l)?1:n,a=!!a||n===3,n===2&&TE(t)&&(o=t.v,l=0|o[ga]);let i=(t=pCe(o,s))===DC?7:0|t[ga],d=fCe(i,l);var u=!(4&d);if(u){4&d&&(t=Bg(t),i=0,d=OS(d,l),l=pu(o,l,s,t));let p=0,f=0;for(;p{const i=dCe(l,r,!1,s);return o=i!==l&&i!=null,i}))!=null)return o&&!wf(n)&&RC(t,s),n}function ko(t,s,r,n){let a=t.v,o=0|a[ga];if((s=dot(a,o,s,r,n))==null)return s;if(o=0|a[ga],!wf(t,o)){const l=hCe(s);l!==s&&(TE(t)&&(a=t.v,o=0|a[ga]),o=pu(a,o,r,s=l,n),RC(a,o))}return s}function uot(t,s,r,n,a,o,l,i){var d=wf(t,r);o=d?1:o,l=!!l||o===3,d=i&&!d,(o===2||d)&&TE(t)&&(r=0|(s=t.v)[ga]);var u=(t=pCe(s,a))===DC?7:0|t[ga],p=fCe(u,r);if(i=!(4&p)){var f=t,y=r;const _=!!(2&p);_&&(y|=2);let b=!_,N=!0,w=0,S=0;for(;w32)for(a|=(127&r)>>4,o=3;o<32&&128&r;o+=7)r=l[i++],a|=(127&r)<>>0,a>>>0);throw Error()}function wCe(t){let s=0,r=t.g;const n=r+10,a=t.h;for(;r>>0}function Sde(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],FS(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 MNs(t){return lw(t)}function FS(t,s){if(t.g=s,s>t.l)throw Error()}function mot(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 pot(t,s){if(s==0)return xC();var r=mot(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):cNs?t.slice(r,s):new Uint8Array(t.subarray(r,s))),r.length==0?xC():new d0(r,yA)}var Tze=[];function fot(t,s,r,n){if(Cde.length){const a=Cde.pop();return a.o(n),a.g.init(t,s,r,n),a}return new TNs(t,s,r,n)}function xot(t){t.g.clear(),t.l=-1,t.h=-1,Cde.length<100&&Cde.push(t)}function got(t){var s=t.g;if(s.g==s.l)return!1;t.m=t.g.g;var r=y0(t.g);if(s=r>>>3,!((r&=7)>=0&&r<=5)||s<1)throw Error();return t.l=s,t.h=r,!0}function coe(t){switch(t.h){case 0:t.h!=0?coe(t):wCe(t.g);break;case 1:FS(t=t.g,t.g+8);break;case 2:if(t.h!=2)coe(t);else{var s=y0(t.g);FS(t=t.g,t.g+s)}break;case 5:FS(t=t.g,t.g+4);break;case 3:for(s=t.l;;){if(!got(t))throw Error();if(t.h==4){if(t.l!=s)throw Error();break}coe(t)}break;default:throw Error()}}function CO(t,s,r){const n=t.g.l;var a=y0(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 jCe(t){var s=y0(t.g),r=mot(t=t.g,s);if(t=t.h,qjs){var n,a=t;(n=h0e)||(n=h0e=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(N9===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),N9=!0}catch{N9=!1}}throw!N9&&(h0e=void 0),i}}else{s=(o=r)+s,r=[];let i,d=null;for(;o=s?H2():(i=t[o++],l<194||(192&i)!=128?(o--,H2()):r.push((31&l)<<6|63&i)):l<240?o>=s-1?H2():(i=t[o++],(192&i)!=128||l===224&&i<160||l===237&&i>=160||(192&(n=t[o++]))!=128?(o--,H2()):r.push((15&l)<<12|(63&i)<<6|63&n)):l<=244?o>=s-2?H2():(i=t[o++],(192&i)!=128||i-144+(l<<28)>>30||(192&(n=t[o++]))!=128||(192&(a=t[o++]))!=128?(o--,H2()):(l=(7&l)<<18|(63&i)<<12|(63&n)<<6|63&a,l-=65536,r.push(55296+(l>>10&1023),56320+(1023&l)))):H2(),r.length>=8192&&(d=hze(d,r),r.length=0)}o=hze(d,r)}return o}function yot(t){const s=y0(t.g);return pot(t.g,s)}function $me(t,s,r){var n=y0(t.g);for(n=t.g.g+n;t.g.g>>0,this.g=s>>>0}};let ANs;function Eze(t){return t?/^-?\d+$/.test(t)?(Rme(t),new qwe(Lc,Rd)):null:ENs||(ENs=new qwe(0,0))}var qwe=class{constructor(t,s){this.h=t>>>0,this.g=s>>>0}};let ENs;function aT(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 PE(t,s){for(;s>127;)t.g.push(127&s|128),s>>>=7;t.g.push(s)}function qme(t,s){if(s>=0)PE(t,s);else{for(let r=0;r<9;r++)t.g.push(127&s|128),s>>=7;t.g.push(1)}}function NCe(t){var s=Lc;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 NA(t,s){s.length!==0&&(t.l.push(s),t.h+=s.length)}function $x(t,s,r){PE(t.g,8*s+r)}function kCe(t,s){return $x(t,s,2),s=t.g.end(),NA(t,s),s.push(t.h),s}function SCe(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 Ume(t,s,r){$x(t,s,2),PE(t.g,r.length),NA(t,t.g.end()),NA(t,r)}function Mde(t,s,r,n){r!=null&&(s=kCe(t,s),n(r,t),SCe(t,s))}function M0(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var CCe=M0(),vot=M0(),MCe=M0(),TCe=M0(),ACe=M0(),_ot=M0(),PNs=M0(),Vme=M0(),bot=M0(),wot=M0();function T0(t,s,r){var n=t.v;yf&&yf in n&&(n=n[yf])&&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 ya=class{constructor(t,s){this.v=not(t,s,void 0,2048)}toJSON(){return rot(this)}j(){var a;var t=mks,s=this.v,r=t.g,n=yf;if(kE&&n&&((a=s[n])==null?void 0:a[r])!=null&&vA(Jjs,3),s=t.g,yze&&yf&&yze===void 0&&(n=(r=this.v)[yf])&&(n=n.da))try{n(r,s,wNs)}catch(o){Oit(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[ga];return mCe(this,t,s)?uCe(this,t,!0):new this.constructor(ME(t,s,!1))}};ya.prototype[_A]=bA,ya.prototype.toString=function(){return this.v.toString()};var IE=class{constructor(t,s,r){this.g=t,this.h=s,t=CCe,this.l=!!t&&r===t||!1}};function Hme(t,s){return new IE(t,s,CCe)}function jot(t,s,r,n,a){Mde(t,r,Cot(s,n),a)}const INs=Hme(function(t,s,r,n,a){return t.h===2&&(CO(t,yCe(s,n,r),a),!0)},jot),LNs=Hme(function(t,s,r,n,a){return t.h===2&&(CO(t,yCe(s,n,r),a),!0)},jot);var Gme=Symbol(),Wme=Symbol(),Uwe=Symbol(),Pze=Symbol(),Ize=Symbol();let Not,kot;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 kNs||(kNs=[0,void 0,!0]);case"number":return f>0?void 0:f===0?SNs||(SNs=[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,Not??(Not=o),kot??(kot=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 d=0;da(o,l,i,n):a}function PCe(t,s,r,n,a){const o=r.g;let l,i;t[s]=(d,u,p)=>o(d,u,p,i||(i=OC(Wme,ECe,PCe,n).T),l||(l=ICe(n)),a)}function ICe(t){let s=t[Uwe];if(s!=null)return s;const r=OC(Wme,ECe,PCe,t);return s=r.ma?(n,a)=>Not(n,a,r):(n,a)=>{for(;got(a)&&a.h!=4;){var o=a.l,l=r[o];if(l==null){var i=r.ba;i&&(i=i[o])&&(i=RNs(i))!=null&&(l=r[o]=i)}if(l==null||!l(a,n,o)){if(l=(i=a).m,coe(i),i.ha)var d=void 0;else d=i.g.g-l,i.g.g=l,d=pot(i.g,d);l=void 0,i=n,d&&((l=i[yf]??(i[yf]=new Bwe))[o]??(l[o]=[])).push(d)}}return(n=Fme(n))&&(n.da=r.qa[Ize]),!0},t[Uwe]=s,t[Ize]=DNs.bind(t),s}function DNs(t,s,r,n){var a=this[Wme];const o=this[Uwe],l=DS(void 0,a.T),i=Fme(t);if(i){var d=!1,u=a.ba;if(u){if(a=(p,f,y)=>{if(y.length!==0)if(u[f])for(const _ of y){p=fot(_);try{d=!0,o(l,p)}finally{xot(p)}}else n==null||n(t,f,y)},s==null)Nde(i,a);else if(i!=null){const p=i[s];p&&a(i,s,p)}if(d){let p=0|t[ga];if(2&p&&2048&p&&!(r!=null&&r.Ka))throw Error();const f=SE(p),y=(_,b)=>{if(b1(t,_,f)!=null){if((r==null?void 0:r.Qa)===1)return;throw Error()}b!=null&&(p=pu(t,p,_,b,f)),delete i[_]};s==null?Git(l,0|l[ga],(_,b)=>{y(_,b)}):y(s,b1(l,s,f))}}}}function RNs(t){const s=(t=Sot(t))[0].g;if(t=t[1]){const r=ICe(t),n=OC(Wme,ECe,PCe,t).T;return(a,o,l)=>s(a,o,l,n,r)}return s}function Kme(t,s,r){t[s]=r.h}function Zme(t,s,r,n){let a,o;const l=r.h;t[s]=(i,d,u)=>l(i,d,u,o||(o=OC(Gme,Kme,Zme,n).T),a||(a=Mot(n)))}function Mot(t){let s=t[Pze];if(!s){const r=OC(Gme,Kme,Zme,t);s=(n,a)=>Tot(n,a,r),t[Pze]=s}return s}function Tot(t,s,r){Git(t,0|t[ga],(n,a)=>{if(a!=null){var o=function(l,i){var d=l[i];if(d)return d;if((d=l.ba)&&(d=d[i])){var u=(d=Sot(d))[0].h;if(d=d[1]){const p=Mot(d),f=OC(Gme,Kme,Zme,d).T;d=l.ma?kot(f,p):(y,_,b)=>u(y,_,b,f,p)}else d=u;return l[i]=d}}(r,n);o?o(s,a,n):n<500||vA(Fwe,3)}}),(t=Fme(t))&&Nde(t,(n,a,o)=>{for(NA(s,s.g.end()),n=0;n{Mde(t,r,DS([l,o],n),a)});else if(Array.isArray(s)){for(let o=0;o>BigInt(32))),aT(t.g,r.h,r.g);break;default:r=Eze(s),aT(t.g,r.h,r.g)}}function Pot(t,s,r){(s=CE(s))!=null&&s!=null&&($x(t,r,0),qme(t.g,s))}function Iot(t,s,r){(s=Yit(s))!=null&&($x(t,r,0),t.g.g.push(s?1:0))}function Lot(t,s,r){(s=mh(s))!=null&&Ume(t,r,Rit(s))}function Dot(t,s,r,n,a){Mde(t,r,Cot(s,n),a)}function Rot(t,s,r){(s=s==null||typeof s=="string"||s instanceof d0?s:void 0)!=null&&Ume(t,r,_Ce(s,!0).buffer)}function Oot(t,s,r){(s=Xit(s))!=null&&s!=null&&($x(t,r,0),PE(t.g,s))}function Fot(t,s,r){return(t.h===5||t.h===2)&&(s=EE(s,0|s[ga],r),t.h==2?$me(t,Sde,s):s.push(Sde(t.g)),!0)}var zd=Wh(function(t,s,r){return t.h===5&&(Kh(s,r,Sde(t.g)),!0)},Aot,Vme),zNs=DE(Fot,function(t,s,r){if((s=LE(Hy,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"))||(Rme(n),n=dR(Lc,Rd))),n;if(a==="number")return(n=jA(n))>=0&&yC(n)||(wA(n),n=Kit(Lc,Rd)),n}}(s),s!=null&&(typeof s=="string"&&Aze(s),s!=null))switch($x(t,r,0),typeof s){case"number":t=t.g,wA(s),aT(t,Lc,Rd);break;case"bigint":r=BigInt.asUintN(64,s),r=new $we(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),aT(t.g,r.h,r.g);break;default:r=Aze(s),aT(t.g,r.h,r.g)}},PNs),lu=Wh(function(t,s,r){return t.h===0&&(Kh(s,r,lw(t.g)),!0)},Pot,TCe),MO=DE(function(t,s,r){return(t.h===0||t.h===2)&&(s=EE(s,0|s[ga],r),t.h==2?$me(t,lw,s):s.push(lw(t.g)),!0)},function(t,s,r){if((s=LE(CE,s))!=null&&s.length){r=kCe(t,r);for(let n=0;n{{const o={ea:!0};n&&Object.assign(o,n),r=fot(r,void 0,void 0,o);try{const l=new t,i=l.v;ICe(s)(i,r);var a=l}finally{xot(r)}}return a}}function Yme(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}}}};Tot(this.v,s,OC(Gme,Kme,Zme,t)),NA(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=Rze.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r}()),t=(s=g0e)?s.createScriptURL(t):t,new class{constructor(r){this.g=r}toString(){return this.g+""}}(t)}function k9(t,...s){if(s.length===0)return Oze(t[0]);let r=t[0];for(let n=0;n({index:yx(n,1)??0??-1,score:dd(n,2)??0,categoryName:mh(Oc(n,3))??""??"",displayName:mh(Oc(n,4))??""??""})),headIndex:s,headName:r}}function gks(t){const s={classifications:w1(t,QNs,1).map(r=>{var n;return qCe(((n=ko(r,Wot,4))==null?void 0:n.g())??[],yx(r,2)??0,mh(Oc(r,3))??"")})};return function(r){return r==null?r:typeof r=="bigint"?(zwe(r)?r=Number(r):(r=NO(64,r),r=zwe(r)?Number(r):String(r)),r):kO(r)?typeof r=="number"?cCe(r):Jit(r):void 0}(Oc(t,2,void 0,void 0,jde))!=null&&(s.timestampMs=_lt(Oc(t,2,void 0,void 0,jde)??aot)),s}function blt(t){var l,i;var s=P4(t,3,Hy,E4()),r=P4(t,2,CE,E4()),n=P4(t,1,mh,E4()),a=P4(t,9,mh,E4());const o={categories:[],keypoints:[]};for(let d=0;ds>127?s-256:s)}function Zze(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 Yze(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 Nlt(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 wa(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 Xze(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]=Nlt(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 Qze(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 wy(t,s,r){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[s]=r}function k_(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)}}$5.forVisionTasks=function(t,s=!1){return C9("vision",t??k9``,s)},$5.forTextTasks=function(t,s=!1){return C9("text",t??k9``,s)},$5.forGenAiTasks=function(t,s=!1){return C9("genai",t??k9``,s)},$5.forAudioTasks=function(t,s=!1){return C9("audio",t??k9``,s)},$5.isSimdSupported=function(t=!1){return wlt(t)};async function vks(t,s,r,n){return t=await(async(a,o,l,i,d)=>{if(o&&await Yze(o),!self.ModuleFactory||l&&(await Yze(l),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&d&&((o=self.Module).locateFile=d.locateFile,d.mainScriptUrlOrBlob&&(o.mainScriptUrlOrBlob=d.mainScriptUrlOrBlob)),d=await self.ModuleFactory(self.Module||d),self.ModuleFactory=self.Module=void 0,new a(d,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 _0e(t,s){const r=ko(t.baseOptions,Tde,1)||new Tde;typeof s=="string"?(sl(r,2,SO(s)),sl(r,1)):s instanceof Uint8Array&&(sl(r,1,aCe(s,!1)),sl(r,2)),qa(t.baseOptions,0,1,r)}function Jze(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 aa(t,s){t.C=Math.max(t.C,s)}function epe(t,s){t.B=new wp,jf(t.B,2,"PassThroughCalculator"),jc(t.B,"free_memory"),lo(t.B,"free_memory_unused_out"),Bc(s,"free_memory"),qx(s,t.B)}function kA(t,s){jc(t.B,s),lo(t.B,s+"_unused_out")}function tpe(t){t.g.addBoolToStream(!0,"free_memory",t.C)}var Kwe=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 d=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=ko(this.baseOptions,Tde,1))!=null&&a.g()||(o=ko(this.baseOptions,Tde,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=ko(u.baseOptions,Vze,3);if(!f){var y=f=new Vze,_=new Fze;M8(y,4,doe,_)}"delegate"in p&&(p.delegate==="GPU"?(p=f,y=new HNs,M8(p,2,doe,y)):(p=f,y=new Fze,M8(p,4,doe,y))),qa(u.baseOptions,0,3,f)}(this,d),d.modelAssetPath)return fetch(d.modelAssetPath.toString()).then(u=>{if(u.ok)return u.arrayBuffer();throw Error(`Failed to fetch model: ${d.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),_0e(this,"/model.dat"),this.m(),this.L()});if(d.modelAssetBuffer instanceof Uint8Array)_0e(this,d.modelAssetBuffer);else if(d.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}(d.modelAssetBuffer).then(u=>{_0e(this,u),this.m(),this.L()})}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let t;if(this.g.ca(s=>{t=GNs(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,Jze(this)}finishProcessing(){this.g.finishProcessing(),Jze(this)}close(){this.B=void 0,this.g.closeGraph()}};function Wb(t,s){if(!t)throw Error(`Unable to obtain required WebGL resource: ${s}`);return t}Kwe.prototype.close=Kwe.prototype.close;class _ks{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 e9e(t,s,r){const n=t.g;if(r=Wb(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 t9e(t,s){const r=t.g,n=Wb(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(n);const a=Wb(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=Wb(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 _ks(r,n,a,o)}function UCe(t,s){if(t.g){if(s!==t.g)throw Error("Cannot change GL context once initialized")}else t.g=s}function bks(t,s,r,n){return UCe(t,s),t.h||(t.m(),t.D()),r?(t.u||(t.u=t9e(t,!0)),r=t.u):(t.A||(t.A=t9e(t,!1)),r=t.A),s.useProgram(t.h),r.bind(),t.l(),t=n(),r.g.bindVertexArray(null),t}function klt(t,s,r){return UCe(t,s),t=Wb(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 Slt(t,s,r){UCe(t,s),t.B||(t.B=Wb(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 wks(t){var s;(s=t.g)==null||s.bindFramebuffer(t.g.FRAMEBUFFER,null)}var Clt=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=Wb(t.createProgram(),"Failed to create WebGL program"),this.X=e9e(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=e9e(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 Zwe(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=SA(t);var r=VCe(t);if(Slt(r,n,Mlt(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 Zwe(this)}N(){return Mlt(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=SA(this),a=VCe(this);n.activeTexture(n.TEXTURE1),r=klt(a,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);const o=Tlt(this);n.texImage2D(n.TEXTURE_2D,0,o,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),Slt(a,n,r),bks(a,n,!1,()=>{Alt(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),Ywe(this)}),wks(a),Ywe(this)}}t.push(r)}return new Cu(t,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&SA(this).deleteTexture(Rv(this,2)),s9e=-1}};Cu.prototype.close=Cu.prototype.close,Cu.prototype.clone=Cu.prototype.clone,Cu.prototype.getAsWebGLTexture=Cu.prototype.N,Cu.prototype.getAsFloat32Array=Cu.prototype.ia,Cu.prototype.getAsUint8Array=Cu.prototype.ja,Cu.prototype.hasWebGLTexture=Cu.prototype.R,Cu.prototype.hasFloat32Array=Cu.prototype.ka,Cu.prototype.hasUint8Array=Cu.prototype.Fa;var s9e=250;function Qg(...t){return t.map(([s,r])=>({start:s,end:r}))}const jks=function(t){return class extends t{Ja(){this.i._registerModelResourcesGraphService()}}}((r9e=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:jlt()?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?'),wa(this,n||"input_audio",o=>{wa(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){wy(this,"__graph_config__",s=>{t(s)}),wa(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),wa(this,n,l=>{this.i._addAudioToInputStream(this.g,s,r,l,a)})}addGpuBufferToStream(t,s,r){wa(this,s,n=>{const[a,o]=Xze(this,t,n);this.i._addBoundTextureToStream(n,a,o,r)})}addBoolToStream(t,s,r){wa(this,s,n=>{this.i._addBoolToInputStream(t,n,r)})}addDoubleToStream(t,s,r){wa(this,s,n=>{this.i._addDoubleToInputStream(t,n,r)})}addFloatToStream(t,s,r){wa(this,s,n=>{this.i._addFloatToInputStream(t,n,r)})}addIntToStream(t,s,r){wa(this,s,n=>{this.i._addIntToInputStream(t,n,r)})}addUintToStream(t,s,r){wa(this,s,n=>{this.i._addUintToInputStream(t,n,r)})}addStringToStream(t,s,r){wa(this,s,n=>{wa(this,t,a=>{this.i._addStringToInputStream(a,n,r)})})}addStringRecordToStream(t,s,r){wa(this,s,n=>{Qze(this,Object.keys(t),a=>{Qze(this,Object.values(t),o=>{this.i._addFlatHashMapToInputStream(a,o,Object.keys(t).length,n,r)})})})}addProtoToStream(t,s,r,n){wa(this,r,a=>{wa(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){wa(this,t,r=>{this.i._addEmptyPacketToInputStream(r,s)})}addBoolVectorToStream(t,s,r){wa(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){wa(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){wa(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){wa(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){wa(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){wa(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)wa(this,o,l=>{this.i._addStringVectorEntry(a,l)});this.i._addStringVectorToInputStream(a,n,r)})}addBoolToInputSidePacket(t,s){wa(this,s,r=>{this.i._addBoolToInputSidePacket(t,r)})}addDoubleToInputSidePacket(t,s){wa(this,s,r=>{this.i._addDoubleToInputSidePacket(t,r)})}addFloatToInputSidePacket(t,s){wa(this,s,r=>{this.i._addFloatToInputSidePacket(t,r)})}addIntToInputSidePacket(t,s){wa(this,s,r=>{this.i._addIntToInputSidePacket(t,r)})}addUintToInputSidePacket(t,s){wa(this,s,r=>{this.i._addUintToInputSidePacket(t,r)})}addStringToInputSidePacket(t,s){wa(this,s,r=>{wa(this,t,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(t,s,r){wa(this,r,n=>{wa(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){wa(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){wa(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){wa(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){wa(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){wa(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){wa(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)wa(this,a,o=>{this.i._addStringVectorEntry(n,o)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(t,s){wy(this,t,s),wa(this,t,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(t,s){k_(this,t,s),wa(this,t,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(t,s){wy(this,t,s),wa(this,t,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(t,s){k_(this,t,s),wa(this,t,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(t,s){wy(this,t,s),wa(this,t,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(t,s){k_(this,t,s),wa(this,t,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(t,s){wy(this,t,s),wa(this,t,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(t,s){k_(this,t,s),wa(this,t,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(t,s){wy(this,t,s),wa(this,t,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(t,s){k_(this,t,s),wa(this,t,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(t,s){wy(this,t,s),wa(this,t,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(t,s){k_(this,t,s),wa(this,t,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(t,s,r){wy(this,t,s),wa(this,t,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(t,s,r){k_(this,t,s),wa(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?'),wy(this,t,(n,a)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),s(n,a)}),wa(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 r9e{get ga(){return this.i}pa(t,s,r){wa(this,s,n=>{const[a,o]=Xze(this,t,n);this.ga._addBoundTextureAsImageToStream(n,a,o,r)})}Z(t,s){wy(this,t,s),wa(this,t,r=>{this.ga._attachImageListener(r)})}aa(t,s){k_(this,t,s),wa(this,t,r=>{this.ga._attachImageVectorListener(r)})}}));var r9e,Jg=class extends jks{};async function _o(t,s,r){return async function(n,a,o,l){return vks(n,a,o,l)}(t,r.canvas??(jlt()?void 0:document.createElement("canvas")),s,r)}function Elt(t,s,r,n){if(t.U){const o=new Qot;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].");Aa(o,1,(a.left+a.right)/2),Aa(o,2,(a.top+a.bottom)/2),Aa(o,4,a.right-a.left),Aa(o,3,a.bottom-a.top)}else Aa(o,1,.5),Aa(o,2,.5),Aa(o,4,1),Aa(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(Aa(o,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[l,i]=Nlt(s);r=dd(o,3)*i/l,a=dd(o,4)*l/i,Aa(o,4,r),Aa(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 ey(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'.");Elt(t,s,r,t.C+1)}function E0(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'.");Elt(t,s,r,n)}function CA(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 Cu([a],r,!1,t.g.i.canvas,t.P,o,s),n?t.clone():t}var Nf=class extends Kwe{constructor(t,s,r,n){super(t),this.g=t,this.X=s,this.U=r,this.oa=n,this.P=new Clt}l(t,s=!0){if("runningMode"in t&&sl(this.baseOptions,2,uR(!!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()}};Nf.prototype.close=Nf.prototype.close;var Xf=class extends Nf{constructor(t,s){super(new Jg(t,s),"image_in","norm_rect_in",!1),this.j={detections:[]},qa(t=this.h=new Qme,0,1,s=new ad),Aa(this.h,2,.5),Aa(this.h,3,.3)}get baseOptions(){return ko(this.h,ad,1)}set baseOptions(t){qa(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&Aa(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&Aa(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}F(t,s){return this.j={detections:[]},ey(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},E0(this,t,r,s),this.j}m(){var t=new Af;Bc(t,"image_in"),Bc(t,"norm_rect_in"),Lo(t,"detections");const s=new Tf;T0(s,nks,this.h);const r=new wp;jf(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),jc(r,"IMAGE:image_in"),jc(r,"NORM_RECT:norm_rect_in"),lo(r,"DETECTIONS:detections"),r.o(s),qx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Zot(o),this.j.detections.push(blt(n));aa(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Xf.prototype.detectForVideo=Xf.prototype.G,Xf.prototype.detect=Xf.prototype.F,Xf.prototype.setOptions=Xf.prototype.o,Xf.createFromModelPath=async function(t,s){return _o(Xf,t,{baseOptions:{modelAssetPath:s}})},Xf.createFromModelBuffer=function(t,s){return _o(Xf,t,{baseOptions:{modelAssetBuffer:s}})},Xf.createFromOptions=function(t,s){return _o(Xf,t,s)};var HCe=Qg([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]),GCe=Qg([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]),WCe=Qg([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Plt=Qg([474,475],[475,476],[476,477],[477,474]),KCe=Qg([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]),ZCe=Qg([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Ilt=Qg([469,470],[470,471],[471,472],[472,469]),YCe=Qg([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]),Llt=[...HCe,...GCe,...WCe,...KCe,...ZCe,...YCe],Dlt=Qg([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 n9e(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var Uc=class extends Nf{constructor(t,s){super(new Jg(t,s),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,qa(t=this.h=new rlt,0,1,s=new ad),this.A=new slt,qa(this.h,0,3,this.A),this.u=new Qme,qa(this.h,0,2,this.u),j1(this.u,4,1),Aa(this.u,2,.5),Aa(this.A,2,.5),Aa(this.h,4,.5)}get baseOptions(){return ko(this.h,ad,1)}set baseOptions(t){qa(this.h,0,1,t)}o(t){return"numFaces"in t&&j1(this.u,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&Aa(this.u,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&Aa(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&Aa(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 n9e(this),ey(this,t,s),this.j}G(t,s,r){return n9e(this),E0(this,t,r,s),this.j}m(){var t=new Af;Bc(t,"image_in"),Bc(t,"norm_rect"),Lo(t,"face_landmarks");const s=new Tf;T0(s,iks,this.h);const r=new wp;jf(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),jc(r,"IMAGE:image_in"),jc(r,"NORM_RECT:norm_rect"),lo(r,"NORM_LANDMARKS:face_landmarks"),r.o(s),qx(t,r),this.g.attachProtoVectorListener("face_landmarks",(n,a)=>{for(const o of n)n=TO(o),this.j.faceLandmarks.push(Jme(n));aa(this,a)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{aa(this,n)}),this.outputFaceBlendshapes&&(Lo(t,"blendshapes"),lo(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,a)=>{if(this.outputFaceBlendshapes)for(const o of n)n=Xme(o),this.j.faceBlendshapes.push(qCe(n.g()??[]));aa(this,a)}),this.g.attachEmptyPacketListener("blendshapes",n=>{aa(this,n)})),this.outputFacialTransformationMatrixes&&(Lo(t,"face_geometry"),lo(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,a)=>{if(this.outputFacialTransformationMatrixes)for(const o of n)(n=ko(n=aks(o),YNs,2))&&this.j.facialTransformationMatrixes.push({rows:yx(n,1)??0??0,columns:yx(n,2)??0??0,data:P4(n,3,Hy,E4()).slice()??[]});aa(this,a)}),this.g.attachEmptyPacketListener("face_geometry",n=>{aa(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Uc.prototype.detectForVideo=Uc.prototype.G,Uc.prototype.detect=Uc.prototype.F,Uc.prototype.setOptions=Uc.prototype.o,Uc.createFromModelPath=function(t,s){return _o(Uc,t,{baseOptions:{modelAssetPath:s}})},Uc.createFromModelBuffer=function(t,s){return _o(Uc,t,{baseOptions:{modelAssetBuffer:s}})},Uc.createFromOptions=function(t,s){return _o(Uc,t,s)},Uc.FACE_LANDMARKS_LIPS=HCe,Uc.FACE_LANDMARKS_LEFT_EYE=GCe,Uc.FACE_LANDMARKS_LEFT_EYEBROW=WCe,Uc.FACE_LANDMARKS_LEFT_IRIS=Plt,Uc.FACE_LANDMARKS_RIGHT_EYE=KCe,Uc.FACE_LANDMARKS_RIGHT_EYEBROW=ZCe,Uc.FACE_LANDMARKS_RIGHT_IRIS=Ilt,Uc.FACE_LANDMARKS_FACE_OVAL=YCe,Uc.FACE_LANDMARKS_CONTOURS=Llt,Uc.FACE_LANDMARKS_TESSELATION=Dlt;var XCe=Qg([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 a9e(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function i9e(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 o9e(t,s=!0){const r=[];for(const a of t){var n=Xme(a);t=[];for(const o of n.g())n=s&&yx(o,1)!=null?yx(o,1)??0:-1,t.push({score:dd(o,2)??0,index:n,categoryName:mh(Oc(o,3))??""??"",displayName:mh(Oc(o,4))??""??""});r.push(t)}return r}var Fp=class extends Nf{constructor(t,s){super(new Jg(t,s),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],qa(t=this.j=new ilt,0,1,s=new ad),this.u=new FCe,qa(this.j,0,2,this.u),this.D=new OCe,qa(this.u,0,3,this.D),this.A=new alt,qa(this.u,0,2,this.A),this.h=new oks,qa(this.j,0,3,this.h),Aa(this.A,2,.5),Aa(this.u,4,.5),Aa(this.D,2,.5)}get baseOptions(){return ko(this.j,ad,1)}set baseOptions(t){qa(this.j,0,1,t)}o(t){var a,o,l,i;if(j1(this.A,3,t.numHands??1),"minHandDetectionConfidence"in t&&Aa(this.A,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Aa(this.u,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Aa(this.D,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var s=new A5,r=s,n=Wwe(t.cannedGesturesClassifierOptions,(a=ko(this.h,A5,3))==null?void 0:a.l());qa(r,0,2,n),qa(this.h,0,3,s)}else t.cannedGesturesClassifierOptions===void 0&&((o=ko(this.h,A5,3))==null||o.g());return t.customGesturesClassifierOptions?(qa(r=s=new A5,0,2,n=Wwe(t.customGesturesClassifierOptions,(l=ko(this.h,A5,4))==null?void 0:l.l())),qa(this.h,0,4,s)):t.customGesturesClassifierOptions===void 0&&((i=ko(this.h,A5,4))==null||i.g()),this.l(t)}Ha(t,s){return a9e(this),ey(this,t,s),i9e(this)}Ia(t,s,r){return a9e(this),E0(this,t,r,s),i9e(this)}m(){var t=new Af;Bc(t,"image_in"),Bc(t,"norm_rect"),Lo(t,"hand_gestures"),Lo(t,"hand_landmarks"),Lo(t,"world_hand_landmarks"),Lo(t,"handedness");const s=new Tf;T0(s,lks,this.j);const r=new wp;jf(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),jc(r,"IMAGE:image_in"),jc(r,"NORM_RECT:norm_rect"),lo(r,"HAND_GESTURES:hand_gestures"),lo(r,"LANDMARKS:hand_landmarks"),lo(r,"WORLD_LANDMARKS:world_hand_landmarks"),lo(r,"HANDEDNESS:handedness"),r.o(s),qx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n){n=TO(o);const l=[];for(const i of w1(n,Xot,1))l.push({x:dd(i,1)??0,y:dd(i,2)??0,z:dd(i,3)??0,visibility:dd(i,4)??0});this.landmarks.push(l)}aa(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{aa(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n){n=iT(o);const l=[];for(const i of w1(n,Yot,1))l.push({x:dd(i,1)??0,y:dd(i,2)??0,z:dd(i,3)??0,visibility:dd(i,4)??0});this.worldLandmarks.push(l)}aa(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{aa(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,a)=>{this.gestures.push(...o9e(n,!1)),aa(this,a)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{aa(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{this.handedness.push(...o9e(n)),aa(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function l9e(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Fp.prototype.recognizeForVideo=Fp.prototype.Ia,Fp.prototype.recognize=Fp.prototype.Ha,Fp.prototype.setOptions=Fp.prototype.o,Fp.createFromModelPath=function(t,s){return _o(Fp,t,{baseOptions:{modelAssetPath:s}})},Fp.createFromModelBuffer=function(t,s){return _o(Fp,t,{baseOptions:{modelAssetBuffer:s}})},Fp.createFromOptions=function(t,s){return _o(Fp,t,s)},Fp.HAND_CONNECTIONS=XCe;var zp=class extends Nf{constructor(t,s){super(new Jg(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],qa(t=this.h=new FCe,0,1,s=new ad),this.u=new OCe,qa(this.h,0,3,this.u),this.j=new alt,qa(this.h,0,2,this.j),j1(this.j,3,1),Aa(this.j,2,.5),Aa(this.u,2,.5),Aa(this.h,4,.5)}get baseOptions(){return ko(this.h,ad,1)}set baseOptions(t){qa(this.h,0,1,t)}o(t){return"numHands"in t&&j1(this.j,3,t.numHands??1),"minHandDetectionConfidence"in t&&Aa(this.j,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Aa(this.h,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Aa(this.u,2,t.minHandPresenceConfidence??.5),this.l(t)}F(t,s){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ey(this,t,s),l9e(this)}G(t,s,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],E0(this,t,r,s),l9e(this)}m(){var t=new Af;Bc(t,"image_in"),Bc(t,"norm_rect"),Lo(t,"hand_landmarks"),Lo(t,"world_hand_landmarks"),Lo(t,"handedness");const s=new Tf;T0(s,cks,this.h);const r=new wp;jf(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),jc(r,"IMAGE:image_in"),jc(r,"NORM_RECT:norm_rect"),lo(r,"LANDMARKS:hand_landmarks"),lo(r,"WORLD_LANDMARKS:world_hand_landmarks"),lo(r,"HANDEDNESS:handedness"),r.o(s),qx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n)n=TO(o),this.landmarks.push(Jme(n));aa(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{aa(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n)n=iT(o),this.worldLandmarks.push(A8(n));aa(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{aa(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{var o=this.handedness,l=o.push;const i=[];for(const d of n){n=Xme(d);const u=[];for(const p of n.g())u.push({score:dd(p,2)??0,index:yx(p,1)??0??-1,categoryName:mh(Oc(p,3))??""??"",displayName:mh(Oc(p,4))??""??""});i.push(u)}l.call(o,...i),aa(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};zp.prototype.detectForVideo=zp.prototype.G,zp.prototype.detect=zp.prototype.F,zp.prototype.setOptions=zp.prototype.o,zp.createFromModelPath=function(t,s){return _o(zp,t,{baseOptions:{modelAssetPath:s}})},zp.createFromModelBuffer=function(t,s){return _o(zp,t,{baseOptions:{modelAssetBuffer:s}})},zp.createFromOptions=function(t,s){return _o(zp,t,s)},zp.HAND_CONNECTIONS=XCe;var Rlt=Qg([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 c9e(t){t.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function d9e(t){try{if(!t.D)return t.h;t.D(t.h)}finally{tpe(t)}}function T9(t,s){t=TO(t),s.push(Jme(t))}var cc=class extends Nf{constructor(t,s){super(new Jg(t,s),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,qa(t=this.j=new ult,0,1,s=new ad),this.I=new OCe,qa(this.j,0,2,this.I),this.W=new dks,qa(this.j,0,3,this.W),this.u=new Qme,qa(this.j,0,4,this.u),this.O=new slt,qa(this.j,0,5,this.O),this.A=new clt,qa(this.j,0,6,this.A),this.M=new dlt,qa(this.j,0,7,this.M),Aa(this.u,2,.5),Aa(this.u,3,.3),Aa(this.O,2,.5),Aa(this.A,2,.5),Aa(this.A,3,.3),Aa(this.M,2,.5),Aa(this.I,2,.5)}get baseOptions(){return ko(this.j,ad,1)}set baseOptions(t){qa(this.j,0,1,t)}o(t){return"minFaceDetectionConfidence"in t&&Aa(this.u,2,t.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in t&&Aa(this.u,3,t.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in t&&Aa(this.O,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"minPoseDetectionConfidence"in t&&Aa(this.A,2,t.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in t&&Aa(this.A,3,t.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in t&&Aa(this.M,2,t.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in t&&(this.outputPoseSegmentationMasks=!!t.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in t&&Aa(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,c9e(this),ey(this,t,n),d9e(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:n,c9e(this),E0(this,t,a,s),d9e(this)}m(){var t=new Af;Bc(t,"input_frames_image"),Lo(t,"pose_landmarks"),Lo(t,"pose_world_landmarks"),Lo(t,"face_landmarks"),Lo(t,"left_hand_landmarks"),Lo(t,"left_hand_world_landmarks"),Lo(t,"right_hand_landmarks"),Lo(t,"right_hand_world_landmarks");const s=new Tf,r=new Lze;jf(r,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),function(a,o){if(o!=null)if(Array.isArray(o))sl(a,2,zme(o,0,hR));else{if(!(typeof o=="string"||o instanceof d0||rCe(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");G_(a,2,aCe(o,!1),xC())}}(r,this.j.g());const n=new wp;jf(n,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),vCe(n,8,Lze,r),jc(n,"IMAGE:input_frames_image"),lo(n,"POSE_LANDMARKS:pose_landmarks"),lo(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),lo(n,"FACE_LANDMARKS:face_landmarks"),lo(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),lo(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),lo(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),lo(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(s),qx(t,n),epe(this,t),this.g.attachProtoListener("pose_landmarks",(a,o)=>{T9(a,this.h.poseLandmarks),aa(this,o)}),this.g.attachEmptyPacketListener("pose_landmarks",a=>{aa(this,a)}),this.g.attachProtoListener("pose_world_landmarks",(a,o)=>{var l=this.h.poseWorldLandmarks;a=iT(a),l.push(A8(a)),aa(this,o)}),this.g.attachEmptyPacketListener("pose_world_landmarks",a=>{aa(this,a)}),this.outputPoseSegmentationMasks&&(lo(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),kA(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(a,o)=>{this.h.poseSegmentationMasks=[CA(this,a,!0,!this.D)],aa(this,o)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",a=>{this.h.poseSegmentationMasks=[],aa(this,a)})),this.g.attachProtoListener("face_landmarks",(a,o)=>{T9(a,this.h.faceLandmarks),aa(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",a=>{aa(this,a)}),this.outputFaceBlendshapes&&(Lo(t,"extra_blendshapes"),lo(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(a,o)=>{var l=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(a=Xme(a),l.push(qCe(a.g()??[]))),aa(this,o)}),this.g.attachEmptyPacketListener("extra_blendshapes",a=>{aa(this,a)})),this.g.attachProtoListener("left_hand_landmarks",(a,o)=>{T9(a,this.h.leftHandLandmarks),aa(this,o)}),this.g.attachEmptyPacketListener("left_hand_landmarks",a=>{aa(this,a)}),this.g.attachProtoListener("left_hand_world_landmarks",(a,o)=>{var l=this.h.leftHandWorldLandmarks;a=iT(a),l.push(A8(a)),aa(this,o)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",a=>{aa(this,a)}),this.g.attachProtoListener("right_hand_landmarks",(a,o)=>{T9(a,this.h.rightHandLandmarks),aa(this,o)}),this.g.attachEmptyPacketListener("right_hand_landmarks",a=>{aa(this,a)}),this.g.attachProtoListener("right_hand_world_landmarks",(a,o)=>{var l=this.h.rightHandWorldLandmarks;a=iT(a),l.push(A8(a)),aa(this,o)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",a=>{aa(this,a)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};cc.prototype.detectForVideo=cc.prototype.G,cc.prototype.detect=cc.prototype.F,cc.prototype.setOptions=cc.prototype.o,cc.createFromModelPath=function(t,s){return _o(cc,t,{baseOptions:{modelAssetPath:s}})},cc.createFromModelBuffer=function(t,s){return _o(cc,t,{baseOptions:{modelAssetBuffer:s}})},cc.createFromOptions=function(t,s){return _o(cc,t,s)},cc.HAND_CONNECTIONS=XCe,cc.POSE_CONNECTIONS=Rlt,cc.FACE_LANDMARKS_LIPS=HCe,cc.FACE_LANDMARKS_LEFT_EYE=GCe,cc.FACE_LANDMARKS_LEFT_EYEBROW=WCe,cc.FACE_LANDMARKS_LEFT_IRIS=Plt,cc.FACE_LANDMARKS_RIGHT_EYE=KCe,cc.FACE_LANDMARKS_RIGHT_EYEBROW=ZCe,cc.FACE_LANDMARKS_RIGHT_IRIS=Ilt,cc.FACE_LANDMARKS_FACE_OVAL=YCe,cc.FACE_LANDMARKS_CONTOURS=Llt,cc.FACE_LANDMARKS_TESSELATION=Dlt;var Qf=class extends Nf{constructor(t,s){super(new Jg(t,s),"input_image","norm_rect",!0),this.j={classifications:[]},qa(t=this.h=new hlt,0,1,s=new ad)}get baseOptions(){return ko(this.h,ad,1)}set baseOptions(t){qa(this.h,0,1,t)}o(t){return qa(this.h,0,2,Wwe(t,ko(this.h,DCe,2))),this.l(t)}sa(t,s){return this.j={classifications:[]},ey(this,t,s),this.j}ta(t,s,r){return this.j={classifications:[]},E0(this,t,r,s),this.j}m(){var t=new Af;Bc(t,"input_image"),Bc(t,"norm_rect"),Lo(t,"classifications");const s=new Tf;T0(s,uks,this.h);const r=new wp;jf(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),jc(r,"IMAGE:input_image"),jc(r,"NORM_RECT:norm_rect"),lo(r,"CLASSIFICATIONS:classifications"),r.o(s),qx(t,r),this.g.attachProtoListener("classifications",(n,a)=>{this.j=gks(JNs(n)),aa(this,a)}),this.g.attachEmptyPacketListener("classifications",n=>{aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Qf.prototype.classifyForVideo=Qf.prototype.ta,Qf.prototype.classify=Qf.prototype.sa,Qf.prototype.setOptions=Qf.prototype.o,Qf.createFromModelPath=function(t,s){return _o(Qf,t,{baseOptions:{modelAssetPath:s}})},Qf.createFromModelBuffer=function(t,s){return _o(Qf,t,{baseOptions:{modelAssetBuffer:s}})},Qf.createFromOptions=function(t,s){return _o(Qf,t,s)};var Bp=class extends Nf{constructor(t,s){super(new Jg(t,s),"image_in","norm_rect",!0),this.h=new mlt,this.embeddings={embeddings:[]},qa(t=this.h,0,1,s=new ad)}get baseOptions(){return ko(this.h,ad,1)}set baseOptions(t){qa(this.h,0,1,t)}o(t){var s=this.h,r=ko(this.h,Uze,2);return r=r?r.clone():new Uze,t.l2Normalize!==void 0?sl(r,1,uR(t.l2Normalize)):"l2Normalize"in t&&sl(r,1),t.quantize!==void 0?sl(r,2,uR(t.quantize)):"quantize"in t&&sl(r,2),qa(s,0,2,r),this.l(t)}za(t,s){return ey(this,t,s),this.embeddings}Aa(t,s,r){return E0(this,t,r,s),this.embeddings}m(){var t=new Af;Bc(t,"image_in"),Bc(t,"norm_rect"),Lo(t,"embeddings_out");const s=new Tf;T0(s,hks,this.h);const r=new wp;jf(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),jc(r,"IMAGE:image_in"),jc(r,"NORM_RECT:norm_rect"),lo(r,"EMBEDDINGS:embeddings_out"),r.o(s),qx(t,r),this.g.attachProtoListener("embeddings_out",(n,a)=>{n=sks(n),this.embeddings=function(o){return{embeddings:w1(o,tks,1).map(l=>{var u,p;const i={headIndex:yx(l,3)??0??-1,headName:mh(Oc(l,4))??""??""};var d=l.v;return dot(d,0|d[ga],qze,f0e(l,1))!==void 0?(l=P4(l=ko(l,qze,f0e(l,1),void 0),1,Hy,E4()),i.floatEmbedding=l.slice()):(d=new Uint8Array(0),i.quantizedEmbedding=((p=(u=ko(l,eks,f0e(l,2),void 0))==null?void 0:u.na())==null?void 0:p.h())??d),i}),timestampMs:_lt(Oc(o,2,void 0,void 0,jde)??aot)}}(n),aa(this,a)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Bp.cosineSimilarity=function(t,s){if(t.floatEmbedding&&s.floatEmbedding)t=Zze(t.floatEmbedding,s.floatEmbedding);else{if(!t.quantizedEmbedding||!s.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=Zze(Kze(t.quantizedEmbedding),Kze(s.quantizedEmbedding))}return t},Bp.prototype.embedForVideo=Bp.prototype.Aa,Bp.prototype.embed=Bp.prototype.za,Bp.prototype.setOptions=Bp.prototype.o,Bp.createFromModelPath=function(t,s){return _o(Bp,t,{baseOptions:{modelAssetPath:s}})},Bp.createFromModelBuffer=function(t,s){return _o(Bp,t,{baseOptions:{modelAssetBuffer:s}})},Bp.createFromOptions=function(t,s){return _o(Bp,t,s)};var Xwe=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 Nks(t){var r,n;const s=function(a){return w1(a,wp,1)}(t.ca()).filter(a=>(mh(Oc(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=ko(s[0],Tf,7))==null?void 0:r.j())==null?void 0:n.g())??new Map).forEach((a,o)=>{t.u[Number(o)]=mh(Oc(a,1))??""})}function u9e(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function h9e(t){try{const s=new Xwe(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return s;t.j(s)}finally{tpe(t)}}Xwe.prototype.close=Xwe.prototype.close;var lm=class extends Nf{constructor(t,s){super(new Jg(t,s),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new $Ce,this.A=new plt,qa(this.h,0,3,this.A),qa(t=this.h,0,1,s=new ad)}get baseOptions(){return ko(this.h,ad,1)}set baseOptions(t){qa(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?sl(this.h,2,SO(t.displayNamesLocale)):"displayNamesLocale"in t&&sl(this.h,2),"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}L(){Nks(this)}segment(t,s,r){const n=typeof s!="function"?s:{};return this.j=typeof s=="function"?s:r,u9e(this),ey(this,t,n),h9e(this)}La(t,s,r,n){const a=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,u9e(this),E0(this,t,a,s),h9e(this)}Da(){return this.u}m(){var t=new Af;Bc(t,"image_in"),Bc(t,"norm_rect");const s=new Tf;T0(s,xlt,this.h);const r=new wp;jf(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),jc(r,"IMAGE:image_in"),jc(r,"NORM_RECT:norm_rect"),r.o(s),qx(t,r),epe(this,t),this.outputConfidenceMasks&&(Lo(t,"confidence_masks"),lo(r,"CONFIDENCE_MASKS:confidence_masks"),kA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>CA(this,o,!0,!this.j)),aa(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],aa(this,n)})),this.outputCategoryMask&&(Lo(t,"category_mask"),lo(r,"CATEGORY_MASK:category_mask"),kA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=CA(this,n,!1,!this.j),aa(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,aa(this,n)})),Lo(t,"quality_scores"),lo(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,aa(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};lm.prototype.getLabels=lm.prototype.Da,lm.prototype.segmentForVideo=lm.prototype.La,lm.prototype.segment=lm.prototype.segment,lm.prototype.setOptions=lm.prototype.o,lm.createFromModelPath=function(t,s){return _o(lm,t,{baseOptions:{modelAssetPath:s}})},lm.createFromModelBuffer=function(t,s){return _o(lm,t,{baseOptions:{modelAssetBuffer:s}})},lm.createFromOptions=function(t,s){return _o(lm,t,s)};var Qwe=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()}};Qwe.prototype.close=Qwe.prototype.close;var jy=class extends Nf{constructor(t,s){super(new Jg(t,s),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new $Ce,this.u=new plt,qa(this.h,0,3,this.u),qa(t=this.h,0,1,s=new ad)}get baseOptions(){return ko(this.h,ad,1)}set baseOptions(t){qa(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 glt,s.keypoint&&s.scribble)throw Error("Cannot provide both keypoint and scribble.");if(s.keypoint){var o=new v0e;G_(o,3,uR(!0),!1),G_(o,1,U6(s.keypoint.x),0),G_(o,2,U6(s.keypoint.y),0),M8(n,1,Gwe,o)}else{if(!s.scribble)throw Error("Must provide either a keypoint or a scribble.");{const i=new pks;for(o of s.scribble)G_(s=new v0e,3,uR(!0),!1),G_(s,1,U6(o.x),0),G_(s,2,U6(o.y),0),vCe(i,1,v0e,s);M8(n,2,Gwe,i)}}this.g.addProtoToStream(n.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),ey(this,t,a);e:{try{const i=new Qwe(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=i;break e}this.j(i)}finally{tpe(this)}l=void 0}return l}m(){var t=new Af;Bc(t,"image_in"),Bc(t,"roi_in"),Bc(t,"norm_rect_in");const s=new Tf;T0(s,xlt,this.h);const r=new wp;jf(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),jc(r,"IMAGE:image_in"),jc(r,"ROI:roi_in"),jc(r,"NORM_RECT:norm_rect_in"),r.o(s),qx(t,r),epe(this,t),this.outputConfidenceMasks&&(Lo(t,"confidence_masks"),lo(r,"CONFIDENCE_MASKS:confidence_masks"),kA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>CA(this,o,!0,!this.j)),aa(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],aa(this,n)})),this.outputCategoryMask&&(Lo(t,"category_mask"),lo(r,"CATEGORY_MASK:category_mask"),kA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=CA(this,n,!1,!this.j),aa(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,aa(this,n)})),Lo(t,"quality_scores"),lo(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,aa(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};jy.prototype.segment=jy.prototype.segment,jy.prototype.setOptions=jy.prototype.o,jy.createFromModelPath=function(t,s){return _o(jy,t,{baseOptions:{modelAssetPath:s}})},jy.createFromModelBuffer=function(t,s){return _o(jy,t,{baseOptions:{modelAssetBuffer:s}})},jy.createFromOptions=function(t,s){return _o(jy,t,s)};var Jf=class extends Nf{constructor(t,s){super(new Jg(t,s),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},qa(t=this.h=new ylt,0,1,s=new ad)}get baseOptions(){return ko(this.h,ad,1)}set baseOptions(t){qa(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?sl(this.h,2,SO(t.displayNamesLocale)):"displayNamesLocale"in t&&sl(this.h,2),t.maxResults!==void 0?j1(this.h,3,t.maxResults):"maxResults"in t&&sl(this.h,3),t.scoreThreshold!==void 0?Aa(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&sl(this.h,4),t.categoryAllowlist!==void 0?kde(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&sl(this.h,5),t.categoryDenylist!==void 0?kde(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&sl(this.h,6),this.l(t)}F(t,s){return this.j={detections:[]},ey(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},E0(this,t,r,s),this.j}m(){var t=new Af;Bc(t,"input_frame_gpu"),Bc(t,"norm_rect"),Lo(t,"detections");const s=new Tf;T0(s,fks,this.h);const r=new wp;jf(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),jc(r,"IMAGE:input_frame_gpu"),jc(r,"NORM_RECT:norm_rect"),lo(r,"DETECTIONS:detections"),r.o(s),qx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Zot(o),this.j.detections.push(blt(n));aa(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Jf.prototype.detectForVideo=Jf.prototype.G,Jf.prototype.detect=Jf.prototype.F,Jf.prototype.setOptions=Jf.prototype.o,Jf.createFromModelPath=async function(t,s){return _o(Jf,t,{baseOptions:{modelAssetPath:s}})},Jf.createFromModelBuffer=function(t,s){return _o(Jf,t,{baseOptions:{modelAssetBuffer:s}})},Jf.createFromOptions=function(t,s){return _o(Jf,t,s)};var Jwe=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 m9e(t){t.landmarks=[],t.worldLandmarks=[],t.segmentationMasks=void 0}function p9e(t){try{const s=new Jwe(t.landmarks,t.worldLandmarks,t.segmentationMasks);if(!t.u)return s;t.u(s)}finally{tpe(t)}}Jwe.prototype.close=Jwe.prototype.close;var $p=class extends Nf{constructor(t,s){super(new Jg(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,qa(t=this.h=new vlt,0,1,s=new ad),this.A=new dlt,qa(this.h,0,3,this.A),this.j=new clt,qa(this.h,0,2,this.j),j1(this.j,4,1),Aa(this.j,2,.5),Aa(this.A,2,.5),Aa(this.h,4,.5)}get baseOptions(){return ko(this.h,ad,1)}set baseOptions(t){qa(this.h,0,1,t)}o(t){return"numPoses"in t&&j1(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&Aa(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&Aa(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&Aa(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,m9e(this),ey(this,t,n),p9e(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:n,m9e(this),E0(this,t,a,s),p9e(this)}m(){var t=new Af;Bc(t,"image_in"),Bc(t,"norm_rect"),Lo(t,"normalized_landmarks"),Lo(t,"world_landmarks"),Lo(t,"segmentation_masks");const s=new Tf;T0(s,xks,this.h);const r=new wp;jf(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),jc(r,"IMAGE:image_in"),jc(r,"NORM_RECT:norm_rect"),lo(r,"NORM_LANDMARKS:normalized_landmarks"),lo(r,"WORLD_LANDMARKS:world_landmarks"),r.o(s),qx(t,r),epe(this,t),this.g.attachProtoVectorListener("normalized_landmarks",(n,a)=>{this.landmarks=[];for(const o of n)n=TO(o),this.landmarks.push(Jme(n));aa(this,a)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],aa(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,a)=>{this.worldLandmarks=[];for(const o of n)n=iT(o),this.worldLandmarks.push(A8(n));aa(this,a)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],aa(this,n)}),this.outputSegmentationMasks&&(lo(r,"SEGMENTATION_MASK:segmentation_masks"),kA(this,"segmentation_masks"),this.g.aa("segmentation_masks",(n,a)=>{this.segmentationMasks=n.map(o=>CA(this,o,!0,!this.u)),aa(this,a)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],aa(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 _o($p,t,{baseOptions:{modelAssetPath:s}})},$p.createFromModelBuffer=function(t,s){return _o($p,t,{baseOptions:{modelAssetBuffer:s}})},$p.createFromOptions=function(t,s){return _o($p,t,s)},$p.POSE_CONNECTIONS=Rlt;let I4=null,V6=null;async function kks(){return I4||V6||(V6=(async()=>{const t=await $5.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm");return I4=await lm.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}),I4})(),V6)}function Sks(t,s,r,n,a){const o=new Float32Array(t.length);for(let l=0;l=0&&(i-=t[d+p]);const y=Math.min(f,r-1)-Math.max(p+1,0)+1;o[d+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[d*r+l]=i/f}}}function Cks(){I4&&(I4.close(),I4=null,V6=null)}function Mks(t,s){const r=k.useRef(null),n=k.useRef(null),a=k.useRef(null),o=k.useRef(null),l=k.useRef(0),i=k.useRef(0),[d,u]=k.useState(null),[p,f]=k.useState(!1),[y,_]=k.useState(null),b=s.type!=="none"&&t!==null;return k.useEffect(()=>{if(s.type==="image"&&s.imageUrl){const N=new Image;N.crossOrigin="anonymous",N.src=s.imageUrl,N.onload=()=>{o.current=N}}else o.current=null},[s.type,s.imageUrl]),k.useEffect(()=>{if(!b||!t){a.current&&(a.current.srcObject=null,a.current=null);return}const N=document.createElement("video");return N.srcObject=t,N.muted=!0,N.playsInline=!0,N.autoplay=!0,N.play().catch(()=>{}),a.current=N,()=>{N.srcObject=null,a.current=null}},[b,t]),k.useEffect(()=>{if(!b){u(null),_(null);return}let N=!1;return(async()=>{f(!0),_(null);try{const S=await kks();if(N)return;f(!1);const C=a.current;if(!C||(await new Promise(we=>{if(C.videoWidth>0)return we();C.onloadedmetadata=()=>we(),setTimeout(we,2e3)}),N))return;const A=C.videoWidth||640,I=C.videoHeight||480,L=r.current;if(!L)return;L.width=A,L.height=I;const O=L.getContext("2d",{willReadFrequently:!1});n.current||(n.current=document.createElement("canvas"));const U=n.current;U.width=A,U.height=I;const q=U.getContext("2d",{willReadFrequently:!0}),$=document.createElement("canvas");$.width=A,$.height=I;const V=$.getContext("2d"),ee=L.captureStream(30);((t==null?void 0:t.getAudioTracks())||[]).forEach(we=>ee.addTrack(we)),N||u(ee);const J=s.blurRadius??15,Y=s.mirror??!1,ce=new Float32Array(A*I),ae=new Float32Array(A*I),ie=new Float32Array(A*I);let le=!1;const fe=4,xe=.6,he=()=>{if(N||!a.current)return;const we=performance.now();if(we-i.current<30){l.current=requestAnimationFrame(he);return}i.current=we;const Ne=a.current;if(Ne.readyState<2){l.current=requestAnimationFrame(he);return}try{const Te=S.segmentForVideo(Ne,we).confidenceMasks;if(Te&&Te.length>0){ae.fill(0);for(let Ee=1;EeRe?(ct=Ee.height*Re,Ue=(Ee.width-ct)/2):(pe=Ee.width/Re,ye=(Ee.height-pe)/2),O.drawImage(Ee,Ue,ye,ct,pe,0,0,A,I)}q.clearRect(0,0,A,I),q.drawImage(Ne,0,0,A,I);const Ae=q.getImageData(0,0,A,I),ze=Ae.data;for(let Ee=0;Ee{N=!0,l.current&&cancelAnimationFrame(l.current),u(null)}},[b,s.type,s.blurRadius,s.imageUrl,t]),k.useEffect(()=>()=>{Cks()},[]),{canvasRef:r,compositedStream:d,isLoading:p,isActive:b,error:y}}function AO({maxDurationSeconds:t=600,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=k.useRef(null),i=k.useRef(null),d=k.useRef(null),[u,p]=k.useState(null),f=k.useRef([]),y=k.useRef(null),_=k.useRef(null),b=k.useRef(null),N=k.useRef(null),w=bE(),[S,C]=k.useState("camera"),A=k.useRef(null),I=k.useRef(null),L=k.useRef(null),O=k.useRef(null),U=k.useRef(null),[q,$]=k.useState(!0),[V,ee]=k.useState(!0),[Z,J]=k.useState(null),[Y,ce]=k.useState(!1),[ae,ie]=k.useState(!1),[le,fe]=k.useState(null),[xe,he]=k.useState(null),[we,Ne]=k.useState(0),[Ve,Te]=k.useState("user"),[Ae,ze]=k.useState(0),[Ee,ve]=k.useState(!1),[Re,Ue]=k.useState(!0),[ye,ct]=k.useState(null),[pe,Ge]=k.useState(!1),[tt,st]=k.useState(null),Ce=k.useRef(null),[et,Ct]=k.useState(()=>{try{const ir=localStorage.getItem("video-bg-config");if(ir)return JSON.parse(ir)}catch{}return{type:"none"}});k.useEffect(()=>{try{localStorage.setItem("video-bg-config",JSON.stringify(et))}catch{}},[et]);const{canvasRef:Ot,compositedStream:ut,isLoading:Oe,isActive:Xe}=Mks(u,et),at=k.useRef(r);at.current=r;const Ke=k.useCallback(ir=>{$(ir)},[]),He=k.useRef(q),gt=k.useCallback(()=>{L.current&&(cancelAnimationFrame(L.current),L.current=null),A.current&&(A.current.getTracks().forEach(ir=>ir.stop()),A.current=null),O.current&&(O.current.getTracks().forEach(ir=>ir.stop()),O.current=null),U.current&&(U.current.srcObject=null,U.current=null)},[]),Mt=k.useCallback(async()=>{var ir;try{const or=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080}},audio:!0});A.current=or;let hr=null;try{hr=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:320},height:{ideal:240}},audio:{echoCancellation:!0,noiseSuppression:!0}})}catch{console.warn("[VideoRecorder] No webcam for PiP overlay")}let an=null;if(!hr)try{an=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{console.warn("[VideoRecorder] No mic audio")}const Gr=or.getVideoTracks()[0],Va=Gr.getSettings(),$a=Va.width||1920,Xt=Va.height||1080,Qa=document.createElement("canvas");Qa.width=$a,Qa.height=Xt,I.current=Qa;const Cr=Qa.getContext("2d");let Fn=null;hr&&(Fn=document.createElement("video"),Fn.srcObject=hr,Fn.muted=!0,Fn.playsInline=!0,Fn.autoplay=!0,await Fn.play(),U.current=Fn);const Kt=document.createElement("video");Kt.srcObject=or,Kt.muted=!0,Kt.playsInline=!0,Kt.autoplay=!0,await Kt.play();const Mr=()=>{if(Cr.drawImage(Kt,0,0,$a,Xt),Fn&&Fn.readyState>=2){const De=Math.round($a*.2),Ze=Math.round(De*(Fn.videoHeight/Fn.videoWidth||.75)),xt=$a-De-20,_t=Xt-Ze-20,Pt=12;Cr.save(),Cr.beginPath(),Cr.moveTo(xt+Pt,_t),Cr.lineTo(xt+De-Pt,_t),Cr.quadraticCurveTo(xt+De,_t,xt+De,_t+Pt),Cr.lineTo(xt+De,_t+Ze-Pt),Cr.quadraticCurveTo(xt+De,_t+Ze,xt+De-Pt,_t+Ze),Cr.lineTo(xt+Pt,_t+Ze),Cr.quadraticCurveTo(xt,_t+Ze,xt,_t+Ze-Pt),Cr.lineTo(xt,_t+Pt),Cr.quadraticCurveTo(xt,_t,xt+Pt,_t),Cr.closePath(),Cr.clip(),Cr.translate(xt+De,_t),Cr.scale(-1,1),Cr.drawImage(Fn,0,0,De,Ze),Cr.restore(),Cr.strokeStyle="rgba(255,255,255,0.6)",Cr.lineWidth=2,Cr.beginPath(),Cr.moveTo(xt+Pt,_t),Cr.lineTo(xt+De-Pt,_t),Cr.quadraticCurveTo(xt+De,_t,xt+De,_t+Pt),Cr.lineTo(xt+De,_t+Ze-Pt),Cr.quadraticCurveTo(xt+De,_t+Ze,xt+De-Pt,_t+Ze),Cr.lineTo(xt+Pt,_t+Ze),Cr.quadraticCurveTo(xt,_t+Ze,xt,_t+Ze-Pt),Cr.lineTo(xt,_t+Pt),Cr.quadraticCurveTo(xt,_t,xt+Pt,_t),Cr.closePath(),Cr.stroke()}L.current=requestAnimationFrame(Mr)};Mr();const On=Qa.captureStream(30),ua=[],$t=or.getAudioTracks();if($t.length&&ua.push(...$t),hr){const De=hr.getAudioTracks();De.length&&ua.push(...De)}else an&&ua.push(...an.getAudioTracks());const Se=new MediaStream([...On.getVideoTracks(),...ua]);return O.current=Se,Gr.onended=()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),gt()},Se}catch(or){return console.error("[VideoRecorder] Screen capture error:",or),or.name!=="NotAllowedError"&&((ir=at.current)==null||ir.call(at,"Failed to start screen capture: "+(or.message||"Unknown error"))),null}},[gt]),Wt=k.useCallback(async()=>{var or,hr;ee(!0),ct(null);const ir=w&&q;console.log("[VideoRecorder] initCamera start",{isMobile:w,usePortraitMode:q,shouldBePortrait:ir,facingMode:Ve});try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Camera not available in this browser or context. Try opening in a new tab.");d.current&&(console.log("[VideoRecorder] stopping existing stream"),d.current.getTracks().forEach(Xt=>Xt.stop()));const an=w&&ir?{facingMode:{ideal:Ve},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:Ve},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",an);const Gr=await navigator.mediaDevices.getUserMedia({video:an,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),Gr.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");d.current=Gr,p(Gr),J(!0);const $a=Gr.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",$a.width,"x",$a.height),l.current){const Xt=l.current;Xt.srcObject=Gr,Xt.muted=!0,Xt.playsInline=!0,Xt.autoplay=!0,Xt.setAttribute("muted",""),Xt.setAttribute("playsinline",""),Xt.setAttribute("autoplay","");try{(or=Xt.load)==null||or.call(Xt)}catch(Cr){console.warn("[VideoRecorder] videoEl.load failed",Cr)}const Qa=async()=>{try{return await Xt.play(),console.log("[VideoRecorder] preview play ok"),Ge(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:Xt.readyState,videoWidth:Xt.videoWidth,videoHeight:Xt.videoHeight})},300),!0}catch(Cr){return console.warn("[VideoRecorder] preview play blocked",Cr),Ge(!0),!1}};await new Promise(Cr=>{let Fn=!1;const Kt=()=>{Fn||(Fn=!0,Cr())},Mr=()=>{Qa().finally(Kt)};Xt.onloadedmetadata=Mr,Xt.onloadeddata=Mr,setTimeout(Kt,1500)})}try{_.current=new AudioContext;const Xt=_.current.createMediaStreamSource(Gr);b.current=_.current.createAnalyser(),b.current.fftSize=256,Xt.connect(b.current);const Qa=()=>{if(b.current){const Cr=new Uint8Array(b.current.frequencyBinCount);b.current.getByteFrequencyData(Cr);const Fn=Cr.reduce((Kt,Mr)=>Kt+Mr)/Cr.length;ze(Math.min(100,Fn/128*100))}N.current=requestAnimationFrame(Qa)};Qa()}catch(Xt){console.warn("Audio context not available:",Xt)}}catch(an){console.error("Camera initialization error:",an),J(!1);let Gr="Failed to access camera or microphone.";an.name==="NotAllowedError"?Gr="Camera permission denied. Please allow camera access in your browser settings.":an.name==="NotFoundError"?Gr="No camera found. Please connect a camera and try again.":an.name==="NotReadableError"?Gr="Camera is in use by another application. Please close other apps using the camera.":an.message&&(Gr=an.message),ct(Gr),(hr=at.current)==null||hr.call(at,Gr)}finally{ee(!1)}},[Ve,w,q]);k.useEffect(()=>{He.current!==q&&Z&&!Y&&!xe&&(He.current=q,Wt())},[q,Z,Y,xe,Wt]),k.useEffect(()=>(Wt(),()=>{d.current&&d.current.getTracks().forEach(ir=>ir.stop()),y.current&&clearInterval(y.current),N.current&&cancelAnimationFrame(N.current),_.current&&_.current.close(),Ce.current&&clearInterval(Ce.current),xe&&URL.revokeObjectURL(xe),gt()}),[Wt,xe]),k.useEffect(()=>{if(V||Z!==!0||xe)return;const ir=d.current,or=l.current;!ir||!or||Xe||(or.srcObject!==ir&&(or.srcObject=ir,or.muted=!0,or.playsInline=!0,or.autoplay=!0,or.setAttribute("muted",""),or.setAttribute("playsinline",""),or.setAttribute("autoplay","")),or.play().then(()=>Ge(!1)).catch(hr=>{Ge(!0),console.warn("Live preview play blocked on mount:",hr)}))},[Z,V,xe,Xe]),k.useEffect(()=>{n==null||n(Y)},[Y,n]);const xs=k.useCallback(async()=>{if(xe)return;const ir=l.current;if(ir)try{await ir.play(),Ge(!1)}catch(or){Ge(!0),console.warn("Live preview still blocked (needs user gesture):",or)}},[xe]),Cs=k.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),y.current&&(clearInterval(y.current),y.current=null),gt(),ce(!1),ie(!1)},[gt]),Us=k.useCallback(async()=>{let ir=null;if(S==="screen"){if(ir=await Mt(),!ir)return}else ir=Xe&&ut?ut:d.current;if(!ir)return;xs(),f.current=[],Ne(0);const hr=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(Gr=>MediaRecorder.isTypeSupported(Gr)),an=new MediaRecorder(ir,hr?{mimeType:hr,videoBitsPerSecond:S==="screen"?4e6:25e5}:{videoBitsPerSecond:S==="screen"?4e6:25e5});an.ondataavailable=Gr=>{Gr.data.size>0&&f.current.push(Gr.data)},an.onstop=()=>{var Xt;const Gr=an.mimeType||hr||((Xt=f.current[0])==null?void 0:Xt.type)||"video/webm",Va=new Blob(f.current,{type:Gr});fe(Va);const $a=URL.createObjectURL(Va);he($a)},i.current=an,an.start(100),ce(!0),y.current=setInterval(()=>{Ne(Gr=>Gr>=t-1?(Cs(),t):Gr+1)},1e3)},[xs,t,Cs,Xe,ut,S,Mt]),Ar=k.useCallback(()=>{Ce.current&&(clearInterval(Ce.current),Ce.current=null),st(3);let ir=3;Ce.current=setInterval(()=>{ir-=1,ir<=0?(Ce.current&&clearInterval(Ce.current),Ce.current=null,st(null),Us()):st(ir)},1e3)},[Us]),Bt=k.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),ie(!0),y.current&&clearInterval(y.current))},[]),Xs=k.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),ie(!1),y.current=setInterval(()=>{Ne(ir=>ir>=t-1?(Cs(),t):ir+1)},1e3))},[t,Cs]),Nr=k.useCallback(()=>{xe&&URL.revokeObjectURL(xe),fe(null),he(null),Ne(0),ve(!1),Ue(!0),l.current&&d.current&&!Xe&&(l.current.srcObject=d.current,l.current.muted=!0,xs())},[xs,xe,Xe]),Vs=k.useCallback(()=>{Te(ir=>ir==="user"?"environment":"user")},[]),ar=k.useCallback(()=>{le&&s(le,we)},[le,we,s]),Or=k.useCallback(()=>{l.current&&xe&&(Ee?l.current.pause():(Ue(!1),l.current.muted=!1,l.current.play()),ve(!Ee))},[xe,Ee]);k.useEffect(()=>{if(!xe)return;const ir=l.current;if(!ir)return;Ue(!1),ir.pause(),ir.removeAttribute("src"),ir.srcObject=null,ir.load(),ir.src=xe,ir.currentTime=0,ir.playsInline=!0,ir.muted=!1,ir.onended=()=>ve(!1);const or=()=>{var Gr;const hr=ir.error,an=hr?`Recorded video failed to play (code ${hr.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",hr),(Gr=at.current)==null||Gr.call(at,an)};return ir.addEventListener("error",or),ir.load(),()=>{ir.removeEventListener("error",or)}},[xe]);const Rn=ir=>{const or=Math.floor(ir/60),hr=ir%60;return`${or}:${hr.toString().padStart(2,"0")}`},bn=S==="screen"?"aspect-video":w&&q?"aspect-[9/16]":"aspect-video";return V?e.jsx("div",{className:Rt("flex items-center justify-center bg-black rounded-lg",bn,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(ps,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):Z===!1?e.jsx("div",{className:Rt("flex items-center justify-center bg-black rounded-lg",bn,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(co,{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:ye||"Please allow camera and microphone access to record videos."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(K,{onClick:()=>Wt(),variant:"secondary",className:"w-full",children:[e.jsx(to,{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:Rt("flex flex-col gap-2",a),children:[!Y&&!xe&&e.jsxs("div",{className:"flex items-center justify-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsxs(K,{variant:S==="camera"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>C("camera"),children:[e.jsx(bx,{className:"h-4 w-4"}),"Camera"]}),e.jsxs(K,{variant:S==="screen"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>C("screen"),children:[e.jsx(mS,{className:"h-4 w-4"}),"Screen"]})]}),S==="camera"&&!Y&&!xe&&e.jsx($js,{value:et,onChange:Ct,isLoading:Oe,disabled:Y}),S==="camera"&&w&&!Y&&!xe&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(pS,{className:Rt("h-4 w-4",q?"text-muted-foreground":"text-primary")}),e.jsx(ge,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx(Lr,{id:"orientation-toggle",checked:q,onCheckedChange:Ke}),e.jsx(ge,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(s0,{className:Rt("h-4 w-4",q?"text-primary":"text-muted-foreground")})]}),S==="screen"&&!Y&&!xe&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 px-4 bg-muted/50 rounded-lg text-sm text-muted-foreground",children:[e.jsx(mS,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"Press record to share your screen. Your webcam will appear as a small overlay."})]}),e.jsxs("div",{className:Rt("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{xs()},children:[e.jsx("video",{ref:l,src:xe??void 0,className:Rt("w-full bg-black",q&&!xe?"object-contain":"object-cover",bn,!xe&&Ve==="user"!==(et.mirror??!1)&&"scale-x-[-1]",Xe&&!xe&&"hidden"),playsInline:!0,controls:!!xe,muted:xe?Re:!0,autoPlay:!xe},xe??"live"),Xe&&!xe&&e.jsx("canvas",{ref:Ot,className:Rt("w-full bg-black",q?"object-contain":"object-cover",bn,Ve==="user"!==(et.mirror??!1)&&"scale-x-[-1]")}),Xe&&Oe&&!xe&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/60 z-20",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(ps,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Loading virtual background…"})]})}),!xe&&pe&&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 xs(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!xe&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),tt!==null&&!xe&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:tt},tt),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),Y&&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:Rt("w-3 h-3 rounded-full",ae?"bg-yellow-500":"bg-red-500 animate-pulse")}),e.jsxs("span",{className:"text-white text-sm font-medium",children:[Rn(we)," / ",Rn(t)]})]}),Y&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(pi,{value:we/t*100,className:"h-1 rounded-none"})}),!xe&&e.jsxs("div",{className:"absolute bottom-20 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx(SL,{className:"h-4 w-4 text-white"}),e.jsx("div",{className:"w-20 h-2 bg-white/20 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-green-500 transition-all duration-75",style:{width:`${Ae}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:xe?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:Nr,children:[e.jsx(to,{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:Or,children:Ee?e.jsx(uh,{className:"h-5 w-5"}):e.jsx(Co,{className:"h-5 w-5"})}),e.jsxs(K,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:ar,children:[e.jsx(ea,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[S==="camera"?e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:Vs,disabled:Y||tt!==null,children:e.jsx(e0,{className:"h-5 w-5"})}):e.jsx("div",{className:"h-12 w-12"}),!Y&&tt===null?e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:S==="screen"?Us:Ar,children:S==="screen"?e.jsx(mS,{className:"h-6 w-6"}):e.jsx(hn,{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:ae?Xs:Bt,children:ae?e.jsx(Co,{className:"h-5 w-5"}):e.jsx(uh,{className:"h-5 w-5"})}),e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:Cs,children:e.jsx(r0,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const Olt="teleprompter_settings",b0e={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function Tks(){try{const t=localStorage.getItem(Olt);return t?{...b0e,...JSON.parse(t)}:b0e}catch{return b0e}}function Aks(t){try{localStorage.setItem(Olt,JSON.stringify(t))}catch{}}function Flt({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=k.useRef(null),d=k.useRef(null),u=k.useRef(0),p=k.useRef(0),[f,y]=k.useState(Tks),{scrollSpeed:_,fontSize:b,lineHeight:N,opacity:w,position:S,isMirrored:C}=f,A=k.useCallback((Z,J)=>{y(Y=>{const ce={...Y,[Z]:J};return Aks(ce),ce})},[]),[I,L]=k.useState(!1),[O,U]=k.useState(null),q=k.useCallback(Z=>{if(!i.current)return;u.current===0&&(u.current=Z);const J=Z-u.current;u.current=Z,p.current+=_*J/1e3;const Y=Math.floor(p.current);Y>0&&(i.current.scrollTop+=Y,p.current-=Y);const{scrollTop:ce,scrollHeight:ae,clientHeight:ie}=i.current;if(ce+ie>=ae){L(!1);return}d.current=requestAnimationFrame(q)},[_]);k.useEffect(()=>(I?(u.current=0,p.current=0,d.current=requestAnimationFrame(q)):d.current&&cancelAnimationFrame(d.current),()=>{d.current&&cancelAnimationFrame(d.current)}),[I,q]),k.useEffect(()=>{if(n&&s)if(i.current&&(i.current.scrollTop=0),a){U(3);let Z=3;const J=setInterval(()=>{Z-=1,Z<=0?(clearInterval(J),U(null),o==null||o(),L(!0)):U(Z)},1e3);return()=>clearInterval(J)}else setTimeout(()=>L(!0),100);else n||(L(!1),U(null))},[n,s,a,o]);const $=k.useCallback(()=>{i.current&&(i.current.scrollTop=0),L(!1)},[]),V=k.useCallback(()=>{L(Z=>!Z)},[]);if(!s)return e.jsx("div",{className:Rt("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(jn,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const ee={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:Rt("absolute inset-0 pointer-events-none",l),children:[O!==null&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:O},O),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),e.jsx("div",{className:Rt("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",ee[S],O!==null&&"opacity-30"),style:{opacity:O!==null?.3:w},children:e.jsxs("div",{ref:i,className:Rt("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",C&&"scale-x-[-1]"),style:{maskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)"},children:[e.jsx("div",{className:"h-full",style:{minHeight:"100%"}}),e.jsx("p",{className:"text-white text-center font-medium drop-shadow-lg",style:{fontSize:`${b}px`,lineHeight:N,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(yo,{children:[e.jsx(vo,{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(So,{className:"h-4 w-4"})})}),e.jsx(uo,{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(ge,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_})]}),e.jsx(Eg,{value:[_],onValueChange:([Z])=>A("scrollSpeed",Z),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(ge,{className:"text-xs",children:"Font Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[b,"px"]})]}),e.jsx(Eg,{value:[b],onValueChange:([Z])=>A("fontSize",Z),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(ge,{className:"text-xs",children:"Line Spacing"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:N.toFixed(1)})]}),e.jsx(Eg,{value:[N*10],onValueChange:([Z])=>A("lineHeight",Z/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(ge,{className:"text-xs",children:"Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(w*100),"%"]})]}),e.jsx(Eg,{value:[w*100],onValueChange:([Z])=>A("opacity",Z/100),min:30,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"text-xs",children:"Position"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:S==="top"?"default":"outline",size:"sm",onClick:()=>A("position","top"),children:e.jsx(lf,{className:"h-4 w-4"})}),e.jsx(K,{variant:S==="center"?"default":"outline",size:"sm",onClick:()=>A("position","center"),children:e.jsx(Xy,{className:"h-4 w-4"})}),e.jsx(K,{variant:S==="bottom"?"default":"outline",size:"sm",onClick:()=>A("position","bottom"),children:e.jsx(Fi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{className:"text-xs",children:"Mirror Mode"}),e.jsx(Lr,{checked:C,onCheckedChange:Z=>A("isMirrored",Z)})]})]})})]}),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(uh,{className:"h-4 w-4"}):e.jsx(Co,{className:"h-4 w-4"})}),e.jsx(K,{variant:"secondary",size:"icon",onClick:$,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(e0,{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(hp,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function Eks({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=va(),[o,l]=k.useState(""),[i,d]=k.useState(null),[u,p]=k.useState("levelup"),{data:f,isLoading:y}=n2s(),{data:_,isLoading:b}=a2s(),{data:N,isLoading:w}=i2s(),S=o2s(),C=k.useMemo(()=>_?_.filter(U=>{const q=!o||U.title.toLowerCase().includes(o.toLowerCase())||U.script_text.toLowerCase().includes(o.toLowerCase())||U.tags.some(V=>V.toLowerCase().includes(o.toLowerCase())),$=!i||U.category_id===i;return q&&$}):[],[_,o,i]),A=k.useMemo(()=>N?N.filter(U=>!o||U.title.toLowerCase().includes(o.toLowerCase())||U.script_text.toLowerCase().includes(o.toLowerCase())):[],[N,o]),I=U=>{t({title:U.title,text:U.script_text})},L=async U=>{try{await S.mutateAsync(U),a({title:"Script saved to My Scripts"})}catch{a({title:"Failed to save script",variant:"destructive"})}},O=y||b||w;return e.jsxs("div",{className:Rt("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(tn,{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:U=>l(U.target.value),className:"pl-9"})]})}),e.jsxs(ta,{value:u,onValueChange:U=>p(U),className:"flex-1 flex flex-col",children:[e.jsxs(Qn,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(ls,{value:"levelup",children:[e.jsx(mn,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(ls,{value:"my-scripts",children:[e.jsx(_x,{className:"h-4 w-4 mr-2"}),"My Scripts"]})]}),e.jsxs(js,{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(Ye,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>d(null),children:"All"}),f==null?void 0:f.map(U=>e.jsx(Ye,{variant:i===U.id?"default":"outline",className:"cursor-pointer",onClick:()=>d(U.id),children:U.name},U.id))]}),e.jsx(di,{className:"flex-1 max-h-[50vh]",children:O?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ps,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(mn,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No scripts found"})]}):e.jsx("div",{className:"space-y-2",children:C.map(U=>e.jsxs(Ie,{className:Rt("cursor-pointer hover:bg-accent/50 transition-colors",r===U.id&&"ring-2 ring-primary"),onClick:()=>I(U),children:[e.jsx(Lt,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Ft,{className:"text-sm font-medium truncate",children:U.title}),U.category&&e.jsx(Ye,{variant:"secondary",className:"mt-1 text-xs",children:U.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(U)},children:e.jsx(_x,{className:"h-4 w-4"})}),e.jsx(ja,{className:"h-4 w-4 text-muted-foreground"})]})]})}),e.jsx(Be,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:U.script_text})})]},U.id))})})]}),e.jsxs(js,{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(Bs,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(di,{className:"flex-1 max-h-[50vh]",children:w?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ps,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):A.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(_x,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No saved scripts"}),e.jsx("p",{className:"text-sm mt-1",children:"Save LevelUp scripts or create your own"})]}):e.jsx("div",{className:"space-y-2",children:A.map(U=>e.jsxs(Ie,{className:Rt("cursor-pointer hover:bg-accent/50 transition-colors",r===U.id&&"ring-2 ring-primary"),onClick:()=>I(U),children:[e.jsx(Lt,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Ft,{className:"text-sm font-medium truncate",children:U.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:U.is_custom?e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(ja,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),e.jsx(Be,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:U.script_text})})]},U.id))})})]})]})]})}function Pks({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=k.useState(()=>{const i=KM(t);return new Set([i.category])}),l=i=>{o(d=>{const u=new Set(d);return u.has(i)?u.delete(i):u.add(i),u})};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(ps,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:r8t.map(i=>{const d=n8t(i.id),u=a.has(i.id),p=d.some(f=>f.id===t);return e.jsxs(uf,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(hf,{className:"flex items-center justify-between w-full p-2.5 rounded-lg bg-muted/50 hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:i.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",d.length,")"]}),p&&!u&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"✓"})]}),e.jsx(Fi,{className:Rt("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(mf,{className:"pt-2",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:d.map(f=>{const y=t===f.id;return e.jsxs("button",{type:"button",onClick:()=>s(f.id),disabled:n,className:Rt("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(ea,{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: "',KM(t).headerText(r),'"']})]})}function zlt({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=k.useState(r.page_template||"default"),[i,d]=k.useState(!1),[u,p]=k.useState(!1),[f,y]=k.useState(r.page_template||"default"),[_,b]=k.useState([]),[N,w]=k.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[S,C]=k.useState(!1),[A,I]=k.useState(!1),L=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";k.useEffect(()=>{t&&_.length===0&&O()},[t]);const O=async()=>{I(!0);try{const{data:ce,error:ae}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ae)throw ae;const ie=(ce||[]).map(le=>({id:le.id,name:[le.first_name,le.last_name].filter(Boolean).join(" ")||"Unnamed",email:le.email||null}));b(ie)}catch(ce){console.error("Failed to fetch contacts:",ce)}finally{I(!1)}},U=async ce=>{w(ce),C(!1),d(!0);try{const{error:ae}=await G.from("agent_videos").update({contact_id:(ce==null?void 0:ce.id)||null,recipient_name:(ce==null?void 0:ce.name)||null}).eq("id",r.id);if(ae)throw ae;me.success(ce?`Assigned to ${ce.name}`:"Contact removed"),a==null||a()}catch(ae){console.error("Failed to update contact:",ae),me.error("Failed to update contact")}finally{d(!1)}},q=async ce=>{l(ce),d(!0);try{const{error:ae}=await G.from("agent_videos").update({page_template:ce}).eq("id",r.id);if(ae)throw ae;y(ce),me.success("Template saved!"),a==null||a()}catch(ae){console.error("Failed to save template:",ae),me.error("Failed to save template"),l(f)}finally{d(!1)}},$=(N==null?void 0:N.name)||null,V=()=>{const ce=r.title||"Video Message",ae=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},ee=async()=>{if(!r.thumbnail_url){me.error("Video thumbnail not available yet");return}const ce=V(),ae=`Watch: ${r.title||"Video Message"} ${L}`;try{const ie=new Blob([ce],{type:"text/html"}),le=new Blob([ae],{type:"text/plain"}),fe=new ClipboardItem({"text/html":ie,"text/plain":le});await navigator.clipboard.write([fe]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ae+` `+ce),me.success("Copied! Paste into your email.")}},Z=async()=>{await navigator.clipboard.writeText(L),p(!0),me.success("Share link copied!"),setTimeout(()=>p(!1),2e3)},J=()=>{const ae=KM(o).headerText($),ie=o==="default"?`Check out this video: ${L}`:`${ae} Check out this special video: ${L}`;window.open(`sms:?body=${encodeURIComponent(ie)}`,"_self")},Y=()=>{const ce=KM(o),ae=ce.headerText($),ie=o==="default"?r.title||"Video Message":ae,le=`${ce.subText} Watch the video: ${L}`,fe=N!=null&&N.email?encodeURIComponent(N.email):"";window.open(`mailto:${fe}?subject=${encodeURIComponent(ie)}&body=${encodeURIComponent(le)}`,"_self")};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(go,{className:"h-5 w-5"}),"Share Video"]}),e.jsx(Rr,{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(ge,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(yo,{open:S,onOpenChange:C,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":S,className:"flex-1 justify-between",disabled:i,children:[N?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ei,{className:"h-4 w-4 text-muted-foreground"}),N.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(wx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(uo,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Ax,{children:[e.jsx(Ex,{placeholder:"Search contacts..."}),e.jsxs(Px,{children:[e.jsx(Ix,{children:A?"Loading...":"No contacts found."}),e.jsx(Lx,{children:_.map(ce=>e.jsxs(op,{value:ce.name,onSelect:()=>U(ce),children:[e.jsx(ea,{className:Rt("mr-2 h-4 w-4",(N==null?void 0:N.id)===ce.id?"opacity-100":"opacity-0")}),ce.name]},ce.id))})]})]})})]}),N&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>U(null),disabled:i,className:"shrink-0",children:e.jsx(Sr,{className:"h-4 w-4"})})]}),N&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',KM(o).headerText(N.name),'"']})]}),e.jsx(Pks,{selectedTemplate:o,onSelect:q,contactName:$,saving:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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:Z,variant:u?"default":"outline",className:"shrink-0 gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ea,{className:"h-4 w-4"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ya,{className:"h-4 w-4"}),"Copy"]})})]})]}),r.thumbnail_url&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Share for Email"}),e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:ee,children:[e.jsx(Uo,{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(ge,{children:"Quick Share"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:J,children:[e.jsx(Si,{className:"h-4 w-4"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:Y,children:[e.jsx(tr,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(gn,{children:e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function Iks(){var st;const t=br(),[s]=Sc(),{toast:r}=va(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:d}=_it(),{data:u}=Uh(),p=Ew(),f=h2s(),[y,_]=k.useState("record"),[b,N]=k.useState(""),[w,S]=k.useState(!1),[C,A]=k.useState(!1),[I,L]=k.useState(!1),[O,U]=k.useState(null),[q,$]=k.useState(0),[V,ee]=k.useState(0),[Z,J]=k.useState(null),[Y,ce]=k.useState(null),[ae,ie]=k.useState(n||""),[le,fe]=k.useState(""),[xe,he]=k.useState(""),[we,Ne]=k.useState(null),[Ve,Te]=k.useState(null),[Ae,ze]=k.useState(null),[Ee,ve]=k.useState(!1),Re=k.useCallback(async(Ce,et)=>{U(Ce),_("uploading");try{const{videoId:Ct,uploadUrl:Ot}=await wE(le||"Quick Video Touch");J(Ct);const{apiKey:ut}=await jE(Ct),Oe=new XMLHttpRequest;Oe.upload.onprogress=He=>{He.lengthComputable&&$(He.loaded/He.total*100)},await new Promise((He,gt)=>{Oe.onload=()=>{Oe.status>=200&&Oe.status<300?He():gt(new Error(`Upload failed: ${Oe.status}`))},Oe.onerror=()=>gt(new Error("Upload failed")),Oe.open("PUT",Ot),Oe.setRequestHeader("AccessKey",ut),Oe.send(Ce)}),_("processing");let Xe=0;const at=Date.now(),Ke=90*1e3;for(;Xe<4;){if(await new Promise(gt=>setTimeout(gt,3e3)),Date.now()-at>Ke){const gt=Ce.size/1048576,Mt=`https://iframe.mediadelivery.net/play/${Ct}/${Ct}`;await p.mutateAsync({bunny_video_id:Ct,playback_url:Mt,file_size_mb:gt,title:le||"Quick Video Touch",notes:xe||void 0,contact_id:ae&&ae!=="none"?ae: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 He=await ow(Ct);if(Xe=He.status,ee(He.encodeProgress||0),Xe===4)ce({playbackUrl:He.directPlayUrl,thumbnailUrl:He.thumbnailUrl,previewUrl:He.previewUrl||null,duration:He.length||et,fileSizeMb:(He.storageSize||Ce.size)/(1024*1024)});else if(Xe===5||Xe===6)throw new Error("Video processing failed")}_("details")}catch(Ct){console.error("Upload error:",Ct),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),_("record")}},[le,r]),Ue=async()=>{if(!(!Z||!Y))try{const Ce=ae&&ae!=="none"?ae:null,et=await p.mutateAsync({bunny_video_id:Z,contact_id:Ce,playback_url:Y.playbackUrl,thumbnail_url:Y.thumbnailUrl,preview_url:Y.previewUrl,duration_seconds:Y.duration,file_size_mb:Y.fileSizeMb,title:le||"Quick Video Touch",notes:xe,task_id:a||null,status:"ready"});Ne(et.id),Te(et.share_token||null),Ce&&await f.mutateAsync({contactId:Ce,videoId:et.id,notes:xe}),r({title:"Video saved successfully!"}),_("share")}catch(Ce){console.error("Save video error:",Ce),r({title:"Failed to save video",description:(Ce==null?void 0:Ce.message)||"Please try again.",variant:"destructive"})}},ye=(Ce,et)=>{navigator.clipboard.writeText(et),ze(Ce),setTimeout(()=>ze(null),2e3),r({title:"Copied to clipboard!"})},ct=()=>Ve?`https://video.relevelup.com/${Ve}`:(Y==null?void 0:Y.playbackUrl)||"",pe=()=>{const Ce=u==null?void 0:u.find(Oe=>Oe.id===ae),et=Ce?`${Ce.first_name}`:"",Ct=(Ce==null?void 0:Ce.phone)||"",Ot=(Ce==null?void 0:Ce.email)||"",ut=ct();return{text:`Hey${et?` ${et}`:""}! I recorded a quick video for you: ${ut}`,link:ut,contactPhone:Ct,contactEmail:Ot}},Ge=()=>{const{text:Ce,contactPhone:et}=pe(),Ct=et?`sms:${et}?body=${encodeURIComponent(Ce)}`:`sms:?body=${encodeURIComponent(Ce)}`;window.open(Ct,"_self")},tt=()=>{const{link:Ce,contactEmail:et}=pe(),Ct="Check out this video",Ot=`I recorded a quick video for you: ${Ce}`,ut=et?`mailto:${et}?subject=${encodeURIComponent(Ct)}&body=${encodeURIComponent(Ot)}`:`mailto:?subject=${encodeURIComponent(Ct)}&body=${encodeURIComponent(Ot)}`;window.open(ut,"_self")};return o?e.jsx(Ls,{title:"QuickVid",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t(-1),children:e.jsx(Ra,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"QuickVid"}),e.jsx("p",{className:"text-muted-foreground",children:"Record a personal video message"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>t("/mission-control/video-library"),className:"gap-1.5",children:[e.jsx(mn,{className:"h-4 w-4"}),"Video Library"]}),d&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm text-warning",children:["Storage: ",i.toFixed(0),"% used"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[l.toFixed(0)," MB remaining"]})]})]})]}),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(AO,{maxDurationSeconds:600,onRecordingComplete:Re,onRecordingStateChange:L,className:"w-full",teleprompterContent:w&&b&&e.jsx(Flt,{text:b,isVisible:w,onToggleVisibility:()=>S(!1),isRecording:I,startCountdown:!1})}),!w&&b&&e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>S(!0),children:[e.jsx(mn,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Ie,{className:"lg:col-span-1",children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsx(_r,{placeholder:"Type or paste your script here...",value:b,onChange:Ce=>N(Ce.target.value),rows:6}),e.jsxs(ZA,{open:C,onOpenChange:A,children:[e.jsx(GNe,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full",children:[e.jsx(mn,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(CC,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(YA,{className:"p-4 border-b",children:e.jsx(XA,{children:"Select a Script"})}),e.jsx(Eks,{onSelectScript:Ce=>{N(Ce.text),A(!1),S(!0)},className:"h-[calc(100vh-80px)]"})]})]}),b&&e.jsx(K,{className:"w-full",onClick:()=>S(!0),children:"Use Script"})]})]})]}),y==="uploading"&&e.jsx(Ie,{className:"max-w-md mx-auto",children:e.jsxs(Be,{className:"pt-6 text-center",children:[e.jsx(Da,{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(pi,{value:q,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[q.toFixed(0),"%"]})]})}),y==="processing"&&e.jsx(Ie,{className:"max-w-md mx-auto",children:e.jsxs(Be,{className:"pt-6 text-center space-y-4",children:[e.jsx(ps,{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(pi,{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(Ie,{className:"max-w-lg mx-auto",children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Video Details"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Title"}),e.jsx(Fe,{value:le,onChange:Ce=>fe(Ce.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Attach to Contact (Optional)"}),e.jsxs(zs,{value:ae,onValueChange:ie,children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"No contact - use anywhere"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(go,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),u==null?void 0:u.map(Ce=>e.jsx(yt,{value:Ce.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ei,{className:"h-4 w-4"}),Ce.first_name," ",Ce.last_name]})},Ce.id))]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Notes"}),e.jsx(_r,{value:xe,onChange:Ce=>he(Ce.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(K,{className:"w-full",onClick:Ue,disabled:p.isPending,children:[p.isPending&&e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),y==="share"&&e.jsxs(Ie,{className:"max-w-lg mx-auto",children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(ea,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(Be,{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:Ge,children:[e.jsx(Si,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:tt,children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>ye("link",pe().link),children:[e.jsx(go,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Ae==="link"&&e.jsx(ea,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>ve(!0),children:[e.jsx(Rl,{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"),U(null),J(null),ce(null)},children:"Record Another"})]})]})]}),we&&Ve&&e.jsx(zlt,{open:Ee,onOpenChange:ve,video:{id:we,share_token:Ve,title:le||null,contact_id:ae||null,thumbnail_url:(Y==null?void 0:Y.thumbnailUrl)||null},contactName:((st=u==null?void 0:u.find(Ce=>Ce.id===ae))==null?void 0:st.first_name)||null})]})}):e.jsx(Ls,{title:"QuickVid",children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center py-12",children:[e.jsx(Qc,{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 Lks({open:t,onOpenChange:s}){const{data:r}=Uh(),{data:n}=Ame(),a=Ew(),o=k.useRef(null),[l,i]=k.useState(null),[d,u]=k.useState(""),[p,f]=k.useState(""),[y,_]=k.useState(""),[b,N]=k.useState(!1),[w,S]=k.useState(0),[C,A]=k.useState("idle"),I=(n==null?void 0:n.total_storage_mb)||0,O=((n==null?void 0:n.max_storage_mb)||1024)-I,U=ee=>{var Y;const Z=(Y=ee.target.files)==null?void 0:Y[0];if(!Z)return;if(!Z.type.startsWith("video/")){me.error("Please select a video file");return}const J=Z.size/(1024*1024);if(J>500){me.error("Video file must be less than 500MB");return}if(J>O){me.error(`Not enough storage. You have ${O.toFixed(1)} MB remaining.`);return}i(Z),d||u(Z.name.replace(/\.[^/.]+$/,""))},q=async()=>{if(!l){me.error("Please select a video file");return}N(!0),S(0),A("creating");try{const{data:ee,error:Z}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:d||l.name,isAgentVideo:!0}});if(Z)throw new Error(Z.message);const{videoId:J,libraryId:Y}=ee;A("uploading");const{data:ce,error:ae}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:J,isAgentVideo:!0}});if(ae)throw new Error(ae.message);await new Promise((fe,xe)=>{const he=new XMLHttpRequest;he.upload.addEventListener("progress",we=>{if(we.lengthComputable){const Ne=Math.round(we.loaded/we.total*100);S(Ne)}}),he.addEventListener("load",()=>{he.status>=200&&he.status<300?fe():xe(new Error(`Upload failed with status ${he.status}`))}),he.addEventListener("error",()=>xe(new Error("Upload failed"))),he.open("PUT",ce.uploadUrl),he.setRequestHeader("AccessKey",ce.apiKey),he.send(l)}),A("processing");const ie=l.size/(1024*1024),le=`https://iframe.mediadelivery.net/embed/${Y}/${J}`;await a.mutateAsync({bunny_video_id:J,playback_url:le,file_size_mb:ie,title:d||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."),$()}catch(ee){console.error("Upload error:",ee),me.error(ee instanceof Error?ee.message:"Failed to upload video")}finally{N(!1),A("idle")}},$=()=>{b||(i(null),u(""),f(""),_(""),S(0),A("idle"),s(!1))},V=()=>{switch(C){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${w}%`;case"processing":return"Saving video...";default:return""}};return e.jsx(fs,{open:t,onOpenChange:$,children:e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Upload Video"}),e.jsx(Rr,{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(ge,{children:"Video File"}),l?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(hn,{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:ee=>{ee.stopPropagation(),i(null)},children:e.jsx(Sr,{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 ee;return(ee=o.current)==null?void 0:ee.click()},children:[e.jsx(Da,{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:U,disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"title",children:"Title"}),e.jsx(Fe,{id:"title",value:d,onChange:ee=>u(ee.target.value),placeholder:"Enter video title",disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Associate with Contact (optional)"}),e.jsxs(zs,{value:y||"__none__",onValueChange:ee=>_(ee==="__none__"?"":ee),disabled:b,children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select a contact"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(ee=>e.jsxs(yt,{value:ee.id,children:[ee.first_name," ",ee.last_name||""]},ee.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(_r,{id:"notes",value:p,onChange:ee=>f(ee.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(ps,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:V()})]}),e.jsx(pi,{value:C==="uploading"?w:C==="processing"?100:10})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:$,disabled:b,children:"Cancel"}),e.jsx(K,{onClick:q,disabled:!l||b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Da,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function Dks(t){return ft({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 Rks(){const{user:t}=$s();return ft({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 Oks(){const{user:t}=$s();return ft({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 Fks(){const{user:t}=$s(),s=es();return Et({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 zks(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function Bks(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function $ks({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=k.useState([]),[d,u]=k.useState(null),[p,f]=k.useState(!1),[y,_]=k.useState(!1),[b,N]=k.useState(""),[w,S]=k.useState(""),[C,A]=k.useState(""),[I,L]=k.useState(!1),O=Fks(),U=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||"",$=r.title||"Video Message";k.useEffect(()=>{t&&l.length===0&&V()},[t]),k.useEffect(()=>{if(t&&(S(`I recorded a video for you — ${$}`),A("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),N(""),r.contact_id)){const ae=l.find(ie=>ie.id===r.contact_id);ae&&(u(ae),N(ae.email||""))}},[t,r.contact_id,l]);const V=async()=>{_(!0);try{const{data:ae,error:ie}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ie)throw ie;i(ae||[])}catch{console.error("Failed to fetch contacts")}finally{_(!1)}},ee=ae=>{u(ae),f(!1),N(ae.email||""),A(`Hey ${ae.first_name}! I recorded a quick video just for you. Click below to watch it:`),S(`I recorded a video for you — ${$}`)},Z=()=>{u(null),N(""),A("Hey! I recorded a quick video just for you. Click below to watch it:")},J=ae=>`${ae.first_name} ${ae.last_name||""}`.trim(),Y=ae=>{const ie=C.split(/\n\n+/).map(xe=>`

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

`).join(""),le=ae?Bks(ae):U,fe=ae?``:"";return`
${ie}

▶ Watch Video

${fe}
`},ce=async()=>{if(!b){me.error("Please enter a recipient email");return}if(!U){me.error("Video does not have a share link");return}L(!0);try{let ae;try{const xe=d?J(d):b.split("@")[0];ae=(await O.mutateAsync({video_id:r.id,recipient_email:b,recipient_name:xe,contact_id:(d==null?void 0:d.id)||null,sent_via:"gmail"})).share_token}catch(xe){console.warn("Failed to create tracking record, sending without tracking:",xe)}const ie=Y(ae),{data:le,error:fe}=await G.functions.invoke("gmail-send",{body:{to:b,subject:w,body:ie,contactId:(d==null?void 0:d.id)||null}});if(fe)throw fe;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(ae){console.error("Gmail send error:",ae),me.error("Failed to send: "+(ae instanceof Error?ae.message:"Unknown error"))}finally{L(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-[560px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(tr,{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(ge,{children:"Send to Contact"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(yo,{open:p,onOpenChange:f,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"flex-1 justify-between",children:[d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ei,{className:"h-4 w-4 text-muted-foreground"}),J(d),d.email&&e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",d.email,")"]})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(wx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(uo,{className:"w-[350px] p-0",align:"start",children:e.jsxs(Ax,{children:[e.jsx(Ex,{placeholder:"Search contacts..."}),e.jsxs(Px,{children:[e.jsx(Ix,{children:y?"Loading...":"No contacts found."}),e.jsx(Lx,{children:l.filter(ae=>ae.email).map(ae=>e.jsxs(op,{value:`${ae.first_name} ${ae.last_name||""} ${ae.email||""}`,onSelect:()=>ee(ae),children:[e.jsx(ea,{className:Rt("mr-2 h-4 w-4",(d==null?void 0:d.id)===ae.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:J(ae)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ae.email})]})]},ae.id))})]})]})})]}),d&&e.jsx(K,{variant:"ghost",size:"icon",onClick:Z,className:"shrink-0",children:e.jsx(Sr,{className:"h-4 w-4"})})]})]}),!d&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(Fe,{id:"video-to",value:b,onChange:ae=>N(ae.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(jo,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{htmlFor:"video-subject",children:"Subject"}),e.jsx(Fe,{id:"video-subject",value:w,onChange:ae=>S(ae.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(_r,{id:"video-message",value:C,onChange:ae=>A(ae.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(ge,{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:$,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(Co,{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(Co,{className:"h-5 w-5 text-primary ml-0.5"})})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients will see the thumbnail with a play button. Clicking opens the video page."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),disabled:I,children:"Cancel"}),e.jsxs(K,{onClick:ce,disabled:I||!b||!w,className:"gap-2",children:[I?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(Nn,{className:"h-4 w-4"}),I?"Sending...":"Send Video Email"]})]})]})]})})}const qks=()=>{const{user:t}=$s();return ft({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 Uks({recipient:t}){return t.watched_at?e.jsxs(Ye,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(Co,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(Ye,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(sh,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(Ye,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(jn,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(Ye,{variant:"outline",className:"text-[10px]",children:[e.jsx(Nn,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function Vks({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=Dks(r);return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(ks,{children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5"}),"Send Analytics: ",n]})}),o?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((l,i)=>e.jsx(Ss,{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(di,{className:"h-[400px]",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Recipient"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{children:"Sent"}),e.jsx(Nt,{children:"Last Activity"})]})}),e.jsx(Pn,{children:a.map(l=>e.jsxs(As,{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(Uks,{recipient:l})}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:gs(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:l.last_activity_at?jl(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function Hks(){const{data:t,isLoading:s}=Rks(),{data:r=[],isLoading:n}=Oks(),[a,o]=k.useState(null),l=s||n,i=r.reduce((d,u)=>{const p=u.agent_videos,f=(p==null?void 0:p.id)||u.video_id;return d[f]||(d[f]={videoId:f,title:(p==null?void 0:p.title)||"Untitled",thumbnailUrl:p==null?void 0:p.thumbnail_url,recipients:[]}),d[f].recipients.push(u),d},{});return l?e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((d,u)=>e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ss,{className:"h-4 w-20"})}),e.jsx(Be,{children:e.jsx(Ss,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(Nn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Be,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(jn,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(sh,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(Be,{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(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(mr,{children:"Click a video to see individual recipient tracking"})]}),e.jsx(Be,{children:Object.keys(i).length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No tracked sends yet. Send a video via Gmail to start tracking."}):e.jsx("div",{className:"space-y-2",children:Object.values(i).map(d=>{const u=d.recipients.filter(f=>f.opened_at).length,p=d.recipients.filter(f=>f.clicked_at).length;return e.jsxs("button",{onClick:()=>o({id:d.videoId,title:d.title}),className:"w-full flex items-center gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-left",children:[e.jsx("div",{className:"h-10 w-16 rounded bg-muted overflow-hidden flex-shrink-0",children:d.thumbnailUrl?e.jsx("img",{src:d.thumbnailUrl,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer",onError:f=>{const 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(hn,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:d.title}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Nn,{className:"h-3 w-3"})," ",d.recipients.length]}),e.jsxs("span",{className:"text-xs text-amber-600 flex items-center gap-1",children:[e.jsx(jn,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(sh,{className:"h-3 w-3"})," ",p]})]})]}),e.jsx(Yo,{className:"h-4 w-4 text-muted-foreground"})]},d.videoId)})})})]}),e.jsx(Vks,{open:!!a,onOpenChange:d=>!d&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function Gks({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=k.useState(!1),[l,i]=k.useState(!1),d=n&&t&&!a,u=s&&!l;return!u&&!d?e.jsx("div",{className:"w-full h-full flex items-center justify-center absolute inset-0 bg-muted",children:e.jsx(hn,{className:"h-12 w-12 text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[u&&e.jsx("img",{src:s,alt:r,loading:"lazy",className:`w-full h-full object-cover absolute inset-0 transition-opacity duration-200 ${d?"opacity-0":"opacity-100"}`,onError:()=>i(!0)}),d&&e.jsx("img",{src:t,alt:r,className:"w-full h-full object-cover absolute inset-0",onError:()=>o(!0)})]})}function Wks({video:t,previewSrc:s,thumbnailSrc:r,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:d,onEmbedToCrm:u,onShareWithTemplate:p,onSendViaGmail:f,isGmailConnected:y,getContactName:_,getShareUrl:b,copyToClipboard:N,formatDuration:w}){const[S,C]=k.useState(!1);return e.jsxs(Ie,{className:"overflow-hidden group cursor-pointer",onClick:n,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",children:[e.jsx(Gks,{previewSrc:s,thumbnailSrc:r,alt:t.title||"Video preview",isHovered:S}),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(Co,{className:"h-6 w-6 text-primary ml-1"})})}),e.jsx("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:w(t.duration_seconds)}),t.status!=="ready"&&e.jsx(Ye,{variant:t.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:t.status})]}),e.jsx(Be,{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(Ei,{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(rn,{className:"h-3 w-3"}),e.jsx("span",{children:gs(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(jn,{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:A=>{A.stopPropagation(),f==null||f()},children:[e.jsx(tr,{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(Ei,{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(rn,{className:"h-3 w-3"}),e.jsx("span",{children:gs(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(jn,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:A=>A.stopPropagation(),children:e.jsx(cx,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",className:"bg-popover",children:[e.jsxs(xa,{onClick:A=>{A.stopPropagation(),n()},children:[e.jsx(jn,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(Jb,{}),e.jsxs(xa,{onClick:A=>{A.stopPropagation(),p()},children:[e.jsx(Rl,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(xa,{onClick:A=>{A.stopPropagation(),N(b(t),"Share link")},children:[e.jsx(go,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(xa,{onClick:A=>{A.stopPropagation(),i()},children:[e.jsx(Q4,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(xa,{onClick:A=>{A.stopPropagation(),d()},children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(xa,{onClick:A=>{A.stopPropagation(),u()},children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),y&&t.share_token&&e.jsxs(xa,{onClick:A=>{A.stopPropagation(),f==null||f()},children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(xa,{onClick:A=>{A.stopPropagation(),o()},children:[e.jsx(pa,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(Jb,{}),t.contact_id&&e.jsxs(xa,{onClick:A=>{A.stopPropagation(),l()},children:[e.jsx(Ei,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(xa,{onClick:A=>{A.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(yr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function Kks(){var He,gt;const t=br(),{data:s,isLoading:r,refetch:n}=l2s(),{data:a}=Ame(),{data:o}=Uh(),l=u2s(),i=d2s(),{isGmailConnected:d,gmailEmail:u}=bp(),{data:p}=Rx(),{data:f=[],isLoading:y}=qks(),[_,b]=k.useState("my"),[N,w]=k.useState(""),[S,C]=k.useState(null),[A,I]=k.useState(!1),[L,O]=k.useState(!1),[U,q]=k.useState(!1),[$,V]=k.useState(!1),[ee,Z]=k.useState(!1),[J,Y]=k.useState(""),[ce,ae]=k.useState(!1),[ie,le]=k.useState(!1),[fe,xe]=k.useState(!1),[he,we]=k.useState(!1),[Ne,Ve]=k.useState(""),[Te,Ae]=k.useState({}),ze=Mt=>{if(!Mt)return"Unassigned";const Wt=o==null?void 0:o.find(xs=>xs.id===Mt);return Wt?`${Wt.first_name} ${Wt.last_name||""}`.trim():"Unknown"},Ee=Mt=>{if(!Mt)return"0:00";const Wt=Math.floor(Mt/60),xs=Mt%60;return`${Wt}:${xs.toString().padStart(2,"0")}`},ve=s==null?void 0:s.filter(Mt=>{if(!N)return!0;const Wt=ze(Mt.contact_id).toLowerCase(),xs=(Mt.title||"").toLowerCase(),Cs=(Mt.notes||"").toLowerCase();return Wt.includes(N.toLowerCase())||xs.includes(N.toLowerCase())||Cs.includes(N.toLowerCase())}),[Re,Ue]=k.useState(!1);k.useEffect(()=>{if(Re)return;(async()=>{if(!(s!=null&&s.length))return;const Wt=s.filter(Cs=>Cs.status==="processing"&&Cs.bunny_video_id);if(!Wt.length)return;let xs=!1;for(const Cs of Wt)try{const{data:Us,error:Ar}=await G.functions.invoke("bunny-upload",{body:{action:"status",videoId:Cs.bunny_video_id,isAgentVideo:!0}});if(Ar||!Us)continue;Us.status===4&&(await G.from("agent_videos").update({status:"ready",playback_url:Us.directPlayUrl,thumbnail_url:Us.thumbnailUrl,preview_url:Us.previewUrl,duration_seconds:Us.length||Cs.duration_seconds,updated_at:new Date().toISOString()}).eq("id",Cs.id),xs=!0)}catch(Us){console.warn("Reconcile check failed for video",Cs.id,Us)}Ue(!0),xs&&n()})()},[s,Re,n]),k.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const Wt=s.filter(Bt=>(Bt==null?void 0:Bt.bunny_video_id)&&!Te[Bt.id]);if(!Wt.length)return;const xs=Wt.map(Bt=>Bt.bunny_video_id),{data:Cs,error:Us}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:xs,isAgentVideo:!0}});if(Us)throw Us;const Ar=(Cs==null?void 0:Cs.assets)||{};Ae(Bt=>{const Xs={...Bt};for(const Nr of Wt)Ar[Nr.bunny_video_id]&&(Xs[Nr.id]={previewUrl:Ar[Nr.bunny_video_id].previewUrl,thumbnailUrl:Ar[Nr.bunny_video_id].thumbnailUrl});return Xs})})().catch(Wt=>console.warn("Failed to load signed Bunny asset URLs",Wt))},[s,Te]);const ye=(a==null?void 0:a.total_storage_mb)||0,ct=(a==null?void 0:a.max_storage_mb)||1024,pe=ye/ct*100,Ge=pe>=80,tt=pe>=100,st=async(Mt,Wt)=>{await navigator.clipboard.writeText(Mt),me.success(`${Wt} copied to clipboard`)},Ce=Mt=>Mt.share_token?`https://video.relevelup.com/${Mt.share_token}`:Mt.playback_url||"",et=Mt=>{const Wt=Ce(Mt),xs=o==null?void 0:o.find(Nr=>Nr.id===Mt.contact_id),Cs=ze(Mt.contact_id),Us=Cs!=="Unassigned"?Cs.split(" ")[0]:"",Ar=(xs==null?void 0:xs.phone)||"",Bt=`Hey${Us?` ${Us}`:""}! I recorded a quick video message for you. Check it out: ${Wt}`,Xs=Ar?`sms:${Ar}?body=${encodeURIComponent(Bt)}`:`sms:?body=${encodeURIComponent(Bt)}`;window.open(Xs,"_self")},Ct=Mt=>{const Wt=o==null?void 0:o.find(Xs=>Xs.id===Mt.contact_id),xs=(Wt==null?void 0:Wt.email)||"",Cs=Ce(Mt),Us="Check out this video",Ar=`I recorded a quick video for you: ${Cs}`,Bt=xs?`mailto:${xs}?subject=${encodeURIComponent(Us)}&body=${encodeURIComponent(Ar)}`:`mailto:?subject=${encodeURIComponent(Us)}&body=${encodeURIComponent(Ar)}`;window.open(Bt,"_self")},Ot=Mt=>{var Us;const Wt=Ce(Mt),xs=Mt.title||"Video Message",Cs=Mt.share_token?`https://video.relevelup.com/thumb/${Mt.share_token}`:((Us=Te[Mt.id])==null?void 0:Us.thumbnailUrl)||Mt.thumbnail_url||"";return``},ut=async Mt=>{if(!Mt.thumbnail_url&&!Mt.share_token){me.error("Video thumbnail not available yet");return}const Wt=Ot(Mt),xs=Ce(Mt),Cs=`Watch: ${Mt.title||"Video Message"} ${xs}`;try{const Us=new Blob([Wt],{type:"text/html"}),Ar=new Blob([Cs],{type:"text/plain"}),Bt=new ClipboardItem({"text/html":Us,"text/plain":Ar});await navigator.clipboard.write([Bt]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(Cs+` `+Wt),me.success("Copied! Paste into your email.")}},Oe=async Mt=>{try{me.loading("Preparing download...",{id:"download"});const{data:Wt,error:xs}=await G.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:Mt.bunny_video_id,isAgentVideo:!0}});if(xs||!(Wt!=null&&Wt.downloadUrl))throw new Error((xs==null?void 0:xs.message)||"Failed to get download URL");const Us=`${((Mt.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,Ar=await fetch(Wt.downloadUrl);if(!Ar.ok)throw new Error("Failed to fetch video file");const Bt=await Ar.blob(),Xs=URL.createObjectURL(Bt),Nr=document.createElement("a");Nr.href=Xs,Nr.download=Us,Nr.rel="noreferrer",document.body.appendChild(Nr),Nr.click(),Nr.remove(),URL.revokeObjectURL(Xs),me.success("Download started",{id:"download"})}catch(Wt){console.error("Download error:",Wt),me.error("Could not force download (your browser may block it).",{id:"download"})}},Xe=async Mt=>{C(Mt),ae(!0),Y(""),Z(!0);try{const{data:Wt,error:xs}=await G.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:Mt.bunny_video_id,title:Mt.title,isAgentVideo:!0,shareToken:Mt.share_token}});if(xs||!(Wt!=null&&Wt.html))throw new Error("Failed to generate CRM embed code");Y(Wt.html)}catch(Wt){console.error("CRM embed error:",Wt),me.error("Failed to generate CRM embed code"),Z(!1)}finally{ae(!1)}},at=Mt=>{C(Mt),I(!0)},Ke=async()=>{if(S)try{await l.mutateAsync({id:S.id,bunnyVideoId:S.bunny_video_id,hardDelete:!0}),O(!1),C(null),me.success("Video deleted successfully")}catch{me.error("Failed to delete video")}};return e.jsx(Ls,{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&&((He=p.team)==null?void 0:He.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(cr,{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(so,{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(Da,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),_==="team"?e.jsx(Zks,{videos:f,isLoading:y,searchTerm:N,setSearchTerm:w}):_==="analytics"?e.jsx(Hks,{}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:Ge?"border-amber-500":tt?"border-destructive":"",children:e.jsxs(Be,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(yL,{className:`h-5 w-5 ${tt?"text-destructive":Ge?"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:[ye.toFixed(1)," MB / ",ct>=1024?`${(ct/1024).toFixed(0)} GB`:`${ct} MB`]})]}),e.jsx(pi,{value:Math.min(pe,100),className:`h-2 ${tt?"[&>div]:bg-destructive":Ge?"[&>div]:bg-amber-500":""}`})]}),Ge&&!tt&&e.jsxs(Ye,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(co,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),tt&&e.jsxs(Ye,{variant:"destructive",children:[e.jsx(co,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),tt&&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(tn,{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:N,onChange:Mt=>w(Mt.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"})}):(ve==null?void 0:ve.length)===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"py-12 text-center",children:[e.jsx(hn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"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(Bs,{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:ve==null?void 0:ve.map(Mt=>{var Wt,xs;return e.jsx(Wks,{video:Mt,previewSrc:(Wt=Te[Mt.id])==null?void 0:Wt.previewUrl,thumbnailSrc:(xs=Te[Mt.id])==null?void 0:xs.thumbnailUrl,onOpen:()=>at(Mt),onDelete:()=>{C(Mt),O(!0)},onRename:()=>{C(Mt),Ve(Mt.title||""),we(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${Mt.contact_id}`),onGetEmbedCode:()=>{C(Mt),V(!0)},onCopyEmailHtml:()=>ut(Mt),onEmbedToCrm:()=>Xe(Mt),onShareWithTemplate:()=>{C(Mt),le(!0)},onSendViaGmail:()=>{C(Mt),xe(!0)},isGmailConnected:d,getContactName:ze,getShareUrl:Ce,copyToClipboard:st,formatDuration:Ee},Mt.id)})}),e.jsx(fs,{open:A,onOpenChange:I,children:e.jsxs(ms,{className:"max-w-2xl",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:(S==null?void 0:S.title)||"Video Preview"}),e.jsx(Rr,{children:(S==null?void 0:S.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ei,{className:"h-3 w-3"}),ze(S.contact_id)]})})]}),S&&e.jsxs("div",{className:"space-y-4",children:[S.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(ps,{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(to,{className:"h-4 w-4 mr-2"}),"Refresh Library"]})]}):e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:S.playback_url?(()=>{let Mt=S.playback_url;return Mt.includes("iframe.mediadelivery.net/play/")&&(Mt=Mt.replace("/play/","/embed/"),Mt+=(Mt.includes("?")?"&":"?")+"autoplay=false&responsive=true"),Mt.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:Mt,title:S.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:S.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:S.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")},S.playback_url)})():e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-muted rounded-lg",children:[e.jsx(hn,{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:()=>et(S),children:[e.jsx(Si,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!d&&e.jsxs(K,{variant:"outline",onClick:()=>Ct(S),children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>st(Ce(S),"Share link"),children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(K,{variant:"outline",onClick:()=>ut(S),children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(K,{variant:"outline",onClick:()=>Oe(S),children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),Xe(S)},children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),le(!0)},children:[e.jsx(Rl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),d&&(S==null?void 0:S.share_token)&&e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),xe(!0)},children:[e.jsx(Nn,{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),O(!0)},children:[e.jsx(yr,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(fs,{open:L,onOpenChange:O,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Delete Video"}),e.jsx(Rr,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Ke,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(Lks,{open:U,onOpenChange:q}),e.jsx(fs,{open:$,onOpenChange:V,children:e.jsxs(ms,{className:"sm:max-w-lg",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Embed Video"}),e.jsx(Rr,{children:"Copy this code to embed the video on your website."})]}),S&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Embed Code"}),e.jsx(_r,{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 Mt=``;st(Mt,"Embed code")},children:[e.jsx(Ya,{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."})]})]})}),S&&e.jsx(zlt,{open:ie,onOpenChange:le,video:S,contactName:ze(S.contact_id)}),S&&e.jsx($ks,{open:fe,onOpenChange:xe,video:S,gmailEmail:u,signedThumbnailUrl:(gt=Te[S.id])==null?void 0:gt.thumbnailUrl}),e.jsx(fs,{open:he,onOpenChange:we,children:e.jsxs(ms,{className:"max-w-sm",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Rename Video"}),e.jsx(Rr,{children:"Enter a new title for this video."})]}),e.jsx(Fe,{value:Ne,onChange:Mt=>Ve(Mt.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:Mt=>{Mt.key==="Enter"&&Ne.trim()&&i.mutate({id:S.id,title:Ne.trim()},{onSuccess:()=>{me.success("Video renamed"),we(!1)}})}}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>we(!1),children:"Cancel"}),e.jsx(K,{disabled:!Ne.trim()||i.isPending,onClick:()=>{i.mutate({id:S.id,title:Ne.trim()},{onSuccess:()=>{me.success("Video renamed"),we(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:ee,onOpenChange:Z,children:e.jsxs(ms,{className:"sm:max-w-lg",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Kr,{className:"h-5 w-5"}),"Embed to CRM"]}),e.jsx(Rr,{children:"Copy this HTML code and paste it into your CRM's email editor. It uses a simple image + link format that works in all CRM email programs."})]}),ce?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ps,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):J?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"CRM Email HTML"}),e.jsx(_r,{readOnly:!0,rows:12,value:J,className:"font-mono text-xs"})]}),e.jsxs(K,{className:"w-full",onClick:()=>{st(J,"CRM embed code")},children:[e.jsx(Ya,{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 Zks({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=k.useMemo(()=>{if(!r)return t;const i=r.toLowerCase();return t.filter(d=>(d.title||"").toLowerCase().includes(i)||(d.owner_name||"").toLowerCase().includes(i)||(d.recipient_name||"").toLowerCase().includes(i))},[t,r]),o=k.useMemo(()=>{const i=new Map;return a.forEach(d=>{const u=i.get(d.owner_user_id);u?u.videos.push(d):i.set(d.owner_user_id,{name:d.owner_name,avatar:d.owner_avatar_url,videos:[d]})}),Array.from(i.entries())},[a]),l=i=>{if(!i)return"0:00";const d=Math.floor(i/60),u=i%60;return`${d}:${u.toString().padStart(2,"0")}`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(tn,{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(Ie,{children:e.jsxs(Be,{className:"py-12 text-center",children:[e.jsx(cr,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No team videos"}),e.jsx("p",{className:"text-muted-foreground",children:t.length===0?"Your teammates haven't recorded any videos yet.":"No videos match your search."})]})}):e.jsx("div",{className:"space-y-6",children:o.map(([i,d])=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(vn,{className:"h-7 w-7",children:[e.jsx(Ca,{src:d.avatar||""}),e.jsx(_n,{children:(d.name||"?").charAt(0).toUpperCase()})]}),e.jsx("h3",{className:"font-semibold text-sm",children:d.name}),e.jsx(Ye,{variant:"secondary",className:"text-xs",children:d.videos.length})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:d.videos.map(u=>e.jsxs(Ie,{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(hn,{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(Be,{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(Ei,{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(jn,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(rn,{className:"h-3 w-3"}),gs(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const Yks=()=>{const{user:t}=$s();return ft({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})},f9e=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Xks({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Yks(),[a,o]=k.useState(""),[l,i]=k.useState("all"),d=k.useMemo(()=>{if(!r)return new Map;const b=new Map;let N=0;return r.forEach(w=>{b.has(w.owner_user_id)||(b.set(w.owner_user_id,{name:w.owner_name||"Unknown",avatar:w.owner_avatar_url,color:f9e[N%f9e.length]}),N++)}),b},[r]),u=k.useMemo(()=>Array.from(d.entries()).map(([b,N])=>({id:b,...N})),[d]),p=k.useMemo(()=>{if(!r)return[];let b=r;if(l!=="all"&&(b=b.filter(N=>N.owner_user_id===l)),a.trim()){const N=a.toLowerCase();b=b.filter(w=>{var S,C,A,I;return w.deal_name.toLowerCase().includes(N)||((S=w.contact_name)==null?void 0:S.toLowerCase().includes(N))||((C=w.property_address)==null?void 0:C.toLowerCase().includes(N))||((A=w.city)==null?void 0:A.toLowerCase().includes(N))||((I=w.owner_name)==null?void 0:I.toLowerCase().includes(N))})}return b},[r,a,l]),f=k.useMemo(()=>{const b=new Map;return p.forEach(N=>{const w=N.stage_name||"Unknown";b.has(w)||b.set(w,{name:w,color:N.stage_color,icon:N.stage_icon,deals:[],totalValue:0});const S=b.get(w);S.deals.push(N),S.totalValue+=N.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(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-[95vw] w-full max-h-[90vh] flex flex-col",children:[e.jsx(ks,{children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(cr,{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(tn,{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(zs,{value:l,onValueChange:i,children:[e.jsx(Os,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"All Members"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Members"}),u.map(b=>e.jsx(yt,{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(Ss,{className:"h-12 w-full mb-2 rounded-lg"}),e.jsx(Ss,{className:"h-24 w-full mb-2 rounded-lg"}),e.jsx(Ss,{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(cr,{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 N=b.icon&&lje[b.icon]||sd;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(N,{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(Ye,{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(di,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:b.deals.map(w=>{const S=d.get(w.owner_user_id);return e.jsx(Qks,{deal:w,ownerColor:(S==null?void 0:S.color)||"#888",ownerName:(S==null?void 0:S.name)||"Unknown",ownerAvatar:(S==null?void 0:S.avatar)||null,formatPrice:_},w.id)})})})]},b.name)})})}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t shrink-0",children:[p.length," deal",p.length!==1?"s":""," across ",f.length," stage",f.length!==1?"s":""," from ",u.length," member",u.length!==1?"s":""]})]})})}function Qks({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(vn,{className:"h-4 w-4",children:[e.jsx(Ca,{src:n||""}),e.jsx(_n,{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(Ye,{variant:"outline",className:Rt("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(Mn,{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(_c,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function Jks({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:Rt("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(cr,{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(wl,{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(di,{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:Rt("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(vn,{className:"h-7 w-7",children:[e.jsx(Ca,{src:l.avatar_url||""}),e.jsx(_n,{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:Rt("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx(Lr,{checked:i,onCheckedChange:()=>r(l.id),className:"scale-75",onClick:d=>d.stopPropagation()})]},l.id)})}),t.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No team members"})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center pt-2 gap-2",children:[t.slice(0,5).map(l=>{const i=s.has(l.id);return e.jsx("button",{onClick:()=>r(l.id),className:"relative",title:l.name,children:e.jsxs(vn,{className:Rt("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(Ca,{src:l.avatar_url||""}),e.jsx(_n,{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 x9e=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function e4s(){const t=_a(),{data:s}=Rx(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=ft({queryKey:["team-pipeline-members",n,t],queryFn:async()=>{const{data:o,error:l}=await G.from("team_members").select("user_id, role").eq("team_id",n).neq("user_id",t);if(l)throw l;if(!o||o.length===0)return[];const i=o.map(p=>p.user_id),{data:d,error:u}=await G.from("profiles").select("id, name, avatar_url").in("id",i);if(u)throw u;return(d||[]).map((p,f)=>({id:p.id,name:p.name||"Unknown",avatar_url:p.avatar_url,color:x9e[f%x9e.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function t4s(t){return ft({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 s4s(){const t=_a();return ft({queryKey:["all-deal-tags-map",t],queryFn:async()=>{if(!t)return{tags:[],byDeal:{},unique:[]};const{data:s,error:r}=await G.from("deal_tags").select("id, deal_id, tag").eq("owner_user_id",t);if(r)throw r;const n=s||[],a={},o=new Set;n.forEach(i=>{a[i.deal_id]||(a[i.deal_id]=[]),a[i.deal_id].push(i.tag),o.add(i.tag)});const l=Array.from(o).sort((i,d)=>i.localeCompare(d));return{tags:n,byDeal:a,unique:l}},enabled:!!t})}function Blt({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=k.useState(!1),l=t.find(d=>d.id===s),i=d=>{d.id!==s&&r(d.id,d.name),o(!1)};return e.jsxs(Ud,{open:a,onOpenChange:o,children:[e.jsx(Vd,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",disabled:n,onClick:d=>d.stopPropagation(),children:[l&&e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:l.color}}),e.jsx("span",{className:"max-w-[80px] truncate",children:(l==null?void 0:l.name)||"Move"}),e.jsx(ja,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(jd,{align:"end",className:"w-48 z-50 bg-popover",onClick:d=>d.stopPropagation(),children:t.map(d=>{const u=d.icon&&lje[d.icon]||sd,p=d.id===s;return e.jsxs(xa,{onClick:()=>i(d),className:Rt("flex items-center gap-2 cursor-pointer",p&&"bg-accent"),children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center shrink-0",style:{backgroundColor:`${d.color}20`},children:e.jsx(u,{className:"h-3 w-3",style:{color:d.color}})}),e.jsx("span",{className:"flex-1",children:d.name}),p&&e.jsx(ea,{className:"h-4 w-4 text-primary"})]},d.id)})})]})}const r4s={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"}},n4s={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 $lt({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var C,A;const d=bE(),u=r4s[t.deal_type],p=n4s[t.priority],f=k.useMemo(()=>t.target_close_date?Vg(pl(t.target_close_date),new Date):null,[t.target_close_date]),y=f!==null&&f<0,_=f!==null&&f<=7&&f>=0,b=k.useMemo(()=>{var O;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const I=((O=t.listing)==null?void 0:O.created_at)||t.listing_date;if(!I)return null;const L=t.contract_date?pl(t.contract_date):new Date;return Vg(L,pl(I))},[t]),N=l&&!t.scorecard_transaction_id,w=!!t.scorecard_transaction_id,S=I=>I?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I):null;return e.jsx(Ie,{className:Rt("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",N&&"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(Be,{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(vn,{className:"h-4 w-4",children:[e.jsx(Ca,{src:i.avatar_url||""}),e.jsx(_n,{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(Ye,{variant:"outline",className:Rt("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(vn,{className:"h-5 w-5",children:e.jsxs(_n,{className:"text-[10px] bg-primary/10 text-primary",children:[(C=t.contact.first_name)==null?void 0:C[0],(A=t.contact.last_name)==null?void 0:A[0]]})}),e.jsxs("span",{className:"truncate",children:[t.contact.first_name," ",t.contact.last_name]})]}),t.listing&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(Do,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),N&&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(Hi,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),w&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx(Hn,{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(jM,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:Rt("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(Mn,{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(_c,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:S(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",S(t.expected_commission)," GCI"]}),(()=>{const I=px(t);return I!==null&&I!==t.expected_commission?e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:["• ",S(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:Rt("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",p.color),children:[e.jsx("div",{className:Rt("w-1.5 h-1.5 rounded-full",p.dot)}),e.jsx("span",{className:"capitalize",children:t.priority})]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.probability,"%"]})]}),o&&d&&n&&a?e.jsx(Blt,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(I,L)=>a(t.id,I,L)}):t.target_close_date?e.jsxs("div",{className:Rt("flex items-center gap-1 text-[10px]",y&&"text-red-600",_&&!y&&"text-amber-600",!y&&!_&&"text-muted-foreground"),children:[y?e.jsx(co,{className:"h-3 w-3"}):e.jsx(nn,{className:"h-3 w-3"}),e.jsx("span",{children:y?`${Math.abs(f)}d overdue`:_?`${f}d left`:gs(pl(t.target_close_date),"MMM d")})]}):null]})]})})}function a4s({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:d=!1,getOwnerInfo:u}){const p=k.useRef(null),f=s.reduce((w,S)=>w+(S.expected_price||0),0),y=s.reduce((w,S)=>w+(S.expected_commission||0),0),_=s.reduce((w,S)=>w+(px(S)||0),0),b=w=>w>=1e6?`$${(w/1e6).toFixed(1)}M`:w>=1e3?`$${(w/1e3).toFixed(0)}K`:`$${w.toFixed(0)}`,N=t.icon&&lje[t.icon]||sd;return e.jsxs("div",{ref:p,className:Rt("flex flex-col h-full min-w-[280px] max-w-[320px] bg-muted/30 rounded-xl border border-border/50 transition-all duration-200",i&&"border-primary/50 bg-primary/5 ring-2 ring-primary/20"),onDragOver:w=>o(w,t.id),onDrop:w=>l(w,t.id),children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:t.color,borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}20`},children:e.jsx(N,{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(Ye,{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(di,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(w=>e.jsx("div",{draggable:!0,onDragStart:S=>{S.dataTransfer.effectAllowed="move",a(w.id,t.id)},children:e.jsx($lt,{deal:w,onClick:()=>r(w),isWonStage:d,ownerInfo:(u==null?void 0:u(w))||null})},w.id)),s.length===0&&e.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground text-sm",children:[e.jsx("p",{className:"mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-xs",children:"Drag deals here or add new"})]})]})}),e.jsx("div",{className:"p-2 border-t border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-foreground",onClick:()=>n(t.id),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})})]})}function i4s({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:Oh,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Weighted GCI",value:r((t==null?void 0:t.weightedGCI)||0),icon:DL,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:GL,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:cL,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:Yo,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(Ie,{className:"animate-pulse",children:e.jsx(Be,{className:"p-4",children:e.jsx("div",{className:"h-10 bg-muted rounded"})})},a))}):e.jsx(S1,{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:n.map(a=>{const o=e.jsx(Ie,{className:"border-border/50 hover:shadow-sm transition-shadow",children:e.jsx(Be,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Rt("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:Rt("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(Jl,{children:[e.jsx(ec,{asChild:!0,children:o}),e.jsx(Il,{children:e.jsx("p",{children:a.tooltip})})]},a.label):o})})})}function o4s({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=$s(),[a,o]=k.useState(t.portal_enabled);if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 opacity-60",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(Ye,{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(uf,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(hf,{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(qr,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(Ye,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(Fi,{className:Rt("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(mf,{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(ge,{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(Lr,{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(ge,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(cke,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:Rt("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(vle,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(yd,{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:Rt("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(vle,{value:"public"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(gd,{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(Gi,{id:"require_onboarding",checked:t.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx(ge,{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(Gi,{id:"allow_spouse",checked:t.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),e.jsx(ge,{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(ge,{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(ge,{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(ge,{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(ge,{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(ge,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs(zs,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"email",children:"Email"}),e.jsxs(yt,{value:"sms",disabled:!t.client_phone,children:["SMS ",!t.client_phone&&"(add phone first)"]})]})]})]})]})]})]})]})})]})})}const l4s=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],c4s=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function d4s({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=Eme(),{data:o}=Uh(),{data:l}=$Xe(),i=nhe(),d=Iit(),u=Lit(),p=JSe(),[f,y]=k.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[_,b]=k.useState(""),[N,w]=k.useState(!1),[S,C]=k.useState(!1),[A,I]=k.useState({first_name:"",last_name:"",email:"",phone:""}),L=(l==null?void 0:l.filter(J=>((r==null?void 0:r.listing_id)===J.id,!0)))||[],[O,U]=k.useState({deal_name:"",deal_type:"buyer",stage_id:"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",brokerage_split_pct:"",team_split_pct:"",referral_fee_pct:"",franchise_fee_pct:"",transaction_fee:"",commission_calc_method:"standard",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""});k.useEffect(()=>{var J,Y,ce,ae,ie,le,fe,xe;t&&(r?(U({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:((J=r.expected_price)==null?void 0:J.toString())||"",commission_percentage:((Y=r.commission_percentage)==null?void 0:Y.toString())||"3",brokerage_split_pct:((ce=r.brokerage_split_pct)==null?void 0:ce.toString())||"",team_split_pct:((ae=r.team_split_pct)==null?void 0:ae.toString())||"",referral_fee_pct:((ie=r.referral_fee_pct)==null?void 0:ie.toString())||"",franchise_fee_pct:((le=r.franchise_fee_pct)==null?void 0:le.toString())||"",transaction_fee:((fe=r.transaction_fee)==null?void 0:fe.toString())||"",commission_calc_method:r.commission_calc_method||"standard",target_close_date:r.target_close_date?pl(r.target_close_date):void 0,contract_date:r.contract_date?pl(r.contract_date):void 0,listing_date:r.listing_date?pl(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}`)):(U({deal_name:"",deal_type:"buyer",stage_id:n||((xe=a==null?void 0:a[0])==null?void 0:xe.id)||"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",brokerage_split_pct:"",team_split_pct:"",referral_fee_pct:"",franchise_fee_pct:"",transaction_fee:"",commission_calc_method:"standard",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""}),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(J=>{var ce,ae,ie;const Y=_.toLowerCase();return((ce=J.first_name)==null?void 0:ce.toLowerCase().includes(Y))||((ae=J.last_name)==null?void 0:ae.toLowerCase().includes(Y))||((ie=J.email)==null?void 0:ie.toLowerCase().includes(Y))}).slice(0,5),$=()=>{const J=parseFloat(O.expected_price)||0,Y=parseFloat(O.commission_percentage)||0;return J*(Y/100)},V=()=>{const J=$();if(!J)return null;const Y=parseFloat(O.brokerage_split_pct)||0,ce=parseFloat(O.team_split_pct)||0,ae=parseFloat(O.referral_fee_pct)||0,ie=parseFloat(O.franchise_fee_pct)||0,le=parseFloat(O.transaction_fee)||0;if(O.commission_calc_method==="referral_first"){let xe=J;ae&&(xe-=J*ae/100);let he=xe;return Y&&(he-=xe*Y/100),ce&&(he-=J*ce/100),ie&&(he-=J*ie/100),le&&(he-=le),Math.max(0,he)}let fe=J;return Y&&(fe=fe*((100-Y)/100)),ce&&(fe=fe*((100-ce)/100)),ae&&(fe=fe-J*ae/100),ie&&(fe=fe-J*ie/100),le&&(fe=fe-le),Math.max(0,fe)},ee=async J=>{var Y,ce,ae;if(J.preventDefault(),!O.deal_name.trim()){me.error("Please enter a deal name");return}try{const ie={deal_name:O.deal_name,deal_type:O.deal_type,stage_id:O.stage_id||null,contact_id:O.contact_id||null,listing_id:O.listing_id||null,property_address:O.property_address||null,city:O.city||null,state:O.state||null,zip_code:O.zip_code||null,expected_price:O.expected_price?parseFloat(O.expected_price):null,expected_commission:$()||null,commission_percentage:O.commission_percentage?parseFloat(O.commission_percentage):3,brokerage_split_pct:O.brokerage_split_pct?parseFloat(O.brokerage_split_pct):null,team_split_pct:O.team_split_pct?parseFloat(O.team_split_pct):null,referral_fee_pct:O.referral_fee_pct?parseFloat(O.referral_fee_pct):null,franchise_fee_pct:O.franchise_fee_pct?parseFloat(O.franchise_fee_pct):null,transaction_fee:O.transaction_fee?parseFloat(O.transaction_fee):null,commission_calc_method:O.commission_calc_method,target_close_date:((Y=O.target_close_date)==null?void 0:Y.toISOString().split("T")[0])||null,contract_date:((ce=O.contract_date)==null?void 0:ce.toISOString().split("T")[0])||null,listing_date:((ae=O.listing_date)==null?void 0:ae.toISOString().split("T")[0])||null,priority:O.priority,probability:parseInt(O.probability)||50,notes:O.notes||null};if(r)await u.mutateAsync({id:r.id,...ie}),me.success("Deal updated successfully");else{const le=await d.mutateAsync(ie);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")}},Z=d.isPending||u.isPending;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:r?"Edit Deal":"Add New Deal"}),e.jsx(Rr,{children:r?"Update the deal details below.":"Enter the details for your new deal."})]}),e.jsxs("form",{onSubmit:ee,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(ge,{htmlFor:"deal_name",children:"Deal Name *"}),e.jsx(Fe,{id:"deal_name",value:O.deal_name,onChange:J=>U(Y=>({...Y,deal_name:J.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Deal Type"}),e.jsxs(zs,{value:O.deal_type,onValueChange:J=>U(Y=>({...Y,deal_type:J})),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:l4s.map(J=>e.jsx(yt,{value:J.value,children:J.label},J.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Stage"}),e.jsxs(zs,{value:O.stage_id||"none",onValueChange:J=>U(Y=>({...Y,stage_id:J==="none"?"":J})),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select stage"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"No Stage"}),a==null?void 0:a.map(J=>e.jsx(yt,{value:J.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:J.color}}),J.name]})},J.id))]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(tn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{value:_,onChange:J=>{b(J.target.value),w(!0),C(!1),J.target.value||U(Y=>({...Y,contact_id:""}))},onFocus:()=>w(!0),placeholder:"Search contacts...",className:"pl-9"}),N&&_&&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(J=>e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2",onClick:()=>{U(Y=>({...Y,contact_id:J.id})),b(`${J.first_name} ${J.last_name}`),w(!1)},children:[e.jsx(Ei,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:[J.first_name," ",J.last_name]}),J.email&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:J.email})]},J.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 J=_.trim().split(/\s+/);I({first_name:J[0]||"",last_name:J.slice(1).join(" ")||"",email:"",phone:""}),C(!0),w(!1)},children:[e.jsx(il,{className:"h-4 w-4"}),e.jsxs("span",{children:['Create new contact "',_.trim(),'"']})]})]})]}),S&&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(il,{className:"h-3.5 w-3.5"}),"Quick Add Contact"]}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>C(!1),children:"Cancel"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Fe,{placeholder:"First name *",value:A.first_name,onChange:J=>I(Y=>({...Y,first_name:J.target.value})),className:"h-8 text-sm"}),e.jsx(Fe,{placeholder:"Last name",value:A.last_name,onChange:J=>I(Y=>({...Y,last_name:J.target.value})),className:"h-8 text-sm"}),e.jsx(Fe,{placeholder:"Email",type:"email",value:A.email,onChange:J=>I(Y=>({...Y,email:J.target.value})),className:"h-8 text-sm"}),e.jsx(Fe,{placeholder:"Phone",type:"tel",value:A.phone,onChange:J=>I(Y=>({...Y,phone:J.target.value})),className:"h-8 text-sm"})]}),e.jsx(K,{type:"button",size:"sm",className:"w-full h-8",disabled:!A.first_name.trim()||i.isPending,onClick:async()=>{try{const J=await i.mutateAsync({first_name:A.first_name.trim(),last_name:A.last_name.trim()||null,email:A.email.trim()||null,phone:A.phone.trim()||null});J&&(U(Y=>({...Y,contact_id:J.id})),b(`${J.first_name} ${J.last_name||""}`.trim()),C(!1))}catch{}},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(il,{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(ge,{className:"flex items-center gap-2",children:[e.jsx(Do,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs(zs,{value:O.listing_id||"none",onValueChange:J=>{const Y=J==="none"?"":J,ce=L.find(ae=>ae.id===Y);U(ce?ae=>{var ie;return{...ae,listing_id:Y,deal_type:"seller",property_address:ce.property_address||ae.property_address,city:ce.city||ae.city,state:ce.state||ae.state,expected_price:((ie=ce.price)==null?void 0:ie.toString())||ae.expected_price}}:ae=>({...ae,listing_id:Y}))},children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select a listing to sync status..."})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"None"}),L.map(J=>e.jsx(yt,{value:J.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:J.property_address||`${J.city}, ${J.state}`}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["$",(J.price/1e3).toFixed(0),"K"]})]})},J.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(ge,{htmlFor:"property_address",children:"Address"}),e.jsx(Fe,{id:"property_address",value:O.property_address,onChange:J=>U(Y=>({...Y,property_address:J.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"city",children:"City"}),e.jsx(Fe,{id:"city",value:O.city,onChange:J=>U(Y=>({...Y,city:J.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"state",children:"State"}),e.jsx(Fe,{id:"state",value:O.state,onChange:J=>U(Y=>({...Y,state:J.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(Fe,{id:"zip_code",value:O.zip_code,onChange:J=>U(Y=>({...Y,zip_code:J.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(ge,{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:O.expected_price,onChange:J=>U(Y=>({...Y,expected_price:J.target.value})),className:"pl-7",placeholder:"500000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"commission_percentage",children:"Commission %"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{id:"commission_percentage",type:"number",step:"0.1",value:O.commission_percentage,onChange:J=>U(Y=>({...Y,commission_percentage:J.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(ge,{children:"Expected GCI"}),e.jsx(Fe,{value:$()?`$${$().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(ge,{className:"text-xs whitespace-nowrap",children:"Calculation Method:"}),e.jsxs(zs,{value:O.commission_calc_method,onValueChange:J=>U(Y=>({...Y,commission_calc_method:J})),children:[e.jsx(Os,{className:"h-7 text-xs",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"standard",children:"Standard (all splits on GCI)"}),e.jsx(yt,{value:"referral_first",children:"Referral First (brokerage split after referral)"})]})]})]}),O.commission_calc_method==="referral_first"&&e.jsx("p",{className:"text-[10px] text-muted-foreground bg-blue-50 dark:bg-blue-950/30 p-2 rounded",children:"💡 Referral fee is deducted from GCI first, then the brokerage split is applied to the remaining amount."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs",children:"Brokerage Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{type:"number",step:"1",min:"0",max:"100",value:O.brokerage_split_pct,onChange:J=>U(Y=>({...Y,brokerage_split_pct:J.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(ge,{className:"text-xs",children:"Team Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{type:"number",step:"1",min:"0",max:"100",value:O.team_split_pct,onChange:J=>U(Y=>({...Y,team_split_pct:J.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(ge,{className:"text-xs",children:"Referral Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{type:"number",step:"1",min:"0",max:"100",value:O.referral_fee_pct,onChange:J=>U(Y=>({...Y,referral_fee_pct:J.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(ge,{className:"text-xs",children:"Franchise Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{type:"number",step:"1",min:"0",max:"100",value:O.franchise_fee_pct,onChange:J=>U(Y=>({...Y,franchise_fee_pct:J.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(ge,{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:O.transaction_fee,onChange:J=>U(Y=>({...Y,transaction_fee:J.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(ge,{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(ge,{children:"Target Close Date"}),e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Rt("w-full justify-start text-left font-normal",!O.target_close_date&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),O.target_close_date?gs(O.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(ff,{mode:"single",selected:O.target_close_date,onSelect:J=>U(Y=>({...Y,target_close_date:J})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Contract Date"}),e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Rt("w-full justify-start text-left font-normal",!O.contract_date&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),O.contract_date?gs(O.contract_date,"PPP"):"Pick a date"]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(ff,{mode:"single",selected:O.contract_date,onSelect:J=>U(Y=>({...Y,contract_date:J})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),(O.deal_type==="seller"||O.deal_type==="dual")&&!O.listing_id&&e.jsxs("div",{className:"space-y-2 col-span-2",children:[e.jsx(ge,{children:"Listing Date (for Days on Market)"}),e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Rt("w-full justify-start text-left font-normal",!O.listing_date&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),O.listing_date?gs(O.listing_date,"PPP"):"Pick a date"]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(ff,{mode:"single",selected:O.listing_date,onSelect:J=>U(Y=>({...Y,listing_date:J})),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(ge,{children:"Priority"}),e.jsxs(zs,{value:O.priority,onValueChange:J=>U(Y=>({...Y,priority:J})),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:c4s.map(J=>e.jsx(yt,{value:J.value,children:J.label},J.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{type:"number",min:"0",max:"100",value:O.probability,onChange:J=>U(Y=>({...Y,probability:J.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(ge,{htmlFor:"notes",children:"Notes"}),e.jsx(_r,{id:"notes",value:O.notes,onChange:J=>U(Y=>({...Y,notes:J.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(o4s,{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:Z,children:[Z&&e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function u4s({dealId:t}){const s=_a(),r=es(),[n,a]=k.useState(""),[o,l]=k.useState(!1),{data:i=[]}=ft({queryKey:["deal-tags",t],queryFn:async()=>{const{data:b,error:N}=await G.from("deal_tags").select("*").eq("deal_id",t).order("created_at");if(N)throw N;return b},enabled:!!t}),{data:d=[]}=ft({queryKey:["all-deal-tags",s],queryFn:async()=>{if(!s)return[];const{data:b,error:N}=await G.from("deal_tags").select("tag").eq("owner_user_id",s);if(N)throw N;return[...new Set(b.map(S=>S.tag))].sort()},enabled:!!s}),u=Et({mutationFn:async b=>{if(!s)throw new Error("Not authenticated");const{error:N}=await G.from("deal_tags").insert({deal_id:t,owner_user_id:s,tag:b.trim()});if(N)throw N},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]}),r.invalidateQueries({queryKey:["all-deal-tags"]}),a("")}}),p=Et({mutationFn:async b=>{const{error:N}=await G.from("deal_tags").delete().eq("id",b);if(N)throw N},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]})}}),f=()=>{const b=n.trim();b&&(i.some(N=>N.tag.toLowerCase()===b.toLowerCase())||u.mutate(b))},y=i.map(b=>b.tag.toLowerCase()),_=d.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(Ye,{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(Sr,{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(Bs,{className:"h-3 w-3"})," Add tag"]})]}),o&&e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-1.5",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 name...",className:"h-8 text-xs flex-1",autoFocus:!0}),e.jsx("button",{type:"button",onClick:f,disabled:!n.trim()||u.isPending,className:"h-8 px-3 rounded-md bg-primary text-primary-foreground text-xs font-medium disabled:opacity-50 shrink-0",children:"Add"}),e.jsx("button",{type:"button",onClick:()=>{l(!1),a("")},className:"h-8 px-2 rounded-md bg-muted text-muted-foreground text-xs shrink-0",children:"Cancel"})]}),n&&_.length>0&&e.jsx("div",{className:"absolute z-20 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-2 text-left text-xs hover:bg-muted active:bg-muted",onClick:N=>{N.preventDefault(),u.mutate(b)},children:b},b))})]})]})}function h4s(t){return ft({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 m4s(){const t=_a(),s=es();return Et({mutationFn:async({dealId:r,file:n})=>{if(!t)throw new Error("Not authenticated");const a=n.name.split(".").pop(),o=`${t}/${r}/${crypto.randomUUID()}.${a}`,{error:l}=await G.storage.from("deal-files").upload(o,n);if(l)throw l;const{data:i,error:d}=await G.from("deal_files").insert({deal_id:r,owner_user_id:t,file_name:n.name,file_size:n.size,file_type:n.type||null,storage_path:o}).select().single();if(d)throw d;return i},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["deal-files",n.dealId]})}})}function p4s(){const t=es();return Et({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 f4s(){const t=es();return Et({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 x4s(t){const{data:s,error:r}=await G.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const g9e={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function g4s({open:t,onOpenChange:s}){const{data:r,isLoading:n}=y2s(),a=v2s(),o=_2s(),l=b2s(),[i,d]=k.useState(!1),[u,p]=k.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[f,y]=k.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(""),d(!1),me.success("Question added")}catch{me.error("Failed to add question")}},b=async C=>{try{await l.mutateAsync(C),me.success("Question removed")}catch{me.error("Failed to remove question")}},N=async(C,A)=>{try{await o.mutateAsync({id:C,is_required:A})}catch{me.error("Failed to update question")}},w=()=>{f.trim()&&(p(C=>({...C,options:[...C.options,f.trim()]})),y(""))},S=C=>{p(A=>({...A,options:A.options.filter((I,L)=>L!==C)}))};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-md max-h-[85vh] flex flex-col",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Custom Intake Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These questions appear on all your portal onboarding forms."})]}),e.jsx(di,{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(ps,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(C=>{var A;return e.jsx("div",{className:"border rounded-lg p-3 space-y-2",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(uu,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:C.question_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Ye,{variant:"secondary",className:"text-xs",children:g9e[C.field_type]||C.field_type}),C.is_required&&e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Required"})]}),C.field_type==="dropdown"&&((A=C.options)==null?void 0:A.length)>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Options: ",C.options.join(", ")]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(Lr,{checked:C.is_required,onCheckedChange:I=>N(C.id,I),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>b(C.id),children:e.jsx(yr,{className:"h-3.5 w-3.5"})})]})]})},C.id)}),!n&&(r==null?void 0:r.length)===0&&!i&&e.jsxs("div",{className:"text-center py-8 border border-dashed rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No custom questions yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add questions that clients will answer during onboarding."})]}),i&&e.jsxs("div",{className:"border-2 border-primary/20 rounded-lg p-4 space-y-3 bg-primary/5",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm font-medium",children:"Question"}),e.jsx(Fe,{value:u.question_text,onChange:C=>p(A=>({...A,question_text:C.target.value})),className:"mt-1",placeholder:"e.g., Do you have a home to sell first?",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm font-medium",children:"Answer Type"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(g9e).map(([C,A])=>e.jsx("button",{type:"button",onClick:()=>p(I=>({...I,field_type:C,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${u.field_type===C?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:A},C))})]}),u.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm font-medium",children:"Options"}),e.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[u.options.map((C,A)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-1 text-sm bg-muted/50 rounded px-2 py-1",children:C}),e.jsx("button",{onClick:()=>S(A),className:"text-muted-foreground hover:text-destructive",children:e.jsx(Sr,{className:"h-3.5 w-3.5"})})]},A)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:f,onChange:C=>y(C.target.value),onKeyDown:C=>C.key==="Enter"&&(C.preventDefault(),w()),placeholder:"Add option...",className:"h-8 text-sm"}),e.jsx(K,{variant:"outline",size:"sm",onClick:w,disabled:!f.trim(),className:"h-8",children:e.jsx(Bs,{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(Lr,{checked:u.is_required,onCheckedChange:C=>p(A=>({...A,is_required:C}))}),e.jsx(ge,{className:"text-xs text-muted-foreground",children:"Required"})]})}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>d(!1),className:"flex-1",children:"Cancel"}),e.jsxs(K,{size:"sm",onClick:_,disabled:!u.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?e.jsx(ps,{className:"h-3 w-3 mr-1 animate-spin"}):null,"Add Question"]})]})]})]})}),e.jsxs("div",{className:"flex justify-between pt-4 border-t shrink-0",children:[i?e.jsx("div",{}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>d(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function y4s({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=k.useState(""),[i,d]=k.useState(!1),{data:u,isLoading:p}=ft({queryKey:["all-owner-portals",s],queryFn:async()=>{const{data:b,error:N}=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(N)throw N;return b},enabled:i||!!n}),f=k.useMemo(()=>!n||!u?null:u.find(b=>b.id===n),[n,u]),y=k.useMemo(()=>!u||!r?[]:u.filter(b=>{var N;return((N=b.client_email)==null?void 0:N.toLowerCase())===r.toLowerCase()&&b.id!==t}),[u,r,t]),_=k.useMemo(()=>{if(!u||!o.trim())return[];const b=o.toLowerCase();return u.filter(N=>{var S,C,A,I;const w=N.deal_pipeline;return((S=N.client_name)==null?void 0:S.toLowerCase().includes(b))||((C=N.client_email)==null?void 0:C.toLowerCase().includes(b))||((A=w==null?void 0:w.deal_name)==null?void 0:A.toLowerCase().includes(b))||((I=w==null?void 0:w.property_address)==null?void 0:I.toLowerCase().includes(b))})},[u,o]);if(n){const b=f==null?void 0:f.deal_pipeline;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(Do,{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(kS,{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(ge,{className:"text-sm font-medium",children:"Link Another Transaction"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Combine buy + sell into one portal"})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>d(!i),children:[e.jsx(Do,{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 N=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(Ye,{variant:"outline",className:"text-[10px] shrink-0 bg-amber-100 border-amber-300 text-amber-700",children:(N==null?void 0:N.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:(N==null?void 0:N.deal_name)||b.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:N==null?void 0:N.property_address})]}),e.jsx(Do,{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(tn,{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(ps,{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 N=b.deal_pipeline;return e.jsxs("button",{onClick:()=>{a(b.id),d(!1),l("")},className:"w-full flex items-center gap-2 border rounded-lg p-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(Ye,{variant:"outline",className:"text-[10px] shrink-0",children:(N==null?void 0:N.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:(N==null?void 0:N.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 QCe({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=k.useState(!1),[d,u]=k.useState([]),[p,f]=k.useState(!1),[y,_]=k.useState("");k.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:N})=>{u(N||[]),f(!1)}))},[l,t]);const b=d.filter(N=>!y||(N.title||N.recipient_name||"").toLowerCase().includes(y.toLowerCase()));return e.jsxs(fs,{open:l,onOpenChange:i,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{variant:a,size:n,className:o||"gap-1.5 shrink-0",children:[e.jsx(Ld,{className:"h-3.5 w-3.5"}),r]})}),e.jsxs(ms,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Select from Video Library"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a video from your library"})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(tn,{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:N=>_(N.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(Ss,{className:"h-16 w-full"}),e.jsx(Ss,{className:"h-16 w-full"})]}):b.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:d.length===0?"No videos in your library yet":"No videos match your search"}):b.map(N=>e.jsxs("button",{onClick:()=>{s(N.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:N.thumbnail_url?e.jsx("img",{src:N.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:w=>{const S=w.currentTarget.parentElement;if(S){w.currentTarget.remove();const C=document.createElement("span");C.innerHTML="🎬",C.className="text-lg",S.appendChild(C)}}}):e.jsx(hn,{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:N.title||N.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[N.duration_seconds?`${Math.round(N.duration_seconds)}s`:"",N.created_at?` · ${new Date(N.created_at).toLocaleDateString()}`:""]})]})]},N.id))})]})]})}function JCe({contactId:t,onVideoReady:s}){const[r,n]=k.useState(!1),[a,o]=k.useState("record"),[l,i]=k.useState(0),[d,u]=k.useState(0),p=Ew(),f=()=>{o("record"),i(0),u(0)},y=b=>{!b&&(a==="uploading"||a==="processing")||(n(b),b||f())},_=k.useCallback(async(b,N)=>{o("uploading");try{const w="Card Video",{videoId:S,libraryId:C}=await wE(w),{uploadUrl:A,apiKey:I}=await jE(S),L=new XMLHttpRequest;L.upload.onprogress=Z=>{Z.lengthComputable&&i(Z.loaded/Z.total*100)},await new Promise((Z,J)=>{L.onload=()=>L.status>=200&&L.status<300?Z():J(new Error("Upload failed")),L.onerror=()=>J(new Error("Upload failed")),L.open("PUT",A),L.setRequestHeader("AccessKey",I),L.send(b)}),o("processing");let O=0;const U=Date.now(),q=9e4,$=`https://iframe.mediadelivery.net/embed/${C}/${S}`;for(;O<4;){if(await new Promise(J=>setTimeout(J,3e3)),Date.now()-U>q){const J=b.size/1048576;await p.mutateAsync({bunny_video_id:S,playback_url:`https://iframe.mediadelivery.net/play/${C}/${S}`,file_size_mb:J,title:w,contact_id:t||void 0,status:"processing",touch_type:"video"}),s($),me.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),f()},1500);return}const Z=await ow(S);if(O=Z.status,u(Z.encodeProgress||0),O===5||O===6)throw new Error("Video processing failed")}const V=await ow(S),ee=(V.storageSize||b.size)/(1024*1024);await p.mutateAsync({bunny_video_id:S,contact_id:t||void 0,playback_url:V.directPlayUrl||$,thumbnail_url:V.thumbnailUrl,preview_url:V.previewUrl||null,duration_seconds:V.length||N,file_size_mb:ee,title:w,status:"ready",touch_type:"video"}),s($),me.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),f()},1500)}catch(w){console.error("Recording upload error:",w),me.error("Failed to process video. Please try again."),o("record")}},[t,s,p]);return e.jsxs(fs,{open:r,onOpenChange:y,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 w-full",children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"Record Video"]})}),e.jsxs(ms,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(AO,{maxDurationSeconds:600,onRecordingComplete:_,onError:b=>me.error(b)}),a==="uploading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(ps,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(pi,{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(ps,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(pi,{value:d,className:"w-64"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(d),"%"]})]}),a==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(si,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}const v4s=t=>`portal-settings-draft:${t}`;function qlt({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=bO(),[o,l]=k.useState(!1),i=k.useMemo(()=>v4s(r.id),[r.id]),[d,u]=k.useState(!1),[p,f]=k.useState(r.next_step_text||""),[y,_]=k.useState(r.next_step_video_url||""),[b,N]=k.useState(r.inspection_date||""),[w,S]=k.useState(r.appraisal_date||""),[C,A]=k.useState(r.welcome_message||""),[I,L]=k.useState(r.review_url||""),[O,U]=k.useState(r.show_post_close_tips),[q,$]=k.useState(r.notify_client),[V,ee]=k.useState(r.require_onboarding),[Z,J]=k.useState(r.allow_spouse),[Y,ce]=k.useState(r.visibility),[ae,ie]=k.useState(r.stage_mapping||[]),[le,fe]=k.useState(null),[xe,he]=k.useState(r.linked_portal_id||null),we=()=>{f(r.next_step_text||""),_(r.next_step_video_url||""),N(r.inspection_date||""),S(r.appraisal_date||""),A(r.welcome_message||""),L(r.review_url||""),U(r.show_post_close_tips),$(r.notify_client),ee(r.require_onboarding),J(r.allow_spouse),ce(r.visibility),ie(r.stage_mapping||[]),he(r.linked_portal_id||null)};k.useEffect(()=>{u(!1);const ve=localStorage.getItem(i);if(ve)try{const Re=JSON.parse(ve);f(Re.nextStepText||""),_(Re.nextStepVideo||""),N(Re.inspectionDate||""),S(Re.appraisalDate||""),A(Re.welcomeMessage||""),L(Re.reviewUrl||""),U(!!Re.showPostClose),$(!!Re.notifyClient),ee(!!Re.requireOnboarding),J(!!Re.allowSpouse),ce(Re.visibility||r.visibility),ie(Re.stageMapping||[]),he(Re.linkedPortalId??null),u(!0);return}catch{localStorage.removeItem(i)}we(),u(!0)},[i,r]),k.useEffect(()=>{if(!d)return;const ve={nextStepText:p,nextStepVideo:y,inspectionDate:b,appraisalDate:w,welcomeMessage:C,reviewUrl:I,showPostClose:O,notifyClient:q,requireOnboarding:V,allowSpouse:Z,visibility:Y,stageMapping:ae,linkedPortalId:xe};p!==(r.next_step_text||"")||y!==(r.next_step_video_url||"")||b!==(r.inspection_date||"")||w!==(r.appraisal_date||"")||C!==(r.welcome_message||"")||I!==(r.review_url||"")||O!==r.show_post_close_tips||q!==r.notify_client||V!==r.require_onboarding||Z!==r.allow_spouse||Y!==r.visibility||JSON.stringify(ae)!==JSON.stringify(r.stage_mapping||[])||xe!==(r.linked_portal_id||null)?localStorage.setItem(i,JSON.stringify(ve)):localStorage.removeItem(i)},[p,y,b,w,C,I,O,q,V,Z,Y,ae,xe,i,d,r]);const Ne=()=>{localStorage.removeItem(i),we()},Ve=async()=>{try{await a.mutateAsync({id:r.id,next_step_text:p||null,next_step_video_url:y||null,inspection_date:b||null,appraisal_date:w||null,welcome_message:C||null,review_url:I||null,show_post_close_tips:O,notify_client:q,require_onboarding:V,allow_spouse:Z,visibility:Y,stage_mapping:ae.length>0?ae:null,linked_portal_id:xe});const ve=r.linked_portal_id;xe&&xe!==ve&&await G.from("client_portals").update({linked_portal_id:r.id}).eq("id",xe),!xe&&ve&&await G.from("client_portals").update({linked_portal_id:null}).eq("id",ve),localStorage.removeItem(i),me.success("Portal settings saved"),s(!1)}catch{me.error("Failed to save settings")}},Te=()=>{ie([...ae,{label:""}])},Ae=ve=>{ie(ae.filter((Re,Ue)=>Ue!==ve)),le===ve&&fe(null)},ze=(ve,Re,Ue)=>{const ye=[...ae];ye[ve]={...ye[ve],[Re]:Ue},ie(ye)},Ee=()=>{const Re=HNe(null).map(Ue=>({label:Ue.label,description:Ue.description,stageId:void 0}));ie(Re)};return e.jsxs(e.Fragment,{children:[e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-lg max-h-[85vh] flex flex-col",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Portal Settings"})}),e.jsxs(ta,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(Qn,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(ls,{value:"general",children:"General"}),e.jsx(ls,{value:"timeline",children:"Timeline"}),e.jsx(ls,{value:"content",children:"Content"})]}),e.jsxs(di,{className:"flex-1 mt-4",children:[e.jsxs(js,{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(ge,{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(ve=>e.jsx("button",{onClick:()=>ce(ve),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${Y===ve?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:ve.charAt(0).toUpperCase()+ve.slice(1)},ve))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ge,{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(Lr,{checked:V,onCheckedChange:ee})]}),V&&e.jsxs("div",{className:"flex items-center justify-between pl-4 border-l-2 border-primary/20",children:[e.jsxs("div",{children:[e.jsx(ge,{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(ge,{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(Lr,{checked:Z,onCheckedChange:J})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ge,{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(Lr,{checked:O,onCheckedChange:U})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ge,{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(Lr,{checked:q,onCheckedChange:$})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(y4s,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:xe,onLink:he})}),e.jsx("div",{children:e.jsx(Fe,{type:"date",value:b,onChange:ve=>N(ve.target.value),className:"mt-1"})}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(Fe,{type:"date",value:w,onChange:ve=>S(ve.target.value),className:"mt-1"})]})]}),e.jsx(js,{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(ge,{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:Ee,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.'}),ae.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:Ee,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:ae.map((ve,Re)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(uu,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(Fe,{value:ve.label,onChange:Ue=>ze(Re,"label",Ue.target.value),placeholder:`Stage ${Re+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:()=>fe(le===Re?null:Re),children:le===Re?"Less":"More"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>Ae(Re),children:e.jsx(yr,{className:"h-3.5 w-3.5"})})]}),le===Re&&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(ge,{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("textarea",{value:ve.description||"",onChange:Ue=>ze(Re,"description",Ue.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(ge,{className:"text-xs text-muted-foreground",children:"Video"}),ve.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:ve.video_url.length>40?ve.video_url.slice(0,40)+"...":ve.video_url}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>ze(Re,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(JCe,{onVideoReady:Ue=>ze(Re,"video_url",Ue)}),e.jsx(QCe,{userId:n,onSelect:Ue=>ze(Re,"video_url",Ue),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 Ue=prompt("Paste a YouTube or Loom URL:");Ue&&ze(Re,"video_url",Ue)},children:[e.jsx(go,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},Re))}),ae.length>0&&e.jsxs(K,{variant:"outline",size:"sm",onClick:Te,className:"mt-2 text-xs w-full",children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"})," Add Stage"]})]})}),e.jsxs(js,{value:"content",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm font-medium",children:"Welcome Message"}),e.jsx("textarea",{value:C,onChange:ve=>A(ve.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(ge,{className:"text-sm font-medium",children:"What's Next"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Tell your client what to expect next"}),e.jsx("textarea",{value:p,onChange:ve=>f(ve.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(ge,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),e.jsx(Fe,{value:y,onChange:ve=>_(ve.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),e.jsxs("div",{children:[e.jsx(ge,{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:I,onChange:ve=>L(ve.target.value),className:"mt-1",placeholder:"https://g.page/r/..."})]})]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2 pt-4 border-t shrink-0",children:[e.jsx(K,{variant:"ghost",onClick:Ne,children:"Reset Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(K,{onClick:Ve,disabled:a.isPending,children:[a.isPending?e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(wc,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})]})}),e.jsx(g4s,{open:o,onOpenChange:l})]})}const _4s=t=>`portal-update-draft:${t}`;function Ult({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const o=k.useMemo(()=>_4s(r),[r]),[l,i]=k.useState(""),[d,u]=k.useState(""),[p,f]=k.useState(""),[y,_]=k.useState(!1),[b,N]=k.useState(a??!1),[w,S]=k.useState(!1),C=bit();k.useEffect(()=>{S(!1);const L=localStorage.getItem(o);if(L)try{const O=JSON.parse(L);i(O.title||""),u(O.content||""),f(O.videoUrl||""),_(!!O.isStageChange),N(typeof O.sendNotification=="boolean"?O.sendNotification:a??!1),S(!0);return}catch{localStorage.removeItem(o)}i(""),u(""),f(""),_(!1),N(a??!1),S(!0)},[o,a]),k.useEffect(()=>{if(!w)return;const L={title:l,content:d,videoUrl:p,isStageChange:y,sendNotification:b};l.trim()||d.trim()||p.trim()||y||b!==(a??!1)?localStorage.setItem(o,JSON.stringify(L)):localStorage.removeItem(o)},[l,d,p,y,b,w,o,a]);const A=()=>{localStorage.removeItem(o),i(""),u(""),f(""),_(!1),N(a??!1)},I=async()=>{if(l.trim())try{if(await C.mutateAsync({portal_id:r,title:l.trim(),content:d.trim()||void 0,video_url:p.trim()||void 0,is_stage_change:y}),b&&n)try{const L=o1(n);await G.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:l.trim(),update_content:d.trim()||null,portal_url:L}}),me.success("Update posted & client notified")}catch(L){console.error("Notification failed:",L),me.success("Update posted (notification failed to send)")}else me.success("Update posted to portal");A(),s(!1)}catch{me.error("Failed to post update")}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm font-medium",children:"Title *"}),e.jsx(Fe,{value:l,onChange:L=>i(L.target.value),className:"mt-1",placeholder:"Inspection cleared!"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm font-medium",children:"Message"}),e.jsx("textarea",{value:d,onChange:L=>u(L.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(ge,{className:"text-sm font-medium",children:"Video URL (optional)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(Fe,{value:p,onChange:L=>f(L.target.value),className:"pl-9",placeholder:"YouTube or Loom link"}),e.jsx(hn,{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),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${y?"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:()=>N(!b),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors flex items-center gap-1.5 ${b?"bg-blue-500/10 text-blue-700 border-blue-200":"bg-background text-muted-foreground border-input"}`,children:[b?e.jsx(Nm,{className:"h-3 w-3"}):e.jsx(Wv,{className:"h-3 w-3"}),b?"Notify Client":"No Notification"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",onClick:A,children:"Clear Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(K,{onClick:I,disabled:!l.trim()||C.isPending,children:[C.isPending?e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})]})})}function Vlt({open:t,onOpenChange:s,portal:r,dealName:n}){const a=bO(),{isGmailConnected:o,gmailEmail:l}=bp(),[i,d]=k.useState(r.client_name||""),[u,p]=k.useState(r.client_email||""),[f,y]=k.useState(!1),[_,b]=k.useState(!1),N=o1(r.slug),w=i.split(" ")[0]||"there",S=`Your Transaction Portal – ${n}`,C=`Hi ${w}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${N} You can view your timeline, key dates, documents, and any updates I post along the way. Let me know if you have any questions!`,A=()=>{navigator.clipboard.writeText(N),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:O}=await G.functions.invoke("gmail-send",{body:{to:u,subject:S,body:C.replace(/\n/g,"
")}});if(O)throw O;me.success(`Invite sent to ${u}`),s(!1)}catch(O){me.error(O.message||"Failed to send invite")}finally{y(!1)}},L=()=>{const O=encodeURIComponent(S),U=encodeURIComponent(C);window.open(`mailto:${u}?subject=${O}&body=${U}`,"_blank"),a.mutateAsync({id:r.id,client_name:i||null,client_email:u||null,invite_sent_at:new Date().toISOString(),invite_method:"email"}).catch(()=>{})};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Invite Client to Portal"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm font-medium",children:"Client Name"}),e.jsx(Fe,{value:i,onChange:O=>d(O.target.value),className:"mt-1",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm font-medium",children:"Client Email"}),e.jsx(Fe,{type:"email",value:u,onChange:O=>p(O.target.value),className:"mt-1",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ge,{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:N})}),e.jsx(K,{variant:"outline",size:"icon",onClick:A,className:"shrink-0",children:_?e.jsx(ea,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Ya,{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(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(tr,{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(Kr,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(K,{variant:"ghost",onClick:A,className:"w-full text-muted-foreground",children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function b4s({deal:t}){const{isAdmin:s,user:r}=$s(),{data:n,isLoading:a}=p2s(t.id),o=JSe(),l=bO(),[i,d]=k.useState(!1),[u,p]=k.useState(!1),[f,y]=k.useState(!1),[_,b]=k.useState(!1),N=`portal-management-ui:${t.id}`;if(k.useEffect(()=>{const O=sessionStorage.getItem(N);if(O)try{const U=JSON.parse(O);p(!!U.settingsOpen),y(!!U.composerOpen),b(!!U.inviteOpen)}catch{sessionStorage.removeItem(N)}},[N]),k.useEffect(()=>{u||f||_?sessionStorage.setItem(N,JSON.stringify({settingsOpen:u,composerOpen:f,inviteOpen:_})):sessionStorage.removeItem(N)},[u,f,_,N]),a)return e.jsx("div",{className:"border rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(ps,{className:"h-3 w-3 animate-spin ml-auto"})]})});const w=async()=>{var O,U;d(!0);try{await o.mutateAsync({deal_id:t.id,visibility:"private",require_onboarding:!0,client_name:t.contact?`${t.contact.first_name} ${t.contact.last_name}`:void 0,client_email:((O=t.contact)==null?void 0:O.email)||void 0,client_phone:((U=t.contact)==null?void 0:U.phone)||void 0}),me.success("Client portal enabled!")}catch{me.error("Failed to create portal")}finally{d(!1)}},S=async O=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:O}),me.success(O?"Portal enabled":"Portal disabled")}catch{me.error("Failed to update portal")}},C=()=>{if(!n)return;const O=o1(n.slug);navigator.clipboard.writeText(O),me.success("Portal link copied!")},A=()=>{if(!n)return;const O=o1(n.slug);window.open(O,"_blank")};if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 border-dashed",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{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(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(qr,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const I=o1(n.slug),L=(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(qr,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(Ye,{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(Lr,{checked:n.is_enabled,onCheckedChange:S})]}),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(Ye,{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:I})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:C,className:"text-xs flex-1 min-w-0",children:[e.jsx(Ya,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:A,className:"text-xs flex-1 min-w-0",children:[e.jsx(Kr,{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(Nn,{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(DM,{className:"h-3 w-3 mr-1 shrink-0"}),"Post Update"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>p(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(So,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(qlt,{open:u,onOpenChange:p,portal:n,dealOwnerId:L}),e.jsx(Ult,{open:f,onOpenChange:y,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(Vlt,{open:_,onOpenChange:b,portal:n,dealName:t.deal_name})]})}const w4s=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function j4s(t){return ft({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 N4s(){const t=es();return Et({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 k4s(){const t=es();return Et({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 S4s({dealId:t,primaryContactId:s}){const r=br(),{data:n,isLoading:a}=j4s(t),{data:o}=Uh(),l=N4s(),i=k4s(),[d,u]=k.useState(!1),[p,f]=k.useState(""),[y,_]=k.useState("Client"),b=new Set((n==null?void 0:n.map(A=>A.contact_id))||[]);s&&b.add(s);const N=o==null?void 0:o.filter(A=>{var L,O,U;if(b.has(A.id))return!1;if(!p.trim())return!0;const I=p.toLowerCase();return((L=A.first_name)==null?void 0:L.toLowerCase().includes(I))||((O=A.last_name)==null?void 0:O.toLowerCase().includes(I))||((U=A.email)==null?void 0:U.toLowerCase().includes(I))}).slice(0,8),w=A=>{l.mutate({dealId:t,contactId:A,role:y}),u(!1),f("")},S=A=>{i.mutate({id:A,dealId:t})},C={Client:"bg-primary/10 text-primary","Co-Buyer":"bg-blue-500/10 text-blue-600","Co-Seller":"bg-emerald-500/10 text-emerald-600",Spouse:"bg-pink-500/10 text-pink-600",Lender:"bg-amber-500/10 text-amber-600","Title Company":"bg-purple-500/10 text-purple-600",Inspector:"bg-orange-500/10 text-orange-600",Appraiser:"bg-cyan-500/10 text-cyan-600",Attorney:"bg-slate-500/10 text-slate-600",Contractor:"bg-lime-500/10 text-lime-600",Other:"bg-muted text-muted-foreground"};return!(n!=null&&n.length)&&!d?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs(yo,{open:d,onOpenChange:u,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"w-full text-muted-foreground",children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"}),"Link a contact (lender, spouse, vendor...)"]})}),e.jsx(uo,{className:"w-80 p-3",align:"start",children:e.jsx(y9e,{search:p,setSearch:f,selectedRole:y,setSelectedRole:_,filteredContacts:N,onAdd:w})})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4"}),"Linked Contacts",n&&n.length>0&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs(yo,{open:d,onOpenChange:u,children:[e.jsx(vo,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx(Bs,{className:"h-3.5 w-3.5"})})}),e.jsx(uo,{className:"w-80 p-3",align:"end",children:e.jsx(y9e,{search:p,setSearch:f,selectedRole:y,setSelectedRole:_,filteredContacts:N,onAdd:w})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(A=>{var I,L,O,U,q,$,V,ee;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/40 group",children:[e.jsx(vn,{className:"h-7 w-7",children:e.jsxs(_n,{className:"text-[10px] bg-primary/10 text-primary",children:[(L=(I=A.contact)==null?void 0:I.first_name)==null?void 0:L[0],(U=(O=A.contact)==null?void 0:O.last_name)==null?void 0:U[0]]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("button",{onClick:()=>r(`/mission-control/contacts/${A.contact_id}`),className:"text-sm font-medium hover:underline text-primary truncate block",children:[(q=A.contact)==null?void 0:q.first_name," ",($=A.contact)==null?void 0:$.last_name]})}),e.jsx(Ye,{variant:"outline",className:`text-[10px] px-1.5 py-0 shrink-0 ${C[A.role]||C.Other}`,children:A.role}),e.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[((V=A.contact)==null?void 0:V.phone)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`tel:${A.contact.phone}`,children:e.jsx(Tn,{className:"h-3 w-3"})})}),((ee=A.contact)==null?void 0:ee.email)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`mailto:${A.contact.email}`,children:e.jsx(tr,{className:"h-3 w-3"})})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>S(A.id),children:e.jsx(yr,{className:"h-3 w-3"})})]})]},A.id)})})]})}function y9e({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(zs,{value:r,onValueChange:n,children:[e.jsx(Os,{className:"h-8 text-sm",children:e.jsx(qs,{placeholder:"Role"})}),e.jsx(Fs,{children:w4s.map(l=>e.jsx(yt,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(tn,{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(di,{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 C4s={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"}},M4s={note:Si,call:Tn,email:tr,meeting:nn,stage_change:Kr,task_completed:Hn,document:Mn,system:rn};function T4s({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var ze,Ee;const{data:l,isLoading:i}=yjs((t==null?void 0:t.id)||""),{data:d,isLoading:u}=_js((t==null?void 0:t.id)||""),p=vjs(),f=wjs(),y=bjs(),_=gjs(),{data:b,isLoading:N}=h4s((t==null?void 0:t.id)||""),w=m4s(),S=p4s(),C=f4s(),A=k.useRef(null),[I,L]=k.useState(""),[O,U]=k.useState(""),[q,$]=k.useState(!1),[V,ee]=k.useState(!1);if(!t)return null;const Z=C4s[t.deal_type],J=(()=>{var Ue;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const ve=((Ue=t.listing)==null?void 0:Ue.created_at)||t.listing_date;if(!ve)return null;const Re=t.contract_date?pl(t.contract_date):new Date;return Vg(Re,pl(ve))})(),Y=ve=>ve?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ve):"-",ce=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")}},ae=async()=>{if(O.trim())try{await f.mutateAsync({deal_id:t.id,title:O,sort_order:((d==null?void 0:d.length)||0)+1}),U(""),me.success("Task added")}catch{me.error("Failed to add task")}},ie=async(ve,Re)=>{try{await y.mutateAsync({id:ve,is_completed:Re,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")}},fe=(d==null?void 0:d.filter(ve=>ve.is_completed).length)||0,xe=(d==null?void 0:d.length)||0,he=(b==null?void 0:b.length)||0,we=ve=>ve<1024?`${ve} B`:ve<1024*1024?`${(ve/1024).toFixed(1)} KB`:`${(ve/(1024*1024)).toFixed(1)} MB`,Ne=ve=>ve?ve.startsWith("image/")?Uo:ve.includes("pdf")?mn:CM:CM,Ve=async ve=>{const Re=ve.target.files;if(!(!Re||!t)){ee(!0);try{for(const Ue of Array.from(Re)){if(Ue.size>20*1024*1024){me.error(`${Ue.name} exceeds 20MB limit`);continue}await w.mutateAsync({dealId:t.id,file:Ue})}me.success("File(s) uploaded")}catch{me.error("Failed to upload file")}finally{ee(!1),A.current&&(A.current.value="")}}},Te=async(ve,Re)=>{if(t)try{await S.mutateAsync({fileId:ve,storagePath:Re,dealId:t.id}),me.success("File deleted")}catch{me.error("Failed to delete file")}},Ae=async(ve,Re)=>{try{const Ue=await x4s(ve),ye=document.createElement("a");ye.href=Ue,ye.download=Re,ye.target="_blank",document.body.appendChild(ye),ye.click(),document.body.removeChild(ye)}catch{me.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(ZA,{open:s,onOpenChange:r,children:e.jsxs(CC,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(YA,{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(Ye,{variant:"outline",className:Rt("text-xs",Z.color),children:Z.label}),e.jsxs(Ye,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(XA,{className:"text-xl",children:t.deal_name}),e.jsx("div",{className:"mt-2",children:e.jsx(u4s,{dealId:t.id})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(Gc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>$(!0),children:e.jsx(yr,{className:"h-4 w-4"})})]})]})}),e.jsx(di,{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(vn,{className:"h-10 w-10",children:e.jsxs(_n,{className:"bg-primary/10 text-primary",children:[(ze=t.contact.first_name)==null?void 0:ze[0],(Ee=t.contact.last_name)==null?void 0:Ee[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(Tn,{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(tr,{className:"h-4 w-4"})})})]})]}),e.jsx(S4s,{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(Mn,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.property_address||"Address TBD"}),e.jsx("p",{className:"text-muted-foreground",children:[t.city,t.state,t.zip_code].filter(Boolean).join(", ")})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected Price"}),e.jsx("p",{className:"text-lg font-bold",children:Y(t.expected_price)})]}),e.jsxs("div",{className:"bg-emerald-500/10 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected GCI"}),e.jsx("p",{className:"text-lg font-bold text-emerald-600",children:Y(t.expected_commission)})]}),(t.brokerage_split_pct||t.team_split_pct||t.referral_fee_pct||t.franchise_fee_pct||t.transaction_fee)&&e.jsxs("div",{className:"col-span-2 bg-muted/30 rounded-lg p-3 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Commission Splits"}),t.brokerage_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Brokerage Split"}),e.jsxs("span",{children:[t.brokerage_split_pct,"%",t.expected_commission?` (${Y(t.expected_commission*t.brokerage_split_pct/100)})`:""]})]}),t.team_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Team Split"}),e.jsxs("span",{children:[t.team_split_pct,"%"]})]}),t.referral_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Referral Fee"}),e.jsxs("span",{children:[t.referral_fee_pct,"%"]})]}),t.franchise_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Franchise Fee"}),e.jsxs("span",{children:[t.franchise_fee_pct,"%"]})]}),t.transaction_fee!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transaction Fee"}),e.jsx("span",{children:Y(t.transaction_fee)})]}),t.net_commission!=null&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"border-t pt-1.5 mt-1.5",children:e.jsxs("div",{className:"flex justify-between text-sm font-semibold",children:[e.jsx("span",{children:"Net to Agent"}),e.jsx("span",{className:"text-emerald-600",children:Y(t.net_commission)})]})})})]}),o&&!t.scorecard_transaction_id&&a&&e.jsxs(K,{onClick:()=>a(t),className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(Hi,{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(Hn,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{children:"Synced to Scorecard"})]}),J!==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:Rt("text-lg font-bold",J>90?"text-red-600":J>60?"text-amber-600":"text-foreground"),children:[J," ",t.contract_date?"(final)":"days"]})]}),t.target_close_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(nn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",gs(pl(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(_c,{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(b4s,{deal:t}),e.jsxs(ta,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(Qn,{className:"w-full grid grid-cols-3",children:[e.jsxs(ls,{value:"tasks",className:"gap-1",children:[e.jsx(Hn,{className:"h-4 w-4"}),"Tasks ",xe>0&&`(${fe}/${xe})`]}),e.jsxs(ls,{value:"files",className:"gap-1",children:[e.jsx(fS,{className:"h-4 w-4"}),"Files ",he>0&&`(${he})`]}),e.jsxs(ls,{value:"activity",className:"gap-1",children:[e.jsx(rn,{className:"h-4 w-4"}),"Activity"]})]}),e.jsxs(js,{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:O,onChange:ve=>U(ve.target.value),onKeyDown:ve=>ve.key==="Enter"&&ae()}),e.jsx(K,{onClick:ae,disabled:!O.trim(),children:e.jsx(Bs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[d==null?void 0:d.map(ve=>e.jsxs("div",{className:Rt("flex items-center gap-3 p-3 rounded-lg border transition-colors",ve.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(Gi,{checked:ve.is_completed,onCheckedChange:Re=>ie(ve.id,!!Re)}),e.jsx("span",{className:Rt("flex-1 text-sm",ve.is_completed&&"line-through text-muted-foreground"),children:ve.title}),ve.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:gs(new Date(ve.due_date),"MMM d")})]},ve.id)),(d==null?void 0:d.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No tasks yet. Add one above!"})]})]}),e.jsxs(js,{value:"files",className:"mt-4 space-y-3",children:[e.jsx("input",{type:"file",ref:A,className:"hidden",multiple:!0,onChange:Ve,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 ve;return(ve=A.current)==null?void 0:ve.click()},disabled:V,children:[V?e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Da,{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(ve=>{const Re=Ne(ve.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(Re,{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:ve.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[we(ve.file_size)," · ",gs(new Date(ve.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S1,{children:e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${ve.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>C.mutate({fileId:ve.id,visible:!ve.visible_on_portal,dealId:t.id}),children:ve.visible_on_portal?e.jsx(jn,{className:"h-4 w-4"}):e.jsx(hp,{className:"h-4 w-4"})})}),e.jsx(Il,{side:"top",children:ve.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ae(ve.storage_path,ve.file_name),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Te(ve.id,ve.storage_path),children:e.jsx(Sr,{className:"h-4 w-4"})})]})]},ve.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(js,{value:"activity",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_r,{placeholder:"Add a note...",value:I,onChange:ve=>L(ve.target.value),rows:2}),e.jsxs(K,{onClick:ce,disabled:!I.trim(),size:"sm",className:"w-full",children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(ve=>{const Re=M4s[ve.activity_type]||rn;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(Re,{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:ve.title}),ve.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:ve.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:jl(new Date(ve.created_at),{addSuffix:!0})})]})]},ve.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(Ll,{open:q,onOpenChange:$,children:e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Delete Deal?"}),e.jsxs(vl,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:le,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function A4s({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=ihe(),o=Lit(),{data:l}=eE(),{data:i}=Mf(),[d,u]=k.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:gs(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});k.useEffect(()=>{if(r&&t){const y=r.deal_type==="seller"?"seller":"buyer",_=r.expected_price||0,b=r.commission_percentage||3,N=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||gs(new Date,"yyyy-MM-dd"),sale_price:_,commission_amount:N,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:d.property_address,city:d.city||null,state:d.state||null,zip:d.zip||null,transaction_type:d.transaction_type,close_date:d.close_date,sale_price:d.sale_price,commission_amount:d.commission_amount||null,brokerage_split_pct:r.brokerage_split_pct||null,team_split_pct:r.team_split_pct||null,franchise_fee_pct:r.franchise_fee_pct||null,referral_fee_pct:r.referral_fee_pct||null,transaction_fee:r.transaction_fee||null,lead_source_id:d.lead_source_id||null,client_type_id:d.client_type_id||null,contact_id:r.contact_id||null,notes:d.notes||null,is_win:!0});await o.mutateAsync({id:r.id,scorecard_transaction_id:_.id,actual_close_date:d.close_date}),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(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{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(Hi,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsx(bs,{className:"text-center text-xl",children:"Congratulations on Closing! 🎉"}),e.jsx(Rr,{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(ge,{htmlFor:"property_address",className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(Fe,{id:"property_address",value:d.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(ge,{htmlFor:"city",children:"City"}),e.jsx(Fe,{id:"city",value:d.city,onChange:y=>u(_=>({..._,city:y.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"state",children:"State"}),e.jsx(Fe,{id:"state",value:d.state,onChange:y=>u(_=>({..._,state:y.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"zip",children:"Zip"}),e.jsx(Fe,{id:"zip",value:d.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(ge,{children:"Transaction Type *"}),e.jsxs(zs,{value:d.transaction_type,onValueChange:y=>u(_=>({..._,transaction_type:y})),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"buyer",children:"Buyer"}),e.jsx(yt,{value:"seller",children:"Seller"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ge,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),e.jsx(Fe,{id:"close_date",type:"date",value:d.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(ge,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(_c,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),e.jsx(Fe,{id:"sale_price",type:"number",value:d.sale_price||"",onChange:y=>u(_=>({..._,sale_price:Number(y.target.value)})),placeholder:"450000",required:!0,min:0}),d.sale_price>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:f(d.sale_price)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ge,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx(RM,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),e.jsx(Fe,{id:"commission_amount",type:"number",value:d.commission_amount||"",onChange:y=>u(_=>({..._,commission_amount:Number(y.target.value)})),placeholder:"13500",min:0}),d.commission_amount>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:f(d.commission_amount)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Lead Source"}),e.jsxs(zs,{value:d.lead_source_id,onValueChange:y=>u(_=>({..._,lead_source_id:y})),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select source"})}),e.jsx(Fs,{children:l==null?void 0:l.map(y=>e.jsx(yt,{value:y.id,children:y.name},y.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Client Type"}),e.jsxs(zs,{value:d.client_type_id,onValueChange:y=>u(_=>({..._,client_type_id:y})),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select type"})}),e.jsx(Fs,{children:i==null?void 0:i.map(y=>e.jsx(yt,{value:y.id,children:y.name},y.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"notes",children:"Notes"}),e.jsx(_r,{id:"notes",value:d.notes,onChange:y=>u(_=>({..._,notes:y.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(gn,{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(ti,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const E4s={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"}},v9e={urgent:0,high:1,medium:2,low:3};function P4s({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=k.useState("target_close_date"),[l,i]=k.useState("asc"),d=_=>{a===_?i(b=>b==="asc"?"desc":"asc"):(o(_),i("asc"))},u=k.useMemo(()=>[...t].sort((_,b)=>{var w,S;let N=0;switch(a){case"deal_name":N=_.deal_name.localeCompare(b.deal_name);break;case"stage":{const C=((w=s.find(I=>I.id===_.stage_id))==null?void 0:w.sort_order)||0,A=((S=s.find(I=>I.id===b.stage_id))==null?void 0:S.sort_order)||0;N=C-A;break}case"expected_price":N=(_.expected_price||0)-(b.expected_price||0);break;case"expected_commission":N=(_.expected_commission||0)-(b.expected_commission||0);break;case"target_close_date":{const C=_.target_close_date?pl(_.target_close_date).getTime():1/0,A=b.target_close_date?pl(b.target_close_date).getTime():1/0;N=C-A;break}case"priority":N=v9e[_.priority]-v9e[b.priority];break}return l==="asc"?N:-N}),[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:()=>d(_),children:[b,a===_?l==="asc"?e.jsx(cu,{className:"ml-2 h-4 w-4"}):e.jsx(Ih,{className:"ml-2 h-4 w-4"}):e.jsx(td,{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(As,{className:"bg-muted/50",children:[e.jsx(Nt,{className:"w-[250px]",children:e.jsx(y,{field:"deal_name",children:"Deal Name"})}),e.jsx(Nt,{className:"w-[150px]",children:e.jsx(y,{field:"stage",children:"Stage"})}),e.jsx(Nt,{className:"w-[100px]",children:"Type"}),e.jsx(Nt,{className:"w-[120px]",children:e.jsx(y,{field:"expected_price",children:"Price"})}),e.jsx(Nt,{className:"w-[120px]",children:e.jsx(y,{field:"expected_commission",children:"GCI"})}),e.jsx(Nt,{className:"w-[130px]",children:e.jsx(y,{field:"target_close_date",children:"Close Date"})}),e.jsx(Nt,{className:"w-[100px]",children:e.jsx(y,{field:"priority",children:"Priority"})})]})}),e.jsx(Pn,{children:u.map(_=>{f(_.stage_id);const b=E4s[_.deal_type],N=_.target_close_date?Vg(pl(_.target_close_date),new Date):null,w=N!==null&&N<0,S=N!==null&&N<=7&&N>=0;return e.jsxs(As,{className:Rt("cursor-pointer hover:bg-muted/50 transition-colors",w&&"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:C=>C.stopPropagation(),children:e.jsx(Blt,{stages:s,currentStageId:_.stage_id||"",onStageSelect:(C,A)=>n(_.id,C,A)})}),e.jsx(dt,{children:e.jsx(Ye,{variant:"outline",className:Rt("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:Rt("flex items-center gap-1 text-sm",w&&"text-red-600",S&&!w&&"text-amber-600"),children:[w&&e.jsx(co,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:gs(pl(_.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx(Ye,{variant:"outline",className:Rt("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 I4s(){const t=_a();return ft({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 L4s(t){const s=_a();return ft({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 D4s(){const t=_a(),s=es();return Et({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 R4s(){const t=es();return Et({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 O4s(){const t=es();return Et({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 e3e(){const t=es();return Et({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 F4s(){const t=es();return Et({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 z4s(t){const s=_a();return ft({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 B4s(){const t=_a(),s=es();return Et({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 $4s(){const t=es();return Et({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 q4s(){const t=_a(),s=es();return Et({mutationFn:async({dealId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("deal_task_templates").select("*").eq("owner_user_id",t).eq("stage_id",n).order("sort_order");if(o)throw o;if(!a||a.length===0)return[];const{data:l}=await G.from("deal_tasks").select("title, stage_id").eq("deal_id",r).eq("stage_id",n),i=new Set((l||[]).map(f=>f.title)),d=a.filter(f=>!i.has(f.title)).map((f,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(d.length===0)return[];const{data:u,error:p}=await G.from("deal_tasks").insert(d).select();if(p)throw p;return u},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}const U4s={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function V4s({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:d,isLoading:u}=L4s(t?r:void 0),p=F4s(),f=q4s(),[y,_]=k.useState(new Set),[b,N]=k.useState(!1),w=(d||[]).filter(I=>I.status!=="done");k.useEffect(()=>{w.length>0&&_(new Set(w.map(I=>I.id)))},[d]);const S=I=>{_(L=>{const O=new Set(L);return O.has(I)?O.delete(I):O.add(I),O})},C=async()=>{N(!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{N(!1)}},A=async()=>{N(!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{N(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-[480px]",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Move Deal"}),e.jsxs(Rr,{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(Ye,{variant:"outline",className:"text-sm",children:a}),e.jsx(ti,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Ye,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ps,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You have ",e.jsx("span",{className:"font-medium text-foreground",children:w.length})," incomplete task",w.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(di,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:w.map(I=>e.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-muted/50 cursor-pointer transition-colors",children:[e.jsx(Gi,{checked:y.has(I.id),onCheckedChange:()=>S(I.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[U4s[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===w.length?_(new Set):_(new Set(w.map(I=>I.id)))},children:y.size===w.length?"Deselect All":"Select All"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:A,disabled:b,children:"Skip"}),e.jsxs(K,{size:"sm",onClick:C,disabled:b,children:[b&&e.jsx(ps,{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(Hn,{className:"h-8 w-8 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All tasks completed! Ready to move."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:C,disabled:b,children:[b&&e.jsx(ps,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function H4s(){const t=_a();return ft({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 G4s({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const d=JSe(),u=bO(),p=f2s(),f=x2s(),[y,_]=k.useState(!1),b=!!(n!=null&&n.archived_at),N=async()=>{_(!0);try{await d.mutateAsync({deal_id:t,visibility:"private",require_onboarding:!0}),me.success("Portal enabled!")}catch{me.error("Failed to create portal")}finally{_(!1)}},w=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")}},S=()=>{n&&(navigator.clipboard.writeText(o1(n.slug)),me.success("Link copied!"))},C=()=>{n&&window.open(o1(n.slug),"_blank")},A=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(Ye,{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(rL,{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(yr,{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(Ye,{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:S,title:"Copy link",children:e.jsx(Ya,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:C,title:"Preview",children:e.jsx(Kr,{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(Nn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(n),title:"Post update",children:e.jsx(DM,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a(n),title:"Settings",children:e.jsx(So,{className:"h-3.5 w-3.5"})}),e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(dx,{className:"h-3.5 w-3.5"})})}),e.jsx(jd,{align:"end",children:e.jsxs(xa,{onClick:A,children:[e.jsx(_M,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(Lr,{checked:n.is_enabled,onCheckedChange:w,className:"ml-1"})]})]}):e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg border-dashed bg-muted/20",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r||"No contact"})]}),e.jsxs(K,{size:"sm",onClick:N,disabled:y,className:"shrink-0 ml-4",children:[y?e.jsx(ps,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(qr,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function W4s(){const{data:t,isLoading:s}=Pme(),{data:r,isLoading:n}=H4s(),[a,o]=k.useState(""),[l,i]=k.useState("all"),d=g2s(),[u,p]=k.useState(null),[f,y]=k.useState(null),[_,b]=k.useState(null),[N,w]=k.useState(null),S=_a(),C=s||n,A=new Map;r==null||r.forEach(V=>A.set(V.deal_id,V));const L=[...(t||[]).filter(V=>{var ce,ae,ie,le,fe;const ee=A.get(V.id),Z=a.toLowerCase(),J=!Z||V.deal_name.toLowerCase().includes(Z)||((ae=(ce=V.contact)==null?void 0:ce.first_name)==null?void 0:ae.toLowerCase().includes(Z))||((le=(ie=V.contact)==null?void 0:ie.last_name)==null?void 0:le.toLowerCase().includes(Z))||((fe=ee==null?void 0:ee.client_name)==null?void 0:fe.toLowerCase().includes(Z));let Y=!0;return l==="active"?Y=!!(ee!=null&&ee.is_enabled)&&!(ee!=null&&ee.archived_at):l==="disabled"?Y=!!ee&&!ee.is_enabled&&!ee.archived_at:l==="archived"?Y=!!(ee!=null&&ee.archived_at):l==="none"?Y=!ee:l==="all"&&(Y=!(ee!=null&&ee.archived_at)||!ee),J&&Y})].sort((V,ee)=>{const Z=A.get(V.id),J=A.get(ee.id);if(Z!=null&&Z.archived_at&&!(J!=null&&J.archived_at))return 1;if(!(Z!=null&&Z.archived_at)&&(J!=null&&J.archived_at)||Z&&!J)return-1;if(!Z&&J)return 1;if(Z&&J){if(Z.is_enabled&&!J.is_enabled)return-1;if(!Z.is_enabled&&J.is_enabled)return 1}return 0}),O=(r==null?void 0:r.filter(V=>!V.archived_at).length)||0,U=(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,$=async()=>{if(N)try{await d.mutateAsync({id:N.id,dealId:N.deal_id}),me.success("Portal permanently deleted"),w(null)}catch{me.error("Failed to delete portal")}};return C?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(ps,{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(qr,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium",children:[O," Portals"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[U," active · ",O-U," 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(tn,{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(Sr,{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(di,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[L.map(V=>{const ee=A.get(V.id)||null,Z=V.contact?`${V.contact.first_name||""} ${V.contact.last_name||""}`.trim():"";return e.jsx(G4s,{dealId:V.id,dealName:V.deal_name,contactName:Z,portal:ee,onSettingsOpen:p,onComposerOpen:J=>y(J),onInviteOpen:(J,Y)=>b({portal:J,dealName:Y}),onDeleteConfirm:w},V.id)}),L.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 bg-muted rounded-full flex items-center justify-center",children:e.jsx(qr,{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(qlt,{open:!!u,onOpenChange:V=>!V&&p(null),portal:u,dealOwnerId:S||""}),f&&e.jsx(Ult,{open:!!f,onOpenChange:V=>!V&&y(null),portalId:f.id,portalSlug:f.slug,notifyClient:f.notify_client}),_&&e.jsx(Vlt,{open:!!_,onOpenChange:V=>!V&&b(null),portal:_.portal,dealName:_.dealName}),e.jsx(Ll,{open:!!N,onOpenChange:V=>!V&&w(null),children:e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Permanently delete this portal?"}),e.jsx(vl,{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(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:$,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class K4s extends k.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,r){console.error("DealPipeline error:",s,r)}render(){return this.state.hasError?e.jsx(Ls,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center h-[60vh] gap-4 text-center px-4",children:[e.jsx("div",{className:"w-16 h-16 bg-destructive/10 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"⚠️"})}),e.jsx("h2",{className:"text-xl font-semibold",children:"Something went wrong"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"There was an error in the deal pipeline. Click below to try again."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>this.setState({hasError:!1,error:null}),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md text-sm font-medium hover:bg-primary/90",children:"Try Again"}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 border border-border rounded-md text-sm font-medium hover:bg-muted",children:"Refresh Page"})]})]})}):this.props.children}}const _6="deal-pipeline-detail-sheet";function Z4s(){var Nr;const t=bE(),{data:s,isLoading:r}=Eme(),{data:n,isLoading:a,refetch:o}=Pme(),{data:l,isLoading:i}=jjs(),d=Pit(),u=xjs(),[p,f]=k.useState("board"),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState(null),[C,A]=k.useState(null),[I,L]=k.useState(null),[O,U]=k.useState(null),[q,$]=k.useState(!1),[V,ee]=k.useState(null),[Z,J]=k.useState(""),[Y,ce]=k.useState("all"),[ae,ie]=k.useState("all"),{data:le}=s4s(),[fe,xe]=k.useState(!1),[he,we]=k.useState(!1),[Ne,Ve]=k.useState(new Set),Te=k.useRef(!1),[Ae,ze]=k.useState(null),{data:Ee}=Rx(),{isTeamLeader:ve,teamMembers:Re}=e4s(),Ue=k.useMemo(()=>Array.from(Ne),[Ne]),{data:ye}=t4s(Ue),ct=k.useMemo(()=>{const Vs=new Map;return Re.forEach(ar=>Vs.set(ar.id,{name:ar.name,avatar_url:ar.avatar_url,color:ar.color})),Vs},[Re]),pe=k.useCallback(Vs=>Vs.owner_user_id&&ct.get(Vs.owner_user_id)||null,[ct]),Ge=k.useCallback(Vs=>{Ve(ar=>{const Or=new Set(ar);return Or.has(Vs)?Or.delete(Vs):Or.add(Vs),Or})},[]);k.useEffect(()=>{!r&&s&&s.length===0&&d.mutate()},[r,s]);const[tt,st]=Sc(),Ce=k.useRef(!1);k.useEffect(()=>{const Vs=tt.get("deal");if(Vs&&n&&n.length>0&&!Ce.current){const ar=n.find(Or=>Or.id===Vs);ar&&(Ce.current=!0,S(ar),N(!0),tt.delete("deal"),st(tt,{replace:!0}))}},[n,tt]);const et=k.useMemo(()=>{if(!ye||!s)return[];const Vs=new Map(s.map(ar=>[ar.name,ar.id]));return ye.map(ar=>{const Or=ar._stage_name&&Vs.get(ar._stage_name)||null;return{...ar,stage_id:Or||ar.stage_id}})},[ye,s]),Ct=k.useMemo(()=>[...n||[],...et],[n,et]);k.useEffect(()=>{if(Te.current||Ct.length===0)return;Te.current=!0;const Vs=sessionStorage.getItem(_6);if(Vs)try{const ar=JSON.parse(Vs);if(!ar.open||!ar.dealId)return;const Or=Ct.find(Rn=>Rn.id===ar.dealId);Or&&(S(Or),N(!0))}catch{sessionStorage.removeItem(_6)}},[Ct]),k.useEffect(()=>{b&&(w!=null&&w.id)?sessionStorage.setItem(_6,JSON.stringify({dealId:w.id,open:!0})):sessionStorage.removeItem(_6)},[b,w==null?void 0:w.id]);const Ot=(le==null?void 0:le.byDeal)||{},ut=(le==null?void 0:le.unique)||[],Oe=Ct.filter(Vs=>{var or,hr,an,Gr,Va,$a;const ar=Z.toLowerCase(),Or=Ot[Vs.id]||[],Rn=!ar||Vs.deal_name.toLowerCase().includes(ar)||((hr=(or=Vs.contact)==null?void 0:or.first_name)==null?void 0:hr.toLowerCase().includes(ar))||((Gr=(an=Vs.contact)==null?void 0:an.last_name)==null?void 0:Gr.toLowerCase().includes(ar))||((Va=Vs.property_address)==null?void 0:Va.toLowerCase().includes(ar))||(($a=Vs.city)==null?void 0:$a.toLowerCase().includes(ar))||Or.some(Xt=>Xt.toLowerCase().includes(ar)),bn=Y==="all"||Vs.deal_type===Y,ir=ae==="all"||Or.includes(ae);return Rn&&bn&&ir}),Xe=k.useMemo(()=>{if(!s)return l||null;const Vs=new Set(s.filter(or=>or.is_won_stage).map(or=>or.id)),ar=new Set(s.filter(or=>or.is_lost_stage).map(or=>or.id)),Or=Ct.filter(or=>or.stage_id&&!Vs.has(or.stage_id)&&!ar.has(or.stage_id)),Rn=Ct.filter(or=>or.stage_id&&Vs.has(or.stage_id)),bn=new Date().getFullYear(),ir=Rn.filter(or=>or.actual_close_date?new Date(or.actual_close_date).getFullYear()===bn:!0);return{totalDeals:Ct.length,activeDeals:Or.length,wonDeals:Rn.length,pipelineValue:Or.reduce((or,hr)=>or+(hr.expected_price||0),0),expectedCommission:Or.reduce((or,hr)=>or+(hr.expected_commission||0),0),expectedNetToAgent:Or.reduce((or,hr)=>or+(px(hr)||0),0),wonValue:Rn.reduce((or,hr)=>or+(hr.expected_price||0),0),weightedGCI:Or.reduce((or,hr)=>or+(hr.expected_commission||0)*((hr.probability??50)/100),0),weightedNet:Or.reduce((or,hr)=>or+(px(hr)||0)*((hr.probability??50)/100),0),ytdWonDeals:ir.length,ytdWonGCI:ir.reduce((or,hr)=>or+(hr.expected_commission||0),0),ytdWonNet:ir.reduce((or,hr)=>or+(px(hr)||0),0),projectedAnnualNet:ir.reduce((or,hr)=>or+(px(hr)||0),0)+Or.reduce((or,hr)=>or+(px(hr)||0)*((hr.probability??50)/100),0)}},[Ct,s,l]),at=Vs=>{S(Vs),N(!0)},Ke=Vs=>{A(Vs||null),S(null),_(!0)},He=Vs=>{S(Vs),N(!1),_(!0)},gt=Vs=>{N(Vs),Vs||sessionStorage.removeItem(_6)},Mt=(Vs,ar)=>{L(Vs)},Wt=(Vs,ar)=>{Vs.preventDefault(),Vs.dataTransfer.dropEffect="move",U(ar)},xs=async(Vs,ar)=>{if(Vs.preventDefault(),U(null),!I)return;const Or=n==null?void 0:n.find(ir=>ir.id===I),Rn=s==null?void 0:s.find(ir=>ir.id===ar),bn=s==null?void 0:s.find(ir=>ir.id===(Or==null?void 0:Or.stage_id));if(!Or||!Rn||Or.stage_id===ar){L(null);return}ze({dealId:I,dealName:Or.deal_name,fromStageName:(bn==null?void 0:bn.name)||"Unknown",toStageName:Rn.name,toStageId:ar,isWonStage:Rn.is_won_stage,deal:Or}),L(null)},Cs=async()=>{if(!Ae)return;const{dealId:Vs,toStageId:ar,toStageName:Or,isWonStage:Rn,deal:bn}=Ae;if(await u.mutateAsync({dealId:Vs,stageId:ar,stageName:Or}),me.success(`Moved to ${Or}`),Rn&&!bn.scorecard_transaction_id){const ir={...bn,stage_id:ar};ee(ir),$(!0)}},Us=k.useCallback(async(Vs,ar,Or)=>{const Rn=n==null?void 0:n.find(or=>or.id===Vs),bn=s==null?void 0:s.find(or=>or.id===ar),ir=s==null?void 0:s.find(or=>or.id===(Rn==null?void 0:Rn.stage_id));!Rn||!bn||Rn.stage_id===ar||ze({dealId:Vs,dealName:Rn.deal_name,fromStageName:(ir==null?void 0:ir.name)||"Unknown",toStageName:Or,toStageId:ar,isWonStage:bn.is_won_stage,deal:Rn})},[n,s]),Ar=Vs=>Oe.filter(ar=>ar.stage_id===Vs),Bt=r||a,Xs=t?"list":p;return e.jsxs(Ls,{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(to,{className:"h-4 w-4"})}),!t&&e.jsx(S1,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(Jl,{children:[e.jsx(ec,{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(pp,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(Il,{children:"Kanban board view"})]}),e.jsxs(Jl,{children:[e.jsx(ec,{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(Rh,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(Il,{children:"Grouped list view"})]}),e.jsxs(Jl,{children:[e.jsx(ec,{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(FM,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(Il,{children:"Sortable table view"})]}),e.jsxs(Jl,{children:[e.jsx(ec,{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(qr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(Il,{children:"Client portal management"})]})]})}),Ee&&!ve&&e.jsxs(K,{variant:"outline",onClick:()=>xe(!0),children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(K,{onClick:()=>Ke(),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),Xs!=="portals"&&e.jsx(i4s,{stats:Xe,isLoading:i}),Xs!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(tn,{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, tags...",value:Z,onChange:Vs=>J(Vs.target.value),className:"pl-9 pr-8"}),Z&&e.jsx("button",{onClick:()=>J(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Sr,{className:"h-4 w-4"})})]}),e.jsxs(zs,{value:Y,onValueChange:ce,children:[e.jsx(Os,{className:"w-[140px]",children:e.jsx(qs,{placeholder:"All Types"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Types"}),e.jsx(yt,{value:"buyer",children:"Buyer"}),e.jsx(yt,{value:"seller",children:"Seller"}),e.jsx(yt,{value:"dual",children:"Dual"}),e.jsx(yt,{value:"referral",children:"Referral"}),e.jsx(yt,{value:"lease",children:"Lease"})]})]}),e.jsxs(zs,{value:ae,onValueChange:ie,children:[e.jsxs(Os,{className:"w-[160px]",children:[e.jsx(hh,{className:"h-3.5 w-3.5 mr-1.5 text-muted-foreground"}),e.jsx(qs,{placeholder:"All Tags"})]}),e.jsxs(Fs,{className:"max-h-[300px]",children:[e.jsx(yt,{value:"all",children:"All Tags"}),ut.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No tags yet"}),ut.map(Vs=>e.jsx(yt,{value:Vs,children:Vs},Vs))]})]}),ae!=="all"&&e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(hh,{className:"h-3 w-3"}),ae,e.jsx("button",{onClick:()=>ie("all"),className:"ml-1 hover:text-foreground","aria-label":"Clear tag filter",children:e.jsx(Sr,{className:"h-3 w-3"})})]}),(Z||Y!=="all"||ae!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[Oe.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[ve&&!t&&Re.length>0&&e.jsx(Jks,{members:Re,enabledMembers:Ne,onToggleMember:Ge,isOpen:he,onToggleOpen:()=>we(Vs=>!Vs)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:Bt?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Vs=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(Ss,{className:"h-full rounded-xl"})},Vs))}):Xs==="board"?e.jsxs(di,{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(Vs=>e.jsx(a4s,{stage:Vs,deals:Ar(Vs.id),onDealClick:at,onAddDeal:Ke,onDragStart:Mt,onDragOver:Wt,onDrop:xs,isDragOver:O===Vs.id,isWonStage:Vs.is_won_stage,getOwnerInfo:pe},Vs.id))}),e.jsx($ue,{orientation:"horizontal"})]}):Xs==="table"?e.jsx(di,{className:"h-full",children:e.jsx(P4s,{deals:Oe,stages:s||[],onDealClick:at,onStageChange:Us})}):Xs==="portals"?e.jsx(W4s,{}):e.jsx(di,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(Vs=>{const ar=Ar(Vs.id);return ar.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:Vs.color}}),e.jsx("h3",{className:"font-semibold",children:Vs.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",ar.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:ar.map(Or=>e.jsx($lt,{deal:Or,onClick:()=>at(Or),stages:s,onStageChange:Us,showStagePicker:!0,isWonStage:Vs.is_won_stage,ownerInfo:pe(Or)},Or.id))})]},Vs.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(pp,{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:()=>Ke(),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&Oe.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(tn,{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:()=>{J(""),ce("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(d4s,{open:y,onOpenChange:_,deal:w,defaultStageId:C}),e.jsx(T4s,{deal:w,open:b,onOpenChange:gt,onEdit:He,isWonStage:w?(Nr=s==null?void 0:s.find(Vs=>Vs.id===w.stage_id))==null?void 0:Nr.is_won_stage:!1,onAddToScorecard:Vs=>{ee(Vs),$(!0),N(!1)}}),e.jsx(A4s,{open:q,onOpenChange:$,deal:V,onComplete:()=>{o(),ee(null)}}),Ae&&e.jsx(V4s,{open:!!Ae,onOpenChange:Vs=>{Vs||ze(null)},dealId:Ae.dealId,dealName:Ae.dealName,fromStageName:Ae.fromStageName,toStageName:Ae.toStageName,toStageId:Ae.toStageId,onConfirm:Cs}),e.jsx(Xks,{open:fe,onOpenChange:xe})]})}function Y4s(){return e.jsx(K4s,{children:e.jsx(Z4s,{})})}function Hlt({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var J;const o=D4s(),l=R4s(),{data:i}=Pme(),d=_a(),{data:u}=ft({queryKey:["contacts-for-tasks",d],queryFn:async()=>{if(!d)return[];const{data:Y,error:ce}=await G.from("innercircle_contacts").select("id, first_name, last_name").eq("owner_user_id",d).order("first_name").limit(500);if(ce)throw ce;return Y},enabled:!!d&&t}),[p,f]=k.useState(""),[y,_]=k.useState(""),[b,N]=k.useState("none"),[w,S]=k.useState("none"),[C,A]=k.useState("medium"),[I,L]=k.useState("todo"),[O,U]=k.useState(),[q,$]=k.useState(!1),[V,ee]=k.useState(!1);k.useEffect(()=>{r?(f(r.title),_(r.description||""),N(r.deal_id||"none"),S(r.contact_id||"none"),A(r.priority),L(r.status),U(r.due_date?mm(r.due_date):void 0)):(f(""),_(""),N(n||"none"),S("none"),A("medium"),L("todo"),U(void 0))},[r,t,n]);const Z=async()=>{if(!p.trim()){me.error("Task title is required");return}try{const Y={title:p.trim(),description:y.trim()||null,deal_id:b==="none"?null:b,contact_id:w==="none"?null:w,stage_id:a||null,priority:C,status:I,due_date:O?gs(O,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...Y}),me.success("Task updated")):(await o.mutateAsync(Y),me.success("Task created")),s(!1)}catch{me.error("Failed to save task")}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-[480px]",children:[e.jsx(ks,{children:e.jsx(bs,{children:r?"Edit Task":"New Task"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Title *"}),e.jsx(Fe,{value:p,onChange:Y=>f(Y.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Description"}),e.jsx(_r,{value:y,onChange:Y=>_(Y.target.value),placeholder:"Optional details...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Priority"}),e.jsxs(zs,{value:C,onValueChange:Y=>A(Y),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"low",children:"🟢 Low"}),e.jsx(yt,{value:"medium",children:"🟡 Medium"}),e.jsx(yt,{value:"high",children:"🟠 High"}),e.jsx(yt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Status"}),e.jsxs(zs,{value:I,onValueChange:Y=>L(Y),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"todo",children:"To Do"}),e.jsx(yt,{value:"in_progress",children:"In Progress"}),e.jsx(yt,{value:"done",children:"Done"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Due Date"}),e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Rt("w-full justify-start text-left font-normal",!O&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),O?gs(O,"PPP"):"Pick a date"]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(ff,{mode:"single",selected:O,onSelect:U,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Link to Deal"}),e.jsxs(yo,{open:q,onOpenChange:$,children:[e.jsx(vo,{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(ma,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),b!=="none"?((J=i==null?void 0:i.find(Y=>Y.id===b))==null?void 0:J.deal_name)||"Select deal":"No Deal"]}),e.jsx(wx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(uo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Ax,{children:[e.jsx(Ex,{placeholder:"Search deals..."}),e.jsxs(Px,{children:[e.jsx(Ix,{children:"No deals found."}),e.jsxs(Lx,{children:[e.jsxs(op,{value:"no-deal",onSelect:()=>{N("none"),$(!1)},children:[e.jsx(ea,{className:Rt("mr-2 h-4 w-4",b==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(Y=>e.jsxs(op,{value:Y.deal_name,onSelect:()=>{N(Y.id),$(!1)},children:[e.jsx(ea,{className:Rt("mr-2 h-4 w-4",b===Y.id?"opacity-100":"opacity-0")}),Y.deal_name]},Y.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Link to Contact"}),e.jsxs(yo,{open:V,onOpenChange:ee,children:[e.jsx(vo,{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(Ei,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),w!=="none"?(()=>{const Y=u==null?void 0:u.find(ce=>ce.id===w);return Y?`${Y.first_name} ${Y.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(wx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(uo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Ax,{children:[e.jsx(Ex,{placeholder:"Search contacts..."}),e.jsxs(Px,{children:[e.jsx(Ix,{children:"No contacts found."}),e.jsxs(Lx,{children:[e.jsxs(op,{value:"no-contact",onSelect:()=>{S("none"),ee(!1)},children:[e.jsx(ea,{className:Rt("mr-2 h-4 w-4",w==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(Y=>e.jsxs(op,{value:`${Y.first_name} ${Y.last_name}`,onSelect:()=>{S(Y.id),ee(!1)},children:[e.jsx(ea,{className:Rt("mr-2 h-4 w-4",w===Y.id?"opacity-100":"opacity-0")}),Y.first_name," ",Y.last_name]},Y.id))]})]})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:Z,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const X4s={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 Q4s({tasks:t}){const s=e3e(),r=O4s(),n=br(),[a,o]=k.useState(null),l=async p=>{const f=p.status==="done"?"todo":"done";try{await s.mutateAsync({id:p.id,status:f})}catch{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(Hn,{className:"h-12 w-12 text-muted-foreground/30 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:"No tasks found"}),e.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Create a new task to get started"})]});const d=new Map,u=[];return t.forEach(p=>{if(p.deal){const f=d.get(p.deal.id)||{dealName:p.deal.deal_name,tasks:[]};f.tasks.push(p),d.set(p.deal.id,f)}else u.push(p)}),e.jsxs("div",{className:"space-y-4",children:[u.length>0&&e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 px-4 py-2 border-b",children:e.jsx("h3",{className:"font-medium text-sm text-muted-foreground",children:"General Tasks"})}),u.map(p=>e.jsx(_9e,{task:p,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:f=>n(`/mission-control/pipeline?deal=${f}`)},p.id))]}),Array.from(d.entries()).map(([p,f])=>e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(`/mission-control/pipeline?deal=${p}`),className:"w-full bg-muted/30 px-4 py-2 border-b flex items-center gap-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(ma,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:f.dealName}),e.jsxs(Ye,{variant:"secondary",className:"ml-auto text-xs",children:[f.tasks.filter(y=>y.status==="done").length,"/",f.tasks.length]}),e.jsx(ja,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),f.tasks.map(y=>e.jsx(_9e,{task:y,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:_=>n(`/mission-control/pipeline?deal=${_}`)},y.id))]},p)),a&&e.jsx(Hlt,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function _9e({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&a0(mm(t.due_date))&&!nu(mm(t.due_date)),i=!o&&t.due_date&&nu(mm(t.due_date)),d=X4s[t.priority];return e.jsxs("div",{className:Rt("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(Hn,{className:"h-5 w-5 text-emerald-500"}):e.jsx(sd,{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:Rt("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(Ei,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(Ye,{variant:"outline",className:Rt("text-[10px] shrink-0",d.color),children:[d.dot," ",d.label]}),t.due_date&&e.jsxs("span",{className:Rt("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(rn,{className:"h-3 w-3"}),gs(mm(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(Gc,{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(yr,{className:"h-3.5 w-3.5 text-destructive"})})]})]})}const J4s=[{status:"todo",label:"To Do",icon:sd,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:tp,color:"border-t-blue-500"},{status:"done",label:"Done",icon:Hn,color:"border-t-emerald-500"}],eSs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function tSs({tasks:t}){const s=e3e(),r=k.useMemo(()=>{const o={todo:[],in_progress:[],done:[]};return t.forEach(l=>o[l.status].push(l)),o},[t]),n=(o,l)=>{o.dataTransfer.setData("taskId",l)},a=async(o,l)=>{o.preventDefault();const i=o.dataTransfer.getData("taskId");if(!i)return;const d=t.find(u=>u.id===i);if(!(!d||d.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:J4s.map(o=>e.jsxs("div",{className:Rt("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(Ye,{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(sSs,{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 sSs({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&a0(mm(t.due_date))&&!nu(mm(t.due_date)),a=!r&&t.due_date&&nu(mm(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:Rt("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:eSs[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:Rt("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(ma,{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(Ei,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]}),t.due_date&&e.jsxs("div",{className:Rt("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(rn,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",gs(mm(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 b9e={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function rSs({tasks:t}){const[s,r]=k.useState(new Date),n=e3e(),a=xc(s),o=nx(s),l=Bh(a),i=Rue(o),d=BSt({start:l,end:i}),u=k.useMemo(()=>{const y=new Map;return t.forEach(_=>{if(!_.due_date)return;const b=_.due_date,N=y.get(b)||[];N.push(_),y.set(b,N)}),y},[t]),p=k.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(v4(s,1)),children:e.jsx(wl,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:gs(s,"MMMM yyyy")}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(Tm(s,1)),children:e.jsx(ja,{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:d.map(y=>{const _=gs(y,"yyyy-MM-dd"),b=u.get(_)||[],N=Fue(y,s),w=nu(y);return e.jsxs("div",{className:Rt("border-r border-b min-h-[100px] p-1",!N&&"bg-muted/30",w&&"bg-primary/5"),children:[e.jsx("div",{className:Rt("text-xs font-medium mb-1 text-right px-1",!N&&"text-muted-foreground/40",w&&"text-primary font-bold"),children:gs(y,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[b.slice(0,3).map(S=>e.jsxs("button",{onClick:()=>f(S),className:Rt("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",S.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[S.status==="done"?e.jsx(Hn,{className:"h-2.5 w-2.5 text-emerald-500 shrink-0"}):e.jsx(sd,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[b9e[S.priority]," ",S.title]})]},S.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:Rt("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(Hn,{className:"h-3.5 w-3.5 text-emerald-500 shrink-0"}):e.jsx(sd,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[b9e[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 nSs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function aSs({open:t,onOpenChange:s,stages:r}){var S;const[n,a]=k.useState(((S=r[0])==null?void 0:S.id)||""),{data:o,isLoading:l}=z4s(n||void 0),i=B4s(),d=$4s(),[u,p]=k.useState(""),[f,y]=k.useState("medium"),[_,b]=k.useState(""),N=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")}},w=async C=>{try{await d.mutateAsync(C),me.success("Template deleted")}catch{me.error("Failed to delete template")}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-[560px]",children:[e.jsx(ks,{children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(pL,{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(ge,{children:"Pipeline Stage"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.filter(C=>!C.is_won_stage&&!C.is_lost_stage).map(C=>e.jsx("button",{onClick:()=>a(C.id),className:Rt("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors",n===C.id?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"),children:C.name},C.id))})]}),e.jsx(di,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((C,A)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border rounded-lg group",children:[e.jsx("span",{className:"text-xs",children:nSs[C.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:C.title}),C.default_due_offset_days&&e.jsxs(Ye,{variant:"outline",className:"text-[10px]",children:["+",C.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>w(C.id),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",children:e.jsx(yr,{className:"h-3.5 w-3.5 text-destructive"})})]},C.id)),(o==null?void 0:o.length)===0&&n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No templates for this stage yet"})]})}),n&&e.jsxs("div",{className:"space-y-3 border-t pt-3",children:[e.jsx(ge,{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:C=>p(C.target.value),className:"flex-1",onKeyDown:C=>C.key==="Enter"&&N()}),e.jsxs(zs,{value:f,onValueChange:C=>y(C),children:[e.jsx(Os,{className:"w-[100px]",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"low",children:"🟢 Low"}),e.jsx(yt,{value:"medium",children:"🟡 Med"}),e.jsx(yt,{value:"high",children:"🟠 High"}),e.jsx(yt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ge,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(Fe,{type:"number",placeholder:"e.g., 7",value:_,onChange:C=>b(C.target.value)})]}),e.jsxs(K,{onClick:N,disabled:!u.trim()||i.isPending,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function iSs(){const{data:t,isLoading:s}=I4s(),{data:r}=Eme(),[n,a]=k.useState("list"),[o,l]=k.useState(""),[i,d]=k.useState("active"),[u,p]=k.useState("all"),[f,y]=k.useState("all"),[_,b]=k.useState(!1),[N,w]=k.useState(!1),S=k.useMemo(()=>{if(!t)return[];const I=new Map;return t.forEach(L=>{L.deal&&I.set(L.deal.id,L.deal.deal_name)}),Array.from(I,([L,O])=>({id:L,name:O}))},[t]),C=k.useMemo(()=>t?t.filter(I=>{var V,ee,Z,J;const L=o.toLowerCase(),O=!L||I.title.toLowerCase().includes(L)||((ee=(V=I.deal)==null?void 0:V.deal_name)==null?void 0:ee.toLowerCase().includes(L))||`${((Z=I.contact)==null?void 0:Z.first_name)||""} ${((J=I.contact)==null?void 0:J.last_name)||""}`.toLowerCase().includes(L),U=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&&a0(mm(I.due_date))&&!nu(mm(I.due_date)),q=u==="all"||I.priority===u,$=f==="all"||f==="no_deal"&&!I.deal_id||I.deal_id===f;return O&&U&&q&&$}):[],[t,o,i,u,f]),A=k.useMemo(()=>{if(!t)return{total:0,overdue:0,dueToday:0,dueThisWeek:0,completed:0};const I=t.filter(L=>L.status!=="done");return{total:I.length,overdue:I.filter(L=>L.due_date&&a0(mm(L.due_date))&&!nu(mm(L.due_date))).length,dueToday:I.filter(L=>L.due_date&&nu(mm(L.due_date))).length,dueThisWeek:I.filter(L=>L.due_date&&R3t(mm(L.due_date))).length,completed:t.filter(L=>L.status==="done").length}},[t]);return e.jsx(Ls,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6 max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage tasks across deals and contacts"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>w(!0),children:[e.jsx(Dg,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(K,{size:"sm",onClick:()=>b(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"New Task"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsxs("button",{onClick:()=>d("active"),className:`p-3 rounded-lg border text-left transition-colors ${i==="active"?"border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs font-medium",children:[e.jsx(Rh,{className:"h-3.5 w-3.5"}),"Active"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.total})]}),e.jsxs("button",{onClick:()=>d("overdue"),className:`p-3 rounded-lg border text-left transition-colors ${i==="overdue"?"border-destructive bg-destructive/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-destructive text-xs font-medium",children:[e.jsx(Qc,{className:"h-3.5 w-3.5"}),"Overdue"]}),e.jsx("p",{className:"text-xl font-bold mt-1 text-destructive",children:A.overdue})]}),e.jsxs("button",{onClick:()=>{d("active")},className:"p-3 rounded-lg border text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-xs font-medium",children:[e.jsx(rn,{className:"h-3.5 w-3.5"}),"Due Today"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.dueToday})]}),e.jsxs("button",{onClick:()=>{d("active")},className:"p-3 rounded-lg border text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-blue-600 text-xs font-medium",children:[e.jsx(xd,{className:"h-3.5 w-3.5"}),"This Week"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.dueThisWeek})]}),e.jsxs("button",{onClick:()=>d("done"),className:`p-3 rounded-lg border text-left transition-colors ${i==="done"?"border-emerald-500 bg-emerald-500/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-emerald-600 text-xs font-medium",children:[e.jsx(Hn,{className:"h-3.5 w-3.5"}),"Completed"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.completed})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 items-start md:items-center",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(tn,{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(zs,{value:u,onValueChange:p,children:[e.jsx(Os,{className:"w-[130px]",children:e.jsx(qs,{placeholder:"Priority"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Priorities"}),e.jsx(yt,{value:"urgent",children:"🔴 Urgent"}),e.jsx(yt,{value:"high",children:"🟠 High"}),e.jsx(yt,{value:"medium",children:"🟡 Medium"}),e.jsx(yt,{value:"low",children:"🟢 Low"})]})]}),e.jsxs(zs,{value:f,onValueChange:y,children:[e.jsx(Os,{className:"w-[160px]",children:e.jsx(qs,{placeholder:"Deal"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Deals"}),e.jsx(yt,{value:"no_deal",children:"No Deal"}),S.map(I=>e.jsx(yt,{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(Rh,{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(Zy,{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(xd,{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(Q4s,{tasks:C}),n==="kanban"&&e.jsx(tSs,{tasks:C}),n==="calendar"&&e.jsx(rSs,{tasks:C})]}),e.jsx(Hlt,{open:_,onOpenChange:b}),e.jsx(aSs,{open:N,onOpenChange:w,stages:r||[]})]})})}const e2e=[{value:"video_intro",label:"Video Intro",icon:hn,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:kL,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:hh,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:Do,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:vd,description:"Links to your social profiles"}],oSs=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],lSs={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function Glt({cardId:t}){const{data:s,isLoading:r}=I4t(t),n=L4t(),a=D4t(),o=R4t(),[l,i]=k.useState(!1),[d,u]=k.useState(""),[p,f]=k.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ss,{className:"h-16 w-full"}),e.jsx(Ss,{className:"h-16 w-full"})]});const y=()=>{d&&n.mutate({card_id:t,block_type:d,sort_order:(s==null?void 0:s.length)||0,config:lSs[d]||{}},{onSuccess:()=>{i(!1),u("")}})},_=C=>{a.mutate({id:C.id,is_visible:!C.is_visible})},b=(C,A)=>{if(!s)return;const I=s.findIndex(U=>U.id===C.id),L=A==="up"?I-1:I+1;if(L<0||L>=s.length)return;const O=s[L];a.mutate({id:C.id,sort_order:O.sort_order}),a.mutate({id:O.id,sort_order:C.sort_order})},N=C=>{confirm("Remove this block from this card?")&&o.mutate(C.id)},w=(C,A)=>{a.mutate({id:C.id,config:A},{onSuccess:()=>f(null)})},S=C=>e2e.find(A=>A.value===C);return e.jsxs("div",{className:"space-y-3",children:[!s||s.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted-foreground mb-4 text-sm",children:"No blocks yet. Add a block to customize this card."}),e.jsxs(K,{size:"sm",onClick:()=>i(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):e.jsxs(e.Fragment,{children:[s.map((C,A)=>{const I=S(C.block_type),L=(I==null?void 0:I.icon)||hh;return e.jsx(Ie,{className:C.is_visible?"":"opacity-50",children:e.jsx(Be,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(uu,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(L,{className:"h-4 w-4 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs",children:(I==null?void 0:I.label)||C.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:cSs(C)})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(C,"up"),disabled:A===0,children:e.jsx(cu,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(C,"down"),disabled:A===s.length-1,children:e.jsx(Ih,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(C),children:C.is_visible?e.jsx(jn,{className:"h-3 w-3"}):e.jsx(hp,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>f(C),children:"Edit"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>N(C),children:e.jsx(yr,{className:"h-3 w-3"})})]})]})})},C.id)}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:e2e.map(C=>{const A=C.icon;return e.jsxs("button",{onClick:()=>u(C.value),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors ${d===C.value?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[e.jsx(A,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:C.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.description})]})]},C.value)})}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:y,disabled:!d||n.isPending,children:"Add Block"})]})]})}),p&&e.jsx(dSs,{block:p,onSave:C=>w(p,C),onClose:()=>f(null)})]})}function cSs(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 dSs({block:t,onSave:s,onClose:r}){const[n,a]=k.useState(t.config),o=e2e.find(l=>l.value===t.block_type);return e.jsx(fs,{open:!0,onOpenChange:r,children:e.jsxs(ms,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsxs(bs,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx(uSs,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(hSs,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(mSs,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(pSs,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(fSs,{config:n,onChange:a}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(K,{onClick:()=>s(n),children:"Save"})]})]})})}function uSs({config:t,onChange:s,cardId:r}){var _,b;const[n,a]=k.useState(""),[o,l]=k.useState((_=t.video_url)!=null&&_.includes("youtube")||(b=t.video_url)!=null&&b.includes("youtu.be")?"youtube":"library"),{data:i}=ft({queryKey:["card-owner",r],queryFn:async()=>{const{data:N}=await G.from("agent_cards").select("user_id").eq("id",r).single();return N==null?void 0:N.user_id},enabled:!!r}),{data:d,isLoading:u}=ft({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:N,error:w}=await G.from("agent_videos").select("id, title, bunny_video_id, thumbnail_url, playback_url, created_at").eq("owner_user_id",i).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(w)throw w;return N||[]},enabled:!!i}),p=(d==null?void 0:d.filter(N=>!n||(N.title||"").toLowerCase().includes(n.toLowerCase())))||[],f=t.bunny_video_id,y=N=>{var A;const w=(A=N.playback_url)==null?void 0:A.match(/\/(?:play|embed)\/(\d+)\//),C=`https://iframe.mediadelivery.net/embed/${w?w[1]:"570924"}/${N.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:C,bunny_video_id:N.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(ta,{value:o,onValueChange:l,children:[e.jsxs(Qn,{className:"w-full",children:[e.jsx(ls,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(ls,{value:"youtube",className:"flex-1",children:"YouTube URL"})]}),e.jsxs(js,{value:"library",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(tn,{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:N=>a(N.target.value),className:"pl-9"})]}),e.jsx(di,{className:"h-[240px]",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ss,{className:"h-14 w-full"}),e.jsx(Ss,{className:"h-14 w-full"})]}):p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:(d==null?void 0:d.length)===0?"No videos in library yet":"No matching videos"}):e.jsx("div",{className:"space-y-1.5 pr-3",children:p.map(N=>e.jsxs("button",{onClick:()=>y(N),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${f===N.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[N.thumbnail_url?e.jsx("img",{src:N.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:w=>{var S;w.currentTarget.style.display="none",(S=w.currentTarget.nextElementSibling)==null||S.classList.remove("hidden")}}):null,e.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${N.thumbnail_url?"hidden":""}`,children:e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:N.title||"Untitled Video"}),f===N.bunny_video_id&&e.jsx(ea,{className:"h-4 w-4 text-primary flex-shrink-0"})]},N.id))})})]}),e.jsx(js,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(ge,{children:"YouTube URL"}),e.jsx(Fe,{placeholder:"https://www.youtube.com/watch?v=...",value:t.video_source==="youtube"&&t.video_url||"",onChange:N=>s({...t,video_url:N.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 hSs({config:t,onChange:s}){const r=t.testimonials||[],n=(l,i,d)=>{const u=[...r];u[l]={...u[l],[i]:d},s({...t,testimonials:u})},a=()=>s({...t,testimonials:[...r,{name:"",quote:"",role:""}]}),o=l=>s({...t,testimonials:r.filter((i,d)=>d!==l)});return e.jsxs("div",{className:"space-y-4",children:[r.map((l,i)=>e.jsx(Ie,{children:e.jsxs(Be,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ge,{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(yr,{className:"h-3 w-3"})})]}),e.jsx(Fe,{placeholder:"Client name",value:l.name,onChange:d=>n(i,"name",d.target.value)}),e.jsx(Fe,{placeholder:"Role/title (optional)",value:l.role||"",onChange:d=>n(i,"role",d.target.value)}),e.jsx("textarea",{className:"w-full min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:"Their testimonial quote...",value:l.quote,onChange:d=>n(i,"quote",d.target.value)})]})},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function mSs({config:t,onChange:s}){const r=t.tags||[],[n,a]=k.useState(""),o=i=>{s({...t,tags:r.includes(i)?r.filter(d=>d!==i):[...r,i]})},l=()=>{n.trim()&&!r.includes(n.trim())&&(s({...t,tags:[...r,n.trim()]}),a(""))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:oSs.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(ge,{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(ge,{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 pSs({config:t,onChange:s}){const r=t.links||[],n=(l,i,d)=>{const u=[...r];u[l]={...u[l],[i]:d},s({...t,links:u})},a=()=>s({...t,links:[...r,{label:"",url:""}]}),o=l=>s({...t,links:r.filter((i,d)=>d!==l)});return e.jsxs("div",{className:"space-y-3",children:[r.map((l,i)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Fe,{placeholder:"Button label",value:l.label,onChange:d=>n(i,"label",d.target.value)}),e.jsx(Fe,{placeholder:"https://...",value:l.url,onChange:d=>n(i,"url",d.target.value)})]}),r.length>1&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 mt-1 text-destructive",onClick:()=>o(i),children:e.jsx(yr,{className:"h-3 w-3"})})]},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const w9e=[{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 fSs({config:t,onChange:s}){const r=t.platforms||[],n=d=>{r.find(u=>u.platform===d)||s({...t,platforms:[...r,{platform:d,url:""}]})},a=(d,u)=>{const p=[...r];p[d]={...p[d],url:u},s({...t,platforms:p})},o=d=>{s({...t,platforms:r.filter((u,p)=>p!==d)})},l=w9e.filter(d=>!r.find(u=>u.platform===d.value)),i=d=>{const u=w1e[d],p=w9e.find(f=>f.value===d);return{label:(p==null?void 0:p.label)||d,color:(u==null?void 0:u.color)||"#666",iconPath:u==null?void 0:u.icon}};return e.jsxs("div",{className:"space-y-4",children:[r.length>0&&e.jsx("div",{className:"space-y-3",children:r.map((d,u)=>{const p=i(d.platform);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg flex items-center justify-center flex-shrink-0 border",style:{borderColor:p.color+"30",backgroundColor:p.color+"10"},children:p.iconPath&&e.jsx("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:p.color,children:e.jsx("path",{d:p.iconPath})})}),e.jsx("div",{className:"flex-1",children:e.jsx(Fe,{placeholder:`Your ${p.label} profile URL`,value:d.url,onChange:f=>a(u,f.target.value)})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive flex-shrink-0",onClick:()=>o(u),children:e.jsx(yr,{className:"h-3.5 w-3.5"})})]},u)})}),l.length>0&&e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs text-muted-foreground mb-2 block",children:"Add a platform"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(d=>{const u=w1e[d.value];return e.jsxs("button",{onClick:()=>n(d.value),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-full border border-border bg-muted hover:bg-muted/80 transition-colors",children:[(u==null?void 0:u.icon)&&e.jsx("svg",{viewBox:"0 0 24 24",width:12,height:12,fill:u.color,children:e.jsx("path",{d:u.icon})}),d.label]},d.value)})})]}),r.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Tap a platform above to add your social media profile."})]})}var xSs=Object.defineProperty,Ade=Object.getOwnPropertySymbols,Wlt=Object.prototype.hasOwnProperty,Klt=Object.prototype.propertyIsEnumerable,j9e=(t,s,r)=>s in t?xSs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,t2e=(t,s)=>{for(var r in s||(s={}))Wlt.call(s,r)&&j9e(t,r,s[r]);if(Ade)for(var r of Ade(s))Klt.call(s,r)&&j9e(t,r,s[r]);return t},s2e=(t,s)=>{var r={};for(var n in t)Wlt.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Ade)for(var n of Ade(t))s.indexOf(n)<0&&Klt.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var vC;(t=>{const s=class qi{constructor(d,u,p,f){if(this.version=d,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],dqi.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=d*4+17;let y=[];for(let b=0;b7)throw new RangeError("Invalid value");let b,N;for(b=p;;b++){const A=qi.getNumDataCodewords(b,u)*8,I=l.getTotalBits(d,b);if(I<=A){N=I;break}if(b>=f)throw new RangeError("Data too long")}for(const A of[qi.Ecc.MEDIUM,qi.Ecc.QUARTILE,qi.Ecc.HIGH])_&&N<=qi.getNumDataCodewords(b,A)*8&&(u=A);let w=[];for(const A of d){r(A.mode.modeBits,4,w),r(A.numChars,A.mode.numCharCountBits(b),w);for(const I of A.getData())w.push(I)}a(w.length==N);const S=qi.getNumDataCodewords(b,u)*8;a(w.length<=S),r(0,Math.min(4,S-w.length),w),r(0,(8-w.length%8)%8,w),a(w.length%8==0);for(let A=236;w.lengthC[I>>>3]|=A<<7-(I&7)),new qi(b,u,C,y)}getModule(d,u){return 0<=d&&d>>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 d=this.version;for(let p=0;p<12;p++)d=d<<1^(d>>>11)*7973;const u=this.version<<12|d;a(u>>>18==0);for(let p=0;p<18;p++){const f=n(u,p),y=this.size-11+p%3,_=Math.floor(p/3);this.setFunctionModule(y,_,f),this.setFunctionModule(_,y,f)}}drawFinderPattern(d,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)),_=d+f,b=u+p;0<=_&&_{(A!=N-y||L>=b)&&C.push(I[A])});return a(C.length==_),C}drawCodewords(d){if(d.length!=Math.floor(qi.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let f=0;f>>3],7-(u&7)),u++)}}a(u==d.length*8)}applyMask(d){if(d<0||d>7)throw new RangeError("Mask value out of range");for(let u=0;u5&&d++):(this.finderPenaltyAddHistory(b,N),_||(d+=this.finderPenaltyCountPatterns(N)*qi.PENALTY_N3),_=this.modules[y][w],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,N)*qi.PENALTY_N3}for(let y=0;y5&&d++):(this.finderPenaltyAddHistory(b,N),_||(d+=this.finderPenaltyCountPatterns(N)*qi.PENALTY_N3),_=this.modules[w][y],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,N)*qi.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),d+=f*qi.PENALTY_N4,a(0<=d&&d<=2568888),d}getAlignmentPatternPositions(){if(this.version==1)return[];{const d=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(d*2-2))*2;let p=[6];for(let f=this.size-7;p.lengthqi.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*d+128)*d+64;if(d>=2){const p=Math.floor(d/7)+2;u-=(25*p-10)*p-55,d>=7&&(u-=36)}return a(208<=u&&u<=29648),u}static getNumDataCodewords(d,u){return Math.floor(qi.getNumRawDataModules(d)/8)-qi.ECC_CODEWORDS_PER_BLOCK[u.ordinal][d]*qi.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][d]}static reedSolomonComputeDivisor(d){if(d<1||d>255)throw new RangeError("Degree out of range");let u=[];for(let f=0;f0);for(const f of d){const y=f^p.shift();p.push(0),u.forEach((_,b)=>p[b]^=qi.reedSolomonMultiply(_,y))}return p}static reedSolomonMultiply(d,u){if(d>>>8||u>>>8)throw new RangeError("Byte out of range");let p=0;for(let f=7;f>=0;f--)p=p<<1^(p>>>7)*285,p^=(u>>>f&1)*d;return a(p>>>8==0),p}finderPenaltyCountPatterns(d){const u=d[1];a(u<=this.size*3);const p=u>0&&d[2]==u&&d[3]==u*3&&d[4]==u&&d[5]==u;return(p&&d[0]>=u*4&&d[6]>=u?1:0)+(p&&d[6]>=u*4&&d[0]>=u?1:0)}finderPenaltyTerminateAndCount(d,u,p){return d&&(this.finderPenaltyAddHistory(u,p),u=0),u+=this.size,this.finderPenaltyAddHistory(u,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(d,u){u[0]==0&&(d+=this.size),u.pop(),u.unshift(d)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=s;function r(i,d,u){if(d<0||d>31||i>>>d)throw new RangeError("Value out of range");for(let p=d-1;p>=0;p--)u.push(i>>>p&1)}function n(i,d){return(i>>>d&1)!=0}function a(i){if(!i)throw new Error("Assertion error")}const o=class Vc{constructor(d,u,p){if(this.mode=d,this.numChars=u,this.bitData=p,u<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(d){let u=[];for(const p of d)r(p,8,u);return new Vc(Vc.Mode.BYTE,d.length,u)}static makeNumeric(d){if(!Vc.isNumeric(d))throw new RangeError("String contains non-numeric characters");let u=[];for(let p=0;p=1<{(s=>{const r=class{constructor(a,o){this.ordinal=a,this.formatBits=o}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(t.QrCode||(t.QrCode={}))})(vC||(vC={}));(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={}))})(vC||(vC={}));var mM=vC;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var gSs={L:mM.QrCode.Ecc.LOW,M:mM.QrCode.Ecc.MEDIUM,Q:mM.QrCode.Ecc.QUARTILE,H:mM.QrCode.Ecc.HIGH},Zlt=128,Ylt="L",Xlt="#FFFFFF",Qlt="#000000",Jlt=!1,ect=1,ySs=4,vSs=0,_Ss=.1;function tct(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 sct(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 bSs(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*_Ss),l=a/s,i=(n.width||o)*l,d=(n.height||o)*l,u=n.x==null?t.length/2-i/2:n.x*l,p=n.y==null?t.length/2-d/2:n.y*l,f=n.opacity==null?1:n.opacity;let y=null;if(n.excavate){let b=Math.floor(u),N=Math.floor(p),w=Math.ceil(i+u-b),S=Math.ceil(d+p-N);y={x:b,y:N,w,h:S}}const _=n.crossOrigin;return{x:u,y:p,h:d,w:i,excavation:y,opacity:f,crossOrigin:_}}function wSs(t,s){return s!=null?Math.max(Math.floor(s),0):t?ySs:vSs}function rct({value:t,level:s,minVersion:r,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let d=ht.useMemo(()=>{const b=(Array.isArray(t)?t:[t]).reduce((N,w)=>(N.push(...mM.QrSegment.makeSegments(w)),N),[]);return mM.QrCode.encodeSegments(b,gSs[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:p,numCells:f,calculatedImageSettings:y}=ht.useMemo(()=>{let _=d.getModules();const b=wSs(n,a),N=_.length+b*2,w=bSs(_,l,b,o);return{cells:_,margin:b,numCells:N,calculatedImageSettings:w}},[d,l,o,n,a]);return{qrcode:d,margin:p,cells:u,numCells:f,calculatedImageSettings:y}}var jSs=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),NSs=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=Zlt,level:l=Ylt,bgColor:i=Xlt,fgColor:d=Qlt,includeMargin:u=Jlt,minVersion:p=ect,boostLevel:f,marginSize:y,imageSettings:_}=n,N=s2e(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:w}=N,S=s2e(N,["style"]),C=_==null?void 0:_.src,A=ht.useRef(null),I=ht.useRef(null),L=ht.useCallback(Y=>{A.current=Y,typeof r=="function"?r(Y):r&&(r.current=Y)},[r]),[O,U]=ht.useState(!1),{margin:q,cells:$,numCells:V,calculatedImageSettings:ee}=rct({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:y,imageSettings:_,size:o});ht.useEffect(()=>{if(A.current!=null){const Y=A.current,ce=Y.getContext("2d");if(!ce)return;let ae=$;const ie=I.current,le=ee!=null&&ie!==null&&ie.complete&&ie.naturalHeight!==0&&ie.naturalWidth!==0;le&&ee.excavation!=null&&(ae=sct($,ee.excavation));const fe=window.devicePixelRatio||1;Y.height=Y.width=o*fe;const xe=o/V*fe;ce.scale(xe,xe),ce.fillStyle=i,ce.fillRect(0,0,V,V),ce.fillStyle=d,jSs?ce.fill(new Path2D(tct(ae,q))):$.forEach(function(he,we){he.forEach(function(Ne,Ve){Ne&&ce.fillRect(Ve+q,we+q,1,1)})}),ee&&(ce.globalAlpha=ee.opacity),le&&ce.drawImage(ie,ee.x+q,ee.y+q,ee.w,ee.h)}}),ht.useEffect(()=>{U(!1)},[C]);const Z=t2e({height:o,width:o},w);let J=null;return C!=null&&(J=ht.createElement("img",{src:C,key:C,style:{display:"none"},onLoad:()=>{U(!0)},ref:I,crossOrigin:ee==null?void 0:ee.crossOrigin})),ht.createElement(ht.Fragment,null,ht.createElement("canvas",t2e({style:Z,height:o,width:o,ref:L,role:"img"},S)),J)});NSs.displayName="QRCodeCanvas";var EO=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=Zlt,level:l=Ylt,bgColor:i=Xlt,fgColor:d=Qlt,includeMargin:u=Jlt,minVersion:p=ect,boostLevel:f,title:y,marginSize:_,imageSettings:b}=n,N=s2e(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:S,numCells:C,calculatedImageSettings:A}=rct({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:_,imageSettings:b,size:o});let I=S,L=null;b!=null&&A!=null&&(A.excavation!=null&&(I=sct(S,A.excavation)),L=ht.createElement("image",{href:b.src,height:A.h,width:A.w,x:A.x+w,y:A.y+w,preserveAspectRatio:"none",opacity:A.opacity,crossOrigin:A.crossOrigin}));const O=tct(I,w);return ht.createElement("svg",t2e({height:o,width:o,viewBox:`0 0 ${C} ${C}`,ref:r,role:"img"},N),!!y&&ht.createElement("title",null,y),ht.createElement("path",{fill:i,d:`M0,0 h${C}v${C}H0z`,shapeRendering:"crispEdges"}),ht.createElement("path",{fill:d,d:O,shapeRendering:"crispEdges"}),L)});EO.displayName="QRCodeSVG";function kSs({slug:t,agentName:s}){const r=k.useRef(null),n=`https://cards.relevelup.com/${t}`,a=k.useCallback(()=>{var f;const o=(f=r.current)==null?void 0:f.querySelector("svg");if(!o)return;const l=document.createElement("canvas"),i=1024;l.width=i,l.height=i;const d=l.getContext("2d");if(!d)return;const u=new XMLSerializer().serializeToString(o),p=new Image;p.onload=()=>{d.fillStyle="#ffffff",d.fillRect(0,0,i,i),d.drawImage(p,0,0,i,i);const 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(ge,{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(EO,{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(Xa,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function w0e(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 SSs(){const{user:t}=$s(),{data:s,isLoading:r}=A4t(t==null?void 0:t.id),n=bE(),[a,o]=k.useState(null),l=k.useMemo(()=>a||(s?w0e(s):null),[a,s]);if(r)return e.jsx(Ls,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 space-y-4",children:[e.jsx(Ss,{className:"h-8 w-48"}),e.jsx(Ss,{className:"h-32 w-full"}),e.jsx(Ss,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Ls,{children:e.jsx(MSs,{userId:t==null?void 0:t.id})});const i=l||w0e(s),d=u=>{o(p=>{const f=p||w0e(s);return typeof u=="function"?u(f):u})};return e.jsx(Ls,{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(TSs,{card:s}),e.jsx(ISs,{card:s,form:i,setForm:d})]}),!n&&e.jsx("div",{className:"w-[400px] shrink-0","aria-hidden":"true"}),!n&&e.jsx("div",{className:"fixed right-8 top-[5.5rem] w-[400px] z-30",style:{height:"calc(100vh - 6.5rem)"},children:e.jsxs("div",{className:"rounded-xl border bg-muted/30 overflow-hidden h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b bg-card shrink-0",children:[e.jsx(pS,{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(CSs,{card:s,form:i})})]})})]})})}function CSs({card:t,form:s}){const{data:r}=ft({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=k.useMemo(()=>({...t,is_published:s.is_published,theme:s.theme,title:s.title||null,positioning_statement:s.positioning_statement||null,bio:s.bio||null,review_snippet:s.review_snippet||null,review_source_url:s.review_source_url||null,booking_url:s.booking_url||null,custom_cta_label:s.custom_cta_label||null,custom_cta_url:t.custom_cta_url,show_photo:s.show_photo,show_bio:s.show_bio,show_video:t.show_video,show_credentials:s.show_credentials,show_social_links:s.show_social_links,show_save_contact:s.show_save_contact,show_leave_review:s.show_leave_review,show_refer_friend:s.show_refer_friend,brokerage_display_name:s.brokerage_display_name||null,brokerage_logo_url:s.brokerage_logo_url||null,brokerage_logo_size:s.brokerage_logo_size,team_name:s.team_name||null,team_logo_url:s.team_logo_url||null,team_logo_size:s.team_logo_size,display_email:s.display_email||null,social_links:t.social_links||[],profile:{name:(r==null?void 0:r.name)||null,email:s.display_email||(r==null?void 0:r.email)||null,phone:(r==null?void 0:r.phone)||null,brokerage_id:(r==null?void 0:r.brokerage_id)||null},brokerage_name:s.brokerage_display_name||null,avatar_url:(r==null?void 0:r.avatar_url)||null}),[t,s,r]);return e.jsx("div",{className:"transform scale-[0.85] origin-top",children:e.jsx(Jje,{card:n})})}function MSs({userId:t}){var d;const[s,r]=k.useState(""),n=IWe(),{data:a}=ft({queryKey:["my-profile-for-card",t],queryFn:async()=>{if(!t)return null;const{data:u}=await G.from("profiles").select("name").eq("id",t).single();return u},enabled:!!t}),o=((d=a==null?void 0:a.name)==null?void 0:d.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||"",l=()=>{if(!t)return;const u=(s.trim()||o).toLowerCase().replace(/[^a-z0-9-]/g,"-");if(!u){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:gd,title:"Shareable Link",desc:"One link that works everywhere"},{icon:Fh,title:"Lead Capture",desc:"Collect leads automatically"},{icon:Ru,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:Rl,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(qr,{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(Ie,{className:"shadow-lg border-2",children:[e.jsxs(Lt,{className:"text-center pb-2",children:[e.jsx(Ft,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(mr,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs(Be,{className:"p-6 pt-2 space-y-5",children:[e.jsxs("div",{children:[e.jsx(ge,{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(qr,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function TSs({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(Ye,{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(gd,{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(Ya,{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(Kr,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function ASs({userId:t}){const s=es(),r=k.useRef(null),[n,a]=k.useState(!1),[o,l]=k.useState(""),{data:i,isLoading:d}=ft({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:ee}=await G.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let Z=(ee==null?void 0:ee.avatar_url)||null;if(!Z){const{data:J}=await G.storage.from("avatars").list(`${t}`);if(J&&J.length>0){const{data:Y}=G.storage.from("avatars").getPublicUrl(`${t}/${J[0].name}`);Z=`${Y.publicUrl}?t=${Date.now()}`,await G.from("profiles").update({avatar_url:Z}).eq("id",t)}}return{...ee,avatar_url:Z}}}),[u,p]=k.useState(null),[f,y]=k.useState(null),[_,b]=k.useState(null),[N,w]=k.useState(!1),S=u??(i==null?void 0:i.name)??"",C=f??(i==null?void 0:i.phone)??"",A=_??(i==null?void 0:i.email)??"",I=i==null?void 0:i.avatar_url,L=((i==null?void 0:i.name)||"A").split(" ").map(ee=>ee[0]).join("").toUpperCase().slice(0,2),O=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),U=Et({mutationFn:async ee=>{const{error:Z}=await G.from("profiles").update(ee).eq("id",t);if(Z)throw Z},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 ee={};if(u!==null&&u!==(i==null?void 0:i.name)&&(ee.name=u),f!==null&&f!==(i==null?void 0:i.phone)&&(ee.phone=f||null),_!==null&&_!==(i==null?void 0:i.email)&&(ee.email=_),Object.keys(ee).length===0){me.info("No changes to save");return}U.mutate(ee)},$=ee=>{var Y;const Z=(Y=ee.target.files)==null?void 0:Y[0];if(!Z)return;if(!Z.type.startsWith("image/")){me.error("Please select an image file");return}const J=new FileReader;J.onloadend=()=>{l(J.result),a(!0)},J.readAsDataURL(Z),ee.target.value=""},V=async ee=>{w(!0);try{const{data:Z}=await G.storage.from("avatars").list(`${t}`);Z&&Z.length>0&&await G.storage.from("avatars").remove(Z.map(ie=>`${t}/${ie.name}`));const J=`${t}/avatar.jpg`,{error:Y}=await G.storage.from("avatars").upload(J,ee,{upsert:!0,contentType:"image/jpeg"});if(Y)throw Y;const{data:ce}=G.storage.from("avatars").getPublicUrl(J),ae=ce.publicUrl+"?t="+Date.now();await G.from("profiles").update({avatar_url:ae}).eq("id",t),s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),me.success("Photo updated!")}catch{me.error("Failed to upload photo")}finally{w(!1)}};return d?e.jsx(Ss,{className:"h-32 w-full rounded-xl"}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:O?"border-amber-300 dark:border-amber-700":"",children:e.jsxs(Be,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ge,{className:"text-sm font-semibold",children:"Profile Info"}),O&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 font-medium",children:[e.jsx(co,{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 ee;return(ee=r.current)==null?void 0:ee.click()},children:[e.jsxs(vn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(Ca,{src:I||void 0,alt:S}),e.jsx(_n,{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(bx,{className:"h-5 w-5 text-white"})}),e.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden",onChange:$})]}),e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:N?"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(ge,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(Fe,{value:S,onChange:ee=>p(ee.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(ge,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),e.jsx(Fe,{value:C,onChange:ee=>y(ee.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsx(Fe,{value:A,onChange:ee=>b(ee.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:q,disabled:U.isPending,className:"w-full",children:U.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(h4e,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:V,aspectRatio:1})]})}function ESs({form:t,setForm:s,userId:r}){const[n,a]=k.useState(null),[o,l]=k.useState(t.brokerage_logo_url?"logo":"name"),[i,d]=k.useState(t.team_logo_url?"logo":"name"),u=_=>{l(_),s(_==="name"?b=>({...b,brokerage_logo_url:""}):b=>({...b,brokerage_display_name:""}))},p=_=>{d(_),s(_==="name"?b=>({...b,team_logo_url:""}):b=>({...b,team_name:""}))},f=async(_,b)=>{var w;const N=(w=_.target.files)==null?void 0:w[0];if(N){if(!N.type.startsWith("image/")){me.error("Please select an image file");return}a(b);try{const S=N.name.split(".").pop()||"png",A=`${r}/${b==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${S}`,{error:I}=await G.storage.from("card-logos").upload(A,N,{upsert:!0});if(I)throw I;const{data:L}=G.storage.from("card-logos").getPublicUrl(A),O=L.publicUrl+"?t="+Date.now();s(b==="brokerage_logo_url"?U=>({...U,[b]:O,brokerage_display_name:""}):U=>({...U,[b]:O,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(Ie,{children:e.jsxs(Be,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(ge,{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(ge,{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(ge,{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(ge,{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(bx,{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(ge,{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(Eg,{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(ge,{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(ge,{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(ge,{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(bx,{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(ge,{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(Eg,{value:[t.team_logo_size||56],onValueChange:([_])=>s(b=>({...b,team_logo_size:_})),min:24,max:120,step:4})]})]})]})]})})}function PSs({form:t,setForm:s}){const r={accent:"#ff5722",dark:"#1a1a2e",button:"#ff5722"},n=t.bold_theme_colors||r,a=(i,d)=>{s(u=>({...u,bold_theme_colors:{...r,...u.bold_theme_colors,[i]:d}}))},o=()=>{s(i=>({...i,bold_theme_colors:null}))},l=[{key:"accent",label:"Accent Color",desc:"Page background, icons, highlights"},{key:"dark",label:"Dark Color",desc:"Header background, action buttons, social icons"},{key:"button",label:"CTA Button Color",desc:"Main call-to-action button"}];return e.jsxs("div",{className:"space-y-3 p-4 rounded-xl border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(ge,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(Rl,{className:"h-4 w-4"})," Brand Colors"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Customize colors to match your brand"})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:o,children:"Reset to Default"})]}),e.jsx("div",{className:"grid gap-3",children:l.map(({key:i,label:d,desc:u})=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"relative shrink-0",children:[e.jsx("input",{type:"color",value:n[i],onChange:p=>a(i,p.target.value),className:"sr-only"}),e.jsx("div",{className:"h-10 w-10 rounded-lg border-2 border-border cursor-pointer shadow-sm hover:scale-105 transition-transform",style:{backgroundColor:n[i]}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:d}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u})]}),e.jsx(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 ISs({card:t,form:s,setForm:r}){var N;const n=LWe(),a=es(),{data:o}=DWe(t.id),[l,i]=k.useState(t.slug),[d,u]=k.useState(!1),[p,f]=k.useState("idle"),y=k.useRef(JSON.stringify(s)),_=k.useRef(null);k.useEffect(()=>{const w=JSON.stringify(s);if(w!==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=w,f("saved"),setTimeout(()=>f("idle"),2e3)},onError:()=>f("idle")})},1500),()=>{_.current&&clearTimeout(_.current)}},[s]);const b=async()=>{const w=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!w){me.error("Please enter a valid URL");return}if(w===t.slug){me.info("No changes to save");return}u(!0);try{const{data:S}=await G.from("agent_cards").select("id").eq("slug",w).neq("id",t.id).maybeSingle();if(S){me.error("This URL is already taken. Try another one.");return}const{error:C}=await G.from("agent_cards").update({slug:w}).eq("id",t.id);if(C)throw C;i(w),a.invalidateQueries({queryKey:["agent-card"]}),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(ta,{defaultValue:"content",children:[e.jsxs(Qn,{className:"w-full h-11 p-1",children:[e.jsxs(ls,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(jx,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(ls,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(jn,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(ls,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Fh,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(ls,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Qy,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(ls,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Cm,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Analytics"]})]}),e.jsxs(js,{value:"content",className:"mt-4 space-y-4",children:[e.jsx(ASs,{userId:t.user_id}),e.jsx(ESs,{form:s,setForm:r,userId:t.user_id}),e.jsx(Ie,{children:e.jsxs(Be,{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(ge,{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(Lr,{checked:s.is_published,onCheckedChange:w=>r(S=>({...S,is_published:w}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{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:w=>i(w.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:b,disabled:d||l===t.slug,className:"shrink-0",children:d?"Saving...":"Update"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is your unique card URL. Only letters, numbers, and dashes allowed."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(Fe,{value:s.display_email,onChange:w=>r(S=>({...S,display_email:w.target.value})),placeholder:"you@yourbusiness.com",className:"h-11",type:"email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional — use a different email on your card instead of your sign-in email."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Theme"}),e.jsxs(zs,{value:s.theme,onValueChange:w=>r(S=>({...S,theme:w})),children:[e.jsx(Os,{className:"h-11",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"standard",children:"✨ Standard — Modern & Clean"}),e.jsx(yt,{value:"luxury",children:"🌙 Luxury — Dark & Gold"}),e.jsx(yt,{value:"bold",children:"🔥 Bold — Vibrant & Punchy"}),e.jsx(yt,{value:"classic",children:"📋 Classic — Professional"})]})]})]}),s.theme==="bold"&&e.jsx(PSs,{form:s,setForm:r}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Title / Tagline"}),e.jsx(Fe,{value:s.title,onChange:w=>r(S=>({...S,title:w.target.value})),placeholder:"e.g. Luxury Real Estate Specialist",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown below your name on the card"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Positioning Statement"}),e.jsx(Fe,{value:s.positioning_statement,onChange:w=>r(S=>({...S,positioning_statement:w.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Bio"}),e.jsx(_r,{value:s.bio,onChange:w=>r(S=>({...S,bio:w.target.value})),placeholder:"A short intro about you and what makes you different...",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Review Snippet"}),e.jsx(Fe,{value:s.review_snippet,onChange:w=>r(S=>({...S,review_snippet:w.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Review Source URL"}),e.jsx(Fe,{value:s.review_source_url,onChange:w=>r(S=>({...S,review_source_url:w.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Booking URL"}),e.jsx(Fe,{value:s.booking_url,onChange:w=>r(S=>({...S,booking_url:w.target.value})),placeholder:"https://calendly.com/your-link",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty to show a built-in lead form instead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Custom CTA Label"}),e.jsx(Fe,{value:s.custom_cta_label,onChange:w=>r(S=>({...S,custom_cta_label:w.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(js,{value:"sections",className:"mt-4",children:e.jsx(Ie,{children:e.jsx(Be,{className:"p-5 divide-y",children:[{key:"show_photo",label:"Photo",desc:"Uses the photo from your Profile Info above"},{key:"show_bio",label:"Bio Section",desc:"Display your bio on the card"},{key:"show_credentials",label:"Credentials",desc:"Show star rating and reviews"},{key:"show_social_links",label:"Social Links",desc:"Display your social media links"},{key:"show_save_contact",label:"Save Contact",desc:"Let visitors save you as a contact"},{key:"show_leave_review",label:"Leave Review",desc:"Link to your review page"},{key:"show_refer_friend",label:"Refer a Friend",desc:"Enable referral submissions"}].map(({key:w,label:S,desc:C})=>e.jsxs("div",{className:"flex items-center justify-between py-4 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ge,{className:"text-sm font-medium",children:S}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C})]}),e.jsx(Lr,{checked:s[w],onCheckedChange:A=>r(I=>({...I,[w]:A}))})]},w))})})}),e.jsx(js,{value:"blocks",className:"mt-4",children:e.jsx(Glt,{cardId:t.id})}),e.jsx(js,{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:jn,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:Cm,color:"text-amber-600 bg-amber-100 dark:text-amber-400 dark:bg-amber-900/30"},{label:"Leads",value:((N=o==null?void 0:o.leads)==null?void 0:N.length)??0,icon:il,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(w=>e.jsx(Ie,{className:"overflow-hidden",children:e.jsxs(Be,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`p-1.5 rounded-md ${w.color}`,children:e.jsx(w.icon,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:w.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:w.value})]})},w.label))}),o&&o.leads.length>0&&e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(Ft,{className:"text-base",children:"Recent Leads"})}),e.jsx(Be,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(w=>e.jsxs("div",{className:"flex items-center justify-between text-sm p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:w.name}),w.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:w.phone})]}),w.intent&&e.jsx(Ye,{variant:"secondary",className:"text-xs",children:w.intent})]},w.id))})]}),(!o||o.leads.length===0)&&e.jsx(Ie,{children:e.jsxs(Be,{className:"p-8 text-center",children:[e.jsx(Cm,{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(js,{value:"qrcode",className:"mt-4 space-y-4",children:e.jsx(Ie,{children:e.jsx(Be,{className:"p-6",children:e.jsx(kSs,{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 LSs(){const t=es(),[s,r]=k.useState(""),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,d]=k.useState(null),[u,p]=k.useState(!1),[f,y]=k.useState(!1),[_,b]=k.useState(null),[N,w]=k.useState(null),[S,C]=k.useState(0),{data:A,isLoading:I}=ft({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:J,error:Y}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(Y)throw Y;return J}}),L=Et({mutationFn:async J=>{const{data:Y,error:ce}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:J}});if(ce)throw ce;if(Y!=null&&Y.error)throw new Error(Y.error);return Y},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),me.success("BoldTrail connected successfully!")},onError:J=>{me.error(J.message||"Failed to connect BoldTrail")}}),O=Et({mutationFn:async()=>{const{data:J,error:Y}=await G.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(Y)throw Y;return J},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),me.success("BoldTrail disconnected")},onError:()=>me.error("Failed to disconnect")}),U=Et({mutationFn:async J=>{const{data:Y,error:ce}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:J}});if(ce)throw ce;if(Y!=null&&Y.error)throw new Error(Y.error);return Y},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),me.success("Sync direction saved")},onError:J=>{me.error(J.message||"Failed to save sync direction")}}),q=Et({mutationFn:async()=>{const{data:J,error:Y}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(Y)throw Y;if(J!=null&&J.error)throw new Error(J.error);return J},onSuccess:J=>{b(null),d(J),a(!0)},onError:J=>{me.error(J.message||"Failed to generate sync preview")}}),$=Et({mutationFn:async()=>{w("Initializing sync..."),C(5);const{data:J,error:Y}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:Z}});if(Y)throw Y;if(J!=null&&J.error)throw new Error(J.error);const ce=J;let ae=ce.sync_log_id,ie=ce.next_phase,le=ce.next_offset;const fe=ce.push_total||0,xe=ce.pull_total||0,he=fe+xe;let we=0,Ne=0;for(;ie!=="finalize";){ie==="push"?(w(`Pushing contacts to BoldTrail... (${we}/${fe})`),C(he>0?we/he*100:0)):ie==="pull"&&(w(`Pulling contacts from BoldTrail... (${Ne}/${xe})`),C(he>0?(fe+Ne)/he*100:0));const{data:Ae,error:ze}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:ie,offset:le,sync_log_id:ae,sync_direction:Z}});if(ze)throw ze;if(Ae!=null&&Ae.error)throw new Error(Ae.error);const Ee=Ae;we+=Ee.chunk_pushed||0,Ne+=Ee.chunk_pulled||0,Ee.progress&&w(Ee.progress),ie==="pull"&&xe>0?C(Math.min(95,Ne/xe*100)):ie==="push"&&fe>0&&C(Math.min(95,we/fe*100)),ie=Ee.next_phase,le=Ee.next_offset}w("Finalizing sync..."),C(95);const{data:Ve,error:Te}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:ae,sync_direction:Z}});if(Te)throw Te;return C(100),Ve},onSuccess:J=>{w(null),C(0),a(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["contacts"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),me.success(`Sync complete! Pushed ${J.contacts_pushed||0}, pulled ${J.contacts_pulled||0}, skipped ${J.contacts_skipped||0} duplicates.`)},onError:J=>{w(null),C(0),me.error(J.message||"Sync failed")}}),V=A==null?void 0:A.connected,ee=(A==null?void 0:A.sync_direction)||"bidirectional",Z=_??ee;return e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:e.jsx(td,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:["BoldTrail",V&&e.jsx(Ye,{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(tp,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(mr,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(Be,{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(si,{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(si,{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(si,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Syncs name, email, phone, address, notes, and lead source"})]}),V?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsx("div",{className:"rounded-lg border p-3 space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"BoldTrail Connected"}),(A==null?void 0:A.last_sync_at)&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sync: ",new Date(A.last_sync_at).toLocaleString(),A.last_sync_status&&e.jsx(Ye,{variant:A.last_sync_status==="success"?"default":"secondary",className:"ml-2 text-[10px]",children:A.last_sync_status})]}),(A==null?void 0:A.boldtrail_contact_count)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[A.boldtrail_contact_count," contacts in BoldTrail"]}),(A==null?void 0:A.last_sync_message)&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:A.last_sync_message})]}),e.jsxs(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Disconnect BoldTrail?"}),e.jsx(vl,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:()=>O.mutate(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsx(Pwe,{value:ee,onChange:J=>U.mutate(J)})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{onClick:()=>q.mutate(),disabled:q.isPending||$.isPending,variant:"outline",className:"gap-2",children:[q.isPending?e.jsx(to,{className:"h-4 w-4 animate-spin"}):e.jsx(jn,{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:J=>r(J.target.value),className:"flex-1"}),e.jsxs(K,{onClick:()=>L.mutate(s),disabled:!s||s.length<10||L.isPending,children:[L.isPending?e.jsx(to,{className:"h-4 w-4 animate-spin mr-2"}):null,"Connect"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Find your API token in BoldTrail → Lead Engine → Lead Dropbox → My API Tokens. Generate a ",e.jsx("strong",{children:"Contacts"})," scope token."]})]})]})})]}),e.jsx(fs,{open:n,onOpenChange:J=>{$.isPending||a(J)},children:e.jsxs(ms,{className:"sm:max-w-lg",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(td,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Rr,{children:"Review what will happen when you sync your contacts."})]}),i&&(()=>{const J=Z==="pull_only"?0:i.to_push,Y=Z==="push_only"?0:i.to_pull;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Pwe,{value:Z,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 ${Z==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:J}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(cu,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${Z==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:Y}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Ih,{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(cr,{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"]}),$.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(pi,{value:S||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:N||"Sync in progress..."})]}),J>0&&e.jsxs(uf,{open:u,onOpenChange:p,children:[e.jsx(hf,{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(cu,{className:"h-3 w-3 text-emerald-600"}),J," contacts to push to BoldTrail"]}),e.jsx(Fi,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(mf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.push_preview.map((ce,ae)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:ce.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:ce.email})]},ae)),i.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",i.to_push-20," more"]})]})})]}),Y>0&&e.jsxs(uf,{open:f,onOpenChange:y,children:[e.jsx(hf,{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(Ih,{className:"h-3 w-3 text-blue-600"}),Y," contacts to pull from BoldTrail"]}),e.jsx(Fi,{className:`h-3 w-3 transition-transform ${f?"rotate-180":""}`})]})}),e.jsx(mf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.pull_preview.map((ce,ae)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:ce.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:ce.email})]},ae)),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"]})]})})]}),J===0&&Y===0&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer."}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),disabled:$.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>$.mutate(),disabled:$.isPending||J===0&&Y===0,className:"gap-2",children:[$.isPending?e.jsx(to,{className:"h-4 w-4 animate-spin"}):e.jsx(td,{className:"h-4 w-4"}),$.isPending?"Syncing...":"Sync Now"]})]})]})})()]})}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ms,{className:"sm:max-w-2xl p-0 overflow-hidden",children:[e.jsx(ks,{className:"p-6 pb-0",children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(td,{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 nct(){const t=br(),[s,r]=k.useState(""),[n,a]=k.useState(""),[o,l]=k.useState("Test from ReLevelUp"),[i,d]=k.useState(!1),{data:u,isLoading:p}=ft({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}d(!0);try{const{data:{session:_}}=await G.auth.getSession();if(!_)throw new Error("Not authenticated");const N=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();N.success?me.success(`Test email sent! Message ID: ${N.messageId}`):me.error(N.error||"Failed to send test email")}catch(_){me.error(_.message||"Failed to send test email")}finally{d(!1)}},y=(u==null?void 0:u.configured)===!0;return e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-orange-500/10 flex items-center justify-center",children:e.jsx(tr,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-lg",children:"Amazon SES — Mass Email"}),e.jsx(mr,{children:"Send bulk email campaigns via Amazon SES"})]})]}),e.jsx(Ye,{variant:y?"default":"secondary",children:p?"Checking...":y?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(si,{className:"h-3 w-3"})," Connected"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(co,{className:"h-3 w-3"})," Not Configured"]})})]})}),y&&e.jsxs(Be,{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(ge,{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(ge,{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(ge,{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(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Send Test"]})]}),e.jsxs(K,{onClick:()=>t("/admin/email-campaigns"),className:"w-full",children:[e.jsx(dh,{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(Be,{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 DSs(){var b,N,w,S;const{user:t}=$s(),s=es(),[r,n]=k.useState(!1),[a,o]=k.useState(""),[l,i]=k.useState(""),{data:d}=ft({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:C,error:A}=await G.from("mass_email_settings").select("*").eq("user_id",t.id).maybeSingle();if(A)throw A;return C}}),{data:u}=ft({queryKey:["agent-profile-email",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:C,error:A}=await G.from("profiles").select("email, name").eq("id",t.id).single();if(A)throw A;return C}}),p=((b=d==null?void 0:d.reply_to_email)==null?void 0:b.trim())||((N=u==null?void 0:u.email)==null?void 0:N.trim())||"",f=((w=d==null?void 0:d.display_name)==null?void 0:w.trim())||((S=u==null?void 0:u.name)==null?void 0:S.trim())||"";k.useEffect(()=>{r||(o(p),i(f))},[r,p,f]);const y=Et({mutationFn:async()=>{if(!t||!a.trim())throw new Error("Please enter a reply-to email");const C={reply_to_email:a.trim(),display_name:l.trim()||null,updated_at:new Date().toISOString()};if(d){const{error:A}=await G.from("mass_email_settings").update(C).eq("user_id",t.id);if(A)throw A}else{const{error:A}=await G.from("mass_email_settings").insert({user_id:t.id,...C});if(A)throw A}},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:C=>me.error(C.message)}),_=!!p;return e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-orange-500/10 flex items-center justify-center",children:e.jsx(Nn,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:["Mass Email",_?e.jsxs(Ye,{variant:"default",className:"text-xs bg-green-600",children:[e.jsx(si,{className:"h-3 w-3 mr-1"})," Set Up"]}):e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"Setup Required"})]}),e.jsx(mr,{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(Be,{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(pa,{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(ge,{className:"text-xs",children:"Display Name"}),e.jsx(Fe,{placeholder:"e.g. 🏡 Karen Hall",value:l,onChange:C=>i(C.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How your name appears in the recipient's inbox"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{className:"text-xs",children:"Reply-To Email *"}),e.jsx(Fe,{type:"email",placeholder:"your@email.com",value:a,onChange:C=>o(C.target.value)})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{size:"sm",onClick:()=>y.mutate(),disabled:y.isPending||!a.trim(),children:[e.jsx(wc,{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(Sr,{className:"h-4 w-4 mr-1"})," Cancel"]})]})]})})]})}function RSs(){const{isAdmin:t}=$s(),s=es(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),{data:d,isLoading:u}=ft({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}=ft({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:I}}=await G.auth.getUser();if(!I)return[];const{data:L,error:O}=await G.from("social_accounts").select("*").eq("user_id",I.id).order("created_at",{ascending:!1});if(O)throw O;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=Et({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")}}),N=Et({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")}}),w=!!(d!=null&&d.is_active),S=(p==null?void 0:p.filter(I=>I.platform==="facebook"))||[],C=(p==null?void 0:p.filter(I=>I.platform==="instagram"))||[],A=(p==null?void 0:p.filter(I=>I.platform==="linkedin"))||[];return e.jsx(Ls,{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(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-destructive/10 flex items-center justify-center",children:e.jsx(tr,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:["Gmail",w&&e.jsx(Ye,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(mr,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(Be,{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(si,{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(si,{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(si,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),w?e.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:d.gmail_email}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Gmail account"})]}),e.jsxs(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Disconnect Gmail?"}),e.jsx(vl,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:()=>b.mutate(d.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:f,disabled:r||u,children:[r?e.jsx(to,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(ti,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Ie,{className:t?"":"opacity-70",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(du,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:["Facebook",t?S.length>0?e.jsx(Ye,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(yd,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(mr,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(Be,{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(vn,{className:"h-8 w-8",children:[e.jsx(Ca,{src:I.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(du,{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(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Disconnect Facebook?"}),e.jsx(vl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:()=>N.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(to,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),e.jsxs(Ie,{className:t?"":"opacity-70",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-pink-500/10 flex items-center justify-center",children:e.jsx(hu,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:["Instagram",t?C.length>0?e.jsx(Ye,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(yd,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(mr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(Be,{className:"space-y-3",children:[C.length>0&&e.jsx("div",{className:"space-y-2",children:C.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ca,{src:I.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(hu,{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(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Disconnect Instagram?"}),e.jsx(vl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:()=>N.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(to,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{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(Ie,{className:t?"":"opacity-70",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-700/10 flex items-center justify-center",children:e.jsx(fp,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?A.length>0?e.jsx(Ye,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(yd,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(mr,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(Be,{className:"space-y-3",children:[A.length>0&&e.jsx("div",{className:"space-y-2",children:A.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ca,{src:I.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(fp,{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(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Disconnect LinkedIn?"}),e.jsx(vl,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:()=>N.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(to,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(LSs,{}),e.jsx(DSs,{}),t&&e.jsx(nct,{})]})})}function OSs(){const[t]=Sc(),s=br(),[r,n]=k.useState("loading"),[a,o]=k.useState("Connecting your Gmail account...");return k.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||d));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(Ie,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(ps,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(si,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Ql,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ft,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(mr,{children:a})]}),e.jsx(Be,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function FSs(){const t=br();return k.useEffect(()=>{const s=setTimeout(()=>{t("/mission-control/integrations",{replace:!0})},1500);return()=>clearTimeout(s)},[t]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Finishing Canva connection…"})]})})}function zSs(){const[t]=Sc(),s=br(),[r,n]=k.useState("loading"),[a,o]=k.useState("Processing your connection...");return k.useEffect(()=>{(async()=>{var f;const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||d));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(Ie,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(ps,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(si,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Ql,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ft,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(mr,{children:a})]}),e.jsx(Be,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const act=new Date().getFullYear(),BSs=Array.from({length:5},(t,s)=>act-s);function $Ss(){const[t,s]=k.useState(act),r=br(),{data:n,isLoading:a}=EDt();return a?e.jsx(Ls,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ss,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(Ss,{className:"h-24"},o))}),e.jsx(Ss,{className:"h-96"})]})}):e.jsx(Ls,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Scorecard Admin"}),e.jsx("p",{className:"text-muted-foreground",children:"View agent performance and scorecards"})]}),e.jsxs(zs,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(Os,{className:"w-[120px]",children:e.jsx(qs,{})}),e.jsx(Fs,{children:BSs.map(o=>e.jsx(yt,{value:String(o),children:o},o))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(cr,{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(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(so,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total 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(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Agents with Scorecards"}),e.jsx(mr,{children:"Click to view individual agent scorecards"})]}),e.jsx(Be,{children:!n||n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(so,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Agent"}),e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:n.map(o=>e.jsxs(As,{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(jn,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const ict=new Date().getFullYear(),qSs=Array.from({length:10},(t,s)=>ict-s);function N9e(){var b;const{userId:t}=ho(),s=br(),n=Fl().pathname.startsWith("/mission-control"),[a,o]=k.useState(ict),{data:l,isLoading:i}=ft({queryKey:["agent-profile",t],queryFn:async()=>{const{data:N,error:w}=await G.from("profiles").select("id, name, email").eq("id",t).single();if(w)throw w;return N},enabled:!!t}),{data:d,isLoading:u}=yke(a,t),{yearStats:p,lifetimeStats:f,showCommission:y}=QXe(a,t),{data:_}=XXe(a,t);return i?e.jsx(Ls,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ss,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(N=>e.jsx(Ss,{className:"h-24"},N))})]})}):e.jsx(Ls,{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(Ra,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:l==null?void 0:l.name}),e.jsx("p",{className:"text-muted-foreground",children:l==null?void 0:l.email})]})]}),e.jsxs(zs,{value:String(a),onValueChange:N=>o(Number(N)),children:[e.jsx(Os,{className:"w-[120px]",children:e.jsx(qs,{})}),e.jsx(Fs,{children:qSs.map(N=>e.jsx(yt,{value:String(N),children:N},N))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Mn,{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(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(cr,{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(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(_c,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:El(p.totalVolume,!0)})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Yo,{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:El(p.averagePrice,!0)})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((b=p.topLeadSource)==null?void 0:b.name)||"-"})]})})]}),_&&e.jsx(Nit,{goals:_,stats:p,year:a,showCommission:y}),e.jsxs(ta,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"transactions",children:"Transactions"}),e.jsx(ls,{value:"charts",children:"Charts"}),e.jsxs(ls,{value:"map",children:[e.jsx(La,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(js,{value:"transactions",children:e.jsx(eCe,{transactions:d||[],showCommission:y,isLoading:u})}),e.jsx(js,{value:"charts",children:e.jsx(tCe,{stats:p,year:a})}),e.jsx(js,{value:"map",children:e.jsx(sCe,{transactions:d||[],isLoading:u})})]})]})})}function USs(){const t=es(),[s,r]=k.useState(""),[n,a]=k.useState("all");hYe();const{data:o,refetch:l}=ft({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:I}=await G.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(I==null?void 0:I.enabled)??!1}}),{data:i,isLoading:d}=ft({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}=ft({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:O}=await G.from("listing_views").select("id");return{total:(I==null?void 0:I.length)||0,pending:(I==null?void 0:I.filter(U=>!U.is_approved).length)||0,active:(I==null?void 0:I.filter(U=>U.status==="active").length)||0,totalShares:(L==null?void 0:L.length)||0,totalViews:(O==null?void 0:O.length)||0}}}),p=async(I,L,O="submit_url")=>{try{const{data:{session:U}}=await G.auth.getSession();if(!U)return;const{data:q,error:$}=await G.functions.invoke("google-indexing",{body:{action:O,listing_id:I,listing_slug:L}});if($)throw $;if((q==null?void 0:q.configured)===!1)return;q!=null&&q.success&&me.success("Submitted to Google for indexing")}catch(U){console.error("Google indexing submission failed:",U)}},f=Et({mutationFn:async()=>{const{data:{session:I}}=await G.auth.getSession();if(!I)throw new Error("Not authenticated");const{data:L,error:O}=await G.functions.invoke("google-indexing",{body:{action:"submit_all"}});if(O)throw O;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=Et({mutationFn:async({id:I,approved:L,slug:O})=>{const{error:U}=await G.from("listings").update({is_approved:L}).eq("id",I);if(U)throw U;return{id:I,approved:L,slug:O}},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")}}),_=Et({mutationFn:async({id:I,featured:L})=>{const{error:O}=await G.from("listings").update({is_featured:L}).eq("id",I);if(O)throw O},onSuccess:(I,{featured:L})=>{t.invalidateQueries({queryKey:["admin-listings"]}),me.success(L?"Listing featured":"Listing unfeatured")}}),b=Et({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")}}),N=Et({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")}}),w=o??!1,S=i==null?void 0:i.filter(I=>{var U,q,$,V;const L=((U=I.city)==null?void 0:U.toLowerCase().includes(s.toLowerCase()))||(($=(q=I.agent)==null?void 0:q.name)==null?void 0:$.toLowerCase().includes(s.toLowerCase()))||((V=I.property_address)==null?void 0:V.toLowerCase().includes(s.toLowerCase())),O=n==="all"||n==="pending"&&!I.is_approved||n==="approved"&&I.is_approved;return L&&O}),C=I=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I),A=I=>{const L={active:"bg-green-500/10 text-green-600 border-green-200",coming_soon:"bg-blue-500/10 text-blue-600 border-blue-200",price_improvement:"bg-amber-500/10 text-amber-600 border-amber-200",under_contract:"bg-purple-500/10 text-purple-600 border-purple-200",sold:"bg-gray-500/10 text-gray-600 border-gray-200"};return L[I]||L.active};return e.jsx(Ls,{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(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(gd,{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(Lr,{checked:w,onCheckedChange:I=>N.mutate(I)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ma,{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(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yo,{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(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cr,{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(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(jn,{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(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vd,{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(Ie,{children:e.jsx(Be,{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(tn,{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(ta,{value:n,onValueChange:I=>a(I),children:e.jsxs(Qn,{children:[e.jsx(ls,{value:"all",children:"All"}),e.jsx(ls,{value:"pending",children:"Pending"}),e.jsx(ls,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{children:["Listings (",(S==null?void 0:S.length)||0,")"]})}),e.jsx(Be,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Property"}),e.jsx(Nt,{children:"Agent"}),e.jsx(Nt,{children:"Price"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-center",children:"Approved"}),e.jsx(Nt,{className:"text-center",children:"Featured"}),e.jsx(Nt,{children:"Views"}),e.jsx(Nt,{children:"Shares"}),e.jsx(Nt,{children:"Date"}),e.jsx(Nt,{})]})}),e.jsx(Pn,{children:d?e.jsx(As,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(S==null?void 0:S.length)===0?e.jsx(As,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):S==null?void 0:S.map(I=>{var L,O,U,q,$;return e.jsxs(As,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(O=(L=I.photos)==null?void 0:L[0])!=null&&O.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(ma,{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:(U=I.property_type)==null?void 0:U.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:C(I.price)}),e.jsx(dt,{children:e.jsx(Ye,{variant:"outline",className:A(I.status),children:($=I.status)==null?void 0:$.replace("_"," ")})}),e.jsx(dt,{className:"text-center",children:e.jsx(Lr,{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(Lr,{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:gs(new Date(I.created_at),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(dx,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",children:[e.jsxs(xa,{onClick:()=>window.open(`/mission-control/listings/${I.id}`,"_blank"),children:[e.jsx(jn,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(xa,{onClick:()=>_.mutate({id:I.id,featured:!I.is_featured}),children:[e.jsx(Gn,{className:"h-4 w-4 mr-2"}),I.is_featured?"Unfeature":"Feature"]}),e.jsxs(xa,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&b.mutate(I.id)},children:[e.jsx(Sr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},I.id)})})]})})})]})]})})}const VSs=()=>{var f,y;const[t,s]=k.useState(""),[r,n]=k.useState(null),{data:a,isLoading:o}=ft({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 N=(_==null?void 0:_.map(C=>C.user_id))||[],{data:w}=await G.from("profiles").select("id, name, email").in("id",N);return _==null?void 0:_.map(C=>({...C,profiles:(w==null?void 0:w.find(A=>A.id===C.user_id))||null}))}}),l=a==null?void 0:a.filter(_=>{var N,w,S,C,A;const b=t.toLowerCase();return((w=(N=_.profiles)==null?void 0:N.name)==null?void 0:w.toLowerCase().includes(b))||((C=(S=_.profiles)==null?void 0:S.email)==null?void 0:C.toLowerCase().includes(b))||((A=_.review_text)==null?void 0:A.toLowerCase().includes(b))}),i=a!=null&&a.length?(a.reduce((_,b)=>_+b.rating,0)/a.length).toFixed(1):"0.0",d=a==null?void 0:a.reduce((_,b)=>(_[b.rating]=(_[b.rating]||0)+1,_),{}),u=(a==null?void 0:a.filter(_=>_.posted_to_google).length)||0,p=_=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(b=>e.jsx(Gn,{className:Rt("h-4 w-4",_>=b?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},b))});return e.jsx(Ls,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{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(Ie,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(mr,{children:"Total Reviews"}),e.jsx(Ft,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Ie,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(mr,{children:"Average Rating"}),e.jsxs(Ft,{className:"flex items-center gap-2 text-3xl",children:[i,e.jsx(Gn,{className:"h-6 w-6 fill-yellow-400 text-yellow-400"})]})]})}),e.jsx(Ie,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(mr,{children:"5-Star Reviews"}),e.jsx(Ft,{className:"text-3xl",children:(d==null?void 0:d[5])||0})]})}),e.jsx(Ie,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(mr,{children:"Posted to Google"}),e.jsxs(Ft,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(Kr,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(tn,{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(Ie,{children:e.jsx(Be,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Member"}),e.jsx(Nt,{children:"Rating"}),e.jsx(Nt,{className:"hidden md:table-cell",children:"Review"}),e.jsx(Nt,{children:"Google"}),e.jsx(Nt,{children:"Date"})]})}),e.jsx(Pn,{children:o?e.jsx(As,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(As,{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,N;return e.jsxs(As,{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:(N=_.profiles)==null?void 0:N.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(Ye,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(Ye,{variant:"outline",children:"No"})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:gs(new Date(_.created_at),"MMM d, yyyy")})]},_.id)})})]})})}),e.jsx(fs,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Review Details"})}),r&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-4 p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:((f=r.profiles)==null?void 0:f.name)||"Unknown Member"}),((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(tr,{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(nn,{className:"h-4 w-4"}),gs(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(Ye,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(Kr,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(Ye,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},HSs=[{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"}],GSs=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 WSs(){const t=es(),{user:s}=$s(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),{data:d,isLoading:u}=ft({queryKey:["weekly-digest-settings"],queryFn:async()=>{const{data:q,error:$}=await G.from("weekly_digest_settings").select("*").single();if($)throw $;return q}}),{data:p,isLoading:f}=ft({queryKey:["weekly-digest-logs"],queryFn:async()=>{const{data:q,error:$}=await G.from("weekly_digest_logs").select("*").order("sent_at",{ascending:!1}).limit(100);if($)throw $;return q}}),{data:y}=ft({queryKey:["digest-subscriber-count"],queryFn:async()=>{const{count:q,error:$}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("digest_opt_out",!1).not("email","is",null);if($)throw $;return q||0}}),{data:_,refetch:b}=ft({queryKey:["digest-queue-status"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const[$,V,ee,Z]=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:$.count||0,processing:V.count||0,sent:ee.count||0,failed:Z.count||0,total:($.count||0)+(V.count||0)+(ee.count||0)+(Z.count||0)}},refetchInterval:5e3});k.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:N=0}=ft({queryKey:["digest-today-failed-count"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const{count:$,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 $||0}}),w=Et({mutationFn:async q=>{const{error:$}=await G.from("weekly_digest_settings").update(q).eq("id",d==null?void 0:d.id);if($)throw $},onSuccess:()=>{t.invalidateQueries({queryKey:["weekly-digest-settings"]}),me.success("Settings updated")},onError:q=>{me.error("Failed to update settings: "+q.message)}}),S=async()=>{n(!0);try{const{data:q,error:$}=await G.functions.invoke("send-weekly-digest",{body:{manual:!0}});if($)throw $;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)}},C=async()=>{var q,$,V,ee,Z,J;if(!(s!=null&&s.email)){me.error("No email found for your account");return}o(!0);try{const{data:Y,error:ce}=await G.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(ce)throw ce;const ae=Y==null?void 0:Y.resendId,ie=Y==null?void 0:Y.resendDetails,le=ie==null?void 0:ie.status,fe=((q=ie==null?void 0:ie.body)==null?void 0:q.status)||((V=($=ie==null?void 0:ie.body)==null?void 0:$.data)==null?void 0:V.status),xe=((Z=(ee=ie==null?void 0:ie.body)==null?void 0:ee.error)==null?void 0:Z.message)||((J=ie==null?void 0:ie.body)==null?void 0:J.message);me.success(ae?`Preview accepted by email provider (id: ${ae})${le?`, status check: ${le}`:""}${fe?`, provider: ${fe}`:""}${xe?` (${xe})`:""}. Check spam/promotions—delivery can take a few minutes.`:"Preview accepted by email provider. Check spam/promotions—delivery can take a few minutes.")}catch(Y){me.error("Failed to send preview: "+Y.message)}finally{o(!1)}},A=async()=>{i(!0);try{const{data:q,error:$}=await G.functions.invoke("send-weekly-digest",{body:{retryFailed:!0}});if($)throw $;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:O}=ft({queryKey:["digest-delivery-stats"],queryFn:async()=>{var J,Y;const q=new Date;q.setUTCHours(0,0,0,0);const[$,V,ee,Z]=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:$.count||0,totalFailed:V.count||0,agentOsEngaged:ee.count||0,lastSent:((Y=(J=Z.data)==null?void 0:J[0])==null?void 0:Y.sent_at)||null}},refetchInterval:L?5e3:!1}),U={totalSent:(O==null?void 0:O.totalSent)||0,totalFailed:(O==null?void 0:O.totalFailed)||0,lastSent:O==null?void 0:O.lastSent,agentOsEngaged:(O==null?void 0:O.agentOsEngaged)||0};return u?e.jsx(Ls,{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(Ls,{title:"Weekly Digest",description:"Configure and manage automated weekly email digests for members",children:e.jsxs(ta,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(Qn,{children:[e.jsxs(ls,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(So,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(ls,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(js,{value:"settings",className:"space-y-6",children:[L&&_&&e.jsx(Ie,{className:"border-primary/50 bg-primary/5",children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(ps,{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(pi,{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(Ie,{children:e.jsx(Be,{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(cr,{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(Ie,{children:e.jsx(Be,{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(Hn,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:U.totalSent}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Delivered"})]})]})})}),e.jsx(Ie,{children:e.jsx(Be,{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(Ql,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:U.totalFailed}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed"})]})]})})}),e.jsx(Ie,{children:e.jsx(Be,{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(rn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:U.lastSent?gs(new Date(U.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(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(rn,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(mr,{children:"Configure when the digest is sent"})]}),e.jsxs(Be,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Enable Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Send automated weekly emails to members"})]}),e.jsx(Lr,{checked:d==null?void 0:d.is_enabled,onCheckedChange:q=>w.mutate({is_enabled:q})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Cron Frequency"}),e.jsxs(zs,{value:(d==null?void 0:d.cron_frequency)||"daily",onValueChange:q=>w.mutate({cron_frequency:q}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"daily",children:"Daily (runs once at selected time)"}),e.jsx(yt,{value:"hourly",children:"Hourly (checks every hour)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(d==null?void 0:d.cron_frequency)==="hourly"?"Cron runs every hour; digest sends when day & hour match.":"Cron runs once daily at the selected hour (UTC)."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Day of Week"}),e.jsxs(zs,{value:String(d==null?void 0:d.send_day),onValueChange:q=>w.mutate({send_day:parseInt(q)}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:HSs.map(q=>e.jsx(yt,{value:q.value,children:q.label},q.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Time (UTC)"}),e.jsxs(zs,{value:String(d==null?void 0:d.send_hour),onValueChange:q=>w.mutate({send_hour:parseInt(q)}),disabled:(d==null?void 0:d.cron_frequency)==="daily",children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:GSs.map(q=>e.jsx(yt,{value:q.value,children:q.label},q.value))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{onClick:C,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(jn,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(K,{onClick:S,disabled:r,className:"flex-1",children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),N>0&&e.jsxs(K,{onClick:A,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(to,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${N} Failed`]})]})]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(mn,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(mr,{children:"Choose what to include in the digest"})]}),e.jsxs(Be,{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(mn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ge,{children:"New Resources"})]}),e.jsx(Lr,{checked:d==null?void 0:d.include_new_resources,onCheckedChange:q=>w.mutate({include_new_resources:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ge,{children:"Community Highlights"})]}),e.jsx(Lr,{checked:d==null?void 0:d.include_community_posts,onCheckedChange:q=>w.mutate({include_community_posts:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ge,{children:"Agent OS Stats"})]}),e.jsx(Lr,{checked:d==null?void 0:d.include_agent_os_stats,onCheckedChange:q=>w.mutate({include_agent_os_stats:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ge,{children:"Upcoming Events"})]}),e.jsx(Lr,{checked:d==null?void 0:d.include_upcoming_events,onCheckedChange:q=>w.mutate({include_upcoming_events:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oh,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ge,{children:"Goals Progress"})]}),e.jsx(Lr,{checked:d==null?void 0:d.include_goals_progress,onCheckedChange:q=>w.mutate({include_goals_progress:q})})]})]})]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Custom Introduction"}),e.jsx(mr,{children:"Personalize the intro message (optional)"})]}),e.jsx(Be,{children:e.jsx(_r,{placeholder:"Here's what's new this week to help you grow your business...",value:(d==null?void 0:d.custom_intro_text)||"",onChange:q=>w.mutate({custom_intro_text:q.target.value||null}),rows:3})})]})]}),e.jsx(js,{value:"stats",children:e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(mr,{children:"Recent digest emails sent to members"})]}),e.jsx(Be,{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(As,{children:[e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{children:"Sent At"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{children:"Resources"}),e.jsx(Nt,{children:"Agent OS"})]})}),e.jsx(Pn,{children:p.map(q=>e.jsxs(As,{children:[e.jsx(dt,{className:"font-medium",children:q.email_sent_to}),e.jsx(dt,{children:gs(new Date(q.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{children:e.jsx(Ye,{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(Ye,{variant:"secondary",children:"Active"}):e.jsx(Ye,{variant:"outline",children:"Not Started"})})]},q.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(tr,{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 KSs={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 ZSs(){var we,Ne,Ve;const t=es(),[s,r]=k.useState(""),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(!0),[N,w]=k.useState(!1),[S,C]=k.useState(""),[A,I]=k.useState(null),{data:L,isLoading:O}=ft({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:Te,error:Ae}=await G.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Ae)throw Ae;const ze=(Te==null?void 0:Te.map(Re=>Re.user_id))||[],{data:Ee}=await G.from("profiles").select("id, name, email").in("id",ze),ve=new Map((Ee==null?void 0:Ee.map(Re=>[Re.id,{name:Re.name,email:Re.email}]))||[]);return Te==null?void 0:Te.map(Re=>({...Re,profile:ve.get(Re.user_id)||null}))}}),{data:U}=ft({queryKey:["all-profiles-for-points",L],queryFn:async()=>{const Ae=[];let ze=0;for(;;){const{data:Ee,error:ve}=await G.from("profiles").select("id, name, email").order("name").range(ze,ze+1e3-1);if(ve)throw ve;if(Ae.push(...Ee),!Ee||Ee.length<1e3)break;ze+=1e3}return Ae}}),$=((U==null?void 0:U.filter(Te=>!(L!=null&&L.some(Ae=>Ae.user_id===Te.id))))||[]).filter(Te=>{var ze,Ee;if(!S)return!0;const Ae=S.toLowerCase();return((ze=Te.name)==null?void 0:ze.toLowerCase().includes(Ae))||((Ee=Te.email)==null?void 0:Ee.toLowerCase().includes(Ae))}),{data:V,isLoading:ee}=ft({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Te,error:Ae}=await G.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Ae)throw Ae;return Te},enabled:!!(n!=null&&n.user_id)&&i}),{data:Z}=ft({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Te,error:Ae}=await G.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Ae)throw Ae;return Te},enabled:!!(n!=null&&n.user_id)}),J=Et({mutationFn:async({userId:Te,points:Ae,reason:ze})=>{const{error:Ee}=await G.from("agent_points").insert({user_id:Te,points:Ae,reason:ze});if(Ee)throw Ee;const{data:ve}=await G.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",Te).maybeSingle(),Re=((ve==null?void 0:ve.total_points)||0)+Ae,Ue=((ve==null?void 0:ve.spendable_points)||0)+Ae,{error:ye}=await G.from("agent_attendance_stats").upsert({user_id:Te,total_points:Math.max(0,Re),spendable_points:Math.max(0,Ue),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(ye)throw ye},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:Te=>{console.error("Error modifying points:",Te),me.error("Failed to modify points")}}),Y=()=>{if(!n||!u||!f){me.error("Please fill in all fields");return}const Te=parseInt(u);if(isNaN(Te)||Te<=0){me.error("Please enter a valid positive number");return}J.mutate({userId:n.user_id,points:_?Te:-Te,reason:f})},ce=()=>{if(!A||!u||!f){me.error("Please fill in all fields");return}const Te=parseInt(u);if(isNaN(Te)||Te<=0){me.error("Please enter a valid positive number");return}J.mutate({userId:A.id,points:Te,reason:f},{onSuccess:()=>{w(!1),I(null),C("")}})},ae=(Te,Ae)=>{a(Te),b(Ae),l(!0)},ie=Te=>{a(Te),d(!0)},le=L==null?void 0:L.filter(Te=>{var ve,Re,Ue,ye;const Ae=((Re=(ve=Te.profile)==null?void 0:ve.name)==null?void 0:Re.toLowerCase())||"",ze=((ye=(Ue=Te.profile)==null?void 0:Ue.email)==null?void 0:ye.toLowerCase())||"",Ee=s.toLowerCase();return Ae.includes(Ee)||ze.includes(Ee)}),fe=(L==null?void 0:L.reduce((Te,Ae)=>Te+Ae.total_points,0))||0,xe=(L==null?void 0:L.length)||0,he=xe>0?Math.round(fe/xe):0;return O?e.jsx(Ls,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ss,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(Te=>e.jsx(Ss,{className:"h-24"},Te))}),e.jsx(Ss,{className:"h-96"})]})}):e.jsx(Ls,{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(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(cr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:xe}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Hi,{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:fe.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Yo,{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:he}),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(tn,{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:Te=>r(Te.target.value),className:"pl-10"})]}),e.jsxs(K,{onClick:()=>w(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Agent Leaderboard"}),e.jsx(mr,{children:"All agents with their points, events, and streaks"})]}),e.jsx(Be,{children:!le||le.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Hi,{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(As,{children:[e.jsx(Nt,{className:"w-12",children:"#"}),e.jsx(Nt,{children:"Agent"}),e.jsx(Nt,{className:"text-center",children:"Total Points"}),e.jsx(Nt,{className:"text-center",children:"Spendable"}),e.jsx(Nt,{className:"text-center",children:"Events"}),e.jsx(Nt,{className:"text-center",children:"Streak"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:le.map((Te,Ae)=>{var ze,Ee,ve,Re;return e.jsxs(As,{children:[e.jsx(dt,{className:"font-medium",children:Ae<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Ae===0?"bg-yellow-100 text-yellow-700":Ae===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Ae+1}):e.jsx("span",{className:"text-muted-foreground",children:Ae+1})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(vn,{className:"h-8 w-8",children:e.jsx(_n,{children:((Ee=(ze=Te.profile)==null?void 0:ze.name)==null?void 0:Ee.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((ve=Te.profile)==null?void 0:ve.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(Re=Te.profile)==null?void 0:Re.email})]})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(Ye,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Te.total_points]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(Ye,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(Vi,{className:"h-3 w-3 mr-1"}),Te.spendable_points||0]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3 text-muted-foreground"}),Te.total_events_attended]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(ch,{className:"h-3 w-3 text-orange-500"}),Te.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:()=>ae(Te,!0),title:"Award points",children:e.jsx(Bs,{className:"h-4 w-4 text-green-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ae(Te,!1),title:"Deduct points",children:e.jsx(Xy,{className:"h-4 w-4 text-red-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie(Te),title:"View history",children:e.jsx(AM,{className:"h-4 w-4"})})]})})]},Te.user_id)})})]})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:_?"Award Points":"Deduct Points"}),e.jsxs(Rr,{children:[_?"Award":"Deduct"," points ",_?"to":"from"," ",((we=n==null?void 0:n.profile)==null?void 0:we.name)||"this agent"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"points",children:"Points Amount"}),e.jsx(Fe,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Te=>p(Te.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"reason",children:"Reason"}),e.jsx(_r,{id:"reason",placeholder:"Enter reason for this adjustment...",value:f,onChange:Te=>y(Te.target.value)})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:Y,disabled:J.isPending,className:_?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:J.isPending?"Saving...":_?"Award Points":"Deduct Points"})]})]})}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ms,{className:"max-w-2xl",children:[e.jsxs(ks,{children:[e.jsxs(bs,{children:["Point History: ",(Ne=n==null?void 0:n.profile)==null?void 0:Ne.name]}),e.jsx(Rr,{children:"View all point transactions and badges for this agent"})]}),e.jsxs(ta,{defaultValue:"history",className:"w-full",children:[e.jsxs(Qn,{className:"grid w-full grid-cols-2",children:[e.jsx(ls,{value:"history",children:"Point History"}),e.jsx(ls,{value:"badges",children:"Badges"})]}),e.jsx(js,{value:"history",className:"mt-4",children:ee?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(Te=>e.jsx(Ss,{className:"h-12"},Te))}):!V||V.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(AM,{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(Te=>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:Te.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:gs(new Date(Te.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(Ye,{variant:Te.points>=0?"default":"destructive",className:Te.points>=0?"bg-green-100 text-green-800":"",children:[Te.points>=0?"+":"",Te.points]})]},Te.id))})}),e.jsx(js,{value:"badges",className:"mt-4",children:!Z||Z.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(rc,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No badges earned yet"})]}):e.jsx("div",{className:"grid grid-cols-2 gap-3",children:Z.map(Te=>e.jsxs("div",{className:`p-3 rounded-lg ${KSs[Te.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rc,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:Te.badge_name})]}),Te.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:Te.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",gs(new Date(Te.earned_at),"MMM d, yyyy")]})]},Te.id))})})]})]})}),e.jsx(fs,{open:N,onOpenChange:Te=>{w(Te),Te||(I(null),C(""),p(""),y(""))},children:e.jsxs(ms,{className:"max-w-md",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Award Points to New Agent"}),e.jsx(Rr,{children:"Select an agent who doesn't have points yet and award them points"})]}),e.jsx("div",{className:"space-y-4 py-4",children:A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(vn,{className:"h-10 w-10",children:e.jsx(_n,{children:((Ve=A.name)==null?void 0:Ve.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:A.name||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:A.email})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>I(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(Fe,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Te=>p(Te.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"new-reason",children:"Reason"}),e.jsx(_r,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:f,onChange:Te=>y(Te.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(tn,{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:S,onChange:Te=>C(Te.target.value),className:"pl-10"})]})]}),e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg",children:$.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(cr,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:S?"No matching agents found":"All agents already have points"})]}):$.slice(0,20).map(Te=>{var Ae;return e.jsxs("button",{onClick:()=>I(Te),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(vn,{className:"h-8 w-8",children:e.jsx(_n,{children:((Ae=Te.name)==null?void 0:Ae.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:Te.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Te.email})]})]},Te.id)})})]})}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),A&&e.jsxs(K,{onClick:ce,disabled:J.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function YSs(){const{data:t,isLoading:s}=T4t(),[r,n]=k.useState(null),[a,o]=k.useState(!1),[l,i]=k.useState(""),[d,u]=k.useState("all"),[p,f]=k.useState("newest"),[y,_]=k.useState("table"),b=k.useMemo(()=>(t==null?void 0:t.map(A=>A.user_id))||[],[t]),N=k.useMemo(()=>(t==null?void 0:t.map(A=>A.id))||[],[t]),{data:w}=ft({queryKey:["card-profiles-lookup",b],queryFn:async()=>{if(b.length===0)return{};const{data:A}=await G.from("profiles").select("id, name, email").in("id",b),I={};return A==null||A.forEach(L=>{I[L.id]={name:L.name||"",email:L.email||""}}),I},enabled:b.length>0}),{data:S}=ft({queryKey:["card-stats-all",N],queryFn:async()=>{if(N.length===0)return{};const A={};N.forEach(O=>{A[O]={views:0,leads:0}});const{data:I}=await G.from("agent_card_interactions").select("card_id").in("card_id",N).eq("interaction_type","card_view");I==null||I.forEach(O=>{A[O.card_id]&&A[O.card_id].views++});const{data:L}=await G.from("agent_card_leads").select("card_id").in("card_id",N);return L==null||L.forEach(O=>{A[O.card_id]&&A[O.card_id].leads++}),A},enabled:N.length>0}),C=k.useMemo(()=>{if(!t)return[];let A=[...t];if(d==="live"?A=A.filter(I=>I.is_published):d==="draft"&&(A=A.filter(I=>!I.is_published)),l.trim()){const I=l.toLowerCase();A=A.filter(L=>{var U,q;const O=w==null?void 0:w[L.user_id];return L.slug.toLowerCase().includes(I)||((U=O==null?void 0:O.name)==null?void 0:U.toLowerCase().includes(I))||((q=O==null?void 0:O.email)==null?void 0:q.toLowerCase().includes(I))})}return p==="newest"?A.sort((I,L)=>new Date(L.created_at).getTime()-new Date(I.created_at).getTime()):p==="oldest"?A.sort((I,L)=>new Date(I.created_at).getTime()-new Date(L.created_at).getTime()):p==="name"?A.sort((I,L)=>{var O,U;return(((O=w==null?void 0:w[I.user_id])==null?void 0:O.name)||"").localeCompare(((U=w==null?void 0:w[L.user_id])==null?void 0:U.name)||"")}):p==="slug"?A.sort((I,L)=>I.slug.localeCompare(L.slug)):p==="views_desc"?A.sort((I,L)=>{var O,U;return(((O=S==null?void 0:S[L.id])==null?void 0:O.views)||0)-(((U=S==null?void 0:S[I.id])==null?void 0:U.views)||0)}):p==="views_asc"?A.sort((I,L)=>{var O,U;return(((O=S==null?void 0:S[I.id])==null?void 0:O.views)||0)-(((U=S==null?void 0:S[L.id])==null?void 0:U.views)||0)}):p==="leads_desc"?A.sort((I,L)=>{var O,U;return(((O=S==null?void 0:S[L.id])==null?void 0:O.leads)||0)-(((U=S==null?void 0:S[I.id])==null?void 0:U.leads)||0)}):p==="leads_asc"&&A.sort((I,L)=>{var O,U;return(((O=S==null?void 0:S[I.id])==null?void 0:O.leads)||0)-(((U=S==null?void 0:S[L.id])==null?void 0:U.leads)||0)}),A},[t,d,l,p,w]);return e.jsxs(Ls,{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(Bs,{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(tn,{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:A=>i(A.target.value),className:"pl-9"})]}),e.jsxs(zs,{value:d,onValueChange:u,children:[e.jsx(Os,{className:"w-full sm:w-36",children:e.jsx(qs,{placeholder:"Status"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Status"}),e.jsx(yt,{value:"live",children:"Live"}),e.jsx(yt,{value:"draft",children:"Draft"})]})]}),e.jsxs(zs,{value:p,onValueChange:f,children:[e.jsx(Os,{className:"w-full sm:w-44",children:e.jsx(qs,{placeholder:"Sort by"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"newest",children:"Newest First"}),e.jsx(yt,{value:"oldest",children:"Oldest First"}),e.jsx(yt,{value:"name",children:"Name A–Z"}),e.jsx(yt,{value:"slug",children:"Slug A–Z"}),e.jsx(yt,{value:"views_desc",children:"Most Views"}),e.jsx(yt,{value:"views_asc",children:"Fewest Views"}),e.jsx(yt,{value:"leads_desc",children:"Most Leads"}),e.jsx(yt,{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(FM,{className:"h-4 w-4"})}),e.jsx(K,{variant:y==="grid"?"default":"ghost",size:"sm",onClick:()=>_("grid"),className:"rounded-l-none",children:e.jsx(pp,{className:"h-4 w-4"})})]})]}),!s&&t&&t.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",C.length," of ",t.length," cards"]}),s?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(A=>e.jsx(Ss,{className:"h-48"},A))}):C.length>0?y==="table"?e.jsx(XSs,{cards:C,cardProfiles:w,cardStats:S,onEdit:n,sortBy:p,setSortBy:f}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:C.map(A=>e.jsx(QSs,{card:A,onEdit:()=>n(A),stats:S==null?void 0:S[A.id]},A.id))}):t&&t.length>0?e.jsx(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(tn,{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(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(cr,{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(Bs,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),e.jsx(JSs,{open:a,onOpenChange:o}),r&&e.jsx(eCs,{card:r,open:!!r,onOpenChange:A=>!A&&n(null)})]})}function XSs({cards:t,cardProfiles:s,cardStats:r,onEdit:n,sortBy:a,setSortBy:o}){const l=d=>{a===`${d}_desc`?o(`${d}_asc`):o(`${d}_desc`)},i=({field:d})=>a===`${d}_desc`?e.jsx(Ih,{className:"h-3 w-3"}):a===`${d}_asc`?e.jsx(cu,{className:"h-3 w-3"}):e.jsx(td,{className:"h-3 w-3 opacity-40"});return e.jsx(Ie,{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(cu,{className:"h-3 w-3"})]})}),e.jsx("th",{className:"text-left p-3 font-medium text-muted-foreground hidden md:table-cell",children:"Slug"}),e.jsx("th",{className:"text-center p-3 font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-right p-3 font-medium",children:e.jsxs("button",{onClick:()=>l("views"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Views ",e.jsx(i,{field:"views"})]})}),e.jsx("th",{className:"text-right p-3 font-medium",children:e.jsxs("button",{onClick:()=>l("leads"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Leads ",e.jsx(i,{field:"leads"})]})}),e.jsx("th",{className:"text-right p-3 font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:t.map(d=>{const u=s==null?void 0:s[d.user_id],p=r==null?void 0:r[d.id],f=`https://cards.relevelup.com/${d.slug}`;return e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30 transition-colors",children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:(u==null?void 0:u.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(u==null?void 0:u.email)||""})]})}),e.jsx("td",{className:"p-3 hidden md:table-cell",children:e.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["/",d.slug]})}),e.jsx("td",{className:"p-3 text-center",children:e.jsx(Ye,{variant:d.is_published?"default":"secondary",className:"text-xs",children:d.is_published?"Live":"Draft"})}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.views)??0}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.leads)??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>n(d),className:"h-8 w-8 p-0",children:e.jsx(pa,{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(Ya,{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(Kr,{className:"h-3.5 w-3.5"})})})]})})]},d.id)})})]})})})}function QSs({card:t,onEdit:s,stats:r}){const[n,a]=k.useState(null);k.useEffect(()=>{(async()=>{const{data:d}=await G.from("profiles").select("name").eq("id",t.user_id).single();let u=null;try{const{data:p}=await G.storage.from("avatars").list(`${t.user_id}`);if(p&&p.length>0){const{data:f}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${p[0].name}`);u=f.publicUrl}}catch{}a({name:(d==null?void 0:d.name)||"Unknown",avatar_url:u})})()},[t.user_id]);const o=`https://cards.relevelup.com/${t.slug}`,l=()=>{navigator.clipboard.writeText(o),me.success("Link copied!")};return e.jsx(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsxs(vn,{className:"h-10 w-10",children:[e.jsx(Ca,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(_n,{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(Ye,{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(jn,{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(cr,{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(pa,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:e.jsx(Ya,{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(Kr,{className:"h-3 w-3"})})})]})]})})}function JSs({open:t,onOpenChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(""),[l,i]=k.useState(""),[d,u]=k.useState(!1),p=IWe(),f=l.trim(),{data:y}=ft({queryKey:["profiles-search-for-cards",f],queryFn:async()=>{let C=G.from("profiles").select("id, name, email").order("name").limit(50);f.length>=2&&(C=C.or(`name.ilike.%${f}%,email.ilike.%${f}%`));const{data:A}=await C;return A||[]},enabled:t}),[_,b]=k.useState(null),N=(y==null?void 0:y.find(C=>C.id===r))||_,w=()=>{if(!r||!a.trim()){me.error("Select an agent and enter a slug");return}p.mutate({user_id:r,slug:a.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-"),is_published:!0},{onSuccess:()=>{s(!1),n(""),o(""),i("")}})},S=C=>{var I;n(C),u(!1);const A=y==null?void 0:y.find(L=>L.id===C);A&&(b(A),o(((I=A.name)==null?void 0:I.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Create Agent Card"}),e.jsx(Rr,{children:"Select an agent and set their card URL slug."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Agent"}),e.jsxs(yo,{open:d,onOpenChange:u,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":d,className:"w-full justify-between font-normal",children:[N?`${N.name} (${N.email})`:"Search for an agent...",e.jsx(wx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(uo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Ax,{shouldFilter:!1,children:[e.jsx(Ex,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(Px,{children:[e.jsx(Ix,{children:"No agents found."}),e.jsx(Lx,{children:(y||[]).map(C=>e.jsxs(op,{value:C.id,onSelect:S,children:[e.jsx(ea,{className:Rt("mr-2 h-4 w-4",r===C.id?"opacity-100":"opacity-0")}),C.name," (",C.email,")"]},C.id))})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(ge,{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:C=>o(C.target.value),placeholder:"john-doe"})]})]}),e.jsx(K,{onClick:w,disabled:p.isPending,className:"w-full",children:p.isPending?"Creating...":"Create Card"})]})]})})}function eCs({card:t,open:s,onOpenChange:r}){const n=LWe(),{data:a}=DWe(t.id),o=es(),[l,i]=k.useState(null),[d,u]=k.useState(!1),[p,f]=k.useState(!1),[y,_]=k.useState(""),[b,N]=k.useState(t.slug),[w,S]=k.useState(!1),[C,A]=k.useState({is_published:t.is_published,theme:t.theme,title:t.title||"",positioning_statement:t.positioning_statement||"",bio:t.bio||"",review_snippet:t.review_snippet||"",review_source_url:t.review_source_url||"",booking_url:t.booking_url||"",custom_cta_label:t.custom_cta_label||"",custom_cta_url:t.custom_cta_url||"",show_photo:t.show_photo,show_bio:t.show_bio,show_credentials:t.show_credentials,show_social_links:t.show_social_links,show_save_contact:t.show_save_contact,show_leave_review:t.show_leave_review,show_refer_friend:t.show_refer_friend,brokerage_display_name:t.brokerage_display_name||"",brokerage_logo_url:t.brokerage_logo_url||"",brokerage_logo_size:t.brokerage_logo_size||56,team_name:t.team_name||"",team_logo_url:t.team_logo_url||"",team_logo_size:t.team_logo_size||56});k.useEffect(()=>{s&&(async()=>{try{const{data:V}=await G.storage.from("avatars").list(`${t.user_id}`);if(V&&V.length>0){const{data:ee}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${V[0].name}`);i(`${ee.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const I=$=>{var Z;const V=(Z=$.target.files)==null?void 0:Z[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 ee=new FileReader;ee.onloadend=()=>{_(ee.result),f(!0)},ee.readAsDataURL(V),$.target.value=""},L=async $=>{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(ce=>`${t.user_id}/${ce.name}`));const ee=`${t.user_id}/avatar.jpg`,{error:Z}=await G.storage.from("avatars").upload(ee,$,{upsert:!0,contentType:"image/jpeg"});if(Z)throw Z;const{data:J}=G.storage.from("avatars").getPublicUrl(ee),Y=`${J.publicUrl}?t=${Date.now()}`;i(Y),await G.from("profiles").update({avatar_url:Y}).eq("id",t.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),me.success("Photo updated!")}catch(V){me.error(V.message||"Upload failed")}finally{u(!1)}},O=async()=>{const $=b.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!$){me.error("Please enter a valid URL");return}if($===t.slug){me.info("No changes to save");return}S(!0);try{const{data:V}=await G.from("agent_cards").select("id").eq("slug",$).neq("id",t.id).maybeSingle();if(V){me.error("This URL is already taken. Try another one.");return}const{error:ee}=await G.from("agent_cards").update({slug:$}).eq("id",t.id);if(ee)throw ee;N($),o.invalidateQueries({queryKey:["agent-cards-admin"]}),me.success("Card address updated!")}catch{me.error("Failed to update card address")}finally{S(!1)}},U=async($,V)=>{var Z;const ee=(Z=$.target.files)==null?void 0:Z[0];if(ee){if(!ee.type.startsWith("image/")){me.error("Please select an image file");return}try{const J=ee.name.split(".").pop()||"png",Y=V==="brokerage_logo_url"?"brokerage-logo":"team-logo",ce=`${t.user_id}/${Y}.${J}`,{error:ae}=await G.storage.from("card-logos").upload(ce,ee,{upsert:!0});if(ae)throw ae;const{data:ie}=G.storage.from("card-logos").getPublicUrl(ce),le=ie.publicUrl+"?t="+Date.now();A(V==="brokerage_logo_url"?fe=>({...fe,[V]:le,brokerage_display_name:""}):fe=>({...fe,[V]:le,team_name:""})),me.success("Logo uploaded!")}catch{me.error("Failed to upload logo")}finally{$.target.value=""}}},q=()=>{n.mutate({id:t.id,...C,title:C.title||null,positioning_statement:C.positioning_statement||null,bio:C.bio||null,review_snippet:C.review_snippet||null,review_source_url:C.review_source_url||null,booking_url:C.booking_url||null,custom_cta_label:C.custom_cta_label||null,custom_cta_url:C.custom_cta_url||null,brokerage_display_name:C.brokerage_display_name||null,brokerage_logo_url:C.brokerage_logo_url||null,brokerage_logo_size:C.brokerage_logo_size,team_name:C.team_name||null,team_logo_url:C.team_logo_url||null,team_logo_size:C.team_logo_size},{onSuccess:()=>r(!1)})};return e.jsxs(e.Fragment,{children:[e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(ms,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Edit Agent Card"}),e.jsxs(Rr,{children:["/card/",t.slug]})]}),e.jsxs(ta,{defaultValue:"content",children:[e.jsxs(Qn,{className:"w-full",children:[e.jsx(ls,{value:"content",className:"flex-1",children:"Content"}),e.jsx(ls,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(ls,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(ls,{value:"analytics",className:"flex-1",children:"Analytics"})]}),e.jsxs(js,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{children:"Published"}),e.jsx(Lr,{checked:C.is_published,onCheckedChange:$=>A(V=>({...V,is_published:$}))})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[e.jsxs(vn,{className:"h-16 w-16",children:[e.jsx(Ca,{src:l||void 0}),e.jsx(_n,{children:"?"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:I,disabled:d}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:d,children:e.jsx("span",{children:d?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Da,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{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:$=>N($.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:O,disabled:w||b===t.slug,className:"shrink-0",children:w?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Theme"}),e.jsxs(zs,{value:C.theme,onValueChange:$=>A(V=>({...V,theme:$})),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"standard",children:"✨ Standard (Modern Clean)"}),e.jsx(yt,{value:"luxury",children:"🌙 Luxury (Dark & Gold)"}),e.jsx(yt,{value:"bold",children:"🔥 Bold (Vibrant & Punchy)"}),e.jsx(yt,{value:"classic",children:"📋 Classic (Professional)"})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Title / Tagline"}),e.jsx(Fe,{value:C.title,onChange:$=>A(V=>({...V,title:$.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(ge,{children:"Positioning Statement"}),e.jsx(Fe,{value:C.positioning_statement,onChange:$=>A(V=>({...V,positioning_statement:$.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Bio"}),e.jsx(_r,{value:C.bio,onChange:$=>A(V=>({...V,bio:$.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Review Snippet"}),e.jsx(Fe,{value:C.review_snippet,onChange:$=>A(V=>({...V,review_snippet:$.target.value})),placeholder:"Best agent we've ever worked with..."})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Review Source URL"}),e.jsx(Fe,{value:C.review_source_url,onChange:$=>A(V=>({...V,review_source_url:$.target.value})),placeholder:"https://g.page/your-business/review"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(Fe,{value:C.booking_url,onChange:$=>A(V=>({...V,booking_url:$.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Custom CTA Label (optional)"}),e.jsx(Fe,{value:C.custom_cta_label,onChange:$=>A(V=>({...V,custom_cta_label:$.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Custom CTA URL (optional)"}),e.jsx(Fe,{value:C.custom_cta_url,onChange:$=>A(V=>({...V,custom_cta_url:$.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(ge,{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:C.brokerage_display_name,onChange:$=>A(V=>({...V,brokerage_display_name:$.target.value,brokerage_logo_url:""})),placeholder:"Brokerage name (or upload logo below)",disabled:!!C.brokerage_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[C.brokerage_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:C.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${C.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>A($=>({...$,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(Da,{className:"h-3.5 w-3.5"}),C.brokerage_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:$=>U($,"brokerage_logo_url")})]})]}),C.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[C.brokerage_logo_size||56,"px"]})]}),e.jsx(Eg,{value:[C.brokerage_logo_size||56],onValueChange:([$])=>A(V=>({...V,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(ge,{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:C.team_name,onChange:$=>A(V=>({...V,team_name:$.target.value,team_logo_url:""})),placeholder:"Team name (or upload logo below)",disabled:!!C.team_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[C.team_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:C.team_logo_url,alt:"Team logo",style:{height:`${C.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>A($=>({...$,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(Da,{className:"h-3.5 w-3.5"}),C.team_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:$=>U($,"team_logo_url")})]})]}),C.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[C.team_logo_size||56,"px"]})]}),e.jsx(Eg,{value:[C.team_logo_size||56],onValueChange:([$])=>A(V=>({...V,team_logo_size:$})),min:24,max:120,step:4})]})]})]})]}),e.jsx(js,{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:$,label:V,hint:ee})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(ge,{children:V}),ee&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ee," ",$==="show_photo"&&e.jsx("a",{href:"/profile",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:"Update Profile"})]})]}),e.jsx(Lr,{checked:C[$],onCheckedChange:Z=>A(J=>({...J,[$]:Z}))})]},$))}),e.jsx(js,{value:"blocks",className:"mt-4",children:e.jsx(Glt,{cardId:t.id})}),e.jsx(js,{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(Ie,{children:e.jsxs(Be,{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(Ie,{children:e.jsxs(Be,{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(Ie,{children:e.jsxs(Be,{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($=>e.jsxs("div",{className:"text-sm p-2 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"font-medium",children:$.name}),$.phone&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",$.phone]}),$.intent&&e.jsx(Ye,{variant:"secondary",className:"ml-2 text-xs",children:$.intent})]},$.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(h4e,{open:p,onClose:()=>f(!1),imageSrc:y,onCropComplete:L,aspectRatio:1})]})}const oT={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"},t3e={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 s3e(t=!0){return ft({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 tCs(){const t=es();return Et({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 sCs(){const t=es();return Et({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 rCs(){const t=es();return Et({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 oct(t,s=!0){return ft({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 nCs(t){return ft({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 aCs(){const t=es();return Et({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 iCs(){const t=es();return Et({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 oCs(){const t=es();return Et({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 lCs(){const t=es();return Et({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 cCs(){const t=es();return Et({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 dCs(){const t=es();return Et({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 uCs(){const t=es();return Et({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 hCs(){const t=es();return Et({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 mCs(){const t=es();return Et({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 pCs(t){const{isAdmin:s}=$s();return ft({queryKey:["marketplace-orders",t,s],queryFn:async()=>{let r=G.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).order("created_at",{ascending:!1});const{data:n,error:a}=await r;if(a)throw a;if(s&&n){const o=[...new Set(n.map(d=>d.user_id))],{data:l}=await G.from("profiles").select("id, name, email").in("id",o),i=new Map((l==null?void 0:l.map(d=>[d.id,d]))||[]);return n.map(d=>({...d,user:i.get(d.user_id)}))}return n}})}function fCs(){const{user:t}=$s();return ft({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 xCs(t){return ft({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 gCs(){const t=es(),{user:s}=$s();return Et({mutationFn:async({orderId:r,status:n,notes:a,trackingNumber:o,trackingUrl:l,previousStatus:i})=>{const d={status:n};o!==void 0&&(d.tracking_number=o),l!==void 0&&(d.tracking_url=l);const{error:u}=await G.from("marketplace_orders").update(d).eq("id",r);if(u)throw u;const{error:p}=await G.from("marketplace_order_status_history").insert({order_id:r,status:n,notes:a,created_by:s==null?void 0:s.id});if(p)throw p;if(["shipped","in_production","processing","completed"].includes(n)&&n!==i)try{await G.functions.invoke("marketplace-order-notify",{body:{orderId:r,notificationType:n==="shipped"?"shipped":"status_update",newStatus:n,trackingNumber:o,trackingUrl:l}})}catch(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 yCs(){const t=es();return Et({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 vCs(){const t=es();return Et({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 _Cs(){const t=es();return Et({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 bCs(){const{data:t,isLoading:s}=s3e(!1),r=tCs(),n=sCs(),a=rCs(),[o,l]=k.useState(!1),[i,d]=k.useState(null),[u,p]=k.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),f=()=>{p({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),d(null)},y=N=>{d(N),p({name:N.name,description:N.description||"",image_url:N.image_url||"",sort_order:N.sort_order,is_active:N.is_active}),l(!0)},_=async N=>{N.preventDefault(),i?await n.mutateAsync({id:i.id,...u}):await r.mutateAsync(u),l(!1),f()},b=async N=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(N)};return s?e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ss,{className:"h-8 w-48"})}),e.jsx(Be,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(N=>e.jsx(Ss,{className:"h-12 w-full"},N))})})]}):e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{children:"Categories"}),e.jsxs(fs,{open:o,onOpenChange:N=>{l(N),N||f()},children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{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(ge,{htmlFor:"name",children:"Name"}),e.jsx(Fe,{id:"name",value:u.name,onChange:N=>p({...u,name:N.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",value:u.description,onChange:N=>p({...u,description:N.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"image_url",children:"Image URL"}),e.jsx(Fe,{id:"image_url",value:u.image_url,onChange:N=>p({...u,image_url:N.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Fe,{id:"sort_order",type:"number",value:u.sort_order,onChange:N=>p({...u,sort_order:parseInt(N.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{id:"is_active",checked:u.is_active,onCheckedChange:N=>p({...u,is_active:N})}),e.jsx(ge,{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(Be,{children:t&&t.length>0?e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Description"}),e.jsx(Nt,{children:"Sort Order"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(N=>e.jsxs(As,{children:[e.jsx(dt,{className:"font-medium",children:N.name}),e.jsx(dt,{className:"max-w-xs truncate",children:N.description}),e.jsx(dt,{children:N.sort_order}),e.jsx(dt,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${N.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:N.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(N),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(N.id),disabled:a.isPending,children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})})]},N.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function wCs(){var he,we;const{data:t,isLoading:s}=oct(void 0,!1),{data:r}=s3e(!1),n=aCs(),a=iCs(),o=oCs(),l=lCs(),i=cCs(),d=dCs(),u=uCs(),p=hCs(),f=mCs(),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState(!1),[C,A]=k.useState(null),[I,L]=k.useState(null),[O,U]=k.useState(!1),[q,$]=k.useState({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),[V,ee]=k.useState({name:"",price_adjustment:0}),[Z,J]=k.useState(""),Y=()=>{$({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),A(null)},ce=Ne=>{A(Ne),$({name:Ne.name,description:Ne.description||"",base_price:Number(Ne.base_price),shipping_fee:Number(Ne.shipping_fee),category_id:Ne.category_id||"",allow_artwork_upload:Ne.allow_artwork_upload,requires_proof_approval:Ne.requires_proof_approval,is_active:Ne.is_active,sort_order:Ne.sort_order}),_(!0)},ae=async Ne=>{Ne.preventDefault();const Ve={...q,category_id:q.category_id||null};C?await a.mutateAsync({id:C.id,...Ve}):await n.mutateAsync(Ve),_(!1),Y()},ie=async Ne=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(Ne)},le=async Ne=>{if(!I||!Ne.target.files||Ne.target.files.length===0)return;U(!0);const Ve=Ne.target.files[0],Te=Ve.name.split(".").pop(),Ae=`products/${I.id}/${Date.now()}.${Te}`;try{const{error:ze}=await G.storage.from("marketplace").upload(Ae,Ve);if(ze)throw ze;const{data:{publicUrl:Ee}}=G.storage.from("marketplace").getPublicUrl(Ae);await l.mutateAsync({product_id:I.id,image_url:Ee,is_primary:!I.images||I.images.length===0}),me.success("Image uploaded successfully")}catch(ze){me.error("Failed to upload image: "+ze.message)}finally{U(!1)}},fe=async Ne=>{Ne.preventDefault(),I&&(await u.mutateAsync({product_id:I.id,name:V.name,price_adjustment:V.price_adjustment}),ee({name:"",price_adjustment:0}))},xe=async()=>{!I||!Z||(await f.mutateAsync({productId:I.id,videoUrl:Z}),J(""))};return s?e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ss,{className:"h-8 w-48"})}),e.jsx(Be,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(Ne=>e.jsx(Ss,{className:"h-64 w-full"},Ne))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{children:"Products"}),e.jsxs(fs,{open:y,onOpenChange:Ne=>{_(Ne),Ne||Y()},children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Product"]})}),e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:C?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:ae,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(ge,{htmlFor:"name",children:"Product Name"}),e.jsx(Fe,{id:"name",value:q.name,onChange:Ne=>$({...q,name:Ne.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"category",children:"Category"}),e.jsxs(zs,{value:q.category_id,onValueChange:Ne=>$({...q,category_id:Ne}),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select category"})}),e.jsx(Fs,{children:r==null?void 0:r.map(Ne=>e.jsx(yt,{value:Ne.id,children:Ne.name},Ne.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",value:q.description,onChange:Ne=>$({...q,description:Ne.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(ge,{htmlFor:"base_price",children:"Base Price ($)"}),e.jsx(Fe,{id:"base_price",type:"number",step:"0.01",min:"0",value:q.base_price,onChange:Ne=>$({...q,base_price:parseFloat(Ne.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(Fe,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:q.shipping_fee,onChange:Ne=>$({...q,shipping_fee:parseFloat(Ne.target.value)||0})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Fe,{id:"sort_order",type:"number",value:q.sort_order,onChange:Ne=>$({...q,sort_order:parseInt(Ne.target.value)||0})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{id:"allow_artwork_upload",checked:q.allow_artwork_upload,onCheckedChange:Ne=>$({...q,allow_artwork_upload:Ne})}),e.jsx(ge,{htmlFor:"allow_artwork_upload",children:"Allow customer to upload artwork"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{id:"requires_proof_approval",checked:q.requires_proof_approval,onCheckedChange:Ne=>$({...q,requires_proof_approval:Ne})}),e.jsx(ge,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{id:"is_active",checked:q.is_active,onCheckedChange:Ne=>$({...q,is_active:Ne})}),e.jsx(ge,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:C?"Update Product":"Create Product"})]})]})]})]}),e.jsx(Be,{children:t&&t.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(Ne=>{var Ve,Te;return e.jsxs(Ie,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[Ne.images&&Ne.images.length>0?e.jsx("img",{src:((Ve=Ne.images.find(Ae=>Ae.is_primary))==null?void 0:Ve.image_url)||Ne.images[0].image_url,alt:Ne.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"}),!Ne.is_active&&e.jsx(Ye,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs(Be,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1",children:Ne.name}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((Te=Ne.category)==null?void 0:Te.name)||"No category"}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("span",{className:"font-bold",children:["$",Number(Ne.base_price).toFixed(2)]}),Number(Ne.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(Ne.shipping_fee).toFixed(2)," shipping"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[Ne.allow_artwork_upload&&e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),Ne.requires_proof_approval&&e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Proof Required"}),Ne.variants&&Ne.variants.length>0&&e.jsxs(Ye,{variant:"outline",className:"text-xs",children:[Ne.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ce(Ne),children:[e.jsx(pa,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(Ne),N(!0)},children:[e.jsx(Xv,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(Ne),S(!0)},children:[e.jsx(hh,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie(Ne.id),children:e.jsx(yr,{className:"h-3 w-3 text-destructive"})})]})]})]},Ne.id)})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No products yet. Create your first product to get started."})})]}),e.jsx(fs,{open:b,onOpenChange:N,children:e.jsxs(ms,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsxs(bs,{children:["Manage Images - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-4",children:(he=I==null?void 0:I.images)==null?void 0:he.map(Ne=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:Ne.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),Ne.is_primary&&e.jsx(Ye,{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:[!Ne.is_primary&&e.jsx(K,{variant:"secondary",size:"icon",onClick:async()=>{var Ve;await d.mutateAsync({imageId:Ne.id,productId:I.id}),L({...I,images:(Ve=I.images)==null?void 0:Ve.map(Te=>({...Te,is_primary:Te.id===Ne.id}))})},disabled:d.isPending,title:"Set as primary",children:e.jsx(Gn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"destructive",size:"icon",onClick:async()=>{var Te;await i.mutateAsync({id:Ne.id,productId:I.id});const Ve=t==null?void 0:t.find(Ae=>Ae.id===I.id);Ve&&L({...Ve,images:(Te=Ve.images)==null?void 0:Te.filter(Ae=>Ae.id!==Ne.id)})},disabled:i.isPending,children:e.jsx(yr,{className:"h-4 w-4"})})]})]},Ne.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:O}),e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[e.jsx(Xv,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:O?"Uploading...":"Click to upload an image"})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx(ge,{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:Z,onChange:Ne=>J(Ne.target.value)}),e.jsxs(K,{onClick:xe,disabled:!Z,children:[e.jsx(hn,{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(fs,{open:w,onOpenChange:S,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsxs(bs,{children:["Manage Variants - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:fe,className:"flex gap-2",children:[e.jsx(Fe,{placeholder:"Variant name (e.g., 500 count)",value:V.name,onChange:Ne=>ee({...V,name:Ne.target.value}),required:!0}),e.jsx(Fe,{type:"number",step:"0.01",placeholder:"Price adj.",value:V.price_adjustment,onChange:Ne=>ee({...V,price_adjustment:parseFloat(Ne.target.value)||0}),className:"w-32"}),e.jsx(K,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(we=I==null?void 0:I.variants)==null?void 0:we.map(Ne=>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:Ne.name}),e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(Ne.price_adjustment)>=0?"+":"","$",Number(Ne.price_adjustment).toFixed(2)]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutateAsync({id:Ne.id,productId:I.id}),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]},Ne.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 jCs=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function NCs(){var N,w,S;const{data:t,isLoading:s}=pCs(),r=gCs(),n=yCs(),[a,o]=k.useState(null),[l,i]=k.useState(!1),[d,u]=k.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,f]=k.useState(!1),y=C=>{o(C),u({status:C.status,notes:"",trackingNumber:C.tracking_number||"",trackingUrl:C.tracking_url||""}),i(!0)},_=async()=>{a&&(await r.mutateAsync({orderId:a.id,status:d.status,notes:d.notes,trackingNumber:d.trackingNumber,trackingUrl:d.trackingUrl,previousStatus:a.status}),i(!1))},b=async(C,A)=>{if(!a||!C.target.files||C.target.files.length===0)return;f(!0);const I=C.target.files[0],L=I.name.split(".").pop(),O=`proofs/${a.id}/${A}/${Date.now()}.${L}`;try{const{error:U}=await G.storage.from("marketplace").upload(O,I);if(U)throw U;const{data:{publicUrl:q}}=G.storage.from("marketplace").getPublicUrl(O);await n.mutateAsync({itemId:A,proofUrl:q,orderId:a.id}),me.success("Proof uploaded successfully")}catch(U){me.error("Failed to upload proof: "+U.message)}finally{f(!1)}};return s?e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ss,{className:"h-8 w-48"})}),e.jsx(Be,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(C=>e.jsx(Ss,{className:"h-16 w-full"},C))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Orders"})}),e.jsx(Be,{children:t&&t.length>0?e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Order #"}),e.jsx(Nt,{children:"Customer"}),e.jsx(Nt,{children:"Date"}),e.jsx(Nt,{children:"Total"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(C=>{var A,I;return e.jsxs(As,{children:[e.jsx(dt,{className:"font-mono",children:C.order_number}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((A=C.user)==null?void 0:A.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(I=C.user)==null?void 0:I.email})]})}),e.jsx(dt,{children:gs(new Date(C.created_at),"MMM d, yyyy")}),e.jsxs(dt,{className:"font-bold",children:["$",Number(C.total).toFixed(2)]}),e.jsx(dt,{children:e.jsx(Ye,{className:t3e[C.status],children:oT[C.status]})}),e.jsx(dt,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>y(C),children:[e.jsx(jn,{className:"h-4 w-4 mr-1"}),"View"]})})]},C.id)})})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No orders yet."})})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ms,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsxs(bs,{children:["Order ",a==null?void 0:a.order_number]})}),a&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Customer"}),e.jsx("p",{children:(N=a.user)==null?void 0:N.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(w=a.user)==null?void 0:w.email})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Shipping Address"}),e.jsx("p",{children:a.shipping_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.shipping_address,e.jsx("br",{}),a.shipping_city,", ",a.shipping_state," ",a.shipping_zip]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Order Items"}),e.jsx("div",{className:"space-y-3",children:(S=a.items)==null?void 0:S.map(C=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:C.product_name}),C.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.variant_name})]}),e.jsxs("p",{className:"font-bold",children:["$",Number(C.unit_price).toFixed(2)," x ",C.quantity]})]}),C.artwork_url&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Customer Artwork:"}),e.jsx("a",{href:C.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Artwork"})]}),e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Proof Status: "}),e.jsx(Ye,{variant:C.proof_status==="approved"?"default":"secondary",children:C.proof_status||"No proof yet"})]}),C.proof_url?e.jsx("a",{href:C.proof_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Proof"}):e.jsxs("div",{children:[e.jsx("input",{type:"file",accept:"image/*,.pdf",onChange:A=>b(A,C.id),className:"hidden",id:`proof-${C.id}`,disabled:p}),e.jsx("label",{htmlFor:`proof-${C.id}`,children:e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("span",{children:[e.jsx(Da,{className:"h-4 w-4 mr-1"}),p?"Uploading...":"Upload Proof"]})})})]})]})})]},C.id))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["$",Number(a.subtotal).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",Number(a.shipping_total).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between font-bold text-lg mt-2",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",Number(a.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Update Order Status"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Status"}),e.jsxs(zs,{value:d.status,onValueChange:C=>u({...d,status:C}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:jCs.map(C=>e.jsx(yt,{value:C,children:oT[C]},C))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Tracking Number"}),e.jsx(Fe,{value:d.trackingNumber,onChange:C=>u({...d,trackingNumber:C.target.value}),placeholder:"Enter tracking number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Tracking URL"}),e.jsx(Fe,{value:d.trackingUrl,onChange:C=>u({...d,trackingUrl:C.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Notes (optional)"}),e.jsx(_r,{value:d.notes,onChange:C=>u({...d,notes:C.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(K,{onClick:_,disabled:r.isPending,className:"w-full",children:[e.jsx(al,{className:"h-4 w-4 mr-2"}),"Update Status"]})]})]}),a.status_history&&a.status_history.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Status History"}),e.jsx("div",{className:"space-y-2",children:a.status_history.map(C=>e.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[e.jsxs("div",{children:[e.jsx(Ye,{variant:"outline",children:oT[C.status]}),C.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:C.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:gs(new Date(C.created_at),"MMM d, h:mm a")})]},C.id))})]})]})]})})]})}function kCs(){const[t,s]=k.useState("products"),r=br();return e.jsx(Ls,{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(Kr,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(ta,{value:t,onValueChange:s,children:[e.jsxs(Qn,{className:"grid w-full grid-cols-3",children:[e.jsxs(ls,{value:"products",className:"flex items-center gap-2",children:[e.jsx(al,{className:"h-4 w-4"}),"Products"]}),e.jsxs(ls,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(Sm,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(ls,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(ip,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(js,{value:"products",children:e.jsx(wCs,{})}),e.jsx(js,{value:"categories",children:e.jsx(bCs,{})}),e.jsx(js,{value:"orders",children:e.jsx(NCs,{})})]})]})})}function lct(){return ft({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 SCs(t){return ft({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 CCs(t){return ft({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 MCs(t){return ft({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 TCs(){return ft({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 ACs(t){return ft({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 ECs(){const t=es();return Et({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"]}),t.invalidateQueries({queryKey:["homereel-credits"]})}})}function PCs(){const t=es();return Et({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 ICs(){const t=es();return Et({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 LCs(){const t=es();return Et({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 DCs(){const t=es();return Et({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 RCs(){const t=es();return Et({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 OCs(){const t=es();return Et({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 FCs(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function j0e(t,s){const r=FCs(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 cct(){return ft({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 zCs(){const t=es();return Et({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 BCs(){const{user:t}=$s(),[s,r]=k.useState("items"),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,d]=k.useState(""),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(null),[N,w]=k.useState(!1),[S,C]=k.useState(null),[A,I]=k.useState(""),[L,O]=k.useState(""),[U,q]=k.useState(null),[$,V]=k.useState(""),[ee,Z]=k.useState("file"),[J,Y]=k.useState(""),[ce,ae]=k.useState(""),[ie,le]=k.useState(""),[fe,xe]=k.useState(!0),[he,we]=k.useState(null),[Ne,Ve]=k.useState(!1),[Te,Ae]=k.useState(!1),ze=k.useRef(null),Ee=k.useRef(null),{data:ve,isLoading:Re}=lct(),{data:Ue,isLoading:ye}=SCs(),{data:ct,isLoading:pe}=TCs(),{data:Ge,isLoading:tt}=cct(),st=PCs(),Ce=ICs(),et=LCs(),Ct=DCs(),Ot=RCs(),ut=OCs(),Oe=zCs(),[Xe,at]=k.useState({}),Ke=Bt=>{Bt?(l(Bt),d(Bt.name),p(Bt.description||""),y(Bt.icon||"")):(l(null),d(""),p(""),y("")),a(!0)},He=async()=>{if(!i.trim()){me.error("Please enter a category name");return}try{o?(await Ce.mutateAsync({id:o.id,name:i,description:u||null,icon:f||null}),me.success("Category updated successfully")):(await st.mutateAsync({name:i,description:u||null,icon:f||null,sort_order:((ve==null?void 0:ve.length)||0)+1}),me.success("Category created successfully")),a(!1)}catch(Bt){console.error("Error saving category:",Bt),me.error("Failed to save category")}},gt=async()=>{if(_)try{await et.mutateAsync(_),me.success("Category deleted successfully"),b(null)}catch(Bt){console.error("Error deleting category:",Bt),me.error("Failed to delete category")}},Mt=Bt=>{var Xs;Bt?(C(Bt),I(Bt.name),O(Bt.description||""),q(Bt.category_id),V(Bt.points_cost.toString()),Z(Bt.item_type),Y(Bt.file_url||""),ae(Bt.preview_image_url||""),le(((Xs=Bt.max_quantity)==null?void 0:Xs.toString())||""),xe(Bt.is_active)):(C(null),I(""),O(""),q(null),V(""),Z("file"),Y(""),ae(""),le(""),xe(!0)),w(!0)},Wt=async(Bt,Xs)=>{Xs==="file"?Ve(!0):Ae(!0);try{const Nr=Bt.name.split(".").pop(),Vs=`${Date.now()}-${Math.random().toString(36).substring(7)}.${Nr}`,ar=`${Xs==="file"?"items":"previews"}/${Vs}`,{error:Or}=await G.storage.from("reward-store").upload(ar,Bt);if(Or)throw Or;const{data:{publicUrl:Rn}}=G.storage.from("reward-store").getPublicUrl(ar);Xs==="file"?Y(Rn):ae(Rn),me.success("File uploaded successfully")}catch(Nr){console.error("Error uploading file:",Nr),me.error("Failed to upload file")}finally{Xs==="file"?Ve(!1):Ae(!1)}},xs=async()=>{if(!A.trim()){me.error("Please enter an item name");return}if(!$||parseInt($)<0){me.error("Please enter a valid points cost");return}try{const Bt={name:A,description:L||null,category_id:U,points_cost:parseInt($),item_type:ee,file_url:J||null,preview_image_url:ce||null,max_quantity:ie?parseInt(ie):null,current_quantity:ie?parseInt(ie):null,is_active:fe,created_by:t==null?void 0:t.id};S?(await Ot.mutateAsync({id:S.id,...Bt,current_quantity:S.max_quantity!==(ie?parseInt(ie):null)?ie?parseInt(ie):null:S.current_quantity}),me.success("Item updated successfully")):(await Ct.mutateAsync(Bt),me.success("Item created successfully")),w(!1)}catch(Bt){console.error("Error saving item:",Bt),me.error("Failed to save item")}},Cs=async()=>{if(he)try{await ut.mutateAsync(he),me.success("Item deleted successfully"),we(null)}catch(Bt){console.error("Error deleting item:",Bt),me.error("Failed to delete item")}},Us=async(Bt,Xs)=>{const Nr=Xe[Bt];if(Nr===void 0||Nr===Xs.toString())return;const Vs=parseInt(Nr);if(isNaN(Vs)||Vs<0){me.error("Please enter a valid positive number");return}try{await Oe.mutateAsync({id:Bt,points:Vs}),me.success("Points updated successfully"),at(ar=>{const Or={...ar};return delete Or[Bt],Or})}catch(ar){console.error("Error updating points:",ar),me.error("Failed to update points")}};return Re||ye||pe||tt?e.jsx(Ls,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ss,{className:"h-8 w-64"}),e.jsx(Ss,{className:"h-96"})]})}):e.jsxs(Ls,{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(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(al,{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:(Ue==null?void 0:Ue.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(Ue==null?void 0:Ue.filter(Bt=>Bt.is_active).length)||0," active"]})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Sm,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(ve==null?void 0:ve.length)||0})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Gn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg. Cost"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[Ue&&Ue.length>0?Math.round(Ue.reduce((Bt,Xs)=>Bt+Xs.points_cost,0)/Ue.length):0," pts"]})]})})]}),e.jsxs(ta,{value:s,onValueChange:r,children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"items",children:"Items"}),e.jsx(ls,{value:"categories",children:"Categories"}),e.jsx(ls,{value:"purchases",children:"Purchases"}),e.jsx(ls,{value:"point-settings",children:"Point Settings"})]}),e.jsx(js,{value:"items",className:"mt-4",children:e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Store Items"}),e.jsx(mr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(K,{onClick:()=>Mt(),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(Be,{children:!Ue||Ue.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Vi,{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(As,{children:[e.jsx(Nt,{children:"Item"}),e.jsx(Nt,{children:"Category"}),e.jsx(Nt,{className:"text-center",children:"Cost"}),e.jsx(Nt,{className:"text-center",children:"Type"}),e.jsx(Nt,{className:"text-center",children:"Quantity"}),e.jsx(Nt,{className:"text-center",children:"Status"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:Ue.map(Bt=>e.jsxs(As,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Bt.preview_image_url?e.jsx("img",{src:Bt.preview_image_url,alt:Bt.name,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded bg-muted flex items-center justify-center",children:e.jsx(Vi,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:Bt.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:Bt.description||"No description"})]})]})}),e.jsx(dt,{children:Bt.category?e.jsx(Ye,{variant:"outline",children:Bt.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-center",children:e.jsxs(Ye,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Bt.points_cost]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[Bt.item_type==="file"?e.jsx(mn,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(go,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:Bt.item_type})]})}),e.jsx(dt,{className:"text-center",children:Bt.max_quantity!==null?e.jsxs("span",{className:Bt.current_quantity===0?"text-red-500":"",children:[Bt.current_quantity,"/",Bt.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(dt,{className:"text-center",children:e.jsx(Ye,{variant:Bt.is_active?"default":"secondary",children:Bt.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:()=>Mt(Bt),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>we(Bt.id),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})})]},Bt.id))})]})})]})}),e.jsx(js,{value:"categories",className:"mt-4",children:e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Categories"}),e.jsx(mr,{children:"Organize your store items into categories"})]}),e.jsxs(K,{onClick:()=>Ke(),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Be,{children:!ve||ve.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Sm,{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(As,{children:[e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Description"}),e.jsx(Nt,{className:"text-center",children:"Items"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:ve.map(Bt=>e.jsxs(As,{children:[e.jsxs(dt,{className:"font-medium",children:[Bt.icon&&e.jsx("span",{className:"mr-2",children:Bt.icon}),Bt.name]}),e.jsx(dt,{className:"text-muted-foreground",children:Bt.description||"—"}),e.jsx(dt,{className:"text-center",children:(Ue==null?void 0:Ue.filter(Xs=>Xs.category_id===Bt.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:()=>Ke(Bt),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(Bt.id),children:e.jsx(yr,{className:"h-4 w-4 text-destructive"})})]})})]},Bt.id))})]})})]})}),e.jsx(js,{value:"purchases",className:"mt-4",children:e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(ip,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(mr,{children:"View all reward redemptions by agents"})]}),e.jsx(Be,{children:!ct||ct.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ip,{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(As,{children:[e.jsx(Nt,{children:"Date"}),e.jsx(Nt,{children:"Agent"}),e.jsx(Nt,{children:"Item"}),e.jsx(Nt,{className:"text-center",children:"Points Spent"})]})}),e.jsx(Pn,{children:ct.map(Bt=>{var Xs,Nr,Vs,ar;return e.jsxs(As,{children:[e.jsx(dt,{className:"text-muted-foreground",children:gs(new Date(Bt.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(Ei,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Xs=Bt.user)==null?void 0:Xs.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((Nr=Bt.user)==null?void 0:Nr.email)||"—"})]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(Vs=Bt.item)!=null&&Vs.preview_image_url?e.jsx("img",{src:Bt.item.preview_image_url,alt:Bt.item.name,className:"h-8 w-8 rounded object-cover"}):e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center",children:e.jsx(Vi,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((ar=Bt.item)==null?void 0:ar.name)||"Deleted item"})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(Ye,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Bt.points_spent]})})]},Bt.id)})})]})})]})})]})]}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:o?"Edit Category":"Add Category"}),e.jsx(Rr,{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(ge,{htmlFor:"categoryName",children:"Name"}),e.jsx(Fe,{id:"categoryName",value:i,onChange:Bt=>d(Bt.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(_r,{id:"categoryDescription",value:u,onChange:Bt=>p(Bt.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(Fe,{id:"categoryIcon",value:f,onChange:Bt=>y(Bt.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{onClick:He,disabled:st.isPending||Ce.isPending,children:st.isPending||Ce.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:N,onOpenChange:w,children:e.jsxs(ms,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:S?"Edit Item":"Add Item"}),e.jsx(Rr,{children:S?"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(ge,{htmlFor:"itemName",children:"Name *"}),e.jsx(Fe,{id:"itemName",value:A,onChange:Bt=>I(Bt.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"itemDescription",children:"Description"}),e.jsx(_r,{id:"itemDescription",value:L,onChange:Bt=>O(Bt.target.value),placeholder:"Describe the item..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"itemCategory",children:"Category"}),e.jsxs(zs,{value:U||"none",onValueChange:Bt=>q(Bt==="none"?null:Bt),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select category"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"No category"}),ve==null?void 0:ve.map(Bt=>e.jsxs(yt,{value:Bt.id,children:[Bt.icon&&`${Bt.icon} `,Bt.name]},Bt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(Fe,{id:"itemPointsCost",type:"number",min:"0",value:$,onChange:Bt=>V(Bt.target.value),placeholder:"e.g., 100"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"itemType",children:"Type"}),e.jsxs(zs,{value:ee,onValueChange:Z,children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"file",children:"File Download"}),e.jsx(yt,{value:"link",children:"External Link"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(Fe,{id:"itemMaxQuantity",type:"number",min:"1",value:ie,onChange:Bt=>le(Bt.target.value),placeholder:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"File / Link URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:J,onChange:Bt=>Y(Bt.target.value),placeholder:ee==="file"?"Upload a file or paste URL":"Paste external link"}),ee==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var Bt;return(Bt=ze.current)==null?void 0:Bt.click()},disabled:Ne,children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx("input",{ref:ze,type:"file",className:"hidden",onChange:Bt=>{var Nr;const Xs=(Nr=Bt.target.files)==null?void 0:Nr[0];Xs&&Wt(Xs,"file")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Preview Image"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:ce,onChange:Bt=>ae(Bt.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var Bt;return(Bt=Ee.current)==null?void 0:Bt.click()},disabled:Te,children:e.jsx(Uo,{className:"h-4 w-4"})}),e.jsx("input",{ref:Ee,type:"file",accept:"image/*",className:"hidden",onChange:Bt=>{var Nr;const Xs=(Nr=Bt.target.files)==null?void 0:Nr[0];Xs&&Wt(Xs,"preview")}})]}),ce&&e.jsx("img",{src:ce,alt:"Preview",className:"mt-2 h-24 rounded object-cover"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{id:"itemIsActive",checked:fe,onCheckedChange:xe}),e.jsx(ge,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(K,{onClick:xs,disabled:Ct.isPending||Ot.isPending,children:Ct.isPending||Ot.isPending?"Saving...":"Save"})]})]})}),e.jsx(Ll,{open:!!_,onOpenChange:()=>b(null),children:e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Delete Category"}),e.jsx(vl,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:gt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(Ll,{open:!!he,onOpenChange:()=>we(null),children:e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Delete Item"}),e.jsx(vl,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:Cs,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Ie,{className:"mt-4",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(So,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(Ft,{children:"Point Reward Settings"}),e.jsx(mr,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(Be,{children:!Ge||Ge.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(So,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No point settings configured."})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Action"}),e.jsx(Nt,{children:"Description"}),e.jsx(Nt,{className:"text-center w-32",children:"Points"}),e.jsx(Nt,{className:"text-right w-24",children:"Save"})]})}),e.jsx(Pn,{children:Ge.map(Bt=>e.jsxs(As,{children:[e.jsx(dt,{children:e.jsx("p",{className:"font-medium",children:Bt.action_name})}),e.jsx(dt,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:Bt.description})}),e.jsx(dt,{className:"text-center",children:e.jsx(Fe,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:Xe[Bt.id]??Bt.points.toString(),onChange:Xs=>at(Nr=>({...Nr,[Bt.id]:Xs.target.value}))})}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{size:"sm",variant:"outline",disabled:Xe[Bt.id]===void 0||Xe[Bt.id]===Bt.points.toString()||Oe.isPending,onClick:()=>Us(Bt.id,Bt.points),children:e.jsx(wc,{className:"h-4 w-4"})})})]},Bt.id))})]})})]})]})}const k9e=()=>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"})]}),S9e=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function $Cs(){const t=es(),[s,r]=k.useState(!1),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,d]=k.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:u,isLoading:p}=ft({queryKey:["canva-integration"],queryFn:async()=>{const{data:C,error:A}=await G.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(A)throw A;return C}}),{data:f}=ft({queryKey:["brokerages-list"],queryFn:async()=>{const{data:C,error:A}=await G.from("brokerages").select("id, name").order("name");if(A)throw A;return C}}),{data:y}=ft({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:C,error:A}=await G.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(A)throw A;return C}}),_=async()=>{var C;r(!0);try{const{data:A}=await G.auth.getSession(),I=(C=A==null?void 0:A.session)==null?void 0:C.access_token;if(!I)throw new Error("Not authenticated");const U=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 U.json();if(!U.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 $=window.open(q.authUrl,"canva-oauth","width=600,height=700,scrollbars=yes,resizable=yes");if(!$){me.error("Popup was blocked. Please allow popups for this site and try again."),r(!1);return}const V=Z=>{var J,Y;Z.origin===window.location.origin&&(((J=Z.data)==null?void 0:J.type)==="canva-oauth-success"?(window.removeEventListener("message",V),me.success("Canva connected successfully!"),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1)):((Y=Z.data)==null?void 0:Y.type)==="canva-oauth-error"&&(window.removeEventListener("message",V),me.error("Canva connection failed: "+(Z.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",V);const ee=setInterval(()=>{$.closed&&(clearInterval(ee),window.removeEventListener("message",V),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(A){console.error("Canva connect error:",A);const I=(A==null?void 0:A.message)||"";I.includes("CANVA_CLIENT_ID")?me.error("Canva app credentials not configured yet."):me.error(I||"Failed to start Canva connection"),r(!1)}},b=Et({mutationFn:async C=>{var $;const{data:A}=await G.auth.getSession(),I=($=A==null?void 0:A.session)==null?void 0:$.access_token;if(!I)throw new Error("Not authenticated");const U=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:C})}),q=await U.json();if(!U.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:C=>{me.error(C.message||"Failed to disconnect Canva")}}),N=Et({mutationFn:async C=>{const{error:A}=await G.from("canva_brokerage_folders").insert({brokerage_id:C.brokerage_id,folder_id:C.folder_id.trim(),folder_name:C.folder_name.trim(),folder_type:C.folder_type,description:C.description.trim()||null,sort_order:(y==null?void 0:y.length)||0});if(A)throw A},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),me.success("Folder added"),l(!1),d({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""})},onError:()=>me.error("Failed to add folder")}),w=Et({mutationFn:async C=>{const{error:A}=await G.from("canva_brokerage_folders").delete().eq("id",C);if(A)throw A},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),me.success("Folder removed")},onError:()=>me.error("Failed to remove folder")}),S=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-accent flex items-center justify-center",children:e.jsx(k9e,{})}),e.jsxs("div",{children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:["Canva Connect",S&&e.jsx(Ye,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(mr,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(Be,{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(si,{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(si,{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(si,{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"})]}),S?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(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Disconnect Canva?"}),e.jsx(vl,{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(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{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(Sm,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",y&&y.length>0&&e.jsx(Ye,{variant:"secondary",className:"text-xs",children:y.length})]}),n?e.jsx(lf,{className:"h-4 w-4"}):e.jsx(Fi,{className:"h-4 w-4"})]}),n&&e.jsxs("div",{className:"border-t p-3 space-y-2",children:[y&&y.length>0?y.map(C=>{var A,I;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50 text-sm",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:C.folder_name}),e.jsx(Ye,{variant:"outline",className:"text-xs shrink-0",children:((A=S9e.find(L=>L.value===C.folder_type))==null?void 0:A.label)||C.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(I=C.brokerages)==null?void 0:I.name," · ID: ",e.jsx("span",{className:"font-mono",children:C.folder_id})]})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive shrink-0 ml-2",onClick:()=>w.mutate(C.id),children:e.jsx(Sr,{className:"h-3.5 w-3.5"})})]},C.id)}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No folders mapped yet"}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5 mt-1",onClick:()=>l(!0),children:[e.jsx(Bs,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:_,disabled:s||p,children:[s?e.jsx(to,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(k9e,{})}),"Connect Canva",e.jsx(ti,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Add Brokerage Folder Mapping"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Brokerage"}),e.jsxs(zs,{value:i.brokerage_id,onValueChange:C=>d(A=>({...A,brokerage_id:C})),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select a brokerage…"})}),e.jsx(Fs,{children:f==null?void 0:f.map(C=>e.jsx(yt,{value:C.id,children:C.name},C.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Canva Folder ID"}),e.jsx(Fe,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:C=>d(A=>({...A,folder_id:C.target.value}))}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Found in the Canva folder URL: canva.com/folder/",e.jsx("strong",{children:"FOLDER_ID"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Folder Display Name"}),e.jsx(Fe,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:C=>d(A=>({...A,folder_name:C.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{children:"Folder Type"}),e.jsxs(zs,{value:i.folder_type,onValueChange:C=>d(A=>({...A,folder_type:C})),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:S9e.map(C=>e.jsx(yt,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ge,{children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(Fe,{placeholder:"What's in this folder?",value:i.description,onChange:C=>d(A=>({...A,description:C.target.value}))})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>N.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||N.isPending,children:[N.isPending?e.jsx(to,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function qCs(){return e.jsx(Ls,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(qu,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx($Cs,{}),e.jsx(nct,{})]})})}const UCs={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 b6(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function VCs(){var ee,Z,J,Y,ce;const t=es(),[s,r]=k.useState("Test Push"),[n,a]=k.useState("Testing web push notification"),[o,l]=k.useState("/community"),[i,d]=k.useState(!1),[u,p]=k.useState(!1),[f,y]=k.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[_,b]=k.useState(null),[N,w]=k.useState(null),{data:S,isLoading:C}=ft({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:ae,error:ie}=await G.from("push_notification_settings").select("*").order("setting_key");if(ie)throw ie;return ae}}),{data:A,isLoading:I}=ft({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:ae,error:ie}=await G.from("push_subscriptions").select("*",{count:"exact",head:!0});if(ie)throw ie;return{totalSubscriptions:ae||0}}}),L=Et({mutationFn:async({settingKey:ae,isEnabled:ie})=>{const{error:le}=await G.from("push_notification_settings").update({is_enabled:ie}).eq("setting_key",ae);if(le)throw le},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),me.success("Notification setting updated")},onError:ae=>{me.error("Failed to update setting: "+ae.message)}}),O=k.useMemo(()=>{var ae,ie;return f.isSupported?`perm=${f.permission??"unknown"} · controller=${f.controllerPresent?"yes":"no"} · sw=${((ae=f.serviceWorker)==null?void 0:ae.activeState)??"unknown"} · sub=${(ie=f.subscription)!=null&&ie.endpoint?"yes":"no"}`:"Push not supported in this browser."},[f]);k.useEffect(()=>{let ae=!0;const ie=async()=>{var he,we,Ne,Ve,Te,Ae,ze;const fe="serviceWorker"in navigator&&"PushManager"in window,xe={isSupported:fe,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((he=navigator.serviceWorker)!=null&&he.controller)};if(!fe){ae&&y(xe);return}try{const{data:Ee,error:ve}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(ve)throw ve;xe.vapidPublicKey=Ee==null?void 0:Ee.vapidPublicKey;const Ue=(await navigator.serviceWorker.getRegistrations()).find(ye=>{var pe,Ge,tt;return(((pe=ye.active)==null?void 0:pe.scriptURL)||((Ge=ye.waiting)==null?void 0:Ge.scriptURL)||((tt=ye.installing)==null?void 0:tt.scriptURL)||"").includes("/sw.js")});if(Ue){xe.pushWorkerScriptUrl=((we=Ue.active)==null?void 0:we.scriptURL)||((Ne=Ue.waiting)==null?void 0:Ne.scriptURL)||((Ve=Ue.installing)==null?void 0:Ve.scriptURL),xe.serviceWorker={scope:Ue.scope,activeState:(Te=Ue.active)==null?void 0:Te.state};const ye=await Ue.pushManager.getSubscription();if(ye){const ct=ye.toJSON();xe.subscription={endpoint:ct.endpoint,p256dh:(Ae=ct.keys)==null?void 0:Ae.p256dh,auth:(ze=ct.keys)==null?void 0:ze.auth}}}}catch(Ee){xe.error=(Ee==null?void 0:Ee.message)||String(Ee)}ae&&y(xe)};ie();const le=window.setInterval(ie,4e3);return()=>{ae=!1,window.clearInterval(le)}},[]);const U=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(ae){me.error(`Local notification failed: ${(ae==null?void 0:ae.message)||String(ae)}`)}},q=async()=>{d(!0),b(null);try{const{data:ae,error:ie}=await G.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(ie)throw ie;b({sent:ae==null?void 0:ae.sent,failed:ae==null?void 0:ae.failed,expiredCleaned:ae==null?void 0:ae.expiredCleaned,vapidPublicKey:ae==null?void 0:ae.vapidPublicKey}),(ae==null?void 0:ae.sent)>0?me.success(`Test notification sent to ${ae.sent} subscriber(s)`):(ae==null?void 0:ae.failed)>0?me.warning(`Notification failed for ${ae.failed} subscriber(s). ${ae.expired||0} expired subscriptions cleaned up.`):me.info("No active subscriptions to send to")}catch(ae){console.error("Error sending test notification:",ae),b({error:(ae==null?void 0:ae.message)||String(ae)}),me.error("Failed to send test notification: "+(ae.message||"Unknown error"))}finally{d(!1)}},$=async()=>{p(!0),w(null);try{const{data:ae,error:ie}=await G.functions.invoke("generate-vapid-keys",{body:{}});if(ie)throw ie;const le=ae==null?void 0:ae.publicKey,fe=ae==null?void 0:ae.privateKey;if(!le||!fe)throw new Error("generate-vapid-keys did not return keys");w({publicKey:le,privateKey:fe}),me.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(ae){console.error("Error generating VAPID keys:",ae),me.error("Failed to generate VAPID keys: "+((ae==null?void 0:ae.message)||"Unknown error"))}finally{p(!1)}},V=Et({mutationFn:async()=>{const{error:ae}=await G.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(ae)throw ae},onSuccess:()=>{me.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:ae=>{me.error("Failed to clear subscriptions: "+ae.message)}});return e.jsx(Ls,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(mr,{children:"Current active push notification subscriptions"})]}),e.jsx(Be,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-4xl font-bold",children:I?"...":(A==null?void 0:A.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(So,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(mr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(Be,{children:C?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:S==null?void 0:S.map(ae=>{const ie=UCs[ae.setting_key]||{label:ae.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:ie.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ie.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ae.description})]})]}),e.jsx(Lr,{checked:ae.is_enabled,onCheckedChange:le=>L.mutate({settingKey:ae.setting_key,isEnabled:le}),disabled:L.isPending})]},ae.id)})})})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Nm,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(mr,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Client push debug"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:O}),f.error&&e.jsx("div",{className:"mt-2 text-destructive",children:f.error}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Backend VAPID public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:f.vapidPublicKey?b6(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: ",(ee=f.serviceWorker)!=null&&ee.scope?b6(f.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((Z=f.serviceWorker)==null?void 0:Z.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: ",(J=f.subscription)!=null&&J.endpoint?b6(f.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(Y=f.subscription)!=null&&Y.p256dh?b6(f.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(ce=f.subscription)!=null&&ce.auth?b6(f.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(K,{variant:"outline",onClick:U,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(ge,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(Fe,{id:"test-title",value:s,onChange:ae=>r(ae.target.value),placeholder:"Enter notification title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"test-body",children:"Notification Body"}),e.jsx(_r,{id:"test-body",value:n,onChange:ae=>a(ae.target.value),placeholder:"Enter notification message",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"test-url",children:"Click URL (optional)"}),e.jsx(Fe,{id:"test-url",value:o,onChange:ae=>l(ae.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(Nn,{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(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(yr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(mr,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(Be,{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(yr,{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:$,disabled:u,children:u?"Generating…":"Generate VAPID keys"})}),N&&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:N.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:N.privateKey})]})]})]})]})]})]})})}function HCs(){const{toast:t}=va(),[s,r]=k.useState([]),[n,a]=k.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=k.useState(!0),{sortKey:i,sortDirection:d,handleSort:u,sortData:p}=rO("presentation_count","desc"),f=p(s,{name:b=>{var N;return((N=b.name)==null?void 0:N.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});k.useEffect(()=>{y()},[]);const y=async()=>{try{l(!0);const{data:b,error:N}=await G.rpc("get_admin_presentation_stats");if(N)throw N;if(!b||b.length===0){l(!1);return}const w=b.map(L=>L.owner_user_id),{data:S,error:C}=await G.from("profiles").select("id, name, email, avatar_url").in("id",w);if(C)throw C;const A=new Map((S==null?void 0:S.map(L=>[L.id,L]))||[]),I=b.map(L=>{const O=A.get(L.owner_user_id);return{owner_user_id:L.owner_user_id,name:(O==null?void 0:O.name)||"Unknown",email:(O==null?void 0:O.email)||"",avatar_url:(O==null?void 0:O.avatar_url)||null,presentation_count:Number(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,O)=>L+O.presentation_count,0),totalViews:I.reduce((L,O)=>L+O.total_views,0),totalLeads:I.reduce((L,O)=>L+O.total_leads,0),totalCtaClicks:I.reduce((L,O)=>L+O.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:cr,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:Rg,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:jn,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:il,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:Cm,color:"text-rose-600"}];return e.jsx(Ls,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:b.label}),e.jsx(b.icon,{className:`h-4 w-4 ${b.color}`})]}),e.jsx(Be,{children:o?e.jsx(Ss,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:b.value.toLocaleString()})})]},b.label))}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Yo,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Be,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((b,N)=>e.jsx(Ss,{className:"h-12 w-full"},N))}):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(As,{children:[e.jsx(Ko,{sortKey:"name",currentSortKey:i,currentDirection:d,onSort:u,children:"Agent"}),e.jsx(Ko,{sortKey:"presentations",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Presentations"}),e.jsx(Ko,{sortKey:"views",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Views"}),e.jsx(Ko,{sortKey:"leads",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Leads"}),e.jsx(Ko,{sortKey:"cta_clicks",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"CTA Clicks"}),e.jsx(Ko,{sortKey:"conversion",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Conversion"})]})}),e.jsx(Pn,{children:f.map(b=>{var w,S;const N=b.total_views>0?(b.total_leads/b.total_views*100).toFixed(1):"0.0";return e.jsxs(As,{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:((S=(w=b.name)==null?void 0:w.charAt(0))==null?void 0:S.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(Ye,{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(N)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[N,"%"]})})]},b.owner_user_id)})})]})})]})]})})}function GCs(){const{toast:t}=va(),[s,r]=k.useState([]),[n,a]=k.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=k.useState(!0);k.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:u,error:p}=await G.rpc("get_admin_guest_book_stats");if(p)throw p;if(!u||u.length===0){l(!1);return}const f=u.map(w=>w.agent_id),{data: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(w=>[w.id,w]))||[]),N=u.map(w=>{const S=b.get(w.agent_id);return{agent_id:w.agent_id,name:(S==null?void 0:S.name)||"Unknown",email:(S==null?void 0:S.email)||"",avatar_url:(S==null?void 0:S.avatar_url)||null,open_house_count:Number(w.open_house_count),total_visitors:Number(w.total_visitors),total_leads:Number(w.total_leads),active_count:Number(w.active_count)}});N.sort((w,S)=>S.total_visitors-w.total_visitors),r(N),a({totalOpenHouses:N.reduce((w,S)=>w+S.open_house_count,0),totalVisitors:N.reduce((w,S)=>w+S.total_visitors,0),totalLeads:N.reduce((w,S)=>w+S.total_leads,0),activeOpenHouses:N.reduce((w,S)=>w+S.active_count,0),agentsUsing:N.length})}catch(u){console.error("Error loading guest book stats:",u),t({title:"Error",description:"Failed to load guest book analytics",variant:"destructive"})}finally{l(!1)}},d=[{label:"Agents Using",value:n.agentsUsing,icon:cr,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:Mn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:si,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:jn,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:il,color:"text-rose-600"}];return e.jsx(Ls,{title:"Guest Book Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Guest Book Analytics"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track open house sign-in usage and lead generation across all agents"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:d.map(u=>e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(Be,{children:o?e.jsx(Ss,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:u.value.toLocaleString()})})]},u.label))}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Yo,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Be,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((u,p)=>e.jsx(Ss,{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(As,{children:[e.jsx(Nt,{children:"Agent"}),e.jsx(Nt,{className:"text-center",children:"Open Houses"}),e.jsx(Nt,{className:"text-center",children:"Active"}),e.jsx(Nt,{className:"text-center",children:"Visitors"}),e.jsx(Nt,{className:"text-center",children:"Leads"}),e.jsx(Nt,{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(As,{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(Ye,{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(Ye,{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 WCs(){const[t]=Sc(),s=br(),[r,n]=k.useState("loading"),[a,o]=k.useState("Processing connection...");return k.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),me.error("Failed to connect: "+(u||d));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(Ie,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(ps,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(si,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(Ql,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(Ft,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(mr,{children:a})]}),e.jsx(Be,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function KCs(){const t=es(),[s,r]=k.useState(""),[n,a]=k.useState(""),[o,l]=k.useState([]),i=k.useRef(null),{data:d,isLoading:u}=ft({queryKey:["prospect-emails"],queryFn:async()=>{const{data:w,error:S}=await G.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(S)throw S;return w}}),p={total:(d==null?void 0:d.length)||0,sent:(d==null?void 0:d.filter(w=>w.status==="sent").length)||0,converted:(d==null?void 0:d.filter(w=>w.status==="converted").length)||0,conversionRate:d!=null&&d.length?Math.round(d.filter(w=>w.status==="converted").length/d.length*100):0},f=Et({mutationFn:async w=>{const{data:S,error:C}=await G.functions.invoke("send-prospect-email",{body:{emails:w}});if(C)throw C;return S},onSuccess:w=>{t.invalidateQueries({queryKey:["prospect-emails"]}),me.success(`${w.sent} email${w.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:w=>{me.error("Failed to send: "+w.message)}}),y=Et({mutationFn:async()=>{var A,I;const{data:{user:w}}=await G.auth.getUser();if(!(w!=null&&w.email))throw new Error("Could not get your email");const{data:S,error:C}=await G.functions.invoke("send-prospect-email",{body:{emails:[{email:w.email,first_name:(I=(A=w.user_metadata)==null?void 0:A.name)==null?void 0:I.split(" ")[0]}],test_mode:!0}});if(C)throw C;return S},onSuccess:()=>{me.success("Test email sent to your inbox!")},onError:w=>{me.error("Failed to send test: "+w.message)}}),_=()=>{if(!s.trim()){me.error("Please enter an email address");return}if(d==null?void 0:d.find(S=>S.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=w=>{var A;const S=(A=w.target.files)==null?void 0:A[0];if(!S)return;const C=new FileReader;C.onload=I=>{var $,V;const O=(($=I.target)==null?void 0:$.result).split(` `).filter(ee=>ee.trim()),U=[],q=(V=O[0])!=null&&V.toLowerCase().includes("email")?1:0;for(let ee=q;eece.trim().replace(/"/g,"")),J=Z[0],Y=Z[1];J&&J.includes("@")&&U.push({email:J,first_name:Y||void 0})}l(U),me.success(`${U.length} entries loaded from CSV`)},C.readAsText(S),i.current&&(i.current.value="")},N=()=>{if(o.length===0){me.error("No entries to send");return}const w=new Set((d==null?void 0:d.map(C=>C.email.toLowerCase()))||[]),S=o.filter(C=>!w.has(C.email.toLowerCase()));if(S.length===0){me.error("All emails have already been prospected");return}S.lengthy.mutate(),disabled:y.isPending,className:"gap-2 ml-4 shrink-0",children:[y.isPending?e.jsx(ps,{className:"h-3 w-3 animate-spin"}):e.jsx(tr,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx(Be,{children:e.jsxs(ta,{defaultValue:"single",children:[e.jsxs(Qn,{className:"mb-4",children:[e.jsxs(ls,{value:"single",children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(ls,{value:"bulk",children:[e.jsx(Da,{className:"h-4 w-4 mr-2"}),"Bulk CSV"]})]}),e.jsx(js,{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(ge,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),e.jsx(Fe,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:s,onChange:w=>r(w.target.value),onKeyDown:w=>w.key==="Enter"&&_()})]}),e.jsxs("div",{className:"w-full sm:w-48",children:[e.jsx(ge,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(Fe,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:w=>a(w.target.value),onKeyDown:w=>w.key==="Enter"&&_()})]}),e.jsxs(K,{onClick:_,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(Nn,{className:"h-4 w-4"}),"Send Invite"]})]})}),e.jsx(js,{value:"bulk",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{ref:i,type:"file",accept:".csv",onChange:b,className:"hidden"}),e.jsxs(K,{variant:"outline",onClick:()=>{var w;return(w=i.current)==null?void 0:w.click()},className:"gap-2",children:[e.jsx(mn,{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(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(cr,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(Sr,{className:"h-4 w-4"}),"Clear"]})]}),e.jsxs("div",{className:"max-h-40 overflow-y-auto border rounded-lg p-3 bg-muted/30 text-sm font-mono space-y-1",children:[o.slice(0,20).map((w,S)=>e.jsxs("div",{className:"text-muted-foreground",children:[w.email,w.first_name?` — ${w.first_name}`:""]},S)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(K,{onClick:N,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(Nn,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(mr,{children:"Track all sent invitations and their conversion status"})]}),e.jsx(Be,{children:u?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((w,S)=>e.jsx(Ss,{className:"h-12 w-full"},S))}):d&&d.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Email"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Sent"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Converted"})]})}),e.jsx("tbody",{children:d.map(w=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-3 px-4 text-sm font-medium text-foreground",children:w.email}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.first_name||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:gs(new Date(w.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:w.status==="converted"?e.jsxs(Ye,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(rn,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.converted_at?gs(new Date(w.converted_at),"MMM d, yyyy"):"—"})]},w.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Oh,{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 PO(t){const s=es(),{toast:r}=va(),n=ft({queryKey:["recruit-stages",t],queryFn:async()=>{if(!t)return[];const{data:d,error:u}=await G.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(u)throw u;return d},enabled:!!t}),a=ft({queryKey:["recruit-prospects",t],queryFn:async()=>{if(!t)return[];const d=1e3;let u=[],p=0,f=!0;for(;f;){const{data:y,error:_}=await G.from("recruit_prospects").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1}).range(p,p+d-1);if(_)throw _;u=u.concat(y),f=y.length===d,p+=d}return u},enabled:!!t}),o=Et({mutationFn:async d=>{const{data:{user:u}}=await G.auth.getUser();if(!u)throw new Error("Not authenticated");const p={first_name:d.first_name||"",last_name:d.last_name||null,email:d.email||null,phone:d.phone||null,current_brokerage:d.current_brokerage||null,license_number:d.license_number||null,experience_years:d.experience_years??null,annual_production:d.annual_production||null,source:d.source||"manual",notes:d.notes||null,stage_id:d.stage_id||null,brokerage_id:t,created_by:u.id,address:d.address||null,city:d.city||null,state:d.state||null,zip_code:d.zip_code||null,last_year_volume:d.last_year_volume||null,last_year_transactions:d.last_year_transactions??null,avg_sale_price:d.avg_sale_price||null,specialties:d.specialties||null,linkedin_url:d.linkedin_url||null,website_url:d.website_url||null,instagram_handle:d.instagram_handle||null,facebook_url:d.facebook_url||null,birthday:d.birthday||null,spouse_name:d.spouse_name||null,interests:d.interests||null,referred_by:d.referred_by||null},{data:f,error: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:d=>r({title:"Error",description:d.message,variant:"destructive"})}),l=Et({mutationFn:async({id:d,...u})=>{const{data:p,error:f}=await G.from("recruit_prospects").update({...u,updated_at:new Date().toISOString()}).eq("id",d).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),i=Et({mutationFn:async d=>{const{error:u}=await G.from("recruit_prospects").delete().eq("id",d);if(u)throw u},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect removed"})}});return{stages:n.data||[],prospects:a.data||[],isLoading:n.isLoading||a.isLoading,addProspect:o,updateProspect:l,deleteProspect:i}}function ZCs(t){const s=es(),{toast:r}=va(),n=ft({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=Et({mutationFn:async o=>{const{data:{user:l}}=await G.auth.getUser();if(!l)throw new Error("Not authenticated");const{data:i,error:d}=await G.from("recruit_activities").insert({...o,created_by:l.id}).select().single();if(d)throw d;return i},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-activities",t]}),r({title:"Activity logged"})},onError:o=>r({title:"Error",description:o.message,variant:"destructive"})});return{activities:n.data||[],isLoading:n.isLoading,addActivity:a}}const C9e=(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 dct({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=k.useState(C9e(n,r)),d=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(C9e(n,r)),s(!1)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs(ta,{defaultValue:"basic",className:"w-full",children:[e.jsxs(Qn,{className:"grid w-full grid-cols-4",children:[e.jsx(ls,{value:"basic",children:"Basic Info"}),e.jsx(ls,{value:"production",children:"Production"}),e.jsx(ls,{value:"social",children:"Social & Web"}),e.jsx(ls,{value:"personal",children:"Personal"})]}),e.jsxs(js,{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(ge,{children:"First Name *"}),e.jsx(Fe,{required:!0,value:l.first_name,onChange:d("first_name")})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Last Name"}),e.jsx(Fe,{value:l.last_name,onChange:d("last_name")})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Email"}),e.jsx(Fe,{type:"email",value:l.email,onChange:d("email")})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Phone"}),e.jsx(Fe,{value:l.phone,onChange:d("phone")})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Current Brokerage"}),e.jsx(Fe,{value:l.current_brokerage,onChange:d("current_brokerage")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"License #"}),e.jsx(Fe,{value:l.license_number,onChange:d("license_number")})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Experience (years)"}),e.jsx(Fe,{type:"number",min:"0",value:l.experience_years,onChange:d("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Address"}),e.jsx(Fe,{placeholder:"Street address",value:l.address,onChange:d("address")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"City"}),e.jsx(Fe,{value:l.city,onChange:d("city")})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"State"}),e.jsx(Fe,{value:l.state,onChange:d("state")})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Zip"}),e.jsx(Fe,{value:l.zip_code,onChange:d("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Pipeline Stage"}),e.jsxs(zs,{value:l.stage_id,onValueChange:p=>i(f=>({...f,stage_id:p})),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:r.map(p=>e.jsx(yt,{value:p.id,children:p.name},p.id))})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Referred By"}),e.jsx(Fe,{placeholder:"Who referred this prospect?",value:l.referred_by,onChange:d("referred_by")})]})]}),e.jsxs(js,{value:"production",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Annual Production Volume"}),e.jsx(Fe,{placeholder:"e.g. $5M, 20 transactions",value:l.annual_production,onChange:d("annual_production")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Last Year Volume"}),e.jsx(Fe,{placeholder:"e.g. $8.2M",value:l.last_year_volume,onChange:d("last_year_volume")})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Last Year Transactions"}),e.jsx(Fe,{type:"number",min:"0",placeholder:"e.g. 24",value:l.last_year_transactions,onChange:d("last_year_transactions")})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Avg Sale Price"}),e.jsx(Fe,{placeholder:"e.g. $350K",value:l.avg_sale_price,onChange:d("avg_sale_price")})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Specialties / Niche"}),e.jsx(Fe,{placeholder:"e.g. Luxury, First-time buyers, Investment",value:l.specialties,onChange:d("specialties")})]})]}),e.jsxs(js,{value:"social",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"LinkedIn URL"}),e.jsx(Fe,{type:"url",placeholder:"https://linkedin.com/in/...",value:l.linkedin_url,onChange:d("linkedin_url")})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Website URL"}),e.jsx(Fe,{type:"url",placeholder:"https://...",value:l.website_url,onChange:d("website_url")})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Instagram Handle"}),e.jsx(Fe,{placeholder:"@handle",value:l.instagram_handle,onChange:d("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Facebook URL"}),e.jsx(Fe,{type:"url",placeholder:"https://facebook.com/...",value:l.facebook_url,onChange:d("facebook_url")})]})]}),e.jsxs(js,{value:"personal",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Birthday"}),e.jsx(Fe,{type:"date",value:l.birthday,onChange:d("birthday")})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Spouse / Partner Name"}),e.jsx(Fe,{value:l.spouse_name,onChange:d("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Interests / Hobbies"}),e.jsx(Fe,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:d("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Notes"}),e.jsx(_r,{value:l.notes,onChange:d("notes"),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:o,children:"Add Prospect"})]})]})]})})}const r2e=[{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 YCs(t){return ft({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 XCs(t){return ft({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 uct(){const t=es(),{toast:s}=va();return Et({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 hct(){const t=es();return Et({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 mct(t){return ft({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 QCs(){const t=es(),{toast:s}=va();return Et({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 JCs(){const t=es();return Et({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 e3s({prospectId:t,prospectName:s,brokerageId:r}){var $;const{data:n=[],isLoading:a}=XCs(t),{data:o=[]}=mct(r),l=uct(),i=Ew(),d=hct(),[u,p]=k.useState("idle"),[f,y]=k.useState(0),[_,b]=k.useState(0),[N,w]=k.useState(""),[S,C]=k.useState(""),[A,I]=k.useState(!1),L=(($=o.find(V=>V.id===N))==null?void 0:$.script_text)||"",O=()=>{p("idle"),y(0),b(0),w(""),C("")},U=k.useCallback(async(V,ee)=>{p("uploading");try{const Z=`Recruiting: ${s}`,{videoId:J,libraryId:Y}=await wE(Z),{uploadUrl:ce,apiKey:ae}=await jE(J),ie=new XMLHttpRequest;ie.upload.onprogress=Te=>{Te.lengthComputable&&y(Te.loaded/Te.total*100)},await new Promise((Te,Ae)=>{ie.onload=()=>ie.status>=200&&ie.status<300?Te():Ae(new Error("Upload failed")),ie.onerror=()=>Ae(new Error("Upload failed")),ie.open("PUT",ce),ie.setRequestHeader("AccessKey",ae),ie.send(V)}),p("processing");let le=0;const fe=Date.now(),xe=9e4,he=`https://iframe.mediadelivery.net/embed/${Y}/${J}`;for(;le<4&&(await new Promise(Ae=>setTimeout(Ae,3e3)),!(Date.now()-fe>xe));){const Te=await ow(J);if(le=Te.status,b(Te.encodeProgress||0),le===5||le===6)throw new Error("Video processing failed")}const we=await ow(J),Ne=(we.storageSize||V.size)/(1024*1024),Ve=await i.mutateAsync({bunny_video_id:J,playback_url:we.directPlayUrl||he,thumbnail_url:we.thumbnailUrl,preview_url:we.previewUrl||null,duration_seconds:we.length||ee,file_size_mb:Ne,title:Z,status:le>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:Ve.id,brokerage_id:r,message:S||void 0}),p("done"),me.success("Video recorded and linked to prospect!"),setTimeout(()=>{I(!1),O()},1500)}catch(Z){me.error(Z.message||"Failed to upload video"),p("record")}},[t,s,r,S,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(hn,{className:"h-4 w-4"})," Video Outreach"]}),e.jsxs(fs,{open:A,onOpenChange:V=>{!V&&(u==="uploading"||u==="processing")||(I(V),V||O())},children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>p("script"),children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"})," Record Video"]})}),e.jsxs(ms,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsxs(bs,{children:["Record Video for ",s]})}),u==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Choose a Script (optional)"}),e.jsxs(zs,{value:N,onValueChange:w,children:[e.jsx(Os,{className:"mt-1",children:e.jsx(qs,{placeholder:"No script — speak freely"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"none",children:"No script"}),o.map(V=>{var ee;return e.jsx(yt,{value:V.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[V.title,e.jsx(Ye,{variant:"outline",className:"text-[9px] ml-1",children:(ee=r2e.find(Z=>Z.value===V.category))==null?void 0:ee.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(ge,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(_r,{value:S,onChange:V=>C(V.target.value),placeholder:`Hi ${s.split(" ")[0]}, I'd love to chat about what we're building here...`,rows:3,className:"mt-1"})]}),e.jsxs(K,{onClick:()=>p("record"),className:"w-full",children:[e.jsx(hn,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),u==="record"&&e.jsx(AO,{maxDurationSeconds:600,onRecordingComplete:U,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(pi,{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(pi,{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(Co,{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 ee,Z;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:(ee=V.video)!=null&&ee.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(hn,{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:((Z=V.video)==null?void 0:Z.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[V.view_count>0?e.jsxs(Ye,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(jn,{className:"h-2.5 w-2.5 mr-0.5"}),V.view_count]}):V.sent_at?e.jsxs(Ye,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(Nn,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(Ye,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(rn,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:gs(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(Ya,{className:"h-3 w-3"})}),!V.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>d.mutate({id:V.id,sent_via:"email"}),children:e.jsx(Nn,{className:"h-3 w-3"})})]})]},V.id)})})]})}function t3s(t){return ft({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("recruit_campaign_sends").select("id, prospect_id, subject, email_number, status, sent_at, opened_at, clicked_at, error_message, created_at").eq("prospect_id",t).neq("status","failed").order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}const M9e=[{value:"call",label:"Phone Call",icon:Tn},{value:"email",label:"Email",icon:tr},{value:"text",label:"Text Message",icon:Si},{value:"meeting",label:"Meeting",icon:nn},{value:"note",label:"Note",icon:mn},{value:"campaign_email",label:"Campaign Email",icon:Nn}];function qp({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 A9({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(Kr,{className:"h-3 w-3 opacity-50"})]}):null}function Gl({label:t,value:s,onChange:r,type:n="text",placeholder:a}){return e.jsxs("div",{children:[e.jsx(ge,{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 pct({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:d}=ZCs((t==null?void 0:t.id)||null),{data:u=[]}=t3s((t==null?void 0:t.id)||null),[p,f]=k.useState({type:"note",title:"",description:""}),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState({});if(!t)return null;const C=()=>{var Z,J;S({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:((Z=t.experience_years)==null?void 0:Z.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:((J=t.last_year_transactions)==null?void 0:J.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||""}),N(!0)},A=()=>{const Z={id:t.id};for(const[J,Y]of Object.entries(w))J==="experience_years"||J==="last_year_transactions"?Z[J]=Y?parseInt(Y):null:Z[J]=Y||null;o(Z),N(!1)},I=()=>N(!1),L=Z=>J=>S(Y=>({...Y,[Z]:J})),O=()=>{p.title.trim()&&(d.mutate({prospect_id:t.id,activity_type:p.type,title:p.title,description:p.description||null}),f({type:"note",title:"",description:""}),_(!1))},U=s.find(Z=>Z.id===t.stage_id),q=t.address||t.city||t.state,$=t.last_year_volume||t.last_year_transactions||t.avg_sale_price||t.specialties||t.annual_production,V=t.linkedin_url||t.website_url||t.instagram_handle||t.facebook_url,ee=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(ZA,{open:n,onOpenChange:Z=>{Z||N(!1),a(Z)},children:e.jsx(CC,{className:"w-full sm:max-w-lg p-0",children:e.jsx(di,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(YA,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(XA,{className:"text-xl",children:[t.first_name," ",t.last_name]}),U&&e.jsx(Ye,{variant:"outline",style:{borderColor:U.color,color:U.color},className:"mt-1",children:U.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[b?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:I,children:e.jsx(Sr,{className:"h-4 w-4"})}),e.jsx(K,{variant:"default",size:"icon",onClick:A,children:e.jsx(wc,{className:"h-4 w-4"})})]}):e.jsx(K,{variant:"ghost",size:"icon",onClick:C,title:"Edit prospect",children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsxs(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Delete prospect?"}),e.jsx(vl,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:()=>{l(t.id),a(!1)},children:"Delete"})]})]})]})]})]})}),!b&&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(tr,{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(Tn,{className:"h-3.5 w-3.5"})," ",t.phone]}),q&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(La,{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(ge,{className:"text-xs text-muted-foreground",children:"Move to Stage"}),e.jsxs(zs,{value:t.stage_id||"",onValueChange:Z=>o({id:t.id,stage_id:Z}),children:[e.jsx(Os,{className:"mt-1",children:e.jsx(qs,{})}),e.jsx(Fs,{children:s.map(Z=>e.jsx(yt,{value:Z.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:Z.color}}),Z.name]})},Z.id))})]})]}),e.jsxs(ta,{defaultValue:"details",className:"w-full",children:[e.jsxs(Qn,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(ls,{value:"details",className:"text-xs",children:"Details"}),e.jsx(ls,{value:"production",className:"text-xs",children:"Production"}),e.jsx(ls,{value:"social",className:"text-xs",children:"Social"}),e.jsx(ls,{value:"personal",className:"text-xs",children:"Personal"})]}),b?e.jsxs(e.Fragment,{children:[e.jsxs(js,{value:"details",className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Gl,{label:"First Name",value:w.first_name,onChange:L("first_name")}),e.jsx(Gl,{label:"Last Name",value:w.last_name,onChange:L("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Gl,{label:"Email",value:w.email,onChange:L("email"),type:"email"}),e.jsx(Gl,{label:"Phone",value:w.phone,onChange:L("phone")})]}),e.jsx(Gl,{label:"Current Brokerage",value:w.current_brokerage,onChange:L("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Gl,{label:"License #",value:w.license_number,onChange:L("license_number")}),e.jsx(Gl,{label:"Experience (years)",value:w.experience_years,onChange:L("experience_years"),type:"number"})]}),e.jsx(Gl,{label:"Address",value:w.address,onChange:L("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Gl,{label:"City",value:w.city,onChange:L("city")}),e.jsx(Gl,{label:"State",value:w.state,onChange:L("state")}),e.jsx(Gl,{label:"Zip",value:w.zip_code,onChange:L("zip_code")})]}),e.jsx(Gl,{label:"Source",value:w.source,onChange:L("source")}),e.jsx(Gl,{label:"Referred By",value:w.referred_by,onChange:L("referred_by")}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Notes"}),e.jsx(_r,{value:w.notes,onChange:Z=>S(J=>({...J,notes:Z.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(js,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(Gl,{label:"Annual Production",value:w.annual_production,onChange:L("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Gl,{label:"Last Year Volume",value:w.last_year_volume,onChange:L("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(Gl,{label:"Last Year Transactions",value:w.last_year_transactions,onChange:L("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(Gl,{label:"Avg Sale Price",value:w.avg_sale_price,onChange:L("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(Gl,{label:"Specialties / Niche",value:w.specialties,onChange:L("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(js,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(Gl,{label:"LinkedIn URL",value:w.linkedin_url,onChange:L("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(Gl,{label:"Website URL",value:w.website_url,onChange:L("website_url"),type:"url",placeholder:"https://..."}),e.jsx(Gl,{label:"Instagram Handle",value:w.instagram_handle,onChange:L("instagram_handle"),placeholder:"@handle"}),e.jsx(Gl,{label:"Facebook URL",value:w.facebook_url,onChange:L("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(js,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(Gl,{label:"Birthday",value:w.birthday,onChange:L("birthday"),type:"date"}),e.jsx(Gl,{label:"Spouse / Partner",value:w.spouse_name,onChange:L("spouse_name")}),e.jsx(Gl,{label:"Interests / Hobbies",value:w.interests,onChange:L("interests"),placeholder:"Golf, travel, community events..."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(js,{value:"details",className:"mt-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(qp,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx(qp,{label:"License #",value:t.license_number}),e.jsx(qp,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx(qp,{label:"Referred By",value:t.referred_by}),e.jsx(qp,{label:"Source",value:t.source})]}),t.notes&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ge,{className:"text-xs text-muted-foreground",children:"Notes"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.notes})]})]}),e.jsx(js,{value:"production",className:"mt-3",children:$?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(qp,{label:"Annual Production",value:t.annual_production}),e.jsx(qp,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx(qp,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx(qp,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx(qp,{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(js,{value:"social",className:"mt-3",children:V?e.jsxs("div",{className:"space-y-2",children:[e.jsx(A9,{label:"LinkedIn",url:t.linkedin_url,icon:fp}),e.jsx(A9,{label:"Website",url:t.website_url,icon:gd}),t.instagram_handle&&e.jsx(A9,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:hu}),e.jsx(A9,{label:"Facebook",url:t.facebook_url,icon:du})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No social profiles added yet"})}),e.jsx(js,{value:"personal",className:"mt-3",children:ee?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(qp,{label:"Birthday",value:t.birthday?gs(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:Vi}),e.jsx(qp,{label:"Spouse / Partner",value:t.spouse_name,icon:Za}),e.jsx("div",{className:"col-span-2",children:e.jsx(qp,{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(e3s,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(jo,{}),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),children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"})," Log Activity"]})]}),y&&e.jsxs("div",{className:"border rounded-lg p-3 mb-4 space-y-3 bg-muted/30",children:[e.jsxs(zs,{value:p.type,onValueChange:Z=>f(J=>({...J,type:Z})),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:M9e.map(Z=>e.jsx(yt,{value:Z.value,children:Z.label},Z.value))})]}),e.jsx(Fe,{placeholder:"Subject / Title",value:p.title,onChange:Z=>f(J=>({...J,title:Z.target.value}))}),e.jsx(_r,{placeholder:"Details (optional)",value:p.description,onChange:Z=>f(J=>({...J,description:Z.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{size:"sm",onClick:O,disabled:!p.title.trim(),children:"Save"})]})]}),e.jsx("div",{className:"space-y-3",children:(()=>{const Z=[...i.map(J=>({type:"manual",data:J,date:J.created_at})),...u.map(J=>({type:"campaign_email",data:J,date:J.sent_at||J.created_at}))].sort((J,Y)=>new Date(Y.date).getTime()-new Date(J.date).getTime());return Z.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"}):Z.map(J=>{if(J.type==="manual"){const ce=J.data,ae=M9e.find(le=>le.value===ce.activity_type),ie=(ae==null?void 0:ae.icon)||mn;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(ie,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",children:ce.title}),ce.description&&e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:ce.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:gs(new Date(ce.created_at),"MMM d, yyyy h:mm a")})]})]},`activity-${ce.id}`)}const Y=J.data;return e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("div",{className:"h-7 w-7 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Nn,{className:"h-3.5 w-3.5 text-primary"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"font-medium",children:["Campaign Email #",Y.email_number]}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:Y.subject}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:[Y.status==="failed"?e.jsx(Ye,{variant:"destructive",className:"text-[10px] px-1.5 py-0 h-4",children:"Failed"}):e.jsxs(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-green-500 text-green-600",children:[e.jsx(Nn,{className:"h-2.5 w-2.5 mr-0.5"})," Sent"]}),Y.opened_at?e.jsxs(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-blue-500 text-blue-600",children:[e.jsx(jn,{className:"h-2.5 w-2.5 mr-0.5"})," Opened ",gs(new Date(Y.opened_at),"MMM d, h:mm a")]}):Y.status!=="failed"?e.jsx(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 text-muted-foreground",children:"Not opened"}):null,Y.clicked_at&&e.jsxs(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-purple-500 text-purple-600",children:[e.jsx(sh,{className:"h-2.5 w-2.5 mr-0.5"})," Clicked ",gs(new Date(Y.clicked_at),"MMM d, h:mm a")]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:gs(new Date(Y.sent_at||Y.created_at),"MMM d, yyyy h:mm a")})]})]},`send-${Y.id}`)})})()})]})]})})})})}const s3s=["first_name","last_name","email","phone","current_brokerage","license_number","experience_years","annual_production","notes","address","city","state","zip_code","last_year_volume","last_year_transactions","avg_sale_price","linkedin_url","website_url","specialties","referred_by"];function fct({open:t,onOpenChange:s,brokerageId:r,stages:n}){var V;const{toast:a}=va(),o=es(),l=k.useRef(null),[i,d]=k.useState([]),[u,p]=k.useState([]),[f,y]=k.useState({}),[_,b]=k.useState(((V=n[0])==null?void 0:V.id)||""),[N,w]=k.useState(!1),[S,C]=k.useState("upload"),[A,I]=k.useState(0),L=()=>{d([]),p([]),y({}),C("upload"),I(0)},O=ee=>{var Y;const Z=(Y=ee.target.files)==null?void 0:Y[0];if(!Z)return;const J=new FileReader;J.onload=ce=>{var we;const ie=((we=ce.target)==null?void 0:we.result).split(/\r?\n/).filter(Ne=>Ne.trim());if(ie.length<2){a({title:"Invalid CSV",description:"File must have a header row and at least one data row",variant:"destructive"});return}const le=U(ie[0]);p(le);const fe={},xe=new Set;le.forEach((Ne,Ve)=>{const Te=Ne.toLowerCase().replace(/[^a-z0-9]/g,"");let Ae=null;/^firstname$/.test(Te)||Te==="first"?Ae="first_name":/^lastname$/.test(Te)||Te==="last"?Ae="last_name":/^email$/.test(Te)||Te==="emailaddress"?Ae="email":/^mobile$|^phone$|^cellphone$|^mobilephone$/.test(Te)?Ae="phone":/officename|currentbrokerage|brokerage|company/.test(Te)?Ae="current_brokerage":/membernumber|licensenumber|license/.test(Te)?Ae="license_number":/experienceyears|yearsexperience/.test(Te)?Ae="experience_years":/^totalvolume$|annualproduction/.test(Te)?Ae="annual_production":/^address$/.test(Te)?Ae="address":/^city$/.test(Te)?Ae="city":/^state$/.test(Te)?Ae="state":/^postalcode$|^zip$|^zipcode$/.test(Te)?Ae="zip_code":/listsidevolume|lastyearvolume/.test(Te)?Ae="last_year_volume":/^totalcount$|lastyeartransactions/.test(Te)?Ae="last_year_transactions":/avgsaleprice|averageprice/.test(Te)?Ae="avg_sale_price":/linkedin/.test(Te)?Ae="linkedin_url":/website/.test(Te)?Ae="website_url":/specialt/.test(Te)?Ae="specialties":/referr/.test(Te)?Ae="referred_by":/^notes$|^note$/.test(Te)&&(Ae="notes"),Ae&&!xe.has(Ae)&&(fe[String(Ve)]=Ae,xe.add(Ae))}),y(fe);const he=ie.slice(1).map(Ne=>{const Ve=U(Ne),Te={};return le.forEach((Ae,ze)=>{Te[String(ze)]=Ve[ze]||""}),Te});d(he),C("map")},J.readAsText(Z)},U=ee=>{const Z=[];let J="",Y=!1;for(const ce of ee)ce==='"'?Y=!Y:ce===","&&!Y?(Z.push(J.trim()),J=""):J+=ce;return Z.push(J.trim()),Z},q=async()=>{w(!0);try{const{data:{user:ee}}=await G.auth.getUser();if(!ee)throw new Error("Not authenticated");const Z=i.map(Y=>{const ce={brokerage_id:r,created_by:ee.id,stage_id:_,source:"csv_import",first_name:"Unknown"},ae=ce;return Object.entries(f).forEach(([ie,le])=>{var xe;const fe=(xe=Y[ie])==null?void 0:xe.trim();fe&&(le==="experience_years"||le==="last_year_transactions"?ae[le]=parseInt(fe.replace(/[^0-9.-]/g,""))||null:le==="annual_production"||le==="last_year_volume"||le==="avg_sale_price"?ae[le]=fe.replace(/[^0-9.$,.-]/g,""):ae[le]=fe)}),ce});let J=0;for(let Y=0;Y{const ee=`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`,Z=new Blob([ee],{type:"text/csv"}),J=URL.createObjectURL(Z),Y=document.createElement("a");Y.href=J,Y.download="recruit-prospects-template.csv",Y.click(),URL.revokeObjectURL(J)};return e.jsx(fs,{open:t,onOpenChange:ee=>{ee||L(),s(ee)},children:e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Import Prospects from CSV"})}),S==="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(Zv,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Upload a CSV file with prospect data"}),e.jsx("input",{ref:l,type:"file",accept:".csv",className:"hidden",onChange:O}),e.jsxs(K,{onClick:()=>{var ee;return(ee=l.current)==null?void 0:ee.click()},children:[e.jsx(Da,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(K,{variant:"link",className:"text-xs",onClick:$,children:"Download CSV template"})]}),S==="map"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," rows found"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"Import to stage:"}),e.jsxs(zs,{value:_,onValueChange:b,children:[e.jsx(Os,{className:"w-[180px]",children:e.jsx(qs,{})}),e.jsx(Fs,{children:n.map(ee=>e.jsx(yt,{value:ee.id,children:ee.name},ee.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{className:"w-[140px]",children:"CSV Column"}),e.jsx(Nt,{className:"w-[160px]",children:"Map To"}),e.jsx(Nt,{children:"Preview"})]})}),e.jsx(Pn,{children:u.map((ee,Z)=>{var J;return e.jsxs(As,{children:[e.jsx(dt,{className:"font-medium text-xs",children:ee}),e.jsx(dt,{children:e.jsxs(zs,{value:f[String(Z)]||"skip",onValueChange:Y=>y(ce=>({...ce,[String(Z)]:Y==="skip"?"":Y})),children:[e.jsx(Os,{className:"h-8 text-xs",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"skip",children:"— Skip —"}),s3s.map(Y=>e.jsx(yt,{value:Y,children:Y.replace(/_/g," ")},Y))]})]})}),e.jsx(dt,{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:((J=i[0])==null?void 0:J[String(Z)])||"—"})]},Z)})})]})}),!Object.values(f).includes("first_name")&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-sm",children:[e.jsx(co,{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:N||!Object.values(f).includes("first_name"),children:N?"Importing...":`Import ${i.length} Prospects`})]})]}),S==="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(ea,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[A," prospects imported successfully!"]}),e.jsx(K,{onClick:()=>{L(),s(!1)},children:"Close"})]})]})})}function xct({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=PO(t),[i,d]=k.useState(!1),[u,p]=k.useState(),[f,y]=k.useState(null),[_,b]=k.useState(!1),[N,w]=k.useState(!1),[S,C]=k.useState(null);if(n)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});const A=$=>r.filter(V=>V.stage_id===$),I=($,V)=>{C(V),$.dataTransfer.effectAllowed="move"},L=$=>{$.preventDefault(),$.dataTransfer.dropEffect="move"},O=($,V)=>{$.preventDefault(),S&&(o.mutate({id:S,stage_id:V}),C(null))},U=$=>{p($),d(!0)},q=$=>{y($),b(!0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.length," prospect",r.length!==1?"s":""]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>w(!0),children:[e.jsx(Da,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>{p(void 0),d(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(di,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map($=>{const V=A($.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:L,onDrop:ee=>O(ee,$.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:$.color}}),e.jsx("h3",{className:"font-semibold text-sm",children:$.name}),e.jsx(Ye,{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(Bs,{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(ee=>e.jsx(Ie,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:$.color},draggable:!0,onDragStart:Z=>I(Z,ee.id),onClick:()=>q(ee),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(uu,{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(Ei,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[ee.first_name," ",ee.last_name]})]}),ee.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ma,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:ee.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ee.email&&e.jsx(tr,{className:"h-3 w-3 text-muted-foreground"}),ee.phone&&e.jsx(Tn,{className:"h-3 w-3 text-muted-foreground"}),ee.experience_years!=null&&e.jsxs(Ye,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[ee.experience_years,"yr"]})]})]})]})},ee.id))})]},$.id)})}),e.jsx($ue,{orientation:"horizontal"})]}),e.jsx(dct,{open:i,onOpenChange:d,stages:s,defaultStageId:u,onSubmit:$=>a.mutate($),isSubmitting:a.isPending}),e.jsx(pct,{prospect:f,stages:s,brokerageId:t,open:_,onOpenChange:b,onUpdate:$=>{o.mutate($),y(V=>V?{...V,...$}:null)},onDelete:$=>l.mutate($)}),e.jsx(fct,{open:N,onOpenChange:w,brokerageId:t,stages:s})]})}function Ede({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=PO(t),{user:i}=$s(),d=es(),[u,p]=k.useState(!1),[f,y]=k.useState(null),[_,b]=k.useState(!1),[N,w]=k.useState(!1),[S,C]=k.useState(""),[A,I]=k.useState("all"),[L,O]=k.useState("all"),[U,q]=k.useState("all"),[$,V]=k.useState(null),[ee,Z]=k.useState("asc"),[J,Y]=k.useState(new Set),[ce,ae]=k.useState(!1),[ie,le]=k.useState(""),fe=k.useMemo(()=>{const ye=new Set;return r.forEach(ct=>{ct.current_brokerage&&ye.add(ct.current_brokerage)}),Array.from(ye).sort()},[r]),{data:xe=[]}=ft({queryKey:["recruit-campaigns-list",t],queryFn:async()=>{const{data:ye,error:ct}=await G.from("recruit_campaigns").select("id, name, warmth_level").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("name");if(ct)throw ct;return ye}}),{data:he=[]}=ft({queryKey:["recruit-campaign-assignments-lookup",t],queryFn:async()=>{let ct=[],pe=0;for(;;){const{data:Ge,error:tt}=await G.from("recruit_campaign_assignments").select("prospect_id, campaign_id, status").eq("brokerage_id",t).range(pe,pe+1e3-1);if(tt)throw tt;if(ct=ct.concat(Ge??[]),!Ge||Ge.length<1e3)break;pe+=1e3}return ct}}),we=k.useMemo(()=>{const ye=new Map;return he.forEach(ct=>{ye.has(ct.prospect_id)||ye.set(ct.prospect_id,new Set),ye.get(ct.prospect_id).add(ct.campaign_id)}),ye},[he]),Ne=ye=>{$===ye?Z(ct=>ct==="asc"?"desc":"asc"):(V(ye),Z("asc"))},Ve=({column:ye})=>$!==ye?e.jsx(td,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):ee==="asc"?e.jsx(cu,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(Ih,{className:"h-3.5 w-3.5 ml-1 text-primary"}),Te=ye=>s.find(ct=>ct.id===ye),Ae=k.useMemo(()=>{let ye=r.filter(ct=>{var Ce,et,Ct;const pe=!S||`${ct.first_name} ${ct.last_name}`.toLowerCase().includes(S.toLowerCase())||((Ce=ct.email)==null?void 0:Ce.toLowerCase().includes(S.toLowerCase()))||((et=ct.current_brokerage)==null?void 0:et.toLowerCase().includes(S.toLowerCase())),Ge=A==="all"||ct.stage_id===A,tt=L==="all"||ct.current_brokerage===L;let st=!0;return U==="in_campaign"?st=we.has(ct.id):U==="not_in_campaign"?st=!we.has(ct.id):U!=="all"&&(st=((Ct=we.get(ct.id))==null?void 0:Ct.has(U))??!1),pe&&Ge&&tt&&st});return $&&(ye=[...ye].sort((ct,pe)=>{var Ce,et;let Ge=null,tt=null;switch($){case"name":Ge=`${ct.first_name} ${ct.last_name||""}`.toLowerCase(),tt=`${pe.first_name} ${pe.last_name||""}`.toLowerCase();break;case"stage":Ge=((Ce=Te(ct.stage_id))==null?void 0:Ce.sort_order)??999,tt=((et=Te(pe.stage_id))==null?void 0:et.sort_order)??999;break;case"brokerage":Ge=(ct.current_brokerage||"").toLowerCase(),tt=(pe.current_brokerage||"").toLowerCase();break;case"experience":Ge=ct.experience_years??-1,tt=pe.experience_years??-1;break;case"production":Ge=(ct.annual_production||"").toLowerCase(),tt=(pe.annual_production||"").toLowerCase();break;case"source":Ge=(ct.source||"").toLowerCase(),tt=(pe.source||"").toLowerCase();break;default:return 0}if(Ge===tt)return 0;if(Ge==null)return 1;if(tt==null)return-1;const st=Ge0&&Ae.every(ye=>J.has(ye.id)),Ee=Ae.some(ye=>J.has(ye.id)),ve=()=>{Y(ze?new Set:new Set(Ae.map(ye=>ye.id)))},Re=ye=>{Y(ct=>{const pe=new Set(ct);return pe.has(ye)?pe.delete(ye):pe.add(ye),pe})},Ue=Et({mutationFn:async()=>{if(!ie||!(i!=null&&i.id))throw new Error("Select a campaign");const ye=new Set(he.filter(Ge=>Ge.campaign_id===ie).map(Ge=>Ge.prospect_id)),ct=Array.from(J).filter(Ge=>!ye.has(Ge)).map(Ge=>({prospect_id:Ge,campaign_id:ie,brokerage_id:t,assigned_by:i.id,status:"active",current_email_number:0}));if(ct.length===0)throw new Error("All selected prospects are already in this campaign");const{error:pe}=await G.from("recruit_campaign_assignments").insert(ct);if(pe)throw pe;return ct.length},onSuccess:ye=>{me.success(`${ye} prospect(s) added to campaign`),ae(!1),Y(new Set),le(""),d.invalidateQueries({queryKey:["recruit-campaign-assignments-lookup"]})},onError:ye=>me.error(ye.message)});return n?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm min-w-[200px]",children:[e.jsx(tn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search prospects...",value:S,onChange:ye=>C(ye.target.value),className:"pl-8"})]}),e.jsxs("div",{className:"flex gap-2",children:[J.size>0&&e.jsxs(K,{variant:"secondary",onClick:()=>ae(!0),className:"gap-1.5",children:[e.jsx(Nn,{className:"h-4 w-4"})," Add ",J.size," to Campaign"]}),e.jsxs(K,{variant:"outline",onClick:()=>w(!0),children:[e.jsx(Da,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>p(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Dg,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(zs,{value:A,onValueChange:I,children:[e.jsx(Os,{className:"w-[160px] h-8 text-xs",children:e.jsx(qs,{placeholder:"All stages"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All stages"}),s.map(ye=>e.jsx(yt,{value:ye.id,children:ye.name},ye.id))]})]}),e.jsxs(zs,{value:L,onValueChange:O,children:[e.jsxs(Os,{className:"w-[200px] h-8 text-xs",children:[e.jsx(ma,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(qs,{placeholder:"All brokerages"})]}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All brokerages"}),fe.map(ye=>e.jsx(yt,{value:ye,children:ye},ye))]})]}),e.jsxs(zs,{value:U,onValueChange:q,children:[e.jsxs(Os,{className:"w-[200px] h-8 text-xs",children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(qs,{placeholder:"Campaign status"})]}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All contacts"}),e.jsx(yt,{value:"in_campaign",children:"In any campaign"}),e.jsx(yt,{value:"not_in_campaign",children:"Not in any campaign"}),xe.map(ye=>e.jsxs(yt,{value:ye.id,children:["In: ",ye.name]},ye.id))]})]}),(A!=="all"||L!=="all"||U!=="all")&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 text-xs text-muted-foreground",onClick:()=>{I("all"),O("all"),q("all")},children:"Clear filters"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{className:"w-[40px]",children:e.jsx(Gi,{checked:ze,onCheckedChange:ve,"aria-label":"Select all",...Ee&&!ze?{"data-state":"indeterminate"}:{}})}),e.jsx(Nt,{className:"cursor-pointer select-none",onClick:()=>Ne("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx(Ve,{column:"name"})]})}),e.jsx(Nt,{className:"cursor-pointer select-none",onClick:()=>Ne("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx(Ve,{column:"stage"})]})}),e.jsx(Nt,{className:"hidden md:table-cell cursor-pointer select-none",onClick:()=>Ne("brokerage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Brokerage ",e.jsx(Ve,{column:"brokerage"})]})}),e.jsx(Nt,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(Nt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>Ne("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx(Ve,{column:"experience"})]})}),e.jsx(Nt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>Ne("production"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Production ",e.jsx(Ve,{column:"production"})]})}),e.jsx(Nt,{className:"hidden lg:table-cell",children:"Campaigns"}),e.jsx(Nt,{className:"w-[50px]"})]})}),e.jsx(Pn,{children:Ae.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):Ae.map(ye=>{const ct=Te(ye.stage_id),pe=we.get(ye.id),Ge=(pe==null?void 0:pe.size)??0;return e.jsxs(As,{className:"cursor-pointer",onClick:()=>{y(ye),b(!0)},children:[e.jsx(dt,{onClick:tt=>tt.stopPropagation(),children:e.jsx(Gi,{checked:J.has(ye.id),onCheckedChange:()=>Re(ye.id),"aria-label":`Select ${ye.first_name}`})}),e.jsxs(dt,{className:"font-medium",children:[ye.first_name," ",ye.last_name]}),e.jsx(dt,{children:ct?e.jsxs(Ye,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:ct.color,color:ct.color,backgroundColor:`${ct.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:ct.color}}),ct.name]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),e.jsx(dt,{className:"hidden md:table-cell",children:ye.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(ma,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:ye.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:[ye.email&&e.jsx(tr,{className:"h-3.5 w-3.5 text-muted-foreground"}),ye.phone&&e.jsx(Tn,{className:"h-3.5 w-3.5 text-muted-foreground"}),!ye.email&&!ye.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(dt,{className:"hidden lg:table-cell",children:ye.experience_years!=null?`${ye.experience_years} yr`:"—"}),e.jsx(dt,{className:"hidden lg:table-cell",children:ye.annual_production||"—"}),e.jsx(dt,{className:"hidden lg:table-cell",children:Ge>0?e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:[Ge," campaign",Ge>1?"s":""]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"None"})}),e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:tt=>{tt.stopPropagation(),l.mutate(ye.id)},children:e.jsx(yr,{className:"h-3.5 w-3.5"})})})]},ye.id)})})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[J.size>0&&e.jsxs("span",{className:"font-medium text-foreground",children:[J.size," selected · "]}),Ae.length," of ",r.length," prospects"]}),e.jsx(fs,{open:ce,onOpenChange:ae,children:e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Add to Campaign"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Add ",e.jsx("span",{className:"font-medium text-foreground",children:J.size})," selected prospect(s) to a recruiting campaign drip."]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Campaign"}),e.jsxs(zs,{value:ie,onValueChange:le,children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select a campaign..."})}),e.jsx(Fs,{children:xe.map(ye=>e.jsxs(yt,{value:ye.id,children:[ye.name," ",e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",ye.warmth_level,")"]})]},ye.id))})]})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>ae(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>Ue.mutate(),disabled:!ie||Ue.isPending,children:Ue.isPending?"Adding...":"Add to Campaign"})]})]})}),e.jsx(dct,{open:u,onOpenChange:p,stages:s,onSubmit:ye=>a.mutate(ye),isSubmitting:a.isPending}),e.jsx(pct,{prospect:f,stages:s,brokerageId:t,open:_,onOpenChange:b,onUpdate:ye=>{o.mutate(ye),y(ct=>ct?{...ct,...ye}:null)},onDelete:ye=>l.mutate(ye)}),e.jsx(fct,{open:N,onOpenChange:w,brokerageId:t,stages:s})]})}function gct({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=PO(t),a=k.useMemo(()=>{if(!s.length||!r.length)return null;const o=r.length,l=s.find(S=>S.name==="Signed"),i=s.find(S=>S.name==="Onboarded"),d=r.filter(S=>S.stage_id===(l==null?void 0:l.id)||S.stage_id===(i==null?void 0:i.id)).length,u=o>0?(d/o*100).toFixed(1):"0",p=new Date,f=o>0?Math.round(r.reduce((S,C)=>S+Vg(p,new Date(C.created_at)),0)/o):0,y=s.map(S=>({...S,count:r.filter(C=>C.stage_id===S.id).length})),_={};r.forEach(S=>{const C=S.source||"unknown";_[C]=(_[C]||0)+1});const b=Object.entries(_).sort((S,C)=>C[1]-S[1]),N=new Date;N.setDate(N.getDate()-30);const w=r.filter(S=>new Date(S.created_at)>=N).length;return{total:o,signed:d,conversionRate:u,avgDays:f,byStage:y,bySrc:b,recentCount:w}},[s,r]);return n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ie,{children:e.jsx(Be,{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(cr,{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(Ie,{children:e.jsx(Be,{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(Yo,{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(Ie,{children:e.jsx(Be,{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(rn,{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(Ie,{children:e.jsx(Be,{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(Oh,{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(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(Be,{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(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Be,{className:"space-y-3",children:[a.bySrc.map(([o,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ye,{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 T9e=[{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 yct({brokerageId:t}){const{toast:s}=va(),[r,n]=k.useState(null),[a,o]=k.useState(null),l=(d,u)=>{navigator.clipboard.writeText(d),n(u),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(T9e.map(d=>d.category))];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pre-built email templates for recruiting outreach. Click to expand and copy."}),i.map(d=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(tr,{className:"h-4 w-4"})," ",d]}),T9e.filter(u=>u.category===d).map(u=>e.jsxs(Ie,{className:`cursor-pointer transition-all ${a===u.id?"ring-2 ring-primary/20":"hover:shadow-sm"}`,onClick:()=>o(a===u.id?null:u.id),children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(Ye,{variant:"secondary",className:"text-[10px]",children:u.category})]})}),a===u.id&&e.jsxs(Be,{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(ea,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Ya,{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(ea,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Ya,{className:"h-3.5 w-3.5 mr-1"}),"Copy Body"]})]})]})]},u.id))]},d))]})}const A9e={call:Tn,email:tr,text:Si,meeting:nn,note:mn};function vct({brokerageId:t}){const{data:s,isLoading:r}=ft({queryKey:["recruit-activity-report",t],queryFn:async()=>{const{data:n,error:a}=await G.from("recruit_prospects").select("id, created_by").eq("brokerage_id",t);if(a)throw a;const o=(n==null?void 0:n.map(_=>_.id))||[];if(o.length===0)return{recruiters:[],recentActivities:[]};const{data:l,error:i}=await G.from("recruit_activities").select("*").in("prospect_id",o).order("created_at",{ascending:!1});if(i)throw i;const d=[...new Set([...n.map(_=>_.created_by),...(l||[]).map(_=>_.created_by)])],{data:u}=await G.from("profiles").select("id, name, email").in("id",d),p=Object.fromEntries((u||[]).map(_=>[_.id,_])),f=Uie(new Date,30);return{recruiters:d.map(_=>{var C,A;const b=(l||[]).filter(I=>I.created_by===_),N=b.filter(I=>new Date(I.created_at)>=f),w={};N.forEach(I=>{w[I.activity_type]=(w[I.activity_type]||0)+1});const S=n.filter(I=>I.created_by===_).length;return{id:_,name:((C=p[_])==null?void 0:C.name)||"Unknown",email:((A=p[_])==null?void 0:A.email)||"",totalActivities:b.length,recentActivities:N.length,byType:w,prospectsCreated:S}}).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(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx(Be,{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(Ei,{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=A9e[o]||mn;return e.jsxs(Ye,{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(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Recent Activity"})}),e.jsx(Be,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=A9e[n.activity_type]||mn;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:gs(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 _ct({brokerageId:t}){const{toast:s}=va(),r=es(),[n,a]=k.useState(!1),[o,l]=k.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:d}=ft({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:w,error:S}=await G.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(S)throw S;return w}}),u=[...new Set(i.map(w=>w.referred_by))],{data:p=[]}=ft({queryKey:["referral-profiles",u],queryFn:async()=>{if(!u.length)return[];const{data:w}=await G.from("profiles").select("id, name, email").in("id",u);return w||[]},enabled:u.length>0}),f=Object.fromEntries(p.map(w=>[w.id,w])),y=Et({mutationFn:async w=>{const{data:{user:S}}=await G.auth.getUser();if(!S)throw new Error("Not authenticated");const{error:C}=await G.from("recruit_referrals").insert({brokerage_id:t,referred_by:S.id,referee_first_name:w.first_name,referee_last_name:w.last_name||null,referee_email:w.email||null,referee_phone:w.phone||null,referee_current_brokerage:w.current_brokerage||null,notes:w.notes||null});if(C)throw C},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),_=Et({mutationFn:async({id:w,status:S,incentive_status:C})=>{const A={updated_at:new Date().toISOString()};S&&(A.status=S),C&&(A.incentive_status=C);const{error:I}=await G.from("recruit_referrals").update(A).eq("id",w);if(I)throw I},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),b=w=>w==="approved"||w==="signed"?e.jsx(ea,{className:"h-3 w-3"}):w==="rejected"?e.jsx(Ql,{className:"h-3 w-3"}):e.jsx(rn,{className:"h-3 w-3"}),N=w=>w==="approved"||w==="signed"||w==="paid"?"bg-green-500/10 text-green-600 border-green-200":w==="rejected"?"bg-red-500/10 text-red-600 border-red-200":"bg-amber-500/10 text-amber-600 border-amber-200";return d?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," referral",i.length!==1?"s":""]}),e.jsxs(K,{onClick:()=>a(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"})," Submit Referral"]})]}),i.length===0?e.jsxs(Ie,{className:"py-12 text-center",children:[e.jsx(il,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No referrals yet. Agents can refer potential recruits here."})]}):e.jsx("div",{className:"space-y-3",children:i.map(w=>{var S;return e.jsx(Ie,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium",children:[w.referee_first_name," ",w.referee_last_name]}),e.jsxs(Ye,{variant:"outline",className:N(w.status),children:[b(w.status)," ",w.status]}),w.incentive_status&&e.jsxs(Ye,{variant:"outline",className:N(w.incentive_status),children:[e.jsx(Vi,{className:"h-3 w-3 mr-1"})," ",w.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[w.referee_email&&e.jsx("p",{children:w.referee_email}),w.referee_phone&&e.jsx("p",{children:w.referee_phone}),w.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",w.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((S=f[w.referred_by])==null?void 0:S.name)||"Unknown"," • ",gs(new Date(w.created_at),"MMM d, yyyy")]})]}),w.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:w.notes})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(zs,{value:w.status,onValueChange:C=>_.mutate({id:w.id,status:C}),children:[e.jsx(Os,{className:"h-7 text-xs w-[110px]",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"pending",children:"Pending"}),e.jsx(yt,{value:"contacted",children:"Contacted"}),e.jsx(yt,{value:"approved",children:"Approved"}),e.jsx(yt,{value:"signed",children:"Signed"}),e.jsx(yt,{value:"rejected",children:"Rejected"})]})]}),e.jsxs(zs,{value:w.incentive_status||"pending",onValueChange:C=>_.mutate({id:w.id,incentive_status:C}),children:[e.jsx(Os,{className:"h-7 text-xs w-[100px]",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"pending",children:"Unpaid"}),e.jsx(yt,{value:"paid",children:"Paid"}),e.jsx(yt,{value:"n/a",children:"N/A"})]})]})]})]})},w.id)})}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:w=>{w.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(ge,{children:"First Name *"}),e.jsx(Fe,{required:!0,value:o.first_name,onChange:w=>l(S=>({...S,first_name:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Last Name"}),e.jsx(Fe,{value:o.last_name,onChange:w=>l(S=>({...S,last_name:w.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Email"}),e.jsx(Fe,{type:"email",value:o.email,onChange:w=>l(S=>({...S,email:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Phone"}),e.jsx(Fe,{value:o.phone,onChange:w=>l(S=>({...S,phone:w.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Current Brokerage"}),e.jsx(Fe,{value:o.current_brokerage,onChange:w=>l(S=>({...S,current_brokerage:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Notes"}),e.jsx(_r,{value:o.notes,onChange:w=>l(S=>({...S,notes:w.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:y.isPending,children:"Submit"})]})]})]})})]})}function bct({brokerageId:t}){const{toast:s}=va(),r=es(),[n,a]=k.useState(!1),{data:o}=ft({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=[]}=ft({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=Et({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"})}}),d=Et({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=`https://bestbrokerage.relevelup.com/join-brokerage/${(o==null?void 0:o.recruit_form_slug)||""}`,p=()=>{navigator.clipboard.writeText(u),a(!0),s({title:"Link copied!"}),setTimeout(()=>a(!1),2e3)},f=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(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Public Interest Form"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ge,{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(Lr,{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(ea,{className:"h-3.5 w-3.5"}):e.jsx(Ya,{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(Kr,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx(Be,{children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(il,{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(Ye,{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(tr,{className:"h-3 w-3"}),y.email]}),y.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{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:gs(new Date(y.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(zs,{value:y.status,onValueChange:_=>d.mutate({id:y.id,status:_}),children:[e.jsx(Os,{className:"h-7 text-xs w-[110px]",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"new",children:"New"}),e.jsx(yt,{value:"contacted",children:"Contacted"}),e.jsx(yt,{value:"converted",children:"Converted"}),e.jsx(yt,{value:"dismissed",children:"Dismissed"})]})]})]},y.id))})})]})]})}function wct({brokerageId:t}){const{toast:s}=va(),r=es(),[n,a]=k.useState(!1),[o,l]=k.useState({prospect_id:"",title:"",description:"",due_date:gs(dl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,d]=k.useState("pending"),{data:u=[]}=ft({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:L,error:O}=await G.from("recruit_prospects").select("id, first_name, last_name").eq("brokerage_id",t).order("first_name");if(O)throw O;return L}}),{data:p=[],isLoading:f}=ft({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const L=u.map(q=>q.id);if(!L.length)return[];const{data:O,error:U}=await G.from("recruit_follow_ups").select("*").in("prospect_id",L).order("due_date");if(U)throw U;return O},enabled:u.length>0}),y=Object.fromEntries(u.map(L=>[L.id,L])),_=Et({mutationFn:async L=>{const{data:{user:O}}=await G.auth.getUser();if(!O)throw new Error("Not authenticated");const{error:U}=await G.from("recruit_follow_ups").insert({prospect_id:L.prospect_id,assigned_to:O.id,title:L.title,description:L.description||null,due_date:new Date(L.due_date).toISOString()});if(U)throw U},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-follow-ups",t]}),s({title:"Follow-up scheduled"}),l({prospect_id:"",title:"",description:"",due_date:gs(dl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:L=>s({title:"Error",description:L.message,variant:"destructive"})}),b=Et({mutationFn:async({id:L,completed:O})=>{const{error:U}=await G.from("recruit_follow_ups").update({completed_at:O?new Date().toISOString():null}).eq("id",L);if(U)throw U},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),N=p.filter(L=>i==="pending"?!L.completed_at:i==="completed"?!!L.completed_at:!0),w=N.filter(L=>!L.completed_at&&a0(new Date(L.due_date))&&!nu(new Date(L.due_date))),S=N.filter(L=>!L.completed_at&&nu(new Date(L.due_date))),C=N.filter(L=>!L.completed_at&&!a0(new Date(L.due_date))&&!nu(new Date(L.due_date))),A=N.filter(L=>!!L.completed_at),I=L=>{const O=y[L.prospect_id],U=!L.completed_at&&a0(new Date(L.due_date))&&!nu(new Date(L.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Gi,{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:[O&&e.jsxs(Ye,{variant:"secondary",className:"text-[10px]",children:[O.first_name," ",O.last_name]}),e.jsxs("span",{className:`flex items-center gap-1 ${U?"text-destructive font-medium":""}`,children:[U?e.jsx(co,{className:"h-3 w-3"}):e.jsx(nn,{className:"h-3 w-3"}),gs(new Date(L.due_date),"MMM d, h:mm a")]}),L.is_automated&&e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},L.id)};return f?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex gap-2",children:["pending","completed","all"].map(L=>e.jsxs(K,{size:"sm",variant:i===L?"default":"outline",onClick:()=>d(L),className:"capitalize text-xs",children:[L," ",L==="pending"&&w.length+S.length+C.length>0&&`(${w.length+S.length+C.length})`]},L))}),e.jsxs(K,{size:"sm",onClick:()=>a(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Follow-up"]})]}),i!=="completed"&&w.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-destructive flex items-center gap-1",children:[e.jsx(co,{className:"h-3.5 w-3.5"})," Overdue (",w.length,")"]}),w.map(I)]}),i!=="completed"&&S.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(rn,{className:"h-3.5 w-3.5"})," Today (",S.length,")"]}),S.map(I)]}),i!=="completed"&&C.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(nn,{className:"h-3.5 w-3.5"})," Upcoming (",C.length,")"]}),C.map(I)]}),i!=="pending"&&A.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(ea,{className:"h-3.5 w-3.5"})," Completed (",A.length,")"]}),A.map(I)]}),N.length===0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-8",children:["No follow-ups ",i!=="all"?`(${i})`:""]}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Schedule Follow-up"})}),e.jsxs("form",{onSubmit:L=>{L.preventDefault(),_.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ge,{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(O=>({...O,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(ge,{children:"Task *"}),e.jsx(Fe,{required:!0,value:o.title,onChange:L=>l(O=>({...O,title:L.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Details"}),e.jsx(_r,{value:o.description,onChange:L=>l(O=>({...O,description:L.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Due Date *"}),e.jsx(Fe,{type:"datetime-local",required:!0,value:o.due_date,onChange:L=>l(O=>({...O,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 r3s=[{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 jct({brokerageId:t}){const{toast:s}=va(),r=es(),[n,a]=k.useState(null),{data:o,isLoading:l}=ft({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:w,error:S}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(S)throw S;return w}}),[i,d]=k.useState({brokerage_id:t,hero_headline:"Join Our Team",hero_subtext:"Take your real estate career to the next level.",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",benefits:r3s,testimonials:[],gallery_images:[],calculator_enabled:!1,calculator_config:{headline:"See What You Could Earn With Us",subtext:"Confidential 60-second calculator — no signup required.",commission_split_pct:80,cap_amount:16e3,monthly_fee:99,transaction_fee:0,show_email_capture:!0,email_capture_label:"Want the full breakdown? Enter your email."},lead_magnet_enabled:!1,lead_magnet_config:{title:"Get the Full Comp Plan PDF",description:"See exactly how splits, caps, and fees work — no call required.",button_text:"Email Me the PDF",pdf_url:null},form_style:"classic",confidential_messaging:!0});k.useEffect(()=>{o&&d({id:o.id,brokerage_id:o.brokerage_id,hero_headline:o.hero_headline,hero_subtext:o.hero_subtext||"",hero_image_url:o.hero_image_url,logo_url:o.logo_url,primary_color:o.primary_color,accent_color:o.accent_color,benefits:o.benefits||[],testimonials:o.testimonials||[],gallery_images:o.gallery_images||[],calculator_enabled:o.calculator_enabled??!1,calculator_config:o.calculator_config||{},lead_magnet_enabled:o.lead_magnet_enabled??!1,lead_magnet_config:o.lead_magnet_config||{},form_style:o.form_style||"classic",confidential_messaging:o.confidential_messaging??!0})},[o]);const u=Et({mutationFn:async()=>{const w={brokerage_id:t,hero_headline:i.hero_headline,hero_subtext:i.hero_subtext,hero_image_url:i.hero_image_url,logo_url:i.logo_url,primary_color:i.primary_color,accent_color:i.accent_color,benefits:JSON.parse(JSON.stringify(i.benefits)),testimonials:JSON.parse(JSON.stringify(i.testimonials)),gallery_images:JSON.parse(JSON.stringify(i.gallery_images)),calculator_enabled:i.calculator_enabled,calculator_config:JSON.parse(JSON.stringify(i.calculator_config)),lead_magnet_enabled:i.lead_magnet_enabled,lead_magnet_config:JSON.parse(JSON.stringify(i.lead_magnet_config)),form_style:i.form_style,confidential_messaging:i.confidential_messaging,updated_at:new Date().toISOString()};if(i.id){const{error:S}=await G.from("recruit_landing_page_settings").update(w).eq("id",i.id);if(S)throw S}else{const{error:S}=await G.from("recruit_landing_page_settings").insert(w);if(S)throw S}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),p=async(w,S)=>{const C=w.name.split(".").pop(),A=`${t}/${S}-${Date.now()}.${C}`,{error:I}=await G.storage.from("recruit-landing").upload(A,w);if(I)throw I;const{data:{publicUrl:L}}=G.storage.from("recruit-landing").getPublicUrl(A);return L},f=async(w,S)=>{var A;const C=(A=w.target.files)==null?void 0:A[0];if(C){a(S);try{const I=await p(C,S);d(L=>({...L,[S]:I})),s({title:"Image uploaded!"})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},y=async w=>{var C;const S=(C=w.target.files)==null?void 0:C[0];if(S){a("gallery");try{const A=await p(S,"gallery");d(I=>({...I,gallery_images:[...I.gallery_images,A]})),s({title:"Gallery image added!"})}catch(A){s({title:"Upload failed",description:A.message,variant:"destructive"})}finally{a(null)}}},_=async(w,S)=>{var A;const C=(A=w.target.files)==null?void 0:A[0];if(C){a(`testimonial-${S}`);try{const I=await p(C,`testimonial-${S}`);d(L=>{const O=[...L.testimonials];return O[S]={...O[S],photo_url:I},{...L,testimonials:O}})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},{data:b}=ft({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:w,error:S}=await G.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(S)throw S;return w}}),N=`https://bestbrokerage.relevelup.com/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:N}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:N,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Kr,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Branding"})}),e.jsx(Be,{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(ge,{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(Da,{className:"h-3.5 w-3.5 mr-1"}),n==="logo_url"?"Uploading...":"Upload Logo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:w=>f(w,"logo_url")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.primary_color,onChange:w=>d(S=>({...S,primary_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Fe,{value:i.primary_color,onChange:w=>d(S=>({...S,primary_color:w.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.accent_color,onChange:w=>d(S=>({...S,accent_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Fe,{value:i.accent_color,onChange:w=>d(S=>({...S,accent_color:w.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Hero Section"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Headline"}),e.jsx(Fe,{value:i.hero_headline,onChange:w=>d(S=>({...S,hero_headline:w.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Subtext"}),e.jsx(_r,{value:i.hero_subtext,onChange:w=>d(S=>({...S,hero_subtext:w.target.value})),rows:2,placeholder:"Take your career to the next level..."})]}),e.jsxs("div",{children:[e.jsx(ge,{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(Da,{className:"h-3.5 w-3.5 mr-1"}),n==="hero_image_url"?"Uploading...":"Upload Image"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:w=>f(w,"hero_image_url")})]}),i.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(w=>({...w,hero_image_url:null})),children:e.jsx(yr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(w=>({...w,benefits:[...w.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Be,{className:"space-y-3",children:[i.benefits.map((w,S)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(uu,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(Fe,{value:w.icon,onChange:C=>{const A=[...i.benefits];A[S]={...w,icon:C.target.value},d(I=>({...I,benefits:A}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Fe,{value:w.title,onChange:C=>{const A=[...i.benefits];A[S]={...w,title:C.target.value},d(I=>({...I,benefits:A}))},placeholder:"Benefit title"}),e.jsx(Fe,{value:w.description,onChange:C=>{const A=[...i.benefits];A[S]={...w,description:C.target.value},d(I=>({...I,benefits:A}))},placeholder:"Short description"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(C=>({...C,benefits:C.benefits.filter((A,I)=>I!==S)})),children:e.jsx(yr,{className:"h-3.5 w-3.5 text-destructive"})})]},S)),i.benefits.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No benefits added yet"})]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{className:"text-base",children:"Testimonials"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(w=>({...w,testimonials:[...w.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Be,{className:"space-y-3",children:[i.testimonials.map((w,S)=>{var C;return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[w.photo_url?e.jsx("img",{src:w.photo_url,alt:w.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted flex items-center justify-center text-xs text-muted-foreground",children:((C=w.name)==null?void 0:C[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${S}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:A=>_(A,S)})]})]}),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:w.name,onChange:A=>{const I=[...i.testimonials];I[S]={...w,name:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Name"}),e.jsx(Fe,{value:w.role,onChange:A=>{const I=[...i.testimonials];I[S]={...w,role:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Role / Title"})]}),e.jsx(_r,{value:w.quote,onChange:A=>{const I=[...i.testimonials];I[S]={...w,quote:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(A=>({...A,testimonials:A.testimonials.filter((I,L)=>L!==S)})),children:e.jsx(yr,{className:"h-3.5 w-3.5 text-destructive"})})]},S)}),i.testimonials.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No testimonials added yet"})]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{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(Uo,{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(Be,{children:i.gallery_images.length>0?e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:i.gallery_images.map((w,S)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:w,alt:`Gallery ${S+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(C=>({...C,gallery_images:C.gallery_images.filter((A,I)=>I!==S)})),children:e.jsx(yr,{className:"h-3 w-3"})})]},S))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No gallery images added yet"})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(qr,{className:"h-4 w-4 text-primary"})," Form Style & Trust"]})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Application Form Style"}),e.jsxs(zs,{value:i.form_style,onValueChange:w=>d(S=>({...S,form_style:w})),children:[e.jsx(Os,{className:"mt-1.5",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"classic",children:"Classic — single-page form (all fields visible)"}),e.jsx(yt,{value:"multi_step",children:"Multi-Step Wizard — 3-step soft CTA (recommended)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1.5",children:"Multi-step wizards convert ~30% better than single long forms."})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(yd,{className:"h-4 w-4 mt-0.5 text-primary"}),e.jsxs("div",{children:[e.jsx(ge,{children:"Show Confidentiality Badges"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Adds "100% Confidential" + "No spam" trust signals around the form.'})]})]}),e.jsx(Lr,{checked:i.confidential_messaging,onCheckedChange:w=>d(S=>({...S,confidential_messaging:w}))})]})]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(wM,{className:"h-4 w-4 text-primary"})," Split & Income Calculator"]}),e.jsx(Lr,{checked:i.calculator_enabled,onCheckedChange:w=>d(S=>({...S,calculator_enabled:w}))})]}),i.calculator_enabled&&e.jsxs(Be,{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Highest-converting recruiting tool. Agents enter their GCI and instantly see what they'd earn at your brokerage."}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Calculator Headline"}),e.jsx(Fe,{value:i.calculator_config.headline||"",onChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,headline:w.target.value}})),placeholder:"See What You Could Earn With Us"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Subtext"}),e.jsx(Fe,{value:i.calculator_config.subtext||"",onChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,subtext:w.target.value}})),placeholder:"Confidential 60-second calculator"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Your Split %"}),e.jsx(Fe,{type:"number",value:i.calculator_config.commission_split_pct??80,onChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,commission_split_pct:parseFloat(w.target.value)||0}}))}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Agent keeps"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Cap Amount ($)"}),e.jsx(Fe,{type:"number",value:i.calculator_config.cap_amount??16e3,onChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,cap_amount:parseFloat(w.target.value)||0}}))}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Annual cap"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Monthly Fee ($)"}),e.jsx(Fe,{type:"number",value:i.calculator_config.monthly_fee??99,onChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,monthly_fee:parseFloat(w.target.value)||0}}))})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Per-Txn Fee ($)"}),e.jsx(Fe,{type:"number",value:i.calculator_config.transaction_fee??0,onChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,transaction_fee:parseFloat(w.target.value)||0}}))})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm",children:"Capture email at end of calculator"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"After seeing results, agents can request a full breakdown via email."})]}),e.jsx(Lr,{checked:i.calculator_config.show_email_capture!==!1,onCheckedChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,show_email_capture:w}}))})]})]})]}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(tS,{className:"h-4 w-4 text-primary"})," Lead Magnet (Gated PDF)"]}),e.jsx(Lr,{checked:i.lead_magnet_enabled,onCheckedChange:w=>d(S=>({...S,lead_magnet_enabled:w}))})]}),i.lead_magnet_enabled&&e.jsxs(Be,{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Captures emails from agents not ready to talk. Offer a comp plan PDF, recruiting deck, or guide."}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Title"}),e.jsx(Fe,{value:i.lead_magnet_config.title||"",onChange:w=>d(S=>({...S,lead_magnet_config:{...S.lead_magnet_config,title:w.target.value}})),placeholder:"Get the Full Comp Plan PDF"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Description"}),e.jsx(_r,{rows:2,value:i.lead_magnet_config.description||"",onChange:w=>d(S=>({...S,lead_magnet_config:{...S.lead_magnet_config,description:w.target.value}})),placeholder:"See exactly how splits, caps, and fees work..."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Button Text"}),e.jsx(Fe,{value:i.lead_magnet_config.button_text||"",onChange:w=>d(S=>({...S,lead_magnet_config:{...S.lead_magnet_config,button_text:w.target.value}})),placeholder:"Email Me the PDF"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"PDF / File URL"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Fe,{value:i.lead_magnet_config.pdf_url||"",onChange:w=>d(S=>({...S,lead_magnet_config:{...S.lead_magnet_config,pdf_url:w.target.value||null}})),placeholder:"https://...",className:"flex-1"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:n==="lead_magnet_pdf",children:e.jsxs("span",{children:[e.jsx(Da,{className:"h-3.5 w-3.5 mr-1"}),n==="lead_magnet_pdf"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"application/pdf,.pdf,.doc,.docx",className:"hidden",onChange:async w=>{var C;const S=(C=w.target.files)==null?void 0:C[0];if(S){a("lead_magnet_pdf");try{const A=await p(S,"lead-magnet");d(I=>({...I,lead_magnet_config:{...I.lead_magnet_config,pdf_url:A}})),s({title:"PDF uploaded!"})}catch(A){s({title:"Upload failed",description:A.message,variant:"destructive"})}finally{a(null)}}}})]})]})]})]})]})]}),e.jsx(n3s,{brokerageId:t}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:()=>u.mutate(),disabled:u.isPending,size:"lg",children:[e.jsx(wc,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function n3s({brokerageId:t}){const{data:s=[]}=ft({queryKey:["lead-magnet-downloads",t],queryFn:async()=>{const{data:r,error:n}=await G.from("recruit_lead_magnet_downloads").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1}).limit(100);if(n)throw n;return r}});return s.length===0?null:e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Xa,{className:"h-4 w-4 text-primary"})," Lead Magnet Downloads (",s.length,")"]})}),e.jsx(Be,{children:e.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:s.map(r=>e.jsx("div",{className:"flex items-center justify-between gap-3 p-2.5 border rounded-lg text-sm",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium truncate",children:[r.first_name||"—"," · ",r.email]}),e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[gs(new Date(r.created_at),"MMM d, yyyy h:mm a")," · via ",r.source]})]})},r.id))})})]})}function a3s(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function i3s({video:t}){return t.cta_clicked_at?e.jsx(Ye,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(Ye,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(jn,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(Ye,{variant:"secondary",children:[e.jsx(Nn,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(Ye,{variant:"outline",children:[e.jsx(rn,{className:"h-3 w-3 mr-1"}),"Draft"]})}function Nct({brokerageId:t}){const{data:s=[],isLoading:r}=YCs(t),{data:n=[]}=mct(t),a=QCs(),o=JCs(),l=hct(),[i,d]=k.useState(""),[u,p]=k.useState(!1),[f,y]=k.useState({title:"",script_text:"",category:"general"}),_=s.filter(C=>{var I,L,O,U;return i?`${((I=C.prospect)==null?void 0:I.first_name)||""} ${((L=C.prospect)==null?void 0:L.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||((U=(O=C.video)==null?void 0:O.title)==null?void 0:U.toLowerCase().includes(i.toLowerCase())):!0}),b={total:s.length,sent:s.filter(C=>C.sent_at).length,viewed:s.filter(C=>C.view_count>0).length,ctaClicked:s.filter(C=>C.cta_clicked_at).length},N=k.useCallback(C=>{if(!C)return;const A=`${window.location.origin}/recruit-video/${C}`;navigator.clipboard.writeText(A),me.success("Share link copied")},[]),w=k.useCallback((C,A)=>{l.mutate({id:C,sent_via:A})},[l]),S=()=>{!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:hn,color:"text-primary"},{label:"Sent",value:b.sent,icon:Nn,color:"text-blue-500"},{label:"Viewed",value:b.viewed,icon:jn,color:"text-amber-500"},{label:"CTA Clicked",value:b.ctaClicked,icon:Hn,color:"text-emerald-500"}].map(C=>e.jsx(Ie,{children:e.jsxs(Be,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:`h-10 w-10 rounded-lg bg-muted flex items-center justify-center ${C.color}`,children:e.jsx(C.icon,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:C.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.label})]})]})},C.label))}),e.jsxs(ta,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(Qn,{children:[e.jsxs(ls,{value:"videos",children:[e.jsx(hn,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(ls,{value:"scripts",children:[e.jsx(mn,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(ls,{value:"analytics",children:[e.jsx(so,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(js,{value:"videos",children:e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ft,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(tn,{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:C=>d(C.target.value),className:"pl-9"})]})]})}),e.jsx(Be,{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(hn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No video outreach yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Record a personalized video from any prospect's profile card"})]}):e.jsx("div",{className:"space-y-3",children:_.map(C=>{var A,I,L,O,U,q;return e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border bg-card hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"relative h-16 w-28 rounded-md overflow-hidden bg-muted flex-shrink-0",children:[(A=C.video)!=null&&A.thumbnail_url?e.jsx("img",{src:C.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(hn,{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:a3s(((I=C.video)==null?void 0:I.duration_seconds)??null)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-medium truncate",children:[(L=C.prospect)==null?void 0:L.first_name," ",(O=C.prospect)==null?void 0:O.last_name]}),e.jsx(i3s,{video:C})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:((U=C.video)==null?void 0:U.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[gs(new Date(C.created_at),"MMM d, yyyy"),((q=C.prospect)==null?void 0:q.current_brokerage)&&` · ${C.prospect.current_brokerage}`]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>N(C.share_token),title:"Copy share link",children:e.jsx(Ya,{className:"h-4 w-4"})}),!C.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(C.id,"email"),title:"Mark as sent",children:e.jsx(Nn,{className:"h-4 w-4"})}),C.share_token&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>window.open(`/recruit-video/${C.share_token}`,"_blank"),title:"Preview landing page",children:e.jsx(Kr,{className:"h-4 w-4"})})]})]},C.id)})})})]})}),e.jsx(js,{value:"scripts",children:e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ft,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(fs,{open:u,onOpenChange:p,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Create Recruiting Script"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Title"}),e.jsx(Fe,{value:f.title,onChange:C=>y(A=>({...A,title:C.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Category"}),e.jsxs(zs,{value:f.category,onValueChange:C=>y(A=>({...A,category:C})),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:r2e.map(C=>e.jsx(yt,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Script"}),e.jsx(_r,{value:f.script_text,onChange:C=>y(A=>({...A,script_text:C.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(K,{onClick:S,disabled:!f.title.trim()||!f.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(Be,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(mn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No scripts yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create teleprompter scripts for common recruiting conversations"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.map(C=>{var I;const A=((I=r2e.find(L=>L.value===C.category))==null?void 0:I.label)||C.category;return e.jsx(Ie,{className:"relative group",children:e.jsxs(Be,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Ye,{variant:"outline",className:"text-[10px] mb-2",children:A}),e.jsx("h4",{className:"font-medium text-sm",children:C.title})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>o.mutate(C.id),children:e.jsx(yr,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-3",children:C.script_text}),C.is_global&&e.jsx(Ye,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},C.id)})})})]})}),e.jsx(js,{value:"analytics",children:e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs(Be,{children:[e.jsx("div",{className:"space-y-4",children:[{label:"Videos Created",count:b.total,pct:100,color:"bg-primary"},{label:"Sent to Prospects",count:b.sent,pct:b.total?Math.round(b.sent/b.total*100):0,color:"bg-blue-500"},{label:"Viewed by Prospect",count:b.viewed,pct:b.sent?Math.round(b.viewed/b.sent*100):0,color:"bg-amber-500"},{label:"CTA Clicked",count:b.ctaClicked,pct:b.viewed?Math.round(b.ctaClicked/b.viewed*100):0,color:"bg-emerald-500"}].map(C=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:C.label}),e.jsxs("span",{className:"font-medium",children:[C.count," (",C.pct,"%)"]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${C.color} rounded-full transition-all`,style:{width:`${C.pct}%`}})})]},C.label))}),s.filter(C=>C.view_count>0).length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"Most Engaged Prospects"}),e.jsx("div",{className:"space-y-2",children:s.filter(C=>C.view_count>0).sort((C,A)=>A.view_count-C.view_count).slice(0,5).map(C=>{var A,I;return e.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded-md bg-muted/30",children:[e.jsxs("span",{className:"font-medium",children:[(A=C.prospect)==null?void 0:A.first_name," ",(I=C.prospect)==null?void 0:I.last_name]}),e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(jn,{className:"h-3.5 w-3.5"})," ",C.view_count]}),C.cta_clicked_at&&e.jsx(Hn,{className:"h-4 w-4 text-emerald-500"})]})]},C.id)})})]})]})]})})]})]})}function kct({brokerageId:t}){const{toast:s}=va(),r=es(),{stages:n,prospects:a}=PO(t),[o,l]=k.useState(!1),[i,d]=k.useState({title:"",target_count:"10",target_stage_id:"",period_start:gs(new Date,"yyyy-MM-dd"),period_end:gs(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:u=[],isLoading:p}=ft({queryKey:["recruit-goals",t],queryFn:async()=>{const{data:b,error:N}=await G.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(N)throw N;return b}}),f=Et({mutationFn:async b=>{const{data:{user:N}}=await G.auth.getUser();if(!N)throw new Error("Not authenticated");const{error:w}=await G.from("recruit_goals").insert({brokerage_id:t,title:b.title,target_count:parseInt(b.target_count),target_stage_id:b.target_stage_id||null,period_start:b.period_start,period_end:b.period_end,created_by:N.id});if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal created"}),l(!1)},onError:b=>s({title:"Error",description:b.message,variant:"destructive"})}),y=Et({mutationFn:async b=>{const{error:N}=await G.from("recruit_goals").delete().eq("id",b);if(N)throw N},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),_=b=>{const N=n.find(S=>S.id===b.target_stage_id);return{count:a.filter(S=>wg(new Date(S.created_at),{start:new Date(b.period_start),end:new Date(b.period_end)})?b.target_stage_id?S.stage_id===b.target_stage_id:!0:!1).length,stage:N}};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(Bs,{className:"h-4 w-4 mr-1"})," New Goal"]})]}),u.length===0?e.jsxs(Ie,{className:"py-12 text-center",children:[e.jsx(Oh,{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:N,stage:w}=_(b),S=Math.min(100,N/b.target_count*100),C=wg(new Date,{start:new Date(b.period_start),end:new Date(b.period_end)});return e.jsxs(Ie,{className:C?"":"opacity-60",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{className:"text-sm",children:b.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[gs(new Date(b.period_start),"MMM d")," – ",gs(new Date(b.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[C?e.jsx(Ye,{className:"text-[10px]",children:"Active"}):e.jsx(Ye,{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(yr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Be,{className:"space-y-2",children:[w&&e.jsxs(Ye,{variant:"outline",className:"text-[10px]",style:{borderColor:w.color,color:w.color},children:["Stage: ",w.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:N}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",b.target_count]})]}),e.jsx(pi,{value:S,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[S.toFixed(0),"% complete"]})]})]},b.id)})}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{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(ge,{children:"Goal Title *"}),e.jsx(Fe,{required:!0,value:i.title,onChange:b=>d(N=>({...N,title:b.target.value})),placeholder:"e.g. Q2 Recruiting Target"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Target Count *"}),e.jsx(Fe,{type:"number",min:"1",required:!0,value:i.target_count,onChange:b=>d(N=>({...N,target_count:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Target Stage (optional)"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:i.target_stage_id,onChange:b=>d(N=>({...N,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(ge,{children:"Start Date"}),e.jsx(Fe,{type:"date",required:!0,value:i.period_start,onChange:b=>d(N=>({...N,period_start:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"End Date"}),e.jsx(Fe,{type:"date",required:!0,value:i.period_end,onChange:b=>d(N=>({...N,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"})]})]})]})})]})}const o3s={first_name:"Sarah",brokerage_name:"ABC Realty",city:"Austin",sender_name:"Jeremy"};function Sct({email:t,mergeValues:s=o3s,selectedSubjectIndex:r,onClose:n}){var d;const a=u=>u.replace(/\{\{first_name\}\}/g,s.first_name).replace(/\{\{brokerage_name\}\}/g,s.brokerage_name).replace(/\{\{city\}\}/g,s.city).replace(/\{\{sender_name\}\}/g,s.sender_name).replace(/\{\{landing_page_link\}\}/g,"https://bestbrokerage.relevelup.com/join-brokerage/your-slug"),o=((d=t.subject_line_options)==null?void 0:d.length)>0?t.subject_line_options:[t.subject_line],l=r??0,i=o[l]||t.subject_line;return e.jsx(fs,{open:!0,onOpenChange:()=>n(),children:e.jsxs(ms,{className:"max-w-2xl max-h-[85vh] overflow-y-auto p-0",children:[e.jsxs(ks,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(bs,{className:"text-base",children:["Email #",t.email_number," — ",t.title]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsxs(Ye,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(rn,{className:"h-3 w-3"}),t.email_number===1?"Sent immediately":`Day ${t.delay_days}`]}),o.length>1&&e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:[o.length," subject variants"]})]})]}),e.jsxs("div",{className:"space-y-0",children:[o.length>1&&e.jsxs("div",{className:"px-6 py-3 border-b bg-muted/20",children:[e.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-2",children:"Subject Line Options"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:o.map((u,p)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-[10px] font-bold uppercase px-1.5 py-0.5 rounded ${p===l?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"}`,children:p===l?"Selected":p===0?"Primary":`Alt ${p}`}),e.jsx("span",{className:"text-sm",children:a(u)})]},p))})]}),e.jsxs("div",{className:"border-b",children:[e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-14",children:"From:"}),e.jsxs("span",{children:[s.sender_name," "]})]}),e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs text-muted-foreground border-t",children:[e.jsx("span",{className:"font-medium w-14",children:"To:"}),e.jsxs("span",{children:[s.first_name," "]})]}),e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs border-t",children:[e.jsx("span",{className:"font-medium w-14 text-muted-foreground",children:"Subject:"}),e.jsx("span",{className:"font-medium",children:a(i)})]})]}),e.jsx("div",{className:"bg-white px-8 py-6",children:e.jsx("div",{className:"prose prose-sm max-w-none [&_p]:my-3 [&_p+p]:mt-4 [&_br]:block [&_br]:mt-2",style:{fontSize:"15px",lineHeight:"1.75",color:"#1a1a1a"},dangerouslySetInnerHTML:{__html:a(t.body_html)}})})]})]})})}async function N0e(t){const{data:{session:s}}=await G.auth.getSession();if(!s)throw new Error("Not authenticated");const r=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-verify-sender",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.access_token}`},body:JSON.stringify(t)}),n=await r.json();if(!r.ok)throw new Error(n.error||"Request failed");return n}function l3s({status:t}){return t==="verified"?e.jsxs(Ye,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-green-500/20",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1"})," Verified"]}):t==="pending"?e.jsxs(Ye,{variant:"secondary",children:[e.jsx(rn,{className:"h-3 w-3 mr-1"})," Pending — check inbox"]}):t==="failed"||t==="temporary_failure"?e.jsxs(Ye,{variant:"destructive",children:[e.jsx(co,{className:"h-3 w-3 mr-1"})," Failed"]}):e.jsxs(Ye,{variant:"outline",children:[e.jsx(co,{className:"h-3 w-3 mr-1"})," Not started"]})}function c3s({brokerageId:t,onVerifiedSelect:s}){const r=es(),[n,a]=k.useState(""),[o,l]=k.useState(""),[i,d]=k.useState(!1),[u,p]=k.useState(null),[f,y]=k.useState(null),{data:_,isLoading:b}=ft({queryKey:["brokerage-verified-senders",t],queryFn:async()=>{const{data:C,error:A}=await G.from("brokerage_verified_senders").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(A)throw A;return C||[]}}),N=Et({mutationFn:async()=>N0e({action:"request_verification",brokerage_id:t,email:n,display_name:o||void 0}),onSuccess:()=>{r.invalidateQueries({queryKey:["brokerage-verified-senders",t]}),me.success("Verification email sent",{description:`Check ${n} and click the AWS verification link.`}),a(""),l(""),d(!1)},onError:C=>me.error(C.message)}),w=async C=>{var A,I;p(C.id);try{const L=await N0e({action:"check_status",sender_id:C.id});r.invalidateQueries({queryKey:["brokerage-verified-senders",t]}),((A=L.sender)==null?void 0:A.status)==="verified"?me.success(`${C.email} is verified! 🎉`):me.info(`Status: ${((I=L.sender)==null?void 0:I.status)||"unknown"}`)}catch(L){me.error(L.message)}finally{p(null)}},S=Et({mutationFn:async C=>N0e({action:"delete",sender_id:C}),onSuccess:()=>{r.invalidateQueries({queryKey:["brokerage-verified-senders",t]}),me.success("Sender removed"),y(null)},onError:C=>me.error(C.message)});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-1",children:"Verified Sender Addresses"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Verify any email address (yours or your brokerage's) so recruiting emails can be sent from that address. Anyone managing this brokerage can use these senders."})]}),b?e.jsx("div",{className:"text-xs text-muted-foreground py-3",children:"Loading…"}):_&&_.length>0?e.jsx("div",{className:"space-y-2",children:_.map(C=>e.jsxs("div",{className:"flex items-center justify-between gap-3 p-3 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-muted flex items-center justify-center shrink-0",children:e.jsx(tr,{className:"h-4 w-4 text-muted-foreground"})}),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:"text-sm font-medium truncate",children:C.email}),e.jsx(l3s,{status:C.status})]}),C.display_name&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:['"',C.display_name,'"']})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[C.status==="verified"&&s&&e.jsx(K,{size:"sm",variant:"outline",onClick:()=>s(C.email),children:"Use"}),C.status!=="verified"&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>w(C),disabled:u===C.id,title:"Refresh status from AWS",children:u===C.id?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(to,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>y(C),className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})]})]},C.id))}):e.jsx("div",{className:"text-xs text-muted-foreground py-2 italic",children:"No verified senders yet. Add one below."}),i?e.jsxs("div",{className:"rounded-lg border p-4 space-y-3 bg-muted/30",children:[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(ge,{className:"text-xs",children:"Email Address *"}),e.jsx(Fe,{type:"email",value:n,onChange:C=>a(C.target.value),placeholder:"broker@yourbrokerage.com",className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{className:"text-xs",children:"Display Name (optional)"}),e.jsx(Fe,{value:o,onChange:C=>l(C.target.value),placeholder:"John at Acme Realty",className:"text-sm"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"We'll ask AWS to send a verification email to this address. The owner must click the link before this sender can be used."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{size:"sm",onClick:()=>N.mutate(),disabled:!n.trim()||N.isPending,children:[N.isPending?e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Send Verification Email"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{d(!1),a(""),l("")},children:"Cancel"})]})]}):e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Sender Address"]}),e.jsx(Ll,{open:!!f,onOpenChange:C=>!C&&y(null),children:e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Remove this sender?"}),e.jsxs(vl,{children:['"',f==null?void 0:f.email,`" will be removed from your verified senders and from Amazon SES. You'd need to verify it again to use it.`]})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:()=>f&&S.mutate(f.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function r3e({brokerageId:t}){const s=es(),[r,n]=k.useState({brokerage_id:t,sender_name:"LevelUp",sender_email:"recruiting@relevelup.com",reply_to_email:"",merge_fields:{city:"",broker_name:""}}),{data:a}=ft({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:d,error:u}=await G.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(u)throw u;return d}}),{data:o}=ft({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:d,error:u}=await G.from("brokerages").select("name, city, state").eq("id",t).single();if(u)throw u;return d}});k.useEffect(()=>{a?n({...a,merge_fields:a.merge_fields||{city:"",broker_name:""}}):o&&n(d=>({...d,merge_fields:{...d.merge_fields,brokerage_name:o.name,city:o.city||""}}))},[a,o]);const l=Et({mutationFn:async()=>{const d={brokerage_id:t,sender_name:r.sender_name,sender_email:r.sender_email,reply_to_email:r.reply_to_email||null,merge_fields:r.merge_fields,updated_at:new Date().toISOString()};if(a!=null&&a.id){const{error:u}=await G.from("brokerage_recruit_settings").update(d).eq("id",a.id);if(u)throw u}else{const{error:u}=await G.from("brokerage_recruit_settings").insert(d);if(u)throw u}},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-recruit-settings",t]}),me.success("Recruiting email settings saved!")},onError:d=>me.error(d.message)}),i=(d,u)=>{n(p=>({...p,merge_fields:{...p.merge_fields,[d]:u}}))};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure the sender identity and merge fields for recruiting emails sent to this brokerage's prospects."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{className:"text-xs",children:"Sender Display Name"}),e.jsx(Fe,{value:r.sender_name,onChange:d=>n({...r,sender_name:d.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{className:"text-xs",children:"Sender Email Address"}),e.jsx(Fe,{value:r.sender_email,onChange:d=>n({...r,sender_email:d.target.value}),placeholder:"recruiting@relevelup.com"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Must be a verified SES identity. Verify your own address below to send from it."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{className:"text-xs",children:"Reply-To Email (optional)"}),e.jsx(Fe,{value:r.reply_to_email,onChange:d=>n({...r,reply_to_email:d.target.value}),placeholder:"jeremy@relevelup.com"})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Lb,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Sender Verification (Amazon SES)"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-4",children:["Verify any email address with AWS so recruiting emails can be sent from that address (e.g. your own broker email, instead of ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-muted text-[10px]",children:"recruiting@relevelup.com"}),")."]}),e.jsx(c3s,{brokerageId:t,onVerifiedSelect:d=>{n(u=>({...u,sender_email:d})),me.success(`Sender set to ${d}`)}})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Default Merge Fields"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"These values will auto-fill in campaign emails for this brokerage."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{className:"text-xs",children:"{{brokerage_name}}"}),e.jsx(Fe,{value:r.merge_fields.brokerage_name||"",onChange:d=>i("brokerage_name",d.target.value),placeholder:(o==null?void 0:o.name)||"Brokerage Name"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{className:"text-xs",children:"{{city}}"}),e.jsx(Fe,{value:r.merge_fields.city||"",onChange:d=>i("city",d.target.value),placeholder:"e.g. Austin"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{className:"text-xs",children:"{{sender_name}}"}),e.jsx(Fe,{value:r.merge_fields.sender_name||"",onChange:d=>i("sender_name",d.target.value),placeholder:"e.g. Jeremy"})]})]})]}),e.jsxs(K,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",children:[e.jsx(wc,{className:"h-4 w-4 mr-1"})," Save Settings"]})]})}const d3s=Hg.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",kc(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),E9e=[{key:"first_name",label:"First Name",preview:"Sarah"},{key:"brokerage_name",label:"Brokerage Name",preview:"ABC Realty"},{key:"city",label:"City",preview:"Austin"},{key:"sender_name",label:"Sender Name",preview:"Jeremy"},{key:"landing_page_link",label:"Landing Page URL",preview:"https://bestbrokerage.relevelup.com/join-brokerage/your-slug"}];function Zu({onClick:t,active:s,disabled:r,icon:n,tooltip:a}){return e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:r,className:`h-8 w-8 p-0 ${s?"bg-accent text-accent-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(n,{className:"h-4 w-4"})})}),e.jsx(Il,{side:"bottom",className:"text-xs",children:a})]})}function u3s({content:t,onChange:s}){const r=Zke({extensions:[Xke.configure({heading:{levels:[1,2,3]}}),d3s,o4e.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}}),l4e.configure({types:["heading","paragraph"]}),c4e,Yat],content:t,editorProps:{attributes:{class:"prose prose-sm max-w-none focus:outline-none min-h-[350px] px-5 py-4",style:"font-size: 15px; line-height: 1.75; color: #1a1a1a;"}},onUpdate:({editor:o})=>{s(o.getHTML())}});k.useEffect(()=>{r&&t!==r.getHTML()&&r.commands.setContent(t)},[t,r]);const n=k.useCallback(()=>{if(!r)return;const o=r.getAttributes("link").href,l=window.prompt("Enter URL",o);if(l!==null){if(l===""){r.chain().focus().extendMarkRange("link").unsetLink().run();return}r.chain().focus().extendMarkRange("link").setLink({href:l}).run()}},[r]),a=k.useCallback(o=>{r&&r.chain().focus().insertContent(`{{${o}}}`).run()},[r]);return r?e.jsx(S1,{delayDuration:300,children:e.jsxs("div",{className:"border rounded-xl overflow-hidden bg-background shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30",children:[e.jsx(Zu,{onClick:()=>r.chain().focus().toggleBold().run(),active:r.isActive("bold"),icon:Y4,tooltip:"Bold"}),e.jsx(Zu,{onClick:()=>r.chain().focus().toggleItalic().run(),active:r.isActive("italic"),icon:aS,tooltip:"Italic"}),e.jsx(Zu,{onClick:()=>r.chain().focus().toggleUnderline().run(),active:r.isActive("underline"),icon:UL,tooltip:"Underline"}),e.jsx(Zu,{onClick:()=>r.chain().focus().toggleStrike().run(),active:r.isActive("strike"),icon:zL,tooltip:"Strikethrough"}),e.jsx(jo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Zu,{onClick:()=>r.chain().focus().toggleHeading({level:1}).run(),active:r.isActive("heading",{level:1}),icon:MM,tooltip:"Heading 1"}),e.jsx(Zu,{onClick:()=>r.chain().focus().toggleHeading({level:2}).run(),active:r.isActive("heading",{level:2}),icon:TM,tooltip:"Heading 2"}),e.jsx(Zu,{onClick:()=>r.chain().focus().toggleHeading({level:3}).run(),active:r.isActive("heading",{level:3}),icon:vL,tooltip:"Heading 3"}),e.jsx(jo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Zu,{onClick:()=>r.chain().focus().toggleBulletList().run(),active:r.isActive("bulletList"),icon:Rh,tooltip:"Bullet List"}),e.jsx(Zu,{onClick:()=>r.chain().focus().toggleOrderedList().run(),active:r.isActive("orderedList"),icon:Yy,tooltip:"Numbered List"}),e.jsx(Zu,{onClick:()=>r.chain().focus().toggleBlockquote().run(),active:r.isActive("blockquote"),icon:xS,tooltip:"Blockquote"}),e.jsx(Zu,{onClick:()=>r.chain().focus().setHorizontalRule().run(),icon:Xy,tooltip:"Divider"}),e.jsx(jo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Zu,{onClick:()=>r.chain().focus().setTextAlign("left").run(),active:r.isActive({textAlign:"left"}),icon:W4,tooltip:"Align Left"}),e.jsx(Zu,{onClick:()=>r.chain().focus().setTextAlign("center").run(),active:r.isActive({textAlign:"center"}),icon:G4,tooltip:"Align Center"}),e.jsx(Zu,{onClick:()=>r.chain().focus().setTextAlign("right").run(),active:r.isActive({textAlign:"right"}),icon:K4,tooltip:"Align Right"}),e.jsx(jo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Zu,{onClick:n,active:r.isActive("link"),icon:go,tooltip:"Insert Link"}),e.jsx(jo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Zu,{onClick:()=>r.chain().focus().undo().run(),disabled:!r.can().undo(),icon:NS,tooltip:"Undo"}),e.jsx(Zu,{onClick:()=>r.chain().focus().redo().run(),disabled:!r.can().redo(),icon:gS,tooltip:"Redo"}),e.jsx("div",{className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs font-medium",onClick:()=>{r&&r.chain().focus().insertContent('

Learn More About Us

').run()},children:"🔘 CTA Button"}),e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs font-medium",children:[e.jsx(BM,{className:"h-3.5 w-3.5"}),"Merge Tags"]})}),e.jsx(jd,{align:"end",className:"w-56",children:E9e.map(o=>e.jsxs(xa,{onClick:()=>a(o.key),className:"flex flex-col items-start gap-0.5",children:[e.jsx("span",{className:"font-medium text-sm",children:o.label}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:`{{${o.key}}}`})]},o.key))})]})]}),e.jsx("div",{className:"bg-white",children:e.jsx(Wke,{editor:r,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[350px] [&_.ProseMirror_p]:my-3 [&_.ProseMirror_ul]:my-3 [&_.ProseMirror_ol]:my-3 [&_.ProseMirror_blockquote]:my-3 [&_.ProseMirror_h1]:my-4 [&_.ProseMirror_h2]:my-3 [&_.ProseMirror_h3]:my-2"})}),e.jsx("div",{className:"border-t px-4 py-2.5 bg-muted/20",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Tags:"}),E9e.map(o=>e.jsx(Ye,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 font-mono text-[10px] px-2 py-0.5",onClick:()=>a(o.key),children:`{{${o.key}}}`},o.key))]})})]})}):null}function h3s({open:t,onClose:s,campaignName:r,stat:n}){return e.jsx(fs,{open:t,onOpenChange:a=>!a&&s(),children:e.jsxs(ms,{className:"max-w-3xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Yo,{className:"h-5 w-5 text-primary"}),r," — Engagement Stats"]}),e.jsx(Rr,{children:"Per-email breakdown of sends, opens, and clicks for this campaign at your brokerage."})]}),!n||n.sent===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 emails sent yet for this campaign"}),e.jsx("p",{className:"text-sm",children:"Stats will appear once emails start sending"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(E9,{icon:tr,color:"text-blue-500",label:"Total Sent",value:n.sent.toLocaleString()}),e.jsx(E9,{icon:jn,color:"text-amber-500",label:"Opens",value:`${n.opened.toLocaleString()}`,sub:`${n.openRate.toFixed(1)}% open rate`}),e.jsx(E9,{icon:Cm,color:"text-green-500",label:"Clicks",value:`${n.clicked.toLocaleString()}`,sub:`${n.clickRate.toFixed(1)}% click rate`}),e.jsx(E9,{icon:Qc,color:"text-destructive",label:"Failed",value:n.failed.toLocaleString()})]}),n.lastSentAt&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[e.jsx(rn,{className:"h-3 w-3"})," Last sent: ",gs(new Date(n.lastSentAt),"MMM d, yyyy h:mm a")]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold mb-2 mt-4",children:"Per-Email Performance"}),e.jsx("div",{className:"space-y-2",children:n.byEmail.map(a=>{const o=a.sent_count>0?a.opened_count/a.sent_count*100:0,l=a.sent_count>0?a.clicked_count/a.sent_count*100:0;return e.jsx(Ie,{className:"overflow-hidden",children:e.jsxs(Be,{className:"py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"h-8 w-8 rounded-full bg-primary/10 text-primary font-bold text-xs flex items-center justify-center shrink-0",children:["#",a.email_number]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.title}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-1",children:[e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(tr,{className:"h-2.5 w-2.5"})," ",a.sent_count.toLocaleString()," sent"]}),e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1 border-amber-500/30 text-amber-600",children:[e.jsx(jn,{className:"h-2.5 w-2.5"})," ",a.opened_count.toLocaleString()," (",o.toFixed(1),"%)"]}),e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1 border-green-500/30 text-green-600",children:[e.jsx(Cm,{className:"h-2.5 w-2.5"})," ",a.clicked_count.toLocaleString()," (",l.toFixed(1),"%)"]}),a.failed_count>0&&e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1 border-destructive/30 text-destructive",children:[e.jsx(Qc,{className:"h-2.5 w-2.5"})," ",a.failed_count.toLocaleString()," failed"]})]})]})]}),a.sent_count>0&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-amber-500 transition-all",style:{width:`${Math.min(o,100)}%`}})}),e.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-green-500 transition-all",style:{width:`${Math.min(l,100)}%`}})})]})]})},a.campaign_email_id)})})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground italic",children:"Open rates count when the email is loaded with images on. Click rates count any tracked link click in the email."})]})]})})}function E9({icon:t,color:s,label:r,value:n,sub:a}){return e.jsx(Ie,{children:e.jsx(Be,{className:"pt-4 pb-3",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(t,{className:`h-6 w-6 ${s}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xl font-bold leading-none",children:n}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:r}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]})]})})})}function Cct(t){return ft({queryKey:["recruit-campaign-stats",t],enabled:!!t,staleTime:6e4,queryFn:async()=>{const{data:s,error:r}=await G.from("recruit_campaign_email_stats").select("*").eq("brokerage_id",t);if(r)throw r;const n=s??[],a={};for(const o of n){a[o.campaign_id]||(a[o.campaign_id]={campaign_id:o.campaign_id,sent:0,opened:0,clicked:0,failed:0,openRate:0,clickRate:0,byEmail:[],lastSentAt:null});const l=a[o.campaign_id];l.sent+=o.sent_count,l.opened+=o.opened_count,l.clicked+=o.clicked_count,l.failed+=o.failed_count,l.byEmail.push(o),o.last_sent_at&&(!l.lastSentAt||o.last_sent_at>l.lastSentAt)&&(l.lastSentAt=o.last_sent_at)}return Object.values(a).forEach(o=>{o.openRate=o.sent>0?o.opened/o.sent*100:0,o.clickRate=o.sent>0?o.clicked/o.sent*100:0,o.byEmail.sort((l,i)=>l.email_number-i.email_number)}),a}})}const P9e={cold:{icon:Bv,color:"text-blue-500",bg:"bg-blue-50 dark:bg-blue-950/30",label:"Cold — Curiosity"},warm:{icon:t1,color:"text-amber-500",bg:"bg-amber-50 dark:bg-amber-950/30",label:"Warm — Growth"},hot:{icon:ch,color:"text-red-500",bg:"bg-red-50 dark:bg-red-950/30",label:"Hot — Private Invite"}};function Mct({brokerageId:t}){var ze,Ee,ve,Re;const{user:s}=$s(),r=es(),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,d]=k.useState(null),[u,p]=k.useState(!1),[f,y]=k.useState(!1),[_,b]=k.useState("editor"),[N,w]=k.useState(null),[S,C]=k.useState(null),{data:A={}}=Cct(t),[I,L]=k.useState({name:"",description:"",theme:"",goal:"",primary_cta:"Learn more",warmth_level:"warm",sender_name:"",sender_email:"",reply_to_email:""}),{data:O}=ft({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:Ue,error:ye}=await G.from("brokerages").select("name, city, state").eq("id",t).single();if(ye)throw ye;return Ue}}),{data:U}=ft({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:Ue,error:ye}=await G.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(ye)throw ye;return Ue}}),q={first_name:"Sarah",brokerage_name:((ze=U==null?void 0:U.merge_fields)==null?void 0:ze.brokerage_name)||(O==null?void 0:O.name)||"Your Brokerage",city:((Ee=U==null?void 0:U.merge_fields)==null?void 0:Ee.city)||(O==null?void 0:O.city)||"Your City",sender_name:((ve=U==null?void 0:U.merge_fields)==null?void 0:ve.sender_name)||(U==null?void 0:U.sender_name)||"Your Name"},$=Ue=>Ue.replace(/\{\{first_name\}\}/g,q.first_name).replace(/\{\{brokerage_name\}\}/g,q.brokerage_name).replace(/\{\{city\}\}/g,q.city).replace(/\{\{sender_name\}\}/g,q.sender_name),{data:V=[],isLoading:ee}=ft({queryKey:["recruit-campaigns",t],queryFn:async()=>{const{data:Ue,error:ye}=await G.from("recruit_campaigns").select("*").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("sort_order");if(ye)throw ye;return Ue}}),{data:Z={}}=ft({queryKey:["recruit-campaign-emails",t],enabled:V.length>0,queryFn:async()=>{const Ue=V.map(Ge=>Ge.id),{data:ye,error:ct}=await G.from("recruit_campaign_emails").select("*").in("campaign_id",Ue).order("email_number");if(ct)throw ct;const pe={};return ye.forEach(Ge=>{pe[Ge.campaign_id]||(pe[Ge.campaign_id]=[]),pe[Ge.campaign_id].push(Ge)}),pe}}),J=Object.values(Z).flat().map(Ue=>Ue.id),{data:Y=[]}=ft({queryKey:["recruit-subject-overrides",t],enabled:J.length>0,queryFn:async()=>{const{data:Ue,error:ye}=await G.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(ye)throw ye;return Ue}}),ce={};Y.forEach(Ue=>{ce[Ue.campaign_email_id]=Ue.selected_subject_index});const ae=Et({mutationFn:async({campaignEmailId:Ue,selectedIndex:ye})=>{const{error:ct}=await G.from("recruit_brokerage_subject_overrides").upsert({brokerage_id:t,campaign_email_id:Ue,selected_subject_index:ye,updated_at:new Date().toISOString()},{onConflict:"brokerage_id,campaign_email_id"});if(ct)throw ct},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-subject-overrides",t]}),me.success("Subject line updated for your brokerage")},onError:Ue=>me.error(Ue.message)}),ie=Et({mutationFn:async Ue=>{const{error:ye}=await G.from("recruit_campaign_emails").update({title:Ue.title,subject_line:Ue.subject_line,subject_line_options:Ue.subject_line_options,body_html:Ue.body_html,body_text:Ue.body_text,delay_days:Ue.delay_days,updated_at:new Date().toISOString()}).eq("id",Ue.id);if(ye)throw ye},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email template saved!"),l(null)},onError:Ue=>me.error(Ue.message)}),le=Et({mutationFn:async()=>{const Ue=I.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),{data:ye,error:ct}=await G.from("recruit_campaigns").insert({name:I.name,slug:Ue,description:I.description||null,theme:I.theme||null,goal:I.goal||null,primary_cta:I.primary_cta||"Learn more",warmth_level:I.warmth_level,brokerage_id:t,created_by:s==null?void 0:s.id,sender_name:I.sender_name||null,sender_email:I.sender_email||null,reply_to_email:I.reply_to_email||null,is_active:!0,sort_order:V.length+1}).select().single();if(ct)throw ct;const pe=[{email_number:1,title:"Introduction",subject_line:"Hey {{first_name}}, quick question",delay_days:0},{email_number:2,title:"Follow Up",subject_line:"Following up, {{first_name}}",delay_days:7},{email_number:3,title:"Value Add",subject_line:"{{first_name}}, thought you'd want to see this",delay_days:14},{email_number:4,title:"Final Touch",subject_line:"Last note, {{first_name}}",delay_days:21}],{error:Ge}=await G.from("recruit_campaign_emails").insert(pe.map(tt=>({campaign_id:ye.id,...tt,body_html:"

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",subject_line_options:[],is_active:!0})));if(Ge)throw Ge;return ye},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Campaign created with 4 starter emails!"),y(!1),L({name:"",description:"",theme:"",goal:"",primary_cta:"Learn more",warmth_level:"warm",sender_name:"",sender_email:"",reply_to_email:""})},onError:Ue=>me.error(Ue.message)}),fe=Et({mutationFn:async Ue=>{const{error:ye}=await G.from("recruit_campaigns").update({name:Ue.name,description:Ue.description,theme:Ue.theme,goal:Ue.goal,primary_cta:Ue.primary_cta,warmth_level:Ue.warmth_level,sender_name:Ue.sender_name,sender_email:Ue.sender_email,reply_to_email:Ue.reply_to_email,updated_at:new Date().toISOString()}).eq("id",Ue.id);if(ye)throw ye},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),me.success("Campaign settings saved!"),w(null)},onError:Ue=>me.error(Ue.message)}),xe=Et({mutationFn:async Ue=>{var st,Ce;const{data:ye}=await G.from("recruit_campaign_emails").select("email_number, delay_days").eq("campaign_id",Ue).order("email_number",{ascending:!1}).limit(1),ct=((st=ye==null?void 0:ye[0])==null?void 0:st.email_number)??0,pe=((Ce=ye==null?void 0:ye[0])==null?void 0:Ce.delay_days)??0,Ge=ct+1,{error:tt}=await G.from("recruit_campaign_emails").insert({campaign_id:Ue,email_number:Ge,title:`Email ${Ge}`,subject_line:"Hey {{first_name}}",subject_line_options:[],body_html:"

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",delay_days:pe+7,is_active:!0});if(tt)throw tt},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email added to campaign!")},onError:Ue=>me.error(Ue.message)}),he=Et({mutationFn:async Ue=>{const{error:ye}=await G.from("recruit_campaigns").delete().eq("id",Ue);if(ye)throw ye},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Campaign deleted")},onError:Ue=>me.error(Ue.message)}),we=Et({mutationFn:async Ue=>{const{error:ye}=await G.from("recruit_campaign_emails").delete().eq("id",Ue);if(ye)throw ye},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email removed from campaign")},onError:Ue=>me.error(Ue.message)}),Ne=Et({mutationFn:async({emailId:Ue,delay_days:ye})=>{const{error:ct}=await G.from("recruit_campaign_emails").update({delay_days:ye,updated_at:new Date().toISOString()}).eq("id",Ue);if(ct)throw ct},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Send delay updated")},onError:Ue=>me.error(Ue.message)});if(ee)return e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});const Ve=V.filter(Ue=>!Ue.brokerage_id),Te=V.filter(Ue=>Ue.brokerage_id===t);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Recruiting Campaigns"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"System campaigns + custom campaigns · Each can have its own email settings"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-1.5",children:[e.jsx(So,{className:"h-4 w-4"})," Default Settings"]}),e.jsxs(K,{size:"sm",onClick:()=>y(!0),className:"gap-1.5",children:[e.jsx(Bs,{className:"h-4 w-4"})," New Campaign"]})]})]}),e.jsx(Ie,{className:"border-primary/20 bg-primary/5",children:e.jsx(Be,{className:"py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(qr,{className:"h-5 w-5 text-primary mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-semibold",children:"Per-Campaign Email Settings"}),e.jsxs("p",{className:"text-muted-foreground",children:["Each campaign can override the default sender name, email, and reply-to. Click the ",e.jsx(So,{className:"inline h-3.5 w-3.5"})," icon on any campaign to customize."]})]})]})})}),Te.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[e.jsx(_L,{className:"h-4 w-4"})," Your Custom Campaigns"]}),e.jsx("div",{className:"space-y-3",children:Te.map(Ue=>Ae(Ue,!0))})]}),Ve.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[e.jsx(qr,{className:"h-4 w-4"})," System Campaigns"]}),e.jsx("div",{className:"space-y-3",children:Ve.map(Ue=>Ae(Ue,!1))})]}),V.length===0&&e.jsx(Ie,{children:e.jsxs(Be,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(tr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No campaigns yet. Create your first campaign to start automated outreach."}),e.jsxs(K,{className:"mt-4",onClick:()=>y(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})}),e.jsx(h3s,{open:!!S,onClose:()=>C(null),campaignName:(S==null?void 0:S.name)||"",stat:S&&A[S.id]||null}),i&&e.jsx(Sct,{email:i,mergeValues:q,selectedSubjectIndex:ce[i.id],onClose:()=>d(null)}),e.jsx(fs,{open:!!o,onOpenChange:Ue=>!Ue&&l(null),children:e.jsxs(ms,{className:"max-w-4xl max-h-[90vh] overflow-y-auto p-0",children:[e.jsxs(ks,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(rS,{className:"h-5 w-5 text-primary"}),"Edit Email #",o==null?void 0:o.email_number]}),e.jsx(Rr,{children:o==null?void 0:o.title})]}),o&&e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Title"}),e.jsx(Fe,{value:o.title,onChange:Ue=>l({...o,title:Ue.target.value}),className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Delay (days after previous)"}),e.jsx(Fe,{type:"number",min:0,max:90,value:o.delay_days,onChange:Ue=>l({...o,delay_days:parseInt(Ue.target.value)||7}),className:"h-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Subject Line"}),e.jsx(Fe,{value:o.subject_line,onChange:Ue=>l({...o,subject_line:Ue.target.value}),placeholder:"e.g. Hey {{first_name}}, quick question...",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ge,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Alternative Subject Lines ",e.jsx("span",{className:"text-muted-foreground font-normal normal-case",children:"(one per line, for A/B testing)"})]}),e.jsx(_r,{value:((Re=o.subject_line_options)==null?void 0:Re.join(` `))||"",onChange:Ue=>l({...o,subject_line_options:Ue.target.value.split(` `).filter(Boolean)}),rows:2,className:"text-sm resize-none"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Body"}),e.jsx(ta,{value:_,onValueChange:Ue=>b(Ue),children:e.jsxs(Qn,{className:"h-7",children:[e.jsx(ls,{value:"editor",className:"text-xs px-3 h-6",children:"Editor"}),e.jsx(ls,{value:"preview",className:"text-xs px-3 h-6",children:"Preview"})]})})]}),_==="editor"?e.jsx(u3s,{content:o.body_html,onChange:Ue=>l({...o,body_html:Ue})}):e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"bg-muted/50 px-4 py-2 border-b space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-12",children:"From:"}),e.jsxs("span",{children:[q.sender_name," "]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-12",children:"To:"}),e.jsxs("span",{children:[q.first_name," "]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-medium w-12 text-muted-foreground",children:"Subject:"}),e.jsx("span",{className:"font-medium",children:$(o.subject_line)})]})]}),e.jsx("div",{className:"bg-white p-6",children:e.jsx("div",{className:"prose prose-sm max-w-none",style:{fontSize:"15px",lineHeight:"1.75",color:"#1a1a1a"},dangerouslySetInnerHTML:{__html:$(o.body_html)}})})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Changes are saved to this campaign's templates"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{size:"sm",onClick:()=>ie.mutate(o),disabled:ie.isPending,className:"gap-1.5",children:[e.jsx(wc,{className:"h-3.5 w-3.5"})," Save Changes"]})]})]})]})]})}),e.jsx(fs,{open:f,onOpenChange:y,children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Bs,{className:"h-5 w-5 text-primary"})," Create Custom Campaign"]}),e.jsx(Rr,{children:"Build your own recruiting email sequence with custom sender settings."})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-medium",children:"Campaign Name *"}),e.jsx(Fe,{value:I.name,onChange:Ue=>L({...I,name:Ue.target.value}),placeholder:"e.g. Q2 Agent Outreach"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(zs,{value:I.warmth_level,onValueChange:Ue=>L({...I,warmth_level:Ue}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"cold",children:"❄️ Cold — Curiosity"}),e.jsx(yt,{value:"warm",children:"☀️ Warm — Growth"}),e.jsx(yt,{value:"hot",children:"🔥 Hot — Private Invite"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-medium",children:"Primary CTA"}),e.jsx(Fe,{value:I.primary_cta,onChange:Ue=>L({...I,primary_cta:Ue.target.value}),placeholder:"Learn more"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-medium",children:"Description"}),e.jsx(_r,{value:I.description,onChange:Ue=>L({...I,description:Ue.target.value}),placeholder:"What is this campaign about?",rows:2})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-medium",children:"Goal"}),e.jsx(Fe,{value:I.goal,onChange:Ue=>L({...I,goal:Ue.target.value}),placeholder:"e.g. Convert warm leads to meetings"})]}),e.jsxs(uf,{children:[e.jsx(hf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs font-medium text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(tr,{className:"h-3.5 w-3.5"})," Email Settings Override"]}),e.jsx(Fi,{className:"h-3.5 w-3.5"})]})}),e.jsxs(mf,{className:"space-y-3 pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave blank to use brokerage defaults."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs",children:"Sender Name"}),e.jsx(Fe,{value:I.sender_name,onChange:Ue=>L({...I,sender_name:Ue.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs",children:"Sender Email"}),e.jsx(Fe,{value:I.sender_email,onChange:Ue=>L({...I,sender_email:Ue.target.value}),placeholder:"e.g. recruiting@send.relevelup.com"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Must be a verified sending domain"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs",children:"Reply-To Email"}),e.jsx(Fe,{value:I.reply_to_email,onChange:Ue=>L({...I,reply_to_email:Ue.target.value}),placeholder:"e.g. jeremy@mybrokerage.com"})]})]})]}),e.jsxs(K,{className:"w-full",disabled:!I.name.trim()||le.isPending,onClick:()=>le.mutate(),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})]})}),e.jsx(fs,{open:!!N,onOpenChange:Ue=>!Ue&&w(null),children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(So,{className:"h-5 w-5 text-primary"})," Campaign Email Settings"]}),e.jsx(Rr,{children:"Override the default sender for this campaign. Leave blank to use brokerage defaults."})]}),N&&e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-medium",children:"Campaign Name"}),e.jsx(Fe,{value:N.name,onChange:Ue=>w({...N,name:Ue.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(zs,{value:N.warmth_level,onValueChange:Ue=>w({...N,warmth_level:Ue}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"cold",children:"❄️ Cold"}),e.jsx(yt,{value:"warm",children:"☀️ Warm"}),e.jsx(yt,{value:"hot",children:"🔥 Hot"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-medium",children:"Goal"}),e.jsx(Fe,{value:N.goal||"",onChange:Ue=>w({...N,goal:Ue.target.value})})]}),e.jsxs("div",{className:"border-t pt-4 space-y-3",children:[e.jsxs("p",{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(tr,{className:"h-4 w-4 text-primary"})," Email Sender Override"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs",children:"Sender Name"}),e.jsx(Fe,{value:N.sender_name||"",onChange:Ue=>w({...N,sender_name:Ue.target.value}),placeholder:"Uses brokerage default"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs",children:"Sender Email"}),e.jsx(Fe,{value:N.sender_email||"",onChange:Ue=>w({...N,sender_email:Ue.target.value}),placeholder:"Uses brokerage default"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Must be a verified sending domain"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs",children:"Reply-To Email"}),e.jsx(Fe,{value:N.reply_to_email||"",onChange:Ue=>w({...N,reply_to_email:Ue.target.value}),placeholder:"Uses brokerage default"})]})]}),e.jsxs(K,{className:"w-full",onClick:()=>fe.mutate(N),disabled:fe.isPending,children:[e.jsx(wc,{className:"h-4 w-4 mr-1"})," Save Campaign Settings"]})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Default Recruiting Email Settings"}),e.jsx(Rr,{children:"These defaults apply to campaigns without their own overrides."})]}),e.jsx(r3e,{brokerageId:t})]})})]});function Ae(Ue,ye){const ct=P9e[Ue.warmth_level]||P9e.cold,pe=ct.icon,Ge=Z[Ue.id]||[],tt=n===Ue.id,st=!!(Ue.sender_name||Ue.sender_email||Ue.reply_to_email),Ce=A[Ue.id];return e.jsxs(Ie,{className:"overflow-hidden transition-shadow hover:shadow-md",children:[e.jsx(Lt,{className:"cursor-pointer hover:bg-muted/40 transition-colors py-4",onClick:()=>a(tt?null:Ue.id),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`h-11 w-11 rounded-xl ${ct.bg} flex items-center justify-center`,children:e.jsx(pe,{className:`h-5 w-5 ${ct.color}`})}),e.jsxs("div",{children:[e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[Ue.name,e.jsx(Ye,{variant:Ue.is_active?"default":"secondary",className:"text-[10px] px-1.5",children:Ue.is_active?"Active":"Draft"}),ye&&e.jsx(Ye,{variant:"outline",className:"text-[10px] px-1.5",children:"Custom"}),st&&e.jsxs(Ye,{variant:"outline",className:"text-[10px] px-1.5 border-primary/30 text-primary",children:[e.jsx(tr,{className:"h-2.5 w-2.5 mr-0.5"})," Custom Sender"]})]}),e.jsx(mr,{className:"text-xs mt-0.5",children:Ue.theme||Ue.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:et=>{et.stopPropagation(),w({...Ue})},children:e.jsx(So,{className:"h-4 w-4 text-muted-foreground"})}),ye&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:et=>{et.stopPropagation(),confirm("Delete this campaign and all its emails? This cannot be undone.")&&he.mutate(Ue.id)},children:e.jsx(yr,{className:"h-4 w-4"})}),Ce&&Ce.sent>0&&e.jsxs("div",{className:"hidden md:flex items-center gap-1.5",children:[e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1 font-medium",title:"Total emails sent",children:[e.jsx(tr,{className:"h-2.5 w-2.5"})," ",Ce.sent.toLocaleString()]}),e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1 border-amber-500/30 text-amber-600 font-medium",title:`${Ce.openRate.toFixed(1)}% open rate`,children:[e.jsx(jn,{className:"h-2.5 w-2.5"})," ",Ce.opened.toLocaleString()," (",Ce.openRate.toFixed(0),"%)"]}),e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1 border-green-500/30 text-green-600 font-medium",title:`${Ce.clickRate.toFixed(1)}% click rate`,children:[e.jsx(Cm,{className:"h-2.5 w-2.5"})," ",Ce.clicked.toLocaleString()," (",Ce.clickRate.toFixed(1),"%)"]})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 px-2 gap-1 text-xs",onClick:et=>{et.stopPropagation(),C(Ue)},title:"View detailed engagement stats",children:[e.jsx(so,{className:"h-3.5 w-3.5"})," Stats"]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(tr,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:[Ge.length," emails"]})]}),e.jsx("div",{className:"h-7 w-7 rounded-md flex items-center justify-center",children:tt?e.jsx(lf,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Fi,{className:"h-4 w-4 text-muted-foreground"})})]})]})}),tt&&e.jsxs(Be,{className:"pt-0 pb-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-3 rounded-lg bg-muted/40 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Goal"}),e.jsx("p",{className:"mt-0.5",children:Ue.goal||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Primary CTA"}),e.jsx("p",{className:"mt-0.5",children:Ue.primary_cta||"—"})]})]}),st&&e.jsxs("div",{className:"p-3 rounded-lg bg-primary/5 border border-primary/10 text-sm",children:[e.jsxs("p",{className:"text-xs font-semibold text-primary mb-1 flex items-center gap-1",children:[e.jsx(tr,{className:"h-3 w-3"})," Campaign Sender Override"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs text-muted-foreground",children:[Ue.sender_name&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",Ue.sender_name]}),Ue.sender_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Email:"})," ",Ue.sender_email]}),Ue.reply_to_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Reply-To:"})," ",Ue.reply_to_email]})]})]}),e.jsx("div",{className:"relative",children:Ge.map((et,Ct)=>{var Ot,ut;return e.jsxs("div",{className:"relative flex gap-4 pb-4 last:pb-0",children:[CtOe.stopPropagation(),onBlur:Oe=>{const Xe=parseInt(Oe.target.value)||0;Xe!==et.delay_days&&Ne.mutate({emailId:et.id,delay_days:Xe})},onKeyDown:Oe=>{Oe.key==="Enter"&&Oe.target.blur()}}),"days"]})]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(rn,{className:"h-3 w-3"}),et.email_number===1?"Sent immediately":`Day ${et.delay_days}`]}),e.jsx("span",{className:"text-border",children:"•"}),e.jsxs("span",{className:"truncate",children:["Subject: ",$(((Ot=et.subject_line_options)==null?void 0:Ot.length)>0&&et.subject_line_options[ce[et.id]??0]||et.subject_line)]})]}),((ut=et.subject_line_options)==null?void 0:ut.length)>1&&e.jsx("div",{className:"mt-2",children:e.jsxs(zs,{value:String(ce[et.id]??0),onValueChange:Oe=>ae.mutate({campaignEmailId:et.id,selectedIndex:parseInt(Oe)}),children:[e.jsx(Os,{className:"h-7 text-xs w-full max-w-sm",children:e.jsx(qs,{placeholder:"Choose subject line"})}),e.jsx(Fs,{children:et.subject_line_options.map((Oe,Xe)=>e.jsxs(yt,{value:String(Xe),className:"text-xs",children:[e.jsxs("span",{className:"font-medium mr-1.5",children:[Xe===0?"Primary":`Alt ${Xe}`,":"]}),$(Oe)]},Xe))})]})})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>d(et),children:e.jsx(jn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{l({...et}),b("editor")},children:e.jsx(pa,{className:"h-4 w-4"})}),ye&&Ge.length>1&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>{confirm("Delete this email from the sequence?")&&we.mutate(et.id)},children:e.jsx(yr,{className:"h-4 w-4"})})]})]})})]},et.id)})}),ye&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5",onClick:()=>xe.mutate(Ue.id),disabled:xe.isPending,children:[e.jsx(Bs,{className:"h-3.5 w-3.5"})," Add Email to Sequence"]})]})]},Ue.id)}}const I9e={active:{icon:Co,color:"bg-green-500/10 text-green-600",label:"Active"},paused:{icon:uh,color:"bg-amber-500/10 text-amber-600",label:"Paused"},completed:{icon:si,color:"bg-blue-500/10 text-blue-600",label:"Completed"},cancelled:{icon:Ql,color:"bg-red-500/10 text-red-600",label:"Cancelled"}},L9e={sent:{icon:tr,color:"text-blue-500"},opened:{icon:jn,color:"text-amber-500"},clicked:{icon:Cm,color:"text-green-500"},failed:{icon:Qc,color:"text-destructive"}};function Tct({brokerageId:t}){var ze,Ee,ve,Re,Ue;const{user:s}=$s(),r=es(),[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,d]=k.useState(new Set),[u,p]=k.useState("assignments"),[f,y]=k.useState(null),[_,b]=k.useState(""),[N,w]=k.useState("all"),[S,C]=k.useState("all"),{data:A={}}=ft({queryKey:["recruit-campaign-emails-for-preview",t],queryFn:async()=>{const{data:ye,error:ct}=await G.from("recruit_campaign_emails").select("*").order("email_number");if(ct)throw ct;const pe={};return(ye??[]).forEach(Ge=>{pe[Ge.campaign_id]||(pe[Ge.campaign_id]=[]),pe[Ge.campaign_id].push(Ge)}),pe}}),{data:I}=ft({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerages").select("name, city, state").eq("id",t).single();if(ct)throw ct;return ye}}),{data:L}=ft({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(ct)throw ct;return ye}}),{data:O=[]}=ft({queryKey:["recruit-subject-overrides",t],queryFn:async()=>{const{data:ye,error:ct}=await G.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(ct)throw ct;return ye}}),U={};O.forEach(ye=>{U[ye.campaign_email_id]=ye.selected_subject_index});const q={first_name:((ze=f==null?void 0:f.prospect)==null?void 0:ze.first_name)||"Sarah",brokerage_name:((Ee=L==null?void 0:L.merge_fields)==null?void 0:Ee.brokerage_name)||(I==null?void 0:I.name)||"Your Brokerage",city:((ve=L==null?void 0:L.merge_fields)==null?void 0:ve.city)||(I==null?void 0:I.city)||"Your City",sender_name:((Re=L==null?void 0:L.merge_fields)==null?void 0:Re.sender_name)||(L==null?void 0:L.sender_name)||"Your Name"},$=ye=>{const ct=A[ye.campaign_id]||[],pe=ye.current_email_number+1;return ct.find(Ge=>Ge.email_number===pe)||null},{data:V=[],isLoading:ee}=ft({queryKey:["recruit-campaign-assignments",t],queryFn:async()=>{let ct=[],pe=0;for(;;){const{data:Ge,error:tt}=await G.from("recruit_campaign_assignments").select(` *, prospect:recruit_prospects(first_name, last_name, email), campaign:recruit_campaigns(name, warmth_level) `).eq("brokerage_id",t).order("created_at",{ascending:!1}).range(pe,pe+1e3-1);if(tt)throw tt;if(ct=ct.concat(Ge??[]),!Ge||Ge.length<1e3)break;pe+=1e3}return ct}}),{data:Z=[]}=ft({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{const{data:ye,error:ct}=await G.from("recruit_campaign_sends").select(` *, prospect:recruit_prospects(first_name, last_name, email), campaign_email:recruit_campaign_emails(title, campaign_id) `).eq("brokerage_id",t).neq("status","failed").order("sent_at",{ascending:!1}).limit(500);if(ct)throw ct;return ye}}),{data:J=[]}=ft({queryKey:["recruit-campaigns"],queryFn:async()=>{const{data:ye,error:ct}=await G.from("recruit_campaigns").select("id, name, warmth_level").eq("is_active",!0).order("sort_order");if(ct)throw ct;return ye}}),{data:Y=[]}=ft({queryKey:["recruit-prospects-for-assign",t],queryFn:async()=>{let ct=[],pe=0;for(;;){const{data:Ge,error:tt}=await G.from("recruit_prospects").select("id, first_name, last_name, email").eq("brokerage_id",t).order("first_name").range(pe,pe+1e3-1);if(tt)throw tt;if(ct=ct.concat(Ge??[]),!Ge||Ge.length<1e3)break;pe+=1e3}return ct}}),ce=new Set(V.map(ye=>`${ye.prospect_id}-${ye.campaign_id}`)),ae=Et({mutationFn:async()=>{if(!o||i.size===0)throw new Error("Select a campaign and at least one prospect");const ye=new Date,ct=Array.from(i).filter(Ge=>!ce.has(`${Ge}-${o}`)).map(Ge=>({prospect_id:Ge,campaign_id:o,brokerage_id:t,assigned_by:s.id,status:"active",current_email_number:0,next_send_at:ye.toISOString(),started_at:ye.toISOString()}));if(ct.length===0)throw new Error("All selected prospects are already assigned to this campaign");const{error:pe}=await G.from("recruit_campaign_assignments").insert(ct);if(pe)throw pe},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),me.success(`Campaign assigned to ${i.size} prospect(s)!`),a(!1),l(""),d(new Set)},onError:ye=>me.error(ye.message)}),ie=Et({mutationFn:async({id:ye,newStatus:ct})=>{const{error:pe}=await G.from("recruit_campaign_assignments").update({status:ct,updated_at:new Date().toISOString()}).eq("id",ye);if(pe)throw pe},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),me.success("Assignment updated")}}),le=Et({mutationFn:async()=>{const{data:ye,error:ct}=await G.functions.invoke("ses-recruit-drip",{body:{action:"process_drips"}});if(ct)throw ct;return ye},onSuccess:ye=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),r.invalidateQueries({queryKey:["recruit-campaign-sends",t]}),me.success(`Wave sent! ${ye.sent} emails delivered, ${ye.skipped} skipped, ${ye.failed} failed`)},onError:ye=>me.error(`Send failed: ${ye.message}`)}),fe=V.filter(ye=>ye.status==="active").length;V.filter(ye=>ye.status==="completed").length;const xe=V.filter(ye=>ye.status==="active"&&ye.next_send_at&&new Date(ye.next_send_at)<=new Date).length,{data:he={}}=Cct(t),we=V.reduce((ye,ct)=>ye+Math.max(0,ct.current_email_number||0),0),Ne=Object.values(he).reduce((ye,ct)=>ye+ct.opened,0),Ve=Object.values(he).reduce((ye,ct)=>ye+ct.clicked,0);Object.values(he).reduce((ye,ct)=>ye+ct.failed,0);const Te=we>0?Math.round(Ne/we*100):0,Ae=we>0?Ve/we*100:0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Campaign Assignments"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Assign recruiting campaigns to prospects — emails auto-send weekly via SES"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[xe>0&&e.jsxs(K,{variant:"outline",onClick:()=>le.mutate(),disabled:le.isPending,className:"border-amber-500/50 text-amber-600 hover:bg-amber-500/10",children:[e.jsx(Fh,{className:"h-4 w-4 mr-1"}),le.isPending?"Sending...":`Send Next Wave (${xe})`]}),e.jsxs(K,{onClick:()=>a(!0),children:[e.jsx(Nn,{className:"h-4 w-4 mr-1"})," Assign Campaign"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(cr,{className:"h-7 w-7 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:V.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Assigned"})]})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Co,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:fe}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active"})]})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(tr,{className:"h-7 w-7 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:we.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emails Sent"})]})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(jn,{className:"h-7 w-7 text-amber-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[Te,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Open Rate (",Ne.toLocaleString(),")"]})]})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Cm,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[Ae.toFixed(1),"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Click Rate (",Ve.toLocaleString(),")"]})]})]})})]}),e.jsxs(ta,{value:u,onValueChange:p,children:[e.jsxs(Qn,{children:[e.jsxs(ls,{value:"assignments",children:["Active Drips (",fe,")"]}),e.jsxs(ls,{value:"history",children:["Send History (",we.toLocaleString(),")"]})]}),e.jsx(js,{value:"assignments",className:"mt-4",children:ee?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):V.length===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(Nn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No campaigns assigned yet"}),e.jsx("p",{className:"text-sm",children:"Assign a recruiting campaign to your prospects to start automated outreach"})]})}):e.jsx("div",{className:"space-y-2",children:V.map(ye=>{var Ce,et,Ct,Ot;const ct=I9e[ye.status]||I9e.active,pe=ct.icon,tt=(A[ye.campaign_id]||[]).length||4,st=$(ye);return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Ye,{className:`text-xs ${ct.color} border-0`,children:[e.jsx(pe,{className:"h-3 w-3 mr-1"}),ct.label]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(Ce=ye.prospect)==null?void 0:Ce.first_name," ",(et=ye.prospect)==null?void 0:et.last_name,e.jsx("span",{className:"text-muted-foreground font-normal ml-2",children:(Ct=ye.prospect)==null?void 0:Ct.email})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(Ot=ye.campaign)==null?void 0:Ot.name," · Email ",ye.current_email_number,"/",tt,ye.next_send_at&&ye.status==="active"&&e.jsxs(e.Fragment,{children:[" ","· ",e.jsx(rn,{className:"h-3 w-3 inline"})," Next: ",gs(new Date(ye.next_send_at),"MMM d, h:mm a"),new Date(ye.next_send_at)<=new Date&&e.jsx(Ye,{variant:"outline",className:"ml-1 text-[10px] px-1 py-0 border-amber-500 text-amber-600",children:"DUE"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[st&&e.jsx(K,{variant:"ghost",size:"sm",title:"Preview next email",onClick:()=>y(ye),children:e.jsx(jn,{className:"h-3.5 w-3.5"})}),ye.status==="active"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie.mutate({id:ye.id,newStatus:"paused"}),children:e.jsx(uh,{className:"h-3.5 w-3.5"})}),ye.status==="paused"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie.mutate({id:ye.id,newStatus:"active"}),children:e.jsx(Co,{className:"h-3.5 w-3.5"})}),(ye.status==="active"||ye.status==="paused")&&e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>ie.mutate({id:ye.id,newStatus:"cancelled"}),children:e.jsx(Ql,{className:"h-3.5 w-3.5"})})]})]},ye.id)})})}),e.jsxs(js,{value:"history",className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Filter:"}),e.jsxs(zs,{value:N,onValueChange:w,children:[e.jsx(Os,{className:"w-[220px] h-8 text-xs",children:e.jsx(qs,{placeholder:"All campaigns"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All campaigns"}),J.map(ye=>e.jsx(yt,{value:ye.id,children:ye.name},ye.id))]})]}),e.jsxs(zs,{value:S,onValueChange:C,children:[e.jsx(Os,{className:"w-[160px] h-8 text-xs",children:e.jsx(qs,{placeholder:"All statuses"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All statuses"}),e.jsx(yt,{value:"sent",children:"Sent (no engagement)"}),e.jsx(yt,{value:"opened",children:"Opened"}),e.jsx(yt,{value:"clicked",children:"Clicked"})]})]}),(N!=="all"||S!=="all")&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:()=>{w("all"),C("all")},children:"Clear"})]}),(()=>{var ct;const ye=Z.filter(pe=>{var Ge;return!(N!=="all"&&((Ge=pe.campaign_email)==null?void 0:Ge.campaign_id)!==N||S==="opened"&&!pe.opened_at||S==="clicked"&&!pe.clicked_at||S==="sent"&&(pe.opened_at||pe.clicked_at))});return ye.length===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(tr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:Z.length===0?"No emails sent yet":"No emails match these filters"}),e.jsx("p",{className:"text-sm",children:Z.length===0?"Emails will appear here once campaigns start sending":"Try clearing the filters above"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing ",ye.length," of ",Z.length," recent sends",N!=="all"&&` · ${(ct=J.find(pe=>pe.id===N))==null?void 0:ct.name}`]}),e.jsx("div",{className:"space-y-1",children:ye.map(pe=>{var Ce,et,Ct;const Ge=L9e[pe.status]||L9e.sent,tt=Ge.icon,st=(Ce=J.find(Ot=>{var ut;return Ot.id===((ut=pe.campaign_email)==null?void 0:ut.campaign_id)}))==null?void 0:Ce.name;return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(tt,{className:`h-4 w-4 flex-shrink-0 ${Ge.color}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm truncate",children:[(et=pe.prospect)==null?void 0:et.first_name," ",(Ct=pe.prospect)==null?void 0:Ct.last_name,e.jsxs("span",{className:"text-muted-foreground font-normal ml-2",children:["Email #",pe.email_number]}),st&&e.jsx(Ye,{variant:"outline",className:"ml-2 text-[10px] px-1.5 py-0 font-normal",children:st})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:pe.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-shrink-0",children:[pe.opened_at&&e.jsxs("span",{className:"flex items-center gap-1 text-amber-500",children:[e.jsx(jn,{className:"h-3 w-3"})," ",gs(new Date(pe.opened_at),"MMM d")]}),pe.clicked_at&&e.jsxs("span",{className:"flex items-center gap-1 text-green-500",children:[e.jsx(Cm,{className:"h-3 w-3"})," ",gs(new Date(pe.clicked_at),"MMM d")]}),e.jsx("span",{children:gs(new Date(pe.sent_at),"MMM d, h:mm a")})]})]},pe.id)})})]})})()]})]}),e.jsx(fs,{open:n,onOpenChange:ye=>{a(ye),ye||(b(""),d(new Set),l(""))},children:e.jsxs(ms,{className:"max-w-lg max-h-[85vh] flex flex-col p-0",children:[e.jsxs(ks,{className:"px-6 pt-6 pb-4",children:[e.jsx(bs,{children:"Assign Campaign to Prospects"}),e.jsx(Rr,{children:"Select a campaign and choose which prospects to enroll. The first email will be sent automatically."})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 space-y-4 pb-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"text-sm font-medium",children:"1. Select Campaign"}),e.jsxs(zs,{value:o,onValueChange:l,children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Choose a campaign..."})}),e.jsx(Fs,{children:J.map(ye=>e.jsx(yt,{value:ye.id,children:ye.name},ye.id))})]})]}),o&&(()=>{const ye=_.toLowerCase(),ct=Y.filter(tt=>`${tt.first_name} ${tt.last_name}`.toLowerCase().includes(ye)||tt.email.toLowerCase().includes(ye)),pe=ct.filter(tt=>!ce.has(`${tt.id}-${o}`)),Ge=pe.length>0&&pe.every(tt=>i.has(tt.id));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{className:"text-sm font-medium",children:"2. Select Prospects"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[i.size," selected"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(tn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name or email...",value:_,onChange:tt=>b(tt.target.value),className:"pl-9 h-9"})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-9 whitespace-nowrap",onClick:()=>{if(Ge){const tt=new Set(i);pe.forEach(st=>tt.delete(st.id)),d(tt)}else{const tt=new Set(i);pe.forEach(st=>tt.add(st.id)),d(tt)}},children:[e.jsx(uL,{className:"h-3.5 w-3.5 mr-1"}),Ge?"Deselect All":`Select All (${pe.length})`]})]}),e.jsx("div",{className:"border rounded-lg max-h-60 overflow-y-auto divide-y",children:ct.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:_?"No prospects match your search":"No prospects found for this brokerage"}):ct.map(tt=>{const st=ce.has(`${tt.id}-${o}`);return e.jsxs("label",{className:`flex items-center gap-3 p-2.5 hover:bg-muted/50 cursor-pointer ${st?"opacity-40":""}`,children:[e.jsx(Gi,{checked:i.has(tt.id),disabled:st,onCheckedChange:Ce=>{const et=new Set(i);Ce?et.add(tt.id):et.delete(tt.id),d(et)}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[tt.first_name," ",tt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:tt.email})]}),st&&e.jsx(Ye,{variant:"outline",className:"text-[10px] shrink-0",children:"Already assigned"})]},tt.id)})}),ct.length>0&&e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Showing ",ct.length," of ",Y.length," prospects",pe.length0&&e.jsx(Ie,{className:"bg-primary/5 border-primary/20",children:e.jsxs(Be,{className:"pt-3 pb-2 text-sm space-y-1",children:[e.jsxs("p",{className:"font-medium text-primary",children:["✅ Ready to assign ",i.size," prospect",i.size>1?"s":""]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["• Campaign: ",e.jsx("strong",{children:(Ue=J.find(ye=>ye.id===o))==null?void 0:Ue.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"• First email sends immediately · follow-ups every 7 days"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"• You can pause or cancel any assignment at any time"})]})})]}),e.jsxs(gn,{className:"px-6 py-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>ae.mutate(),disabled:ae.isPending||!o||i.size===0,children:[e.jsx(Nn,{className:"h-4 w-4 mr-1"}),ae.isPending?"Assigning...":`Assign & Start (${i.size})`]})]})]})}),f&&(()=>{const ye=$(f);return ye?e.jsx(Sct,{email:ye,mergeValues:q,selectedSubjectIndex:U[ye.id],onClose:()=>y(null)}):null})()]})}function Act({brokerageId:t}){const s=es(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState(!1),d=k.useRef(!1),{data:u,isLoading:p}=ft({queryKey:["recruit-stages-editor",t],queryFn:async()=>{const{data:w,error:S}=await G.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(S)throw S;return w},enabled:!!t});k.useEffect(()=>{if(u){if(d.current){d.current=!1;return}n(u.map(w=>({id:w.id,name:w.name,color:w.color,sort_order:w.sort_order}))),o([]),i(!1)}},[u]);const f=Et({mutationFn:async()=>{for(const C of a){const{error:A}=await G.from("recruit_pipeline_stages").delete().eq("id",C);if(A)throw A}const w=r.filter(C=>C.id&&!C.isNew),S=r.filter(C=>!C.id||C.isNew);for(const C of w){const{error:A}=await G.from("recruit_pipeline_stages").update({name:C.name,color:C.color,sort_order:C.sort_order}).eq("id",C.id);if(A)throw A}if(S.length>0){const{error:C}=await G.from("recruit_pipeline_stages").insert(S.map(A=>({brokerage_id:t,name:A.name,color:A.color,sort_order:A.sort_order})));if(C)throw C}},onSuccess:()=>{o([]),s.invalidateQueries({queryKey:["recruit-stages-editor",t]}),s.invalidateQueries({queryKey:["recruit-stages",t]}),me.success("Pipeline stages saved!"),i(!1)},onError:w=>me.error(w.message)}),y=(w,S,C)=>{n(A=>A.map((I,L)=>L===w?{...I,[S]:C}:I)),i(!0)},_=()=>{const w=r.length>0?Math.max(...r.map(S=>S.sort_order)):0;n(S=>[...S,{name:"",color:"#6366f1",sort_order:w+1,isNew:!0}]),i(!0)},b=w=>{const S=r[w];S.id&&!S.isNew&&o(C=>[...C,S.id]),n(C=>C.filter((A,I)=>I!==w)),i(!0)},N=(w,S)=>{const C=w+S;if(C<0||C>=r.length)return;const A=[...r];[A[w],A[C]]=[A[C],A[w]],A.forEach((I,L)=>I.sort_order=L+1),n(A),i(!0)};return p?e.jsx("div",{className:"text-sm text-muted-foreground py-8 text-center",children:"Loading stages…"}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Pipeline Stages"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Customize the recruiting pipeline stages for this brokerage. Changes will apply to the Kanban board and all prospect tracking."})]}),e.jsx("div",{className:"space-y-2",children:r.map((w,S)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>N(S,-1),disabled:S===0,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▲"}),e.jsx("button",{type:"button",onClick:()=>N(S,1),disabled:S===r.length-1,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▼"})]}),e.jsx(uu,{className:"h-4 w-4 text-muted-foreground/50 shrink-0"}),e.jsx("input",{type:"color",value:w.color,onChange:C=>y(S,"color",C.target.value),className:"h-8 w-8 rounded cursor-pointer border-0 p-0 shrink-0"}),e.jsx(Fe,{value:w.name,onChange:C=>y(S,"name",C.target.value),placeholder:"Stage name…",className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground w-6 text-center shrink-0",children:S+1}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(S),className:"text-destructive hover:text-destructive shrink-0 h-8 w-8",children:e.jsx(yr,{className:"h-4 w-4"})})]},w.id||`new-${S}`))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:_,className:"gap-1",children:[e.jsx(Bs,{className:"h-4 w-4"})," Add Stage"]}),l&&e.jsxs(K,{size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-1",children:[e.jsx(wc,{className:"h-4 w-4"})," Save Changes"]})]}),r.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No stages configured. Add stages to build your recruiting pipeline."})]})}function m3s({brokerageId:t}){const{data:s=[],isLoading:r}=ft({queryKey:["recruit-unsubscribed",t],queryFn:async()=>{const{data:n,error:a}=await G.from("recruit_prospects").select("id, first_name, last_name, email, unsubscribed_at, unsubscribe_reason, current_brokerage").eq("brokerage_id",t).not("unsubscribed_at","is",null).order("unsubscribed_at",{ascending:!1}).limit(500);if(a)throw a;return n||[]},enabled:!!t});return r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 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("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(vS,{className:"h-5 w-5 text-muted-foreground"}),"Unsubscribed Prospects"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Prospects who opted out of recruiting emails. They will not receive further outreach."})]}),e.jsxs(Ye,{variant:"secondary",className:"text-base px-3 py-1",children:[s.length," total"]})]}),s.length===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(vS,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No prospects have unsubscribed. Nice work!"})]})}):e.jsx("div",{className:"grid gap-3",children:s.map(n=>e.jsxs(Ie,{className:"hover:shadow-sm transition-shadow",children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"text-base",children:[n.first_name," ",n.last_name]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-1",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(tr,{className:"h-3 w-3"}),n.email]}),n.current_brokerage&&e.jsxs("span",{children:["· ",n.current_brokerage]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground whitespace-nowrap",children:[e.jsx(nn,{className:"h-3 w-3"}),n.unsubscribed_at&&gs(new Date(n.unsubscribed_at),"MMM d, yyyy")]})]})}),n.unsubscribe_reason&&e.jsx(Be,{className:"pt-0",children:e.jsxs("div",{className:"text-sm bg-muted/40 rounded-md px-3 py-2 italic text-muted-foreground",children:['"',n.unsubscribe_reason,'"']})})]},n.id))})]})}function p3s({brokerageId:t,trigger:s,initialProspectId:r,open:n,onOpenChange:a}){const[o,l]=k.useState(!1),i=n??o,d=a??l,[u,p]=k.useState("pick-recipients"),[f,y]=k.useState(new Set(r?[r]:[])),[_,b]=k.useState("all"),[N,w]=k.useState(""),[S,C]=k.useState(null),[A,I]=k.useState(""),[L,O]=k.useState(0),[U,q]=k.useState(0),[$,V]=k.useState(""),[ee,Z]=k.useState(""),[J,Y]=k.useState(null),{prospects:ce,stages:ae}=PO(t),ie=uct(),le=Ew(),{data:fe=[]}=ft({queryKey:["brokerage-recruit-video-pool",t],queryFn:async()=>{const{data:ve,error:Re}=await G.from("agent_videos").select("id, title, thumbnail_url, duration_seconds, created_at, owner_user_id").eq("touch_type","recruiting").eq("status","ready").eq("is_deleted",!1).order("created_at",{ascending:!1}).limit(50);if(Re)throw Re;return ve??[]},enabled:i&&u==="pick-video"}),xe=k.useCallback(()=>{p("pick-recipients"),y(new Set(r?[r]:[])),b("all"),w(""),C(null),I(""),O(0),q(0),V(""),Z(""),Y(null)},[r]),he=ve=>{!ve&&(u==="uploading"||u==="processing"||u==="sending")||(d(ve),ve||setTimeout(xe,200))},we=k.useMemo(()=>ce.filter(ve=>{if(!ve.email||_!=="all"&&ve.stage_id!==_)return!1;if(N){const Re=N.toLowerCase();if(!`${ve.first_name} ${ve.last_name??""}`.toLowerCase().includes(Re)&&!ve.email.toLowerCase().includes(Re))return!1}return!0}),[ce,_,N]),Ne=ve=>{y(Re=>{const Ue=new Set(Re);return Ue.has(ve)?Ue.delete(ve):Ue.add(ve),Ue})},Ve=()=>{f.size===we.length?y(new Set):y(new Set(we.map(ve=>ve.id)))},Te=k.useCallback(async(ve,Re)=>{p("uploading");try{const Ue=`Recruiting blast (${f.size} recipients)`,{videoId:ye,libraryId:ct}=await wE(Ue),{uploadUrl:pe,apiKey:Ge}=await jE(ye),tt=new XMLHttpRequest;tt.upload.onprogress=Xe=>{Xe.lengthComputable&&O(Xe.loaded/Xe.total*100)},await new Promise((Xe,at)=>{tt.onload=()=>tt.status>=200&&tt.status<300?Xe():at(new Error("Upload failed")),tt.onerror=()=>at(new Error("Upload failed")),tt.open("PUT",pe),tt.setRequestHeader("AccessKey",Ge),tt.send(ve)}),p("processing");const st=`https://iframe.mediadelivery.net/embed/${ct}/${ye}`;let Ce=0;const et=Date.now(),Ct=9e4;for(;Ce<4&&(await new Promise(at=>setTimeout(at,3e3)),!(Date.now()-et>Ct));){const Xe=await ow(ye);if(Ce=Xe.status,q(Xe.encodeProgress||0),Ce===5||Ce===6)throw new Error("Video processing failed")}const Ot=await ow(ye),ut=(Ot.storageSize||ve.size)/(1024*1024),Oe=await le.mutateAsync({bunny_video_id:ye,playback_url:Ot.directPlayUrl||st,thumbnail_url:Ot.thumbnailUrl,preview_url:Ot.previewUrl||null,duration_seconds:Ot.length||Re,file_size_mb:ut,title:Ue,status:Ce>=4?"ready":"processing",touch_type:"recruiting"});C(Oe.id),I(Ue),p("compose")}catch(Ue){me.error((Ue==null?void 0:Ue.message)||"Failed to upload video"),p("pick-video")}},[f.size,le]),Ae=k.useCallback(async()=>{if(!(!S||f.size===0)){p("sending");try{const ve=[];for(const ye of f){const ct=await ie.mutateAsync({prospect_id:ye,video_id:S,brokerage_id:t,message:ee||void 0});ve.push(ct.id)}const{data:Re,error:Ue}=await G.functions.invoke("send-recruit-video-email",{body:{recruit_video_ids:ve,brokerage_id:t,subject_override:$||void 0,message_override:ee||void 0}});if(Ue)throw new Error(Ue.message);Y({sent:(Re==null?void 0:Re.sent)??0,total:(Re==null?void 0:Re.total)??ve.length}),p("done"),me.success(`Sent ${(Re==null?void 0:Re.sent)??0} of ${(Re==null?void 0:Re.total)??ve.length} videos`)}catch(ve){me.error((ve==null?void 0:ve.message)||"Failed to send"),p("compose")}}},[S,f,t,ee,$,ie]),ze=f.size,Ee=ce.filter(ve=>!ve.email).length;return e.jsxs(fs,{open:i,onOpenChange:he,children:[s&&e.jsx(ui,{asChild:!0,children:s}),e.jsxs(ms,{className:"max-w-3xl max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsx(ks,{children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-primary"}),"Send Recruiting Video",ze>0&&e.jsxs(Ye,{variant:"secondary",className:"ml-2",children:[e.jsx(cr,{className:"h-3 w-3 mr-1"}),ze," ",ze===1?"recipient":"recipients"]})]})}),u==="pick-recipients"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(tn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search prospects...",value:N,onChange:ve=>w(ve.target.value),className:"pl-9"})]}),e.jsxs(zs,{value:_,onValueChange:b,children:[e.jsx(Os,{className:"w-48",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All stages"}),ae.map(ve=>e.jsx(yt,{value:ve.id,children:ve.name},ve.id))]})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("button",{onClick:Ve,className:"hover:underline",children:[f.size===we.length&&we.length>0?"Deselect all":"Select all"," ","(",we.length,")"]}),Ee>0&&e.jsxs("span",{children:[Ee," prospect(s) hidden — no email on file"]})]}),e.jsx(di,{className:"flex-1 border rounded-md",children:we.length===0?e.jsx("div",{className:"p-8 text-center text-sm text-muted-foreground",children:"No prospects match. Make sure prospects have email addresses."}):e.jsx("div",{className:"divide-y",children:we.map(ve=>{const Re=f.has(ve.id),Ue=ae.find(ye=>ye.id===ve.stage_id);return e.jsxs("label",{className:"flex items-center gap-3 p-3 hover:bg-muted/30 cursor-pointer",children:[e.jsx(Gi,{checked:Re,onCheckedChange:()=>Ne(ve.id)}),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 text-sm truncate",children:[ve.first_name," ",ve.last_name]}),Ue&&e.jsx(Ye,{variant:"outline",className:"text-[10px]",style:{borderColor:Ue.color,color:Ue.color},children:Ue.name})]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[ve.email," ",ve.current_brokerage&&`· ${ve.current_brokerage}`]})]})]},ve.id)})})}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>he(!1),children:"Cancel"}),e.jsx(K,{disabled:ze===0,onClick:()=>p("pick-video"),children:"Next: Choose Video"})]})]}),u==="pick-video"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(ta,{defaultValue:"record",className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(Qn,{className:"self-start",children:[e.jsxs(ls,{value:"record",children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"}),"Record New"]}),e.jsxs(ls,{value:"library",children:[e.jsx(cS,{className:"h-3.5 w-3.5 mr-1"}),"Use Existing"]})]}),e.jsx(js,{value:"record",className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"text-center py-8 space-y-4",children:[e.jsx(Ld,{className:"h-12 w-12 mx-auto text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Record a fresh video"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Same video sent to all ",ze," ",ze===1?"recipient":"recipients"," — each gets their own tracked link."]})]}),e.jsxs(K,{onClick:()=>p("record"),children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Start Recording"]})]})}),e.jsx(js,{value:"library",className:"flex-1 overflow-auto",children:fe.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No recruiting videos in library yet."}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3 p-1",children:fe.map(ve=>e.jsxs("button",{onClick:()=>{C(ve.id),I(ve.title||"Untitled"),p("compose")},className:"text-left group rounded-md border overflow-hidden hover:border-primary transition-colors",children:[e.jsx("div",{className:"aspect-video bg-muted relative",children:ve.thumbnail_url?e.jsx("img",{src:ve.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(hn,{className:"h-8 w-8 text-muted-foreground"})})}),e.jsx("div",{className:"p-2",children:e.jsx("p",{className:"text-xs font-medium truncate",children:ve.title||"Untitled"})})]},ve.id))})})]}),e.jsx(gn,{children:e.jsx(K,{variant:"outline",onClick:()=>p("pick-recipients"),children:"Back"})})]}),u==="record"&&e.jsxs("div",{className:"flex-1 overflow-auto",children:[e.jsx(AO,{maxDurationSeconds:600,onRecordingComplete:Te}),e.jsx("div",{className:"mt-2 flex justify-start",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>p("pick-video"),children:"← Back"})})]}),(u==="uploading"||u==="processing")&&e.jsxs("div",{className:"py-12 space-y-4 text-center",children:[e.jsx(ps,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsx("p",{className:"font-medium",children:u==="uploading"?"Uploading video…":"Processing video…"}),e.jsx(pi,{value:u==="uploading"?L:U,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(u==="uploading"?L:U),"%"]})]}),u==="compose"&&e.jsxs("div",{className:"flex-1 overflow-auto space-y-4",children:[e.jsxs("div",{className:"rounded-md border p-3 bg-muted/30 flex items-center gap-3",children:[e.jsx(Hn,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("span",{className:"font-medium",children:A})," selected · sending to ",e.jsx("strong",{children:ze})," recipient",ze===1?"":"s"]})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Subject (optional override)"}),e.jsx(Fe,{value:$,onChange:ve=>V(ve.target.value),placeholder:"[First Name], I made you a quick video 🎥",className:"mt-1"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Leave blank to use the default personalized subject."})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Personal message shown in the email & on the landing page"}),e.jsx(_r,{value:ee,onChange:ve=>Z(ve.target.value),placeholder:"Hey there — wanted to share a quick thought on what we're building here...",rows:5,className:"mt-1"})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>p("pick-video"),children:"Back"}),e.jsxs(K,{onClick:Ae,disabled:!S||ze===0,children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"})," Send to ",ze," ",ze===1?"prospect":"prospects"]})]})]}),u==="sending"&&e.jsxs("div",{className:"py-12 text-center space-y-3",children:[e.jsx(ps,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending to ",ze," recipient",ze===1?"":"s","…"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Each prospect gets their own tracked share link."})]}),u==="done"&&J&&e.jsxs("div",{className:"py-12 text-center space-y-4",children:[e.jsx("div",{className:`h-16 w-16 rounded-full mx-auto flex items-center justify-center ${J.sent===J.total?"bg-primary/10":"bg-muted"}`,children:J.sent===J.total?e.jsx(Hn,{className:"h-8 w-8 text-primary"}):e.jsx(co,{className:"h-8 w-8 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold text-lg",children:[J.sent," of ",J.total," sent"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"View engagement under the Video Outreach tab."})]}),e.jsx(K,{onClick:()=>he(!1),children:"Done"})]})]})]})}function f3s(){var i;const[t,s]=k.useState(""),[r,n]=k.useState("board"),{data:a=[],isLoading:o}=ft({queryKey:["all-brokerages"],queryFn:async()=>{const{data:d,error:u}=await G.from("brokerages").select("id, name").order("name");if(u)throw u;return d}}),l=t||((i=a[0])==null?void 0:i.id)||"";return o?e.jsx(Ls,{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(Ls,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[a.length>1?e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage:"}),e.jsxs(zs,{value:l,onValueChange:s,children:[e.jsxs(Os,{className:"w-[280px]",children:[e.jsx(ma,{className:"mr-2 h-4 w-4"}),e.jsx(qs,{placeholder:"Select brokerage"})]}),e.jsx(Fs,{children:a.map(d=>e.jsx(yt,{value:d.id,children:d.name},d.id))})]})]}):e.jsx("div",{}),l&&e.jsx(p3s,{brokerageId:l,trigger:e.jsxs(K,{size:"sm",className:"gap-1.5",children:[e.jsx(hn,{className:"h-4 w-4"})," Record & Send Video"]})})]}),l?e.jsxs(ta,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(Qn,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ls,{value:"pipeline",children:"Pipeline"}),e.jsxs(ls,{value:"contacts",children:[e.jsx(cr,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ls,{value:"video-outreach",children:[e.jsx(hn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ls,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ls,{value:"referrals",children:"Referrals"}),e.jsx(ls,{value:"interest",children:"Interest Form"}),e.jsx(ls,{value:"landing-page",children:"Landing Page"}),e.jsx(ls,{value:"goals",children:"Goals"}),e.jsx(ls,{value:"metrics",children:"Metrics"}),e.jsx(ls,{value:"templates",children:"Email Templates"}),e.jsxs(ls,{value:"campaigns",children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ls,{value:"drip-assignments",children:[e.jsx(Nn,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(ls,{value:"activity",children:"Recruiter Activity"}),e.jsxs(ls,{value:"email-settings",children:[e.jsx(So,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ls,{value:"pipeline-stages",children:[e.jsx(bS,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]}),e.jsxs(ls,{value:"unsubscribed",children:[e.jsx(vS,{className:"h-3.5 w-3.5 mr-1"}),"Unsubscribed"]})]}),e.jsxs(js,{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(pp,{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(zM,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(xct,{brokerageId:l}):e.jsx(Ede,{brokerageId:l})]}),e.jsx(js,{value:"contacts",children:e.jsx(Ede,{brokerageId:l})}),e.jsx(js,{value:"video-outreach",children:e.jsx(Nct,{brokerageId:l})}),e.jsx(js,{value:"follow-ups",children:e.jsx(wct,{brokerageId:l})}),e.jsx(js,{value:"referrals",children:e.jsx(_ct,{brokerageId:l})}),e.jsx(js,{value:"interest",children:e.jsx(bct,{brokerageId:l})}),e.jsx(js,{value:"landing-page",children:e.jsx(jct,{brokerageId:l})}),e.jsx(js,{value:"goals",children:e.jsx(kct,{brokerageId:l})}),e.jsx(js,{value:"metrics",children:e.jsx(gct,{brokerageId:l})}),e.jsx(js,{value:"templates",children:e.jsx(yct,{brokerageId:l})}),e.jsx(js,{value:"campaigns",children:e.jsx(Mct,{brokerageId:l})}),e.jsx(js,{value:"drip-assignments",children:e.jsx(Tct,{brokerageId:l})}),e.jsx(js,{value:"activity",children:e.jsx(vct,{brokerageId:l})}),e.jsx(js,{value:"email-settings",children:e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Email Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Configure sender identity, merge fields, and brokerage location for recruiting emails."}),e.jsx(r3e,{brokerageId:l})]})}),e.jsx(js,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(Act,{brokerageId:l})})}),e.jsx(js,{value:"unsubscribed",children:e.jsx(m3s,{brokerageId:l})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ma,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function x3s(){var l;const{managedBrokerages:t,selectedBrokerageId:s,setSelectedBrokerageId:r}=$s(),[n,a]=k.useState("board"),o=s||((l=t[0])==null?void 0:l.id)||"";return t.length===0?e.jsx(Ls,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ma,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages assigned to you. Contact an admin for access."})]})}):e.jsx(Ls,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"space-y-6",children:[t.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage:"}),e.jsxs(zs,{value:o,onValueChange:r,children:[e.jsxs(Os,{className:"w-[280px]",children:[e.jsx(ma,{className:"mr-2 h-4 w-4"}),e.jsx(qs,{placeholder:"Select brokerage"})]}),e.jsx(Fs,{children:t.map(i=>e.jsx(yt,{value:i.id,children:i.name},i.id))})]})]}),o?e.jsxs(ta,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(Qn,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ls,{value:"pipeline",children:"Pipeline"}),e.jsxs(ls,{value:"contacts",children:[e.jsx(cr,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ls,{value:"video-outreach",children:[e.jsx(hn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ls,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ls,{value:"referrals",children:"Referrals"}),e.jsx(ls,{value:"interest",children:"Interest Form"}),e.jsx(ls,{value:"landing-page",children:"Landing Page"}),e.jsx(ls,{value:"goals",children:"Goals"}),e.jsx(ls,{value:"metrics",children:"Metrics"}),e.jsx(ls,{value:"templates",children:"Email Templates"}),e.jsxs(ls,{value:"campaigns",children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ls,{value:"drip-assignments",children:[e.jsx(Nn,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(ls,{value:"activity",children:"Recruiter Activity"}),e.jsxs(ls,{value:"email-settings",children:[e.jsx(So,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ls,{value:"pipeline-stages",children:[e.jsx(bS,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]})]}),e.jsxs(js,{value:"pipeline",children:[e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex items-center rounded-md border bg-muted p-0.5",children:[e.jsxs(K,{variant:n==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("board"),children:[e.jsx(pp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(K,{variant:n==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("table"),children:[e.jsx(zM,{className:"h-3.5 w-3.5"})," Table"]})]})}),n==="board"?e.jsx(xct,{brokerageId:o}):e.jsx(Ede,{brokerageId:o})]}),e.jsx(js,{value:"contacts",children:e.jsx(Ede,{brokerageId:o})}),e.jsx(js,{value:"video-outreach",children:e.jsx(Nct,{brokerageId:o})}),e.jsx(js,{value:"follow-ups",children:e.jsx(wct,{brokerageId:o})}),e.jsx(js,{value:"referrals",children:e.jsx(_ct,{brokerageId:o})}),e.jsx(js,{value:"interest",children:e.jsx(bct,{brokerageId:o})}),e.jsx(js,{value:"landing-page",children:e.jsx(jct,{brokerageId:o})}),e.jsx(js,{value:"goals",children:e.jsx(kct,{brokerageId:o})}),e.jsx(js,{value:"metrics",children:e.jsx(gct,{brokerageId:o})}),e.jsx(js,{value:"templates",children:e.jsx(yct,{brokerageId:o})}),e.jsx(js,{value:"campaigns",children:e.jsx(Mct,{brokerageId:o})}),e.jsx(js,{value:"drip-assignments",children:e.jsx(Tct,{brokerageId:o})}),e.jsx(js,{value:"activity",children:e.jsx(vct,{brokerageId:o})}),e.jsx(js,{value:"email-settings",children:e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Email Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Configure sender identity, merge fields, and brokerage location for recruiting emails."}),e.jsx(r3e,{brokerageId:o})]})}),e.jsx(js,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(Act,{brokerageId:o})})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ma,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found."})]})]})})}function g3s(){const[t,s]=k.useState(""),{data:r,isLoading:n}=ft({queryKey:["admin-brokerage-content-activity"],queryFn:async()=>{const{data:i}=await G.from("brokerages").select("id, name");if(!i)return[];const{data:d}=await G.from("brokerage_content").select("id, brokerage_id, content_type, created_at"),{data:u}=await G.from("brokerage_content_categories").select("id, brokerage_id"),p=d||[],f=u||[],y=i.map(_=>{const b=p.filter(S=>S.brokerage_id===_.id),N=f.filter(S=>S.brokerage_id===_.id),w=b.length>0?b.reduce((S,C)=>C.created_at>S?C.created_at:S,b[0].created_at):null;return{brokerage_id:_.id,brokerage_name:_.name,total_items:b.length,videos:b.filter(S=>S.content_type==="video").length,pdfs:b.filter(S=>S.content_type==="pdf").length,links:b.filter(S=>S.content_type==="link"||S.content_type==="canva_link").length,events:b.filter(S=>S.content_type==="event").length,graphics:b.filter(S=>S.content_type==="graphic").length,latest_item_date:w,categories:N.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,d)=>i+d.total_items,0),l=a.filter(i=>i.total_items>0).length;return e.jsx(Ls,{title:"Brokerage Content Activity",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qu,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(Be,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(Be,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Brokerages"})}),e.jsxs(Be,{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(tn,{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(Ie,{children:e.jsx(Be,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Brokerage"}),e.jsx(Nt,{className:"text-center",children:"Total"}),e.jsx(Nt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"})," Videos"]})}),e.jsx(Nt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(mn,{className:"h-3 w-3"})," PDFs"]})}),e.jsx(Nt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Do,{className:"h-3 w-3"})," Links"]})}),e.jsx(Nt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(xd,{className:"h-3 w-3"})," Events"]})}),e.jsx(Nt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Uo,{className:"h-3 w-3"})," Graphics"]})}),e.jsx(Nt,{className:"text-center",children:"Categories"}),e.jsx(Nt,{children:"Last Upload"})]})}),e.jsx(Pn,{children:n?e.jsx(As,{children:e.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(As,{children:e.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(As,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ma,{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(Ye,{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:gs(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function y3s(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 v3s=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function Kb(t){const s=[];for(let r=0,n=t.length;rUp||t.height>Up)&&(t.width>Up&&t.height>Up?t.width>t.height?(t.height*=Up/t.width,t.width=Up):(t.width*=Up/t.height,t.height=Up):t.width>Up?(t.height*=Up/t.width,t.width=Up):(t.width*=Up/t.height,t.height=Up))}function Ide(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 N3s(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function k3s(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),N3s(a)}const gp=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||gp(r,s)};function S3s(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function C3s(t,s){return Ect(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function M3s(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?S3s(r):C3s(r,n);return document.createTextNode(`${a}{${o}}`)}function D9e(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=v3s();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(M3s(l,r,a,n)),s.appendChild(i)}function T3s(t,s,r){D9e(t,s,":before",r),D9e(t,s,":after",r)}const R9e="application/font-woff",O9e="image/jpeg",A3s={woff:R9e,woff2:R9e,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:O9e,jpeg:O9e,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function E3s(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function n3e(t){const s=E3s(t).toLowerCase();return A3s[s]||""}function P3s(t){return t.split(/,/)[1]}function n2e(t){return t.search(/^(data:)/)!==-1}function I3s(t,s){return`data:${s};base64,${t}`}async function Ict(t,s,r){const n=await fetch(t,s);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);const a=await n.blob();return new Promise((o,l)=>{const i=new FileReader;i.onerror=l,i.onloadend=()=>{try{o(r({res:n,result:i.result}))}catch(d){l(d)}},i.readAsDataURL(a)})}const k0e={};function L3s(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 a3e(t,s,r){const n=L3s(t,s,r.includeQueryParams);if(k0e[n]!=null)return k0e[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await Ict(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),P3s(i)));a=I3s(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 k0e[n]=a,a}async function D3s(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):Ide(s)}async function R3s(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 Ide(i)}const r=t.poster,n=n3e(r),a=await a3e(r,n,s);return Ide(a)}async function O3s(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await spe(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function F3s(t,s){return gp(t,HTMLCanvasElement)?D3s(t):gp(t,HTMLVideoElement)?R3s(t,s):gp(t,HTMLIFrameElement)?O3s(t,s):t.cloneNode(Lct(t))}const z3s=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",Lct=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function B3s(t,s,r){var n,a;if(Lct(s))return s;let o=[];return z3s(t)&&t.assignedNodes?o=Kb(t.assignedNodes()):gp(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=Kb(t.contentDocument.body.childNodes):o=Kb(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||gp(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>spe(i,r)).then(d=>{d&&s.appendChild(d)}),Promise.resolve()),s}function $3s(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):Ect(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`),gp(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 q3s(t,s){gp(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),gp(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function U3s(t,s){if(gp(t,HTMLSelectElement)){const r=s,n=Array.from(r.children).find(a=>t.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function V3s(t,s,r){return gp(s,Element)&&($3s(t,s,r),T3s(t,s,r),q3s(t,s),U3s(t,s)),s}async function H3s(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;oF3s(n,s)).then(n=>B3s(t,n,s)).then(n=>V3s(t,n,s)).then(n=>H3s(n,s))}const Dct=/url\((['"]?)([^'"]+?)\1\)/g,G3s=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,W3s=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function K3s(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function Z3s(t){const s=[];return t.replace(Dct,(r,n,a)=>(s.push(a),r)),s.filter(r=>!n2e(r))}async function Y3s(t,s,r,n,a){try{const o=r?y3s(s,r):s,l=n3e(s);let i;return a||(i=await a3e(o,l,n)),t.replace(K3s(s),`$1${i}$3`)}catch{}return t}function X3s(t,{preferredFontFormat:s}){return s?t.replace(W3s,r=>{for(;;){const[n,,a]=G3s.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function Rct(t){return t.search(Dct)!==-1}async function Oct(t,s,r){if(!Rct(t))return t;const n=X3s(t,r);return Z3s(n).reduce((o,l)=>o.then(i=>Y3s(i,l,s,r)),Promise.resolve(n))}async function P5(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await Oct(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function Q3s(t,s){await P5("background",t,s)||await P5("background-image",t,s),await P5("mask",t,s)||await P5("-webkit-mask",t,s)||await P5("mask-image",t,s)||await P5("-webkit-mask-image",t,s)}async function J3s(t,s){const r=gp(t,HTMLImageElement);if(!(r&&!n2e(t.src))&&!(gp(t,SVGImageElement)&&!n2e(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await a3e(n,n3e(n),s);await new Promise((o,l)=>{t.onload=o,t.onerror=s.onImageErrorHandler?(...d)=>{try{o(s.onImageErrorHandler(...d))}catch(u){l(u)}}:l;const i=t;i.decode&&(i.decode=o),i.loading==="lazy"&&(i.loading="eager"),r?(t.srcset="",t.src=a):t.href.baseVal=a})}async function e5s(t,s){const n=Kb(t.childNodes).map(a=>Fct(a,s));await Promise.all(n).then(()=>t)}async function Fct(t,s){gp(t,Element)&&(await Q3s(t,s),await J3s(t,s),await e5s(t,s))}function t5s(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 F9e={};async function z9e(t){let s=F9e[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},F9e[t]=s,s}async function B9e(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),Ict(i,s.fetchRequestInit,({result:d})=>(r=r.replace(l,`url(${d})`),[l,d]))});return Promise.all(o).then(()=>r)}function $9e(t){if(t==null)return[];const s=[],r=/(\/\*[\s\S]*?\*\/)/gi;let n=t.replace(r,"");const a=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const d=a.exec(n);if(d===null)break;s.push(d[0])}n=n.replace(a,"");const o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,l="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",i=new RegExp(l,"gi");for(;;){let d=o.exec(n);if(d===null){if(d=i.exec(n),d===null)break;o.lastIndex=i.lastIndex}else i.lastIndex=o.lastIndex;s.push(d[0])}return s}async function s5s(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{Kb(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const d=o.href,u=z9e(d).then(p=>B9e(p,s)).then(p=>$9e(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(z9e(a.href).then(i=>B9e(i,s)).then(i=>$9e(i).forEach(d=>{l.insertRule(d,l.cssRules.length)})).catch(i=>{console.error("Error loading remote stylesheet",i)})),console.error("Error inlining remote css file",o)}}),Promise.all(n).then(()=>(t.forEach(a=>{if("cssRules"in a)try{Kb(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function r5s(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>Rct(s.style.getPropertyValue("src")))}async function n5s(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=Kb(t.ownerDocument.styleSheets),n=await s5s(r,s);return r5s(n)}function zct(t){return t.trim().replace(/["']/g,"")}function a5s(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(zct(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function i5s(t,s){const r=await n5s(t,s),n=a5s(t);return(await Promise.all(r.filter(o=>n.has(zct(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return Oct(o.cssText,l,s)}))).join(` `)}async function o5s(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await i5s(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 l5s(t,s={}){const{width:r,height:n}=Pct(t,s),a=await spe(t,s,!0);return await o5s(a,s),await Fct(a,s),t5s(a,s),await k3s(a,r,n)}async function c5s(t,s={}){const{width:r,height:n}=Pct(t,s),a=await l5s(t,s),o=await Ide(a),l=document.createElement("canvas"),i=l.getContext("2d"),d=s.pixelRatio||w3s(),u=s.canvasWidth||r,p=s.canvasHeight||n;return l.width=u*d,l.height=p*d,s.skipAutoScale||j3s(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 d5s(t,s={}){return(await c5s(t,s)).toDataURL()}const MA=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),rpe={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},P9={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},u5s=({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})]})]}),Bct=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,d=(f=t.photos)==null?void 0:f[a],u=rpe[s],p=[t.bedrooms?`${t.bedrooms} Bed`:null,t.bathrooms?`${t.bathrooms} Bath`:null,t.sqft?`${t.sqft.toLocaleString()} Sq Ft`:null].filter(Boolean).join(" • ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Georgia', 'Times New Roman', serif",color:"#FFFFFF"},children:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"linear-gradient(180deg, rgba(10,10,30,0.3) 0%, rgba(10,10,30,0.85) 100%)"}}),e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between",padding:l.w*.06},children:[e.jsx("div",{children:e.jsx("div",{style:{display:"inline-block",background:"linear-gradient(135deg, #C9A84C, #E8D48B)",color:"#1A1A2E",padding:`${l.w*.012}px ${l.w*.035}px`,fontSize:l.w*.032,fontWeight:700,letterSpacing:"0.25em",textTransform:"uppercase"},children:u})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:l.w*.07,fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,textShadow:"0 2px 12px rgba(0,0,0,0.5)"},children:MA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",MA(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(u5s,{branding:n,dim:l})]})]})]})});Bct.displayName="LuxuryDarkTemplate";const h5s=({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})]})]}),$ct=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,d=(_=t.photos)==null?void 0:_[a],u=rpe[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:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",top:l.w*.04,left:0,background: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:MA(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(h5s,{branding:n,dim:l,accentColor:y})]})]})});$ct.displayName="ModernCleanTemplate";const m5s=({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})]})]}),qct=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,d=(y=t.photos)==null?void 0:y[a],u=rpe[s],p={"just-listed":"linear-gradient(135deg, #059669, #10B981)","just-sold":"linear-gradient(135deg, #7C3AED, #A855F7)","open-house":"linear-gradient(135deg, #2563EB, #3B82F6)","price-drop":"linear-gradient(135deg, #DC2626, #F43F5E)"},f=[t.bedrooms?`${t.bedrooms} BD`:null,t.bathrooms?`${t.bathrooms} BA`:null,t.sqft?`${t.sqft.toLocaleString()} SF`:null].filter(Boolean).join(" | ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Arial Black', 'Helvetica Neue', sans-serif",color:"#FFFFFF"},children:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.4)"}}),e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column",padding:l.w*.05},children:[e.jsx("div",{style:{background:p[s],padding:`${l.w*.025}px ${l.w*.04}px`,fontSize:l.w*.055,fontWeight:900,letterSpacing:"0.08em",alignSelf:"flex-start",borderRadius:l.w*.01,boxShadow:"0 8px 32px rgba(0,0,0,0.3)",transform:"rotate(-2deg)",marginBottom:l.w*.03},children:u}),e.jsx("div",{style:{flex:1}}),e.jsxs("div",{style:{background:"rgba(0,0,0,0.65)",backdropFilter:"blur(10px)",borderRadius:l.w*.015,padding:l.w*.04},children:[e.jsx("div",{style:{fontSize:l.w*.08,fontWeight:900,lineHeight:1,marginBottom:l.w*.01},children:MA(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(m5s,{branding:n,dim:l})]})]})]})});qct.displayName="BoldColorfulTemplate";const p5s=({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})]})]}),Uct=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,d=(f=t.photos)==null?void 0:f[a],u=rpe[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:MA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",MA(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(p5s,{branding:n,dim:l})]}),e.jsxs("div",{style:{width:p?"100%":"58%",height:p?"60%":"100%",position:"relative",overflow:"hidden",order:p?1:2},children:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:l.w*.02,border:"1px solid rgba(255,255,255,0.4)",pointerEvents:"none"}})]})]})})});Uct.displayName="EditorialTemplate";const f5s=[{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:"📉"}],q9e=[{value:"instagram-square",label:"Instagram Post",dimensions:"1080×1080",icon:e.jsx(hu,{className:"h-4 w-4"})},{value:"instagram-story",label:"Instagram Story",dimensions:"1080×1920",icon:e.jsx(hu,{className:"h-4 w-4"})},{value:"facebook-post",label:"Facebook Post",dimensions:"1200×630",icon:e.jsx(du,{className:"h-4 w-4"})}],x5s=[{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:"📰"}],U9e=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),V9e={"luxury-dark":Bct,"modern-clean":$ct,"bold-colorful":qct,editorial:Uct};function g5s(){const[t,s]=k.useState(""),[r,n]=k.useState("address"),[a,o]=k.useState(!1),[l,i]=k.useState([]),[d,u]=k.useState(null),[p,f]=k.useState(0),[y,_]=k.useState("just-listed"),[b,N]=k.useState(["instagram-square"]),[w,S]=k.useState("luxury-dark"),[C,A]=k.useState(!1),[I,L]=k.useState(""),[O,U]=k.useState(""),[q,$]=k.useState(""),[V,ee]=k.useState(!1),[Z,J]=k.useState(!1),[Y,ce]=k.useState([]),[ae,ie]=k.useState("search"),le=k.useRef({});k.useEffect(()=>{(async()=>{const{data:{user:Ee}}=await G.auth.getUser();if(!Ee)return;const{data:ve}=await G.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",Ee.id).single();if(ve){L(ve.name||""),$(ve.avatar_url||"");const Re=ve.brokerages;U((Re==null?void 0:Re.name)||"")}})()},[]);const fe=async()=>{var ze;if(t.trim()){o(!0),i([]);try{const{data:Ee,error:ve}=await G.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(ve)throw ve;if(Ee.error)throw new Error(Ee.error);i(Ee.listings||[]),((ze=Ee.listings)==null?void 0:ze.length)===0&&me.info("No listings found. Try a different search.")}catch(Ee){me.error(Ee.message||"Search failed")}finally{o(!1)}}},xe=ze=>{var Ee;u(ze),f(0),ie("customize"),ze.soldDate||(Ee=ze.status)!=null&&Ee.toLowerCase().includes("sold")?_("just-sold"):_("just-listed")},he=ze=>{N(Ee=>Ee.includes(ze)?Ee.filter(ve=>ve!==ze):[...Ee,ze])},we=k.useCallback(async()=>{if(!(!d||b.length===0)){ee(!0),ce([]),ie("generate");try{await new Promise(Ee=>setTimeout(Ee,500));const ze=[];for(const Ee of b){const ve=`${w}-${Ee}`,Re=le.current[ve];if(!Re)continue;const Ue=P9[Ee],ye=await d5s(Re,{width:Ue.width,height:Ue.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});ze.push({format:Ee,imageUrl:ye})}ce(ze),me.success(`Generated ${ze.length} social post${ze.length>1?"s":""}!`)}catch(ze){me.error(ze.message||"Generation failed")}finally{ee(!1)}}},[d,b,w,p,C,I,O,q,y]),Ne=async()=>{if(!(!d||b.length===0)){ee(!0),ce([]),ie("generate");try{const ze={...d,photos:d.photos.length>0?[d.photos[p]]:[]},Ee=[];for(const ve of b){const{data:Re,error:Ue}=await G.functions.invoke("generate-listing-social-post",{body:{listing:ze,postType:y,format:ve,branding:C?{enabled:!0,agentName:I,brokerage:O}:{enabled:!1}}});if(Ue)throw Ue;if(Re.error)throw new Error(Re.error);Ee.push({format:ve,imageUrl:Re.imageUrl})}ce(Ee),me.success(`Generated ${Ee.length} AI post${Ee.length>1?"s":""}!`)}catch(ze){me.error(ze.message||"AI generation failed")}finally{ee(!1)}}},Ve=()=>Z?Ne():we(),Te=(ze,Ee)=>{var Re;const ve=document.createElement("a");ve.href=ze,ve.download=`${((Re=d==null?void 0:d.address)==null?void 0:Re.replace(/\s+/g,"-"))||"listing"}-${y}-${Ee}.png`,document.body.appendChild(ve),ve.click(),document.body.removeChild(ve)},Ae=d?{listing:d,postType:y,format:"instagram-square",branding:C?{enabled:!0,agentName:I,brokerage:O,agentPhotoUrl:q||void 0}:{enabled:!1},selectedPhotoIndex:p}:null;return e.jsx(Ls,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(qu,{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:()=>ie("search"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ae==="search"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(tn,{className:"h-3.5 w-3.5"})," 1. Find Listing"]}),e.jsx(ja,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("button",{onClick:()=>d&&ie("customize"),disabled:!d,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ae==="customize"?"bg-primary text-primary-foreground":d?"bg-muted text-muted-foreground hover:text-foreground":"bg-muted text-muted-foreground/50 cursor-not-allowed"}`,children:[e.jsx(qr,{className:"h-3.5 w-3.5"})," 2. Customize"]}),e.jsx(ja,{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 ${ae==="generate"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground/50"}`,children:[e.jsx(Uo,{className:"h-3.5 w-3.5"})," 3. Generate"]})]}),ae==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(tn,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(GXe,{})]}),e.jsx(mr,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(Be,{className:"space-y-4",children:[e.jsx(ta,{value:r,onValueChange:ze=>n(ze),children:e.jsxs(Qn,{children:[e.jsxs(ls,{value:"address",children:[e.jsx(La,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(ls,{value:"mls",children:[e.jsx(hh,{className:"h-4 w-4 mr-1.5"})," MLS #"]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:t,onChange:ze=>s(ze.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:ze=>ze.key==="Enter"&&fe()}),e.jsxs(K,{onClick:fe,disabled:a||!t.trim(),children:[a?e.jsx(ps,{className:"h-4 w-4 animate-spin"}):e.jsx(tn,{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((ze,Ee)=>{var ve;return e.jsx(Ie,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>xe(ze),children:e.jsx(Be,{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:(ve=ze.photos)!=null&&ve[0]?e.jsx("img",{src:ze.photos[0],alt:ze.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(Mn,{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:U9e(ze.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:ze.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ze.city,", ",ze.state," ",ze.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[ze.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Z4,{className:"h-3 w-3"})," ",ze.bedrooms]}),ze.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(of,{className:"h-3 w-3"})," ",ze.bathrooms]}),ze.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(wL,{className:"h-3 w-3"})," ",ze.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:ze.mlsNumber}),e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:ze.status})]})]})]})})},ze.mlsNumber||Ee)})})]})]}),ae==="customize"&&d&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(Ie,{className:"lg:col-span-1",children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(Ft,{className:"text-base",children:"Selected Listing"})}),e.jsxs(Be,{className:"space-y-3",children:[d.photos.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[4/3] rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:d.photos[p],alt:"Listing photo",className:"w-full h-full object-cover"})}),d.photos.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(ze=>Math.max(0,ze-1)),disabled:p===0,children:e.jsx(wl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p+1," of ",d.photos.length]}),e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(ze=>Math.min(d.photos.length-1,ze+1)),disabled:p===d.photos.length-1,children:e.jsx(ja,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg",children:U9e(d.price)}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.city,", ",d.state," ",d.zip]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[d.bedrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.bedrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Beds"})]}),d.bathrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.bathrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Baths"})]}),d.sqft>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.sqft.toLocaleString()}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Sq Ft"})]})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{ie("search"),u(null)},children:[e.jsx(e0,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(Ie,{className:"lg:col-span-2",children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(qr,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(mr,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(Be,{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(Rl,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:Z?"AI Custom Generation":"Template-Based (Free)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Z?"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(Lr,{checked:Z,onCheckedChange:J}),Z&&e.jsx(Ev,{className:"h-4 w-4 text-purple-500"})]})]}),!Z&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ge,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Rl,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:x5s.map(ze=>e.jsxs("button",{onClick:()=>S(ze.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${w===ze.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:ze.preview}),e.jsx("span",{className:"text-sm font-medium",children:ze.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:ze.description})]},ze.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Post Type"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:f5s.map(ze=>e.jsxs("button",{onClick:()=>_(ze.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${y===ze.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:ze.icon})," ",ze.label]},ze.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Output Formats"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:q9e.map(ze=>e.jsxs("button",{onClick:()=>he(ze.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${b.includes(ze.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[ze.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:ze.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ze.dimensions})]})]},ze.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ge,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ei,{className:"h-4 w-4"})," Agent Branding"]}),e.jsx(Lr,{checked:C,onCheckedChange:A})]}),C&&e.jsxs("div",{className:"space-y-3 pl-6 border-l-2 border-primary/20",children:[q&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:q,alt:"Agent",className:"w-12 h-12 rounded-full object-cover border-2 border-primary/30"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Profile photo will appear on the post"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{className:"text-xs text-muted-foreground",children:"Agent Name"}),e.jsx(Fe,{value:I,onChange:ze=>L(ze.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{className:"text-xs text-muted-foreground",children:"Brokerage (optional)"}),e.jsx(Fe,{value:O,onChange:ze=>U(ze.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!Z&&Ae&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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*(P9[b[0]||"instagram-square"].height/P9[b[0]||"instagram-square"].width)},children:(()=>{const ze=V9e[w],Ee=b[0]||"instagram-square";return e.jsx(ze,{...Ae,format:Ee})})()})})]}),e.jsx(K,{onClick:Ve,disabled:b.length===0||V,size:"lg",className:"w-full gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-5 w-5 animate-spin"})," Generating ",b.length," post",b.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[Z?e.jsx(Ev,{className:"h-5 w-5"}):e.jsx(qr,{className:"h-5 w-5"}),"Generate ",b.length," Social Post",b.length>1?"s":"",Z&&e.jsx(Ye,{variant:"outline",className:"ml-2 text-[10px]",children:"Uses Credits"})]})})]})]})]}),ae==="generate"&&e.jsxs("div",{className:"space-y-4",children:[V&&e.jsx(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(ps,{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:Z?"AI is creating your unique designs":"Rendering templates to high-res images"})]})}),Y.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Generated Posts"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ie("customize"),children:[e.jsx(e0,{className:"h-3.5 w-3.5 mr-1.5"})," Regenerate"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Y.map((ze,Ee)=>{const ve=q9e.find(Re=>Re.value===ze.format);return e.jsxs(Ie,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:ze.imageUrl,alt:`${ze.format} social post`,className:"w-full rounded"})}),e.jsxs(Be,{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:[ve==null?void 0:ve.icon,e.jsx("span",{className:"text-sm font-medium",children:ve==null?void 0:ve.label})]}),e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:ve==null?void 0:ve.dimensions})]}),e.jsxs(K,{size:"sm",className:"w-full gap-1.5",onClick:()=>Te(ze.imageUrl,ze.format),children:[e.jsx(Xa,{className:"h-3.5 w-3.5"})," Download"]})]})]},Ee)})})]})]}),ae==="generate"&&!Z&&d&&Ae&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:b.map(ze=>{const Ee=V9e[w],ve=P9[ze];return e.jsx("div",{style:{width:ve.width,height:ve.height},children:e.jsx(Ee,{ref:Re=>{le.current[`${w}-${ze}`]=Re},...Ae,format:ze})},`${w}-${ze}`)})})]})})}function y5s(){return ft({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 v5s(t){return ft({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 _5s(){const t=es();return Et({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 Vct(){const t=es();return Et({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 b5s(){const t=es();return Et({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 w5s(){const t=es();return Et({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 j5s(){const t=es();return Et({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 N5s(){const t=es();return Et({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 k5s(){const t=es();return Et({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 S5s(){const t=es();return Et({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 C5s(){const t=es();return Et({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 M5s(){return ft({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 T5s(t){return ft({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 Hct(t){return ft({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 A5s(){const t=es();return Et({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 E5s(){const{user:t}=$s(),s=br(),{data:r,isLoading:n}=y5s(),a=_5s(),o=Vct(),l=b5s(),[i,d]=k.useState(!1),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(!0),N=async()=>{if(!(!u.trim()||!t))try{const C=await a.mutateAsync({title:u.trim(),description:f.trim()||void 0,is_sequential:_,created_by:t.id});me.success("Course created"),d(!1),p(""),y(""),b(!0),s(`/admin/lms/${C.id}`)}catch{me.error("Failed to create course")}},w=async C=>{try{await o.mutateAsync({id:C.id,is_published:!C.is_published}),me.success(C.is_published?"Course unpublished":"Course published")}catch{me.error("Failed to update course")}},S=async C=>{if(confirm("Delete this course and all its modules? This cannot be undone."))try{await l.mutateAsync(C),me.success("Course deleted")}catch{me.error("Failed to delete")}};return e.jsxs(Ls,{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(Dh,{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(so,{className:"h-4 w-4 mr-2"}),"Analytics"]}),e.jsxs(K,{onClick:()=>d(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"New Course"]})]})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:[1,2,3].map(C=>e.jsx(Ie,{className:"animate-pulse",children:e.jsxs(Lt,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-2"})]})},C))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:r.map(C=>{var O,U;const A=((U=(O=C.modules)==null?void 0:O[0])==null?void 0:U.count)??0,I=C.access||[],L=I.length===0?"No access set":I.some(q=>q.access_type==="all")?"All agents":`${I.length} rule(s)`;return e.jsxs(Ie,{className:"group hover:shadow-md transition-all hover:border-primary/50 cursor-pointer",onClick:()=>s(`/admin/lms/${C.id}`),children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Ft,{className:"text-base truncate",children:C.title}),C.description&&e.jsx(mr,{className:"mt-1 line-clamp-2",children:C.description})]}),e.jsx(Ye,{variant:C.is_published?"default":"secondary",className:"ml-2 shrink-0",children:C.is_published?"Published":"Draft"})]})}),e.jsxs(Be,{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(oh,{className:"h-3.5 w-3.5"}),A," module",A!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[C.is_sequential?e.jsx(Yy,{className:"h-3.5 w-3.5"}):e.jsx(_S,{className:"h-3.5 w-3.5"}),C.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cr,{className:"h-3.5 w-3.5"}),L]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs(K,{size:"sm",variant:"ghost",onClick:q=>{q.stopPropagation(),w(C)},children:[C.is_published?e.jsx(hp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(jn,{className:"h-3.5 w-3.5 mr-1"}),C.is_published?"Unpublish":"Publish"]}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:q=>{q.stopPropagation(),S(C.id)},children:e.jsx(yr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(ti,{className:"h-4 w-4 text-muted-foreground"})]})]})]},C.id)})}):e.jsx(Ie,{className:"border-dashed",children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(oh,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-1",children:"No courses yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first training course to get started"}),e.jsxs(K,{onClick:()=>d(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Create Course"]})]})})]}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Create New Course"}),e.jsx(Rr,{children:"Set up a new training course for your agents"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Course Title"}),e.jsx(Fe,{value:u,onChange:C=>p(C.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Description"}),e.jsx(_r,{value:f,onChange:C=>y(C.target.value),placeholder:"What will agents learn?",rows:3})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order"})]}),e.jsx(Lr,{checked:_,onCheckedChange:b})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:N,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function P5s(){const{courseId:t}=ho(),s=br(),{data:r,isLoading:n}=v5s(t),a=Vct(),o=w5s(),l=j5s(),i=N5s(),d=k5s(),u=S5s(),p=C5s(),{data:f}=ft({queryKey:["all-brokerages"],queryFn:async()=>{const{data:ut}=await G.from("brokerages").select("id, name").order("name");return ut||[]}}),[y,_]=k.useState(null),[b,N]=k.useState(!1),[w,S]=k.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[C,A]=k.useState(null),[I,L]=k.useState({title:"",resource_type:"link",url:""}),[O,U]=k.useState(new Set),[q,$]=k.useState(null),[V,ee]=k.useState(0),[Z,J]=k.useState(!1),Y=k.useRef(null),ce=k.useRef(null),[ae,ie]=k.useState(!1),[le,fe]=k.useState(""),[xe,he]=k.useState(""),[we,Ne]=k.useState(""),[Ve,Te]=k.useState(!1);if(n)return e.jsx(Ls,{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(Ls,{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(Ra,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Ae=r.modules||[],ze=r.access||[],Ee=ze.some(ut=>ut.access_type==="all"),ve=ze.filter(ut=>ut.access_type==="brokerage").map(ut=>ut.brokerage_id),Re=(f||[]).filter(ut=>ut.name.toLowerCase().includes(le.toLowerCase())),Ue=ut=>{const Oe=new Set(O);Oe.has(ut)?Oe.delete(ut):Oe.add(ut),U(Oe)},ye=async()=>{if(!q)return null;J(!0),ee(0);try{const{data:ut,error:Oe}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:q.name}});if(Oe)throw new Error(Oe.message);const{videoId:Xe,libraryId:at}=ut,{data:Ke,error:He}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Xe,libraryId:at}});if(He)throw new Error(He.message);const gt=new XMLHttpRequest;return await new Promise((Mt,Wt)=>{gt.upload.onprogress=xs=>{xs.lengthComputable&&ee(Math.round(xs.loaded/xs.total*100))},gt.onload=()=>gt.status>=200&>.status<300?Mt():Wt(new Error(`Upload failed: ${gt.status}`)),gt.onerror=()=>Wt(new Error("Upload failed")),gt.open("PUT",Ke.uploadUrl),gt.setRequestHeader("AccessKey",Ke.apiKey),gt.send(q)}),`https://iframe.mediadelivery.net/embed/${at}/${Xe}`}catch(ut){return console.error("Bunny upload error:",ut),me.error("Video upload failed"),null}finally{J(!1),ee(0)}},ct=async()=>{if(w.title.trim())try{let ut=w.video_url.trim()||void 0;if(q){const Oe=await ye();if(!Oe)return;ut=Oe}await o.mutateAsync({course_id:r.id,title:w.title.trim(),description:w.description.trim()||void 0,video_url:ut,text_content:w.text_content.trim()||void 0,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):void 0,sort_order:Ae.length}),me.success("Module added"),N(!1),S({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),$(null)}catch{me.error("Failed to add module")}},pe=async()=>{if(y)try{let ut=w.video_url.trim()||null;if(q){const Oe=await ye();if(!Oe)return;ut=Oe}await l.mutateAsync({id:y.id,title:w.title.trim(),description:w.description.trim()||null,video_url:ut,text_content:w.text_content.trim()||null,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):null}),me.success("Module updated"),_(null),$(null)}catch{me.error("Failed to update")}},Ge=async ut=>{if(confirm("Delete this module?"))try{await i.mutateAsync(ut),me.success("Module deleted")}catch{me.error("Failed to delete")}},tt=async ut=>{if(I.title.trim())try{await d.mutateAsync({module_id:ut,title:I.title.trim(),resource_type:I.resource_type,url:I.url.trim()||void 0}),me.success("Resource added"),A(null),L({title:"",resource_type:"link",url:""})}catch{me.error("Failed to add resource")}},st=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[{access_type:"all"}]}),me.success("Access updated: All brokerages / all agents")}catch{me.error("Failed to update access")}},Ce=async ut=>{const Oe=ze.filter(He=>He.access_type==="brokerage").map(He=>He.brokerage_id),Xe=Oe.includes(ut);let at;Xe?at=Oe.filter(He=>He!==ut):at=[...Oe,ut];const Ke=at.map(He=>({access_type:"brokerage",brokerage_id:He}));try{await p.mutateAsync({courseId:r.id,accessRules:Ke}),me.success(Xe?"Brokerage removed":"Brokerage added")}catch{me.error("Failed to update access")}},et=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[]}),me.success("Access cleared")}catch{me.error("Failed")}},Ct=async(ut,Oe)=>{const Xe=Oe==="up"?ut-1:ut+1;if(!(Xe<0||Xe>=Ae.length))try{await Promise.all([l.mutateAsync({id:Ae[ut].id,sort_order:Xe}),l.mutateAsync({id:Ae[Xe].id,sort_order:ut})])}catch{me.error("Failed to reorder")}},Ot=async()=>{try{await a.mutateAsync({id:r.id,title:xe,description:we||null}),me.success("Course updated"),Te(!1)}catch{me.error("Failed to update")}};return e.jsxs(Ls,{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(Ra,{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(Ye,{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(Yy,{className:"h-3.5 w-3.5"}):e.jsx(_S,{className:"h-3.5 w-3.5"}),r.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{children:[Ae.length," module",Ae.length!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{he(r.title),Ne(r.description||""),Te(!0)},children:[e.jsx(pa,{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(hp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(jn,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(ta,{defaultValue:"modules",className:"w-full",children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"modules",children:"Modules"}),e.jsx(ls,{value:"access",children:"Access & Permissions"}),e.jsx(ls,{value:"settings",children:"Settings"})]}),e.jsxs(js,{value:"modules",className:"mt-6 space-y-4",children:[Ae.map((ut,Oe)=>e.jsxs(Ie,{className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>Ue(ut.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(),Ct(Oe,"up")},disabled:Oe===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(lf,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:Xe=>{Xe.stopPropagation(),Ct(Oe,"down")},disabled:Oe===Ae.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Fi,{className:"h-3.5 w-3.5"})})]})}),e.jsx(Ye,{variant:"outline",className:"shrink-0 font-mono text-xs",children:Oe+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:ut.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[ut.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(hn,{className:"h-3 w-3"})," Video"]}),ut.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(mn,{className:"h-3 w-3"})," Text"]}),ut.duration_minutes&&e.jsxs("span",{children:[ut.duration_minutes," min"]}),ut.resources&&ut.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Do,{className:"h-3 w-3"})," ",ut.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:Xe=>{var at;Xe.stopPropagation(),_(ut),S({title:ut.title,description:ut.description||"",video_url:ut.video_url||"",text_content:ut.text_content||"",duration_minutes:((at=ut.duration_minutes)==null?void 0:at.toString())||""})},children:e.jsx(pa,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:Xe=>{Xe.stopPropagation(),Ge(ut.id)},children:e.jsx(yr,{className:"h-3.5 w-3.5"})})]})]}),O.has(ut.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[ut.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:ut.description}),ut.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:ut.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:ut.video_url})]}),ut.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:ut.text_content}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Resources"}),e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{A(ut.id),L({title:"",resource_type:"link",url:""})},children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),ut.resources&&ut.resources.length>0?e.jsx("div",{className:"space-y-1",children:ut.resources.map(Xe=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(Ye,{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(Sr,{className:"h-3 w-3"})})]},Xe.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},ut.id)),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{N(!0),S({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx(js,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(Be,{className:"space-y-5",children:[e.jsxs("div",{className:Rt("flex items-center gap-3 p-4 rounded-xl border-2 cursor-pointer transition-all",Ee?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:st,children:[e.jsx("div",{className:Rt("h-10 w-10 rounded-full flex items-center justify-center shrink-0",Ee?"bg-primary/15 text-primary":"bg-muted text-muted-foreground"),children:e.jsx(gd,{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(Lr,{checked:Ee,onCheckedChange:st})]}),!Ee&&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:ve.length===0?"No brokerages selected — agents won't see this course":`${ve.length} brokerage${ve.length!==1?"s":""} selected`})]}),ve.length>0&&e.jsx(K,{size:"sm",variant:"ghost",className:"text-xs text-muted-foreground",onClick:et,children:"Clear all"})]}),e.jsx(Fe,{placeholder:"Search brokerages...",value:le,onChange:ut=>fe(ut.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:Re.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):Re.map(ut=>{const Oe=ve.includes(ut.id);return e.jsxs("div",{className:Rt("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",Oe?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>Ce(ut.id),children:[e.jsx("div",{className:Rt("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",Oe?"bg-primary border-primary":"border-muted-foreground/30"),children:Oe&&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(ma,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:ut.name}),Oe&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},ut.id)})})]})]})]})}),e.jsxs(js,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Course Thumbnail"})}),e.jsx(Be,{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(Sr,{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(Xv,{className:"h-8 w-8 mb-1 opacity-50"}),e.jsx("span",{className:"text-xs",children:"No thumbnail"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a thumbnail image for this course. Recommended: 800×450px (16:9)."}),e.jsx("input",{ref:ce,type:"file",accept:"image/*",className:"hidden",onChange:async ut=>{var Xe;const Oe=(Xe=ut.target.files)==null?void 0:Xe[0];if(!(!Oe||!r)){ie(!0);try{const at=Oe.name.split(".").pop(),Ke=`${r.id}/thumbnail.${at}`,{error:He}=await G.storage.from("lms-thumbnails").upload(Ke,Oe,{upsert:!0});if(He)throw He;const{data:gt}=G.storage.from("lms-thumbnails").getPublicUrl(Ke),Mt=`${gt.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:Mt}),me.success("Thumbnail uploaded")}catch{me.error("Failed to upload thumbnail")}finally{ie(!1),ce.current&&(ce.current.value="")}}}}),e.jsxs(K,{variant:"outline",size:"sm",disabled:ae,onClick:()=>{var ut;return(ut=ce.current)==null?void 0:ut.click()},children:[ae?e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Da,{className:"h-4 w-4 mr-2"}),ae?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Course Settings"})}),e.jsxs(Be,{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(Lr,{checked:r.is_sequential,onCheckedChange:ut=>a.mutateAsync({id:r.id,is_sequential:ut}).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(Lr,{checked:r.is_published,onCheckedChange:ut=>a.mutateAsync({id:r.id,is_published:ut}).then(()=>me.success("Updated"))})]})]})]})]})]})]}),e.jsx(fs,{open:b||!!y,onOpenChange:ut=>{ut||(N(!1),_(null))},children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:y?"Edit Module":"Add Module"}),e.jsx(Rr,{children:"Configure the module content"})]}),e.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-auto",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Title"}),e.jsx(Fe,{value:w.title,onChange:ut=>S(Oe=>({...Oe,title:ut.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Description"}),e.jsx(_r,{value:w.description,onChange:ut=>S(Oe=>({...Oe,description:ut.target.value})),placeholder:"Brief description",rows:2})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Video"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:Rt("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 ut;return(ut=Y.current)==null?void 0:ut.click()},children:[e.jsx("input",{ref:Y,type:"file",accept:"video/*",className:"hidden",onChange:ut=>{var Xe;const Oe=(Xe=ut.target.files)==null?void 0:Xe[0];Oe&&($(Oe),S(at=>({...at,video_url:""})))}}),q?e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm",children:[e.jsx(hn,{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:ut=>{ut.stopPropagation(),$(null)},children:e.jsx(Sr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1 text-muted-foreground",children:[e.jsx(Da,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Click to upload a video file"})]})]}),Z&&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(ps,{className:"h-3.5 w-3.5 animate-spin"}),e.jsxs("span",{children:["Uploading to Bunny.net... ",V,"%"]})]}),e.jsx(pi,{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:w.video_url,onChange:ut=>S(Oe=>({...Oe,video_url:ut.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Text Content"}),e.jsx(_r,{value:w.text_content,onChange:ut=>S(Oe=>({...Oe,text_content:ut.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Duration (minutes)"}),e.jsx(Fe,{type:"number",value:w.duration_minutes,onChange:ut=>S(Oe=>({...Oe,duration_minutes:ut.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{N(!1),_(null),$(null)},children:"Cancel"}),e.jsxs(K,{onClick:y?pe:ct,disabled:!w.title.trim()||Z,children:[Z?e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(wc,{className:"h-4 w-4 mr-2"}),Z?"Uploading...":y?"Save Changes":"Add Module"]})]})]})}),e.jsx(fs,{open:!!C,onOpenChange:ut=>{ut||A(null)},children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Add Resource"}),e.jsx(Rr,{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(ge,{children:"Title"}),e.jsx(Fe,{value:I.title,onChange:ut=>L(Oe=>({...Oe,title:ut.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Type"}),e.jsxs(zs,{value:I.resource_type,onValueChange:ut=>L(Oe=>({...Oe,resource_type:ut})),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"link",children:"Link"}),e.jsx(yt,{value:"pdf",children:"PDF"}),e.jsx(yt,{value:"template",children:"Template"}),e.jsx(yt,{value:"worksheet",children:"Worksheet"})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"URL"}),e.jsx(Fe,{value:I.url,onChange:ut=>L(Oe=>({...Oe,url:ut.target.value})),placeholder:"https://..."})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>A(null),children:"Cancel"}),e.jsx(K,{onClick:()=>C&&tt(C),disabled:!I.title.trim(),children:"Add Resource"})]})]})}),e.jsx(fs,{open:Ve,onOpenChange:Te,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Edit Course"}),e.jsx(Rr,{children:"Update the course title and description"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Title"}),e.jsx(Fe,{value:xe,onChange:ut=>he(ut.target.value)})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Description"}),e.jsx(_r,{value:we,onChange:ut=>Ne(ut.target.value),rows:3})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Te(!1),children:"Cancel"}),e.jsx(K,{onClick:Ot,disabled:!xe.trim(),children:"Save"})]})]})})]})}function I5s(){return ft({queryKey:["lms-stats-overview"],queryFn:async()=>{const{data:t,error:s}=await G.rpc("get_lms_stats");if(s)throw s;return t}})}function L5s(){return ft({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 D5s(t){return ft({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 R5s(){const t=br(),{data:s,isLoading:r}=I5s(),{data:n,isLoading:a}=L5s(),[o,l]=k.useState(null),{data:i,isLoading:d}=D5s(o),[u,p]=k.useState(""),f=n==null?void 0:n.find(b=>b.course_id===o),y=i==null?void 0:i.filter(b=>{var N,w;return!u||((N=b.agent_name)==null?void 0:N.toLowerCase().includes(u.toLowerCase()))||((w=b.email)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))}),_=[{label:"Total Courses",value:(s==null?void 0:s.total_courses)??0,icon:oh,color:"text-primary"},{label:"Published",value:(s==null?void 0:s.published_courses)??0,icon:Hn,color:"text-emerald-500"},{label:"Enrolled Agents",value:(s==null?void 0:s.total_enrollments)??0,icon:cr,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:Hi,color:"text-amber-500"},{label:"Active (30d)",value:(s==null?void 0:s.active_learners)??0,icon:Yo,color:"text-violet-500"},{label:"Total Modules",value:(s==null?void 0:s.total_modules)??0,icon:so,color:"text-rose-500"}];return e.jsx(Ls,{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(Ra,{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(Dh,{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(Ie,{className:Rt("transition-all",r&&"animate-pulse"),children:e.jsxs(Be,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b.icon,{className:Rt("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(so,{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(Ie,{className:"animate-pulse",children:e.jsx(Be,{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 N=o===b.course_id;return e.jsx(Ie,{className:Rt("cursor-pointer transition-all hover:shadow-md",N?"border-primary ring-1 ring-primary/30 shadow-md":"hover:border-primary/40"),onClick:()=>l(N?null:b.course_id),children:e.jsxs(Be,{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(Ye,{variant:b.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:b.is_published?"Live":"Draft"})]})}),e.jsx(ja,{className:Rt("h-4 w-4 text-muted-foreground transition-transform shrink-0 ml-2",N&&"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(pi,{value:b.avg_completion_pct,className:"h-2"})]})]})},b.course_id)})}):e.jsx(Ie,{className:"border-dashed",children:e.jsx(Be,{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(Rb,{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(tn,{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"})]}),d?e.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(b=>e.jsx(Ie,{className:"animate-pulse",children:e.jsx(Be,{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,N)=>{const w=b.completion_pct>=100;return e.jsx(Ie,{className:Rt("transition-all",w&&"border-emerald-200 bg-emerald-50/30 dark:border-emerald-900/40 dark:bg-emerald-950/10"),children:e.jsx(Be,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Rt("flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold shrink-0",N===0?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":N===1?"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400":N===2?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-muted text-muted-foreground"),children:N+1}),e.jsxs(vn,{className:"h-9 w-9 shrink-0",children:[e.jsx(Ca,{src:b.avatar_url||void 0}),e.jsx(_n,{className:"text-xs bg-primary/10 text-primary",children:(b.agent_name||b.email||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:b.agent_name||b.email}),w&&e.jsxs(Ye,{variant:"default",className:"text-[10px] px-1.5 py-0 bg-emerald-500 hover:bg-emerald-600 shrink-0",children:[e.jsx(Hn,{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(rn,{className:"h-3 w-3"}),gs(new Date(b.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:Rt("text-sm font-bold",w?"text-emerald-600 dark:text-emerald-400":"text-foreground"),children:[b.completion_pct,"%"]}),e.jsx(pi,{value:b.completion_pct,className:"h-1.5 mt-1"})]})]})})},b.user_id)})}):e.jsx(Ie,{className:"border-dashed",children:e.jsx(Be,{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(Ie,{className:"border-dashed",children:e.jsxs(Be,{className:"py-16 text-center",children:[e.jsx(cr,{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 O5s(){const{user:t}=$s(),s=br(),{data:r,isLoading:n}=M5s();return e.jsx(Ls,{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(Dh,{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(Ie,{className:"animate-pulse",children:e.jsxs(Be,{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(F5s,{course:a,userId:t==null?void 0:t.id,onClick:()=>s(`/levelup-u/${a.id}`)},a.id))}):e.jsx(Ie,{className:"border-dashed",children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(oh,{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 F5s({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=Hct(t.id),o=(a==null?void 0:a.filter(d=>d.completed).length)??0,l=n>0?Math.round(o/n*100):0;return e.jsxs(Ie,{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(Dh,{className:"h-10 w-10 text-primary/40"})}),e.jsxs(Be,{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(oh,{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(Yy,{className:"h-3.5 w-3.5"}):e.jsx(_S,{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(pi,{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(ja,{className:"h-3.5 w-3.5"})]})})]})]})}function z5s(){const{courseId:t}=ho(),s=br(),{user:r}=$s(),{data:n,isLoading:a}=T5s(t),{data:o}=Hct(t),l=A5s(),[i,d]=k.useState(null),u=(n==null?void 0:n.modules)||[],p=new Set((o==null?void 0:o.filter(C=>C.completed).map(C=>C.module_id))||[]),f=p.size,y=u.length>0?Math.round(f/u.length*100):0;k.useEffect(()=>{if(u.length>0&&!i){const C=u.find(A=>!p.has(A.id));d((C==null?void 0:C.id)||u[0].id)}},[u,i,p]);const _=u.find(C=>C.id===i),b=u.findIndex(C=>C.id===i),N=(C,A)=>{if(!(n!=null&&n.is_sequential)||A===0)return!1;for(let I=0;I{if(!(!_||!r||!t))try{await l.mutateAsync({courseId:t,moduleId:_.id,userId:r.id}),me.success("Module completed! 🎉"),b{const A=C.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(A)return`https://www.youtube.com/embed/${A[1]}`;const I=C.match(/vimeo\.com\/(\d+)/);if(I)return`https://player.vimeo.com/video/${I[1]}`;const L=C.match(/(?:iframe\.mediadelivery\.net|video\.bunnycdn\.com)\/(?:play|embed)\/(\d+)\/([a-f0-9-]+)/);return L?`https://iframe.mediadelivery.net/embed/${L[1]}/${L[2]}?responsive=true`:C};return a?e.jsx(Ls,{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(Ls,{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(Ra,{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(pi,{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(Ie,{className:"lg:sticky lg:top-4",children:e.jsxs(Be,{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(di,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((C,A)=>{const I=N(C,A),L=p.has(C.id),O=C.id===i;return e.jsxs("button",{disabled:I,onClick:()=>!I&&d(C.id),className:Rt("w-full flex items-center gap-3 p-3 rounded-lg text-left transition-all text-sm",O?"bg-primary/10 text-primary":"hover:bg-muted/50",I&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"shrink-0",children:I?e.jsx(yd,{className:"h-4 w-4 text-muted-foreground"}):L?e.jsx(Hn,{className:"h-4 w-4 text-green-500"}):e.jsx(sd,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:Rt("font-medium truncate",O&&"text-primary"),children:[A+1,". ",C.title]}),C.duration_minutes&&e.jsxs("span",{className:"text-[11px] text-muted-foreground flex items-center gap-0.5 mt-0.5",children:[e.jsx(rn,{className:"h-3 w-3"})," ",C.duration_minutes," min"]})]})]},C.id)})})})]})}),e.jsx("div",{className:"space-y-4",children:_?e.jsxs(e.Fragment,{children:[_.video_url&&e.jsx(Ie,{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-video bg-black",children:e.jsx("iframe",{src:S(_.video_url),className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}),e.jsx(Ie,{children:e.jsxs(Be,{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(Ye,{className:"bg-green-500/15 text-green-600 border-green-500/30 shrink-0",children:[e.jsx(Hn,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(K,{size:"sm",onClick:w,disabled:l.isPending,children:[e.jsx(Hn,{className:"h-4 w-4 mr-1"}),"Mark Complete"]})]}),_.text_content&&e.jsx("div",{className:"prose prose-sm max-w-none text-foreground border-t pt-4 whitespace-pre-wrap",children:_.text_content}),_.resources&&_.resources.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Resources"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:_.resources.map(C=>e.jsxs("a",{href:C.url||C.file_url||"#",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-sm",children:[C.resource_type==="pdf"?e.jsx(mn,{className:"h-4 w-4 text-red-500 shrink-0"}):C.resource_type==="template"?e.jsx(Dh,{className:"h-4 w-4 text-purple-500 shrink-0"}):e.jsx(Do,{className:"h-4 w-4 text-blue-500 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:C.title}),e.jsx(Kr,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]},C.id))})]}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-4",children:[e.jsxs(K,{variant:"outline",size:"sm",disabled:b===0,onClick:()=>b>0&&d(u[b-1].id),children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-1"})," Previous"]}),bd(u[b+1].id),children:["Next ",e.jsx(ja,{className:"h-3.5 w-3.5 ml-1"})]}):y===100&&e.jsx(Ye,{className:"bg-green-500/15 text-green-600 border-green-500/30 text-sm px-3 py-1.5",children:"🎉 Course Complete!"})]})]})})]}):e.jsx(Ie,{children:e.jsx(Be,{className:"flex items-center justify-center py-16 text-muted-foreground",children:"Select a module to begin"})})})]})]})}):e.jsx(Ls,{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(Ra,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function B5s({headline:t,subtext:s,primaryColor:r,accentColor:n,heroImageUrl:a,logoUrl:o,brokerageName:l}){return e.jsxs("section",{className:"relative min-h-screen flex items-center justify-center overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0",style:{background:`linear-gradient(160deg, ${n} 0%, ${r} 50%, ${n}ee 100%)`}}),a&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center opacity-20",style:{backgroundImage:`url(${a})`}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle at 25% 25%, white 1px, transparent 1px), radial-gradient(circle at 75% 75%, white 1px, transparent 1px)",backgroundSize:"60px 60px"}}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-32 bg-gradient-to-t from-white to-transparent"}),e.jsxs("div",{className:"relative z-10 text-center max-w-4xl mx-auto px-6 py-24",children:[o&&e.jsx(ur.img,{src:o,alt:l,className:"h-14 md:h-20 w-auto mx-auto mb-10 drop-shadow-2xl",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.8,delay:.2}}),e.jsx(ur.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.3},children:e.jsx("span",{className:"inline-block text-white/70 text-sm md:text-base font-medium tracking-[0.2em] uppercase mb-6",children:"Your Next Chapter Starts Here"})}),e.jsx(ur.h1,{className:"text-4xl md:text-6xl lg:text-7xl font-bold text-white mb-8 leading-[1.1] tracking-tight",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.9,delay:.5},children:t}),e.jsx(ur.p,{className:"text-lg md:text-xl text-white/80 mb-12 max-w-2xl mx-auto leading-relaxed font-light",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.7},children:s}),e.jsxs(ur.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.7,delay:.9},className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs("a",{href:"#apply",className:"group inline-flex items-center gap-3 px-10 py-4 rounded-full text-lg font-semibold shadow-2xl transition-all duration-300 hover:scale-105 hover:shadow-3xl",style:{backgroundColor:"white",color:n},children:["Get In Touch",e.jsx(ti,{className:"h-5 w-5 transition-transform group-hover:translate-x-1"})]}),e.jsx("a",{href:"#benefits",className:"inline-flex items-center gap-2 px-8 py-4 rounded-full text-base font-medium text-white/90 border border-white/30 backdrop-blur-sm transition-all duration-300 hover:bg-white/10 hover:border-white/50",children:"Learn More"})]})]}),e.jsx(ur.div,{className:"absolute bottom-8 left-1/2 -translate-x-1/2 z-10",animate:{y:[0,8,0]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:e.jsx("div",{className:"w-6 h-10 border-2 border-white/40 rounded-full flex justify-center pt-2",children:e.jsx("div",{className:"w-1.5 h-3 bg-white/60 rounded-full"})})})]})}function kf({children:t,className:s="",delay:r=0,direction:n="up"}){const a=k.useRef(null),o=VPt(a,{once:!0,margin:"-80px"}),l={hidden:{opacity:0,y:n==="up"?40:0,x:n==="left"?-40:n==="right"?40:0},visible:{opacity:1,y:0,x:0}};return e.jsx(ur.div,{ref:a,initial:"hidden",animate:o?"visible":"hidden",variants:l,transition:{duration:.7,delay:r,ease:[.25,.46,.45,.94]},className:s,children:t})}function $5s({benefits:t,accentColor:s,primaryColor:r}){return t.length===0?null:e.jsx("section",{id:"benefits",className:"py-24 md:py-32 px-6 bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(kf,{children:e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("span",{className:"text-sm font-semibold tracking-[0.15em] uppercase mb-4 block",style:{color:r},children:"Why Top Agents Choose Us"}),e.jsx("h2",{className:"text-3xl md:text-5xl font-bold mb-4 tracking-tight",style:{color:s},children:"Built For Your Success"}),e.jsx("div",{className:"w-16 h-1 mx-auto rounded-full mt-6",style:{backgroundColor:r}})]})}),e.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8",children:t.map((n,a)=>e.jsx(kf,{delay:a*.1,children:e.jsxs("div",{className:"group relative p-8 rounded-2xl border border-gray-100 bg-white hover:border-transparent hover:shadow-2xl transition-all duration-500 h-full",children:[e.jsx("div",{className:"absolute inset-0 rounded-2xl opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{background:`linear-gradient(135deg, ${r}08, ${s}05)`}}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl flex items-center justify-center text-2xl mb-5 transition-transform duration-300 group-hover:scale-110",style:{backgroundColor:`${r}12`},children:n.icon}),e.jsx("h3",{className:"text-xl font-bold mb-3 tracking-tight",style:{color:s},children:n.title}),e.jsx("p",{className:"text-gray-500 leading-relaxed text-[15px]",children:n.description})]})]})},a))})]})})}function q5s({images:t,primaryColor:s,accentColor:r}){const[n,a]=k.useState(null);return t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"py-24 md:py-32 px-6 bg-gray-50",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(kf,{children:e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white border border-gray-200 mb-6",children:[e.jsx(cr,{className:"h-4 w-4",style:{color:s}}),e.jsx("span",{className:"text-sm font-medium text-gray-600",children:"Life at Our Brokerage"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl font-bold tracking-tight",style:{color:r},children:"Our Team & Culture"})]})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3 md:gap-4",children:t.map((o,l)=>e.jsx(kf,{delay:l*.08,children:e.jsxs("button",{onClick:()=>a(l),className:"relative w-full aspect-[4/3] overflow-hidden rounded-xl group cursor-pointer",children:[e.jsx("img",{src:o,alt:`Team ${l+1}`,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-all duration-500"})]})},l))})]})}),n!==null&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/90 flex items-center justify-center p-4 cursor-pointer",onClick:()=>a(null),children:[e.jsx("button",{onClick:()=>a(null),className:"absolute top-6 right-6 text-white/80 hover:text-white transition-colors",children:e.jsx(Sr,{className:"h-8 w-8"})}),e.jsx("img",{src:t[n],alt:"Gallery",className:"max-w-full max-h-[85vh] object-contain rounded-lg",onClick:o=>o.stopPropagation()})]})]})}function U5s({testimonials:t,primaryColor:s,accentColor:r}){return t.length===0?null:e.jsx("section",{className:"py-24 md:py-32 px-6 bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(kf,{children:e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("span",{className:"text-sm font-semibold tracking-[0.15em] uppercase mb-4 block",style:{color:s},children:"Agent Testimonials"}),e.jsx("h2",{className:"text-3xl md:text-5xl font-bold tracking-tight",style:{color:r},children:"Hear From Our Agents"}),e.jsx("div",{className:"w-16 h-1 mx-auto rounded-full mt-6",style:{backgroundColor:s}})]})}),e.jsx("div",{className:"grid md:grid-cols-2 gap-8",children:t.map((n,a)=>{var o;return e.jsx(kf,{delay:a*.15,direction:a%2===0?"left":"right",children:e.jsxs("div",{className:"relative p-8 md:p-10 rounded-2xl bg-gray-50 border border-gray-100 h-full",children:[e.jsx(xS,{className:"h-8 w-8 mb-5 opacity-20",style:{color:s}}),e.jsxs("p",{className:"text-gray-700 text-lg leading-relaxed mb-8 font-light italic",children:['"',n.quote,'"']}),e.jsxs("div",{className:"flex items-center gap-4",children:[n.photo_url?e.jsx("img",{src:n.photo_url,alt:n.name,className:"h-12 w-12 rounded-full object-cover ring-2 ring-white shadow-md"}):e.jsx("div",{className:"h-12 w-12 rounded-full flex items-center justify-center text-white text-base font-bold shadow-md",style:{background:`linear-gradient(135deg, ${s}, ${r})`},children:((o=n.name)==null?void 0:o[0])||"?"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-base",style:{color:r},children:n.name}),n.role&&e.jsx("p",{className:"text-sm text-gray-500",children:n.role})]})]})]})},a)})})]})})}function V5s({form:t,setForm:s,onSubmit:r,isPending:n,primaryColor:a,accentColor:o}){return e.jsxs("section",{id:"apply",className:"py-24 md:py-32 px-6 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 top-0 h-1/2",style:{background:`linear-gradient(160deg, ${o}, ${a})`}}),e.jsx("div",{className:"absolute inset-0 top-1/2 bg-gray-50"}),e.jsxs("div",{className:"relative z-10 max-w-xl mx-auto",children:[e.jsx(kf,{children:e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-3 tracking-tight",children:"Want to Learn More?"}),e.jsx("p",{className:"text-white/70 text-lg font-light",children:"Drop your info below and we'll share more about what makes us different."})]})}),e.jsx(kf,{delay:.2,children:e.jsxs("form",{onSubmit:l=>{l.preventDefault(),r()},className:"bg-white rounded-3xl shadow-2xl p-8 md:p-10 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"First Name *"}),e.jsx(Fe,{required:!0,value:t.first_name,onChange:l=>s(i=>({...i,first_name:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"John"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Last Name"}),e.jsx(Fe,{value:t.last_name,onChange:l=>s(i=>({...i,last_name:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"Smith"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Email *"}),e.jsx(Fe,{type:"email",required:!0,value:t.email,onChange:l=>s(i=>({...i,email:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"john@email.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Phone"}),e.jsx(Fe,{value:t.phone,onChange:l=>s(i=>({...i,phone:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Current Brokerage"}),e.jsx(Fe,{value:t.current_brokerage,onChange:l=>s(i=>({...i,current_brokerage:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"Your current brokerage name"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"License #"}),e.jsx(Fe,{value:t.license_number,onChange:l=>s(i=>({...i,license_number:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Years Experience"}),e.jsx(Fe,{type:"number",min:"0",value:t.experience_years,onChange:l=>s(i=>({...i,experience_years:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Annual Production"}),e.jsx(Fe,{value:t.annual_production,onChange:l=>s(i=>({...i,annual_production:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"e.g. $5M, 20 transactions"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Why are you interested?"}),e.jsx(_r,{value:t.why_interested,onChange:l=>s(i=>({...i,why_interested:l.target.value})),rows:3,className:"rounded-lg border-gray-200 focus:border-gray-400 transition-colors resize-none",placeholder:"Tell us about your goals and what you're looking for..."})]}),e.jsx(K,{type:"submit",className:"w-full h-13 text-base font-semibold rounded-xl group transition-all duration-300 hover:shadow-lg",style:{background:`linear-gradient(135deg, ${a}, ${o})`},disabled:n,children:n?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),"Submitting..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Send My Info",e.jsx(ti,{className:"h-4 w-4 transition-transform group-hover:translate-x-1"})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-gray-400 pt-1",children:[e.jsx(Ru,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Your information is confidential and will not be shared."})]})]})})]})]})}function H5s({form:t,setForm:s,onSubmit:r,isPending:n,primaryColor:a,accentColor:o,showConfidentialBadges:l=!0}){const[i,d]=k.useState(1),[u,p]=k.useState(""),f=3,y=!!t.first_name&&!!t.email,_=b=>{p(b),s(N=>({...N,why_interested:b})),setTimeout(()=>d(2),200)};return e.jsxs("section",{id:"apply",className:"py-24 md:py-32 px-6 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 top-0 h-1/2",style:{background:`linear-gradient(160deg, ${o}, ${a})`}}),e.jsx("div",{className:"absolute inset-0 top-1/2 bg-gray-50"}),e.jsxs("div",{className:"relative z-10 max-w-xl mx-auto",children:[e.jsx(kf,{children:e.jsxs("div",{className:"text-center mb-8",children:[l&&e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-semibold bg-white/15 text-white backdrop-blur mb-4",children:[e.jsx(yd,{className:"h-2.5 w-2.5"})," 100% Confidential"]}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-3 tracking-tight",children:"Start a Confidential Conversation"}),e.jsx("p",{className:"text-white/70 text-lg font-light",children:"No high-pressure sales calls. Ever."})]})}),e.jsx(kf,{delay:.15,children:e.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl p-8 md:p-10",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-7",children:[[1,2,3].map(b=>e.jsx("div",{className:"h-1 flex-1 rounded-full transition-colors duration-500",style:{backgroundColor:b<=i?a:"#e5e7eb"}},b)),e.jsxs("span",{className:"text-xs text-gray-400 ml-2",children:[i,"/",f]})]}),e.jsxs(qNe,{mode:"wait",children:[i===1&&e.jsxs(ur.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.25},className:"space-y-3",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",style:{color:o},children:"What's most important to you?"}),e.jsx("p",{className:"text-sm text-gray-500 mb-5",children:"Pick the one that resonates most. We'll tailor the conversation."}),[{val:"Better commission split / cap",label:"Better Splits & Caps",icon:"💰"},{val:"Better technology and tools",label:"Better Tech & Tools",icon:"🛠️"},{val:"Better training and mentorship",label:"Better Training",icon:"📚"},{val:"Better culture and team",label:"Better Culture",icon:"🤝"},{val:"Just exploring options confidentially",label:"Just Exploring",icon:"🔍"}].map(b=>e.jsxs("button",{type:"button",onClick:()=>_(b.val),className:"w-full flex items-center gap-3 p-4 rounded-xl border-2 border-gray-100 hover:border-gray-300 transition-all text-left group",children:[e.jsx("span",{className:"text-2xl",children:b.icon}),e.jsx("span",{className:"font-medium text-gray-700 group-hover:text-gray-900 flex-1",children:b.label}),e.jsx(ti,{className:"h-4 w-4 text-gray-300 group-hover:text-gray-500 group-hover:translate-x-1 transition-all"})]},b.val))]},"step1"),i===2&&e.jsxs(ur.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.25},className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",style:{color:o},children:"How can we reach you?"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"We'll text first, on your schedule."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"First Name *"}),e.jsx(Fe,{required:!0,value:t.first_name,onChange:b=>s(N=>({...N,first_name:b.target.value})),className:"h-11",placeholder:"John"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Last Name"}),e.jsx(Fe,{value:t.last_name,onChange:b=>s(N=>({...N,last_name:b.target.value})),className:"h-11",placeholder:"Smith"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Email *"}),e.jsx(Fe,{type:"email",required:!0,value:t.email,onChange:b=>s(N=>({...N,email:b.target.value})),className:"h-11",placeholder:"john@email.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Phone (preferred)"}),e.jsx(Fe,{value:t.phone,onChange:b=>s(N=>({...N,phone:b.target.value})),className:"h-11",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:()=>d(1),className:"h-11",children:[e.jsx(Ra,{className:"h-4 w-4 mr-1"})," Back"]}),e.jsxs(K,{type:"button",disabled:!y,onClick:()=>d(3),className:"flex-1 h-11 text-white font-semibold",style:{background:`linear-gradient(135deg, ${a}, ${o})`},children:["Continue ",e.jsx(ti,{className:"h-4 w-4 ml-1"})]})]})]},"step2"),i===3&&e.jsxs(ur.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.25},className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",style:{color:o},children:"A few quick details (optional)"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Helps us prepare a more personalized comp comparison."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Current Brokerage"}),e.jsx(Fe,{value:t.current_brokerage,onChange:b=>s(N=>({...N,current_brokerage:b.target.value})),className:"h-11",placeholder:"(stays private)"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Years Experience"}),e.jsx(Fe,{type:"number",min:"0",value:t.experience_years,onChange:b=>s(N=>({...N,experience_years:b.target.value})),className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Annual Production"}),e.jsx(Fe,{value:t.annual_production,onChange:b=>s(N=>({...N,annual_production:b.target.value})),className:"h-11",placeholder:"e.g. $5M"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-gray-700 text-sm font-medium",children:"Anything else?"}),e.jsx(_r,{value:t.why_interested,onChange:b=>s(N=>({...N,why_interested:b.target.value})),rows:2,className:"resize-none",placeholder:"Optional message..."})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:()=>d(2),className:"h-11",children:[e.jsx(Ra,{className:"h-4 w-4 mr-1"})," Back"]}),e.jsx(K,{type:"button",onClick:r,disabled:n,className:"flex-1 h-12 text-white font-semibold rounded-xl",style:{background:`linear-gradient(135deg, ${a}, ${o})`},children:n?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),"Sending..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ea,{className:"h-4 w-4"})," Start the Conversation"]})})]})]},"step3")]}),l&&e.jsxs("div",{className:"mt-6 pt-5 border-t border-gray-100 grid grid-cols-3 gap-2 text-[10px] text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-1 justify-center",children:[e.jsx(Ru,{className:"h-3 w-3"})," Confidential"]}),e.jsxs("div",{className:"flex items-center gap-1 justify-center",children:[e.jsx(Si,{className:"h-3 w-3"})," Text first"]}),e.jsxs("div",{className:"flex items-center gap-1 justify-center",children:[e.jsx(Tn,{className:"h-3 w-3"})," No spam"]})]})]})})]})]})}function G5s({config:t,primaryColor:s,accentColor:r,brokerageId:n,brokerageName:a}){const{toast:o}=va(),[l,i]=k.useState("250000"),[d,u]=k.useState("70"),[p,f]=k.useState("150"),[y,_]=k.useState(""),[b,N]=k.useState(!1),[w,S]=k.useState(!1),C=t.commission_split_pct??80,A=t.cap_amount??16e3,I=t.monthly_fee??99,L=t.transaction_fee??0,O=k.useMemo(()=>{const $=parseFloat(l)||0,V=parseFloat(d)||0,ee=parseFloat(p)||0,Z=$*(V/100)-ee*12,J=1-C/100,Y=$*J,ce=Math.min(Y,A),ae=$-ce-I*12-L,ie=ae-Z;return{currentNet:Z,newNet:ae,diff:ie}},[l,d,p,C,A,I,L]),U=$=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format($),q=async $=>{if($.preventDefault(),!!y){S(!0);try{const{error:V}=await G.from("recruit_lead_magnet_downloads").insert({brokerage_id:n,email:y,source:"calculator"});if(V)throw V;N(!0),o({title:"Sent!",description:"Check your email for the full breakdown."})}catch(V){o({title:"Error",description:V.message,variant:"destructive"})}finally{S(!1)}}};return e.jsx("section",{className:"py-20 md:py-28 px-6 bg-gray-50",children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(kf,{children:e.jsxs("div",{className:"text-center mb-10",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-xs font-semibold mb-4",style:{backgroundColor:`${s}15`,color:r},children:[e.jsx(yd,{className:"h-3 w-3"})," 100% Confidential — No Signup Required"]}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold tracking-tight mb-3",style:{color:r},children:t.headline||"See What You Could Earn With Us"}),e.jsx("p",{className:"text-gray-500 text-lg font-light max-w-xl mx-auto",children:t.subtext||"Confidential 60-second calculator — no signup required."})]})}),e.jsx(kf,{delay:.15,children:e.jsxs("div",{className:"bg-white rounded-3xl shadow-xl overflow-hidden grid md:grid-cols-2",children:[e.jsxs("div",{className:"p-8 md:p-10 border-r border-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx(wM,{className:"h-5 w-5",style:{color:s}}),e.jsx("h3",{className:"font-semibold",style:{color:r},children:"Your Numbers"})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx(ge,{className:"text-gray-600 text-sm",children:"Your GCI Last 12 Months"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm",children:"$"}),e.jsx(Fe,{type:"number",value:l,onChange:$=>i($.target.value),className:"pl-7 h-11 text-base",placeholder:"250,000"})]})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-gray-600 text-sm",children:"Your Current Commission Split (%)"}),e.jsx(Fe,{type:"number",value:d,onChange:$=>u($.target.value),className:"mt-1.5 h-11 text-base",placeholder:"70"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-gray-600 text-sm",children:"Your Current Monthly Fees"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm",children:"$"}),e.jsx(Fe,{type:"number",value:p,onChange:$=>f($.target.value),className:"pl-7 h-11 text-base",placeholder:"150"})]})]})]})]}),e.jsxs("div",{className:"p-8 md:p-10 text-white",style:{background:`linear-gradient(160deg, ${r}, ${s})`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx(Yo,{className:"h-5 w-5"}),e.jsxs("h3",{className:"font-semibold",children:["Your Earnings at ",a]})]}),e.jsxs("div",{className:"space-y-4 mb-6",children:[e.jsxs("div",{className:"flex items-baseline justify-between border-b border-white/20 pb-3",children:[e.jsx("span",{className:"text-white/70 text-sm",children:"Current take-home"}),e.jsx("span",{className:"text-xl font-semibold",children:U(O.currentNet)})]}),e.jsxs("div",{className:"flex items-baseline justify-between border-b border-white/20 pb-3",children:[e.jsx("span",{className:"text-white/70 text-sm",children:"With us"}),e.jsx("span",{className:"text-xl font-semibold",children:U(O.newNet)})]})]}),e.jsxs(ur.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},className:"bg-white/10 backdrop-blur rounded-2xl p-5 text-center",children:[e.jsx("p",{className:"text-white/80 text-xs uppercase tracking-wide mb-1",children:O.diff>=0?"You could earn":"Difference"}),e.jsxs("p",{className:"text-4xl font-bold mb-1",children:[O.diff>=0?"+":"",U(O.diff)]}),e.jsx("p",{className:"text-white/70 text-xs",children:O.diff>=0?"more per year":"per year"})]},O.diff),t.show_email_capture&&!b&&e.jsxs("form",{onSubmit:q,className:"mt-6 space-y-2",children:[e.jsx("p",{className:"text-white/80 text-xs",children:t.email_capture_label||"Want the full breakdown? Enter your email."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{type:"email",required:!0,value:y,onChange:$=>_($.target.value),placeholder:"you@email.com",className:"bg-white/95 border-0 text-gray-900 h-10 text-sm"}),e.jsx(K,{type:"submit",disabled:w,className:"h-10 bg-white text-gray-900 hover:bg-white/90 text-sm font-semibold",children:"Send"})]})]}),b&&e.jsxs("div",{className:"mt-6 flex items-center gap-2 text-sm text-white/90 bg-white/10 rounded-lg p-3",children:[e.jsx(ea,{className:"h-4 w-4"})," Check your inbox shortly."]})]})]})}),e.jsx("p",{className:"text-center text-xs text-gray-400 mt-4",children:"Estimates only. Actual results vary by individual production and plan terms."})]})})}function W5s({config:t,primaryColor:s,accentColor:r,brokerageId:n}){const{toast:a}=va(),[o,l]=k.useState(""),[i,d]=k.useState(""),[u,p]=k.useState(!1),[f,y]=k.useState(!1),_=async b=>{b.preventDefault(),y(!0);try{const{error:N}=await G.from("recruit_lead_magnet_downloads").insert({brokerage_id:n,email:o,first_name:i||null,source:"lead_magnet",user_agent:navigator.userAgent,referrer:document.referrer||null});if(N)throw N;p(!0),t.pdf_url&&window.open(t.pdf_url,"_blank","noopener,noreferrer")}catch(N){a({title:"Error",description:N.message,variant:"destructive"})}finally{y(!1)}};return e.jsx("section",{className:"py-20 md:py-24 px-6 bg-white",children:e.jsx("div",{className:"max-w-3xl mx-auto",children:e.jsx(kf,{children:e.jsx("div",{className:"rounded-3xl p-8 md:p-12 shadow-xl border border-gray-100",style:{background:`linear-gradient(135deg, ${s}08, ${r}08)`},children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-8",children:[e.jsx("div",{className:"shrink-0 h-24 w-24 rounded-2xl flex items-center justify-center shadow-lg",style:{background:`linear-gradient(135deg, ${s}, ${r})`},children:e.jsx(tS,{className:"h-12 w-12 text-white"})}),e.jsxs("div",{className:"flex-1 text-center md:text-left",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-semibold mb-3",style:{backgroundColor:`${s}15`,color:r},children:[e.jsx(yd,{className:"h-2.5 w-2.5"})," No call required — instant download"]}),e.jsx("h3",{className:"text-2xl md:text-3xl font-bold tracking-tight mb-2",style:{color:r},children:t.title||"Get the Full Comp Plan PDF"}),e.jsx("p",{className:"text-gray-500 leading-relaxed mb-5",children:t.description||"See exactly how splits, caps, and fees work — no call required."}),u?e.jsxs("div",{className:"flex items-center gap-2 p-4 rounded-xl bg-green-50 border border-green-200 text-green-800 text-sm",children:[e.jsx(ea,{className:"h-5 w-5 shrink-0"}),e.jsxs("span",{children:["Sent! ",t.pdf_url?"Your download should open in a new tab.":"Check your email shortly."]})]}):e.jsxs("form",{onSubmit:_,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(Fe,{value:i,onChange:b=>d(b.target.value),placeholder:"First name (optional)",className:"h-11"}),e.jsx(Fe,{type:"email",required:!0,value:o,onChange:b=>l(b.target.value),placeholder:"your@email.com",className:"h-11"})]}),e.jsxs(K,{type:"submit",disabled:f,className:"w-full sm:w-auto h-12 px-6 text-white font-semibold",style:{background:`linear-gradient(135deg, ${s}, ${r})`},children:[e.jsx(tS,{className:"h-4 w-4 mr-2"}),f?"Sending...":t.button_text||"Email Me the PDF"]})]})]})]})})})})})}function K5s(){const{slug:t}=ho(),{toast:s}=va(),[r,n]=k.useState(!1),[a,o]=k.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",experience_years:"",annual_production:"",license_number:"",why_interested:""});k.useEffect(()=>{document.body.classList.add("recruit-landing-page");const $=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[class*="lc_text_widget"]','[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]",'div[id^="hubspot"]',".widget-visible"].forEach(J=>document.querySelectorAll(J).forEach(Y=>Y.style.display="none"))};$();const V=[setTimeout($,500),setTimeout($,1500),setTimeout($,3e3)],ee=new MutationObserver($);return ee.observe(document.body,{childList:!0,subtree:!0}),()=>{document.body.classList.remove("recruit-landing-page"),V.forEach(clearTimeout),ee.disconnect()}},[]);const{data:l,isLoading:i,error:d}=ft({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:$,error:V}=await G.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(V)throw V;return $},enabled:!!t}),{data:u}=ft({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:$,error:V}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(V&&V.code!=="PGRST116")throw V;return $},enabled:!!(l!=null&&l.id)}),p=Et({mutationFn:async()=>{const $={brokerage_id:l.id,first_name:a.first_name,last_name:a.last_name||null,email:a.email,phone:a.phone||null,current_brokerage:a.current_brokerage||null,experience_years:a.experience_years?parseInt(a.experience_years):null,annual_production:a.annual_production||null,license_number:a.license_number||null,why_interested:a.why_interested||null},{error:V}=await G.from("recruit_interest_submissions").insert($);if(V)throw V;G.functions.invoke("recruit-lead-notify",{body:{lead:$,brokerage_id:l.id}}).catch(ee=>console.error("Lead notification error:",ee))},onSuccess:()=>n(!0),onError:$=>s({title:"Error",description:$.message,variant:"destructive"})});if(i)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-3 border-gray-200 border-t-gray-800"}),e.jsx("span",{className:"text-sm text-gray-400 tracking-wide",children:"Loading..."})]})});if(d||!l||!l.recruit_form_enabled)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs("div",{className:"max-w-md w-full mx-4 text-center",children:[e.jsx(ma,{className:"h-10 w-10 mx-auto text-gray-300 mb-4"}),e.jsx("p",{className:"text-gray-400 text-lg",children:"This page is not available."})]})});const f=u,y=(f==null?void 0:f.primary_color)||"#406E71",_=(f==null?void 0:f.accent_color)||"#2a4c64",b=(f==null?void 0:f.benefits)||[],N=(f==null?void 0:f.testimonials)||[],w=(f==null?void 0:f.gallery_images)||[],S=(f==null?void 0:f.hero_headline)||`Join ${l.name}`,C=(f==null?void 0:f.hero_subtext)||"Take your real estate career to the next level with a brokerage that invests in your growth.",A=(f==null?void 0:f.calculator_enabled)===!0,I=(f==null?void 0:f.calculator_config)||{},L=(f==null?void 0:f.lead_magnet_enabled)===!0,O=(f==null?void 0:f.lead_magnet_config)||{},U=(f==null?void 0:f.form_style)||"classic",q=(f==null?void 0:f.confidential_messaging)!==!1;return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs(ur.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{duration:.6},className:"max-w-md w-full mx-4 text-center",children:[e.jsx("div",{className:"h-20 w-20 rounded-full flex items-center justify-center mx-auto mb-6 shadow-lg",style:{background:`linear-gradient(135deg, ${y}, ${_})`},children:e.jsx(ea,{className:"h-10 w-10 text-white"})}),e.jsx("h2",{className:"text-3xl font-bold mb-3 tracking-tight",style:{color:_},children:"Thank You!"}),e.jsxs("p",{className:"text-gray-500 text-lg leading-relaxed mb-8",children:["Your interest in joining ",e.jsx("span",{className:"font-semibold",style:{color:_},children:l.name})," has been received. A member of our recruitment team will be in touch shortly."]}),e.jsx("div",{className:"w-16 h-1 mx-auto rounded-full",style:{backgroundColor:y}})]})}):e.jsxs("div",{className:"min-h-screen bg-white",style:{"--recruit-primary":y,"--recruit-accent":_},children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-40 bg-white/80 backdrop-blur-lg border-b border-gray-100/50",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6 h-14 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(f==null?void 0:f.logo_url)&&e.jsx("img",{src:f.logo_url,alt:l.name,className:"h-8 w-auto"}),e.jsx("span",{className:"font-semibold text-sm tracking-tight",style:{color:_},children:l.name})]}),e.jsxs("a",{href:"#apply",className:"inline-flex items-center gap-2 px-5 py-2 rounded-full text-sm font-semibold text-white transition-all duration-300 hover:shadow-md hover:scale-105",style:{background:`linear-gradient(135deg, ${y}, ${_})`},children:["Apply Now ",e.jsx(ti,{className:"h-3.5 w-3.5"})]})]})}),e.jsx(B5s,{headline:S,subtext:C,primaryColor:y,accentColor:_,heroImageUrl:f==null?void 0:f.hero_image_url,logoUrl:f==null?void 0:f.logo_url,brokerageName:l.name}),e.jsx($5s,{benefits:b,accentColor:_,primaryColor:y}),e.jsx(q5s,{images:w,primaryColor:y,accentColor:_}),e.jsx(U5s,{testimonials:N,primaryColor:y,accentColor:_}),A&&e.jsx(G5s,{config:I,primaryColor:y,accentColor:_,brokerageId:l.id,brokerageName:l.name}),L&&e.jsx(W5s,{config:O,primaryColor:y,accentColor:_,brokerageId:l.id}),U==="multi_step"?e.jsx(H5s,{form:a,setForm:o,onSubmit:()=>p.mutate(),isPending:p.isPending,primaryColor:y,accentColor:_,showConfidentialBadges:q}):e.jsx(V5s,{form:a,setForm:o,onSubmit:()=>p.mutate(),isPending:p.isPending,primaryColor:y,accentColor:_}),e.jsx("footer",{className:"py-10 text-center bg-white border-t border-gray-100",children:e.jsxs("p",{className:"text-sm text-gray-400",children:["© ",new Date().getFullYear()," ",l.name,". All rights reserved."]})})]})}function Z5s(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 Y5s(){var y,_,b,N;const{shareToken:t}=ho(),s=k.useRef(!1),{data:r,isLoading:n,error:a}=ft({queryKey:["public-recruit-video",t],queryFn:async()=>{var L;if(!t)throw new Error("No token");const{data:w,error:S}=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(S)throw S;const{data:C}=await G.from("profiles").select("name, avatar_url, title").eq("id",(L=w.video)==null?void 0:L.owner_user_id).single(),{data:A}=await G.from("brokerages").select("name").eq("id",w.brokerage_id).single(),{data:I}=await G.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",w.brokerage_id).maybeSingle();return{rv:w,profile:C,brokerage:A,settings:I}},enabled:!!t});if(k.useEffect(()=>{var w;!((w=r==null?void 0:r.rv)!=null&&w.id)||s.current||(s.current=!0,G.rpc("log_recruit_video_view",{p_recruit_video_id:r.rv.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null}).then(()=>{}))},[(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:d}=r,u=(d==null?void 0:d.primary_color)||"#3b82f6",p=((_=o.prospect)==null?void 0:_.first_name)||"there",f=(b=o.video)!=null&&b.playback_url?Z5s(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(Nc,{children:e.jsx("title",{children:i!=null&&i.name?`${i.name} — A Message For You`:"Personal Video Message"})}),e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100",children:[e.jsx("header",{className:"border-b bg-white/80 backdrop-blur-sm",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-4 flex items-center gap-3",children:[(d==null?void 0:d.logo_url)&&e.jsx("img",{src:d.logo_url,alt:"",className:"h-8 object-contain"}),e.jsx("span",{className:"font-semibold text-sm",style:{color:u},children:(i==null?void 0:i.name)||"Recruiting"})]})}),e.jsxs("main",{className:"max-w-3xl mx-auto px-4 py-8 space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground",children:["Hey ",p,", ",l==null?void 0:l.name," has a message for you"]}),o.message&&e.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:o.message})]}),f&&e.jsx("div",{className:"rounded-xl overflow-hidden shadow-xl bg-black",children:e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:f,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border p-6 flex items-center gap-4",children:[l!=null&&l.avatar_url?e.jsx("img",{src:l.avatar_url,alt:"",className:"h-14 w-14 rounded-full object-cover"}):e.jsx("div",{className:"h-14 w-14 rounded-full flex items-center justify-center text-white text-lg font-bold",style:{backgroundColor:u},children:((N=l==null?void 0:l.name)==null?void 0:N.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(nn,{className:"h-5 w-5 mr-2"})," Schedule a Conversation"]})})]}),e.jsx("footer",{className:"text-center py-6 text-xs text-muted-foreground",children:"Powered by LevelUp"})]})]})}const X5s="relzejiswnotikjgvjhz",H9e=`https://${X5s}.supabase.co/functions/v1/recruit-unsubscribe`;function Q5s(){const[t]=Sc(),s=t.get("token")||"",[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[d,u]=k.useState(""),[p,f]=k.useState({});k.useEffect(()=>{document.body.classList.add("recruit-unsubscribe-page");const _=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[class*="lc_text_widget"]','[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]",'div[id^="hubspot"]',".widget-visible"].forEach(S=>document.querySelectorAll(S).forEach(C=>C.style.display="none"))};_();const b=[setTimeout(_,500),setTimeout(_,1500),setTimeout(_,3e3)],N=new MutationObserver(_);return N.observe(document.body,{childList:!0,subtree:!0}),()=>{document.body.classList.remove("recruit-unsubscribe-page"),b.forEach(clearTimeout),N.disconnect()}},[]),k.useEffect(()=>{if(!s){f({error:"Missing unsubscribe token in link."}),n(!1);return}fetch(`${H9e}?token=${encodeURIComponent(s)}`).then(async _=>{const b=await _.json();if(!_.ok)throw new Error(b.error||"Lookup failed");f(b),b.already_unsubscribed&&i(!0)}).catch(_=>f({error:_.message||"Could not load status"})).finally(()=>n(!1))},[s]);const y=async()=>{o(!0);try{const _=await fetch(H9e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:s,reason:d.trim()||null})}),b=await _.json();if(!_.ok)throw new Error(b.error||"Failed");i(!0)}catch(_){f({...p,error:_.message||"Could not unsubscribe"})}finally{o(!1)}};return 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.jsx("div",{className:"w-full max-w-lg bg-white rounded-2xl shadow-xl border border-slate-200 p-8 sm:p-10",children:r?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3 text-slate-500",children:[e.jsx(ps,{className:"h-8 w-8 animate-spin"}),e.jsx("p",{className:"text-sm",children:"Loading…"})]}):p.error?e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("div",{className:"mx-auto w-14 h-14 rounded-full bg-red-50 flex items-center justify-center",children:e.jsx(co,{className:"h-7 w-7 text-red-500"})}),e.jsx("h1",{className:"text-xl font-semibold text-slate-800",children:"Link Invalid"}),e.jsx("p",{className:"text-sm text-slate-500",children:p.error}),e.jsx("p",{className:"text-xs text-slate-400 pt-2",children:"If you continue to receive emails you don't want, please reply directly to one of them and we'll remove you immediately."})]}):l?e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-14 h-14 rounded-full bg-emerald-50 flex items-center justify-center",children:e.jsx(Hn,{className:"h-7 w-7 text-emerald-500"})}),e.jsxs("h1",{className:"text-xl font-semibold text-slate-800",children:["You're unsubscribed",p.first_name?`, ${p.first_name}`:""]}),e.jsxs("p",{className:"text-sm text-slate-500",children:["You won't receive any more recruiting emails from ",p.brokerage_name||"this brokerage",". Your conversation remains 100% confidential."]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-slate-400 pt-2",children:[e.jsx(Lb,{className:"h-3.5 w-3.5"}),"Confidential opt-out · Confirmed"]})]}):e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"mx-auto w-14 h-14 rounded-full bg-slate-100 flex items-center justify-center",children:e.jsx(Lb,{className:"h-7 w-7 text-slate-500"})}),e.jsxs("h1",{className:"text-xl font-semibold text-slate-800",children:["Unsubscribe",p.first_name?`, ${p.first_name}`:"","?"]}),e.jsxs("p",{className:"text-sm text-slate-500",children:["You'll be removed from ",p.brokerage_name||"this brokerage","'s recruiting emails immediately. Everything stays confidential."]}),p.email&&e.jsx("p",{className:"text-xs text-slate-400",children:p.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"reason",className:"text-xs text-slate-500",children:"Optional — what's the main reason? (helps us improve)"}),e.jsx(_r,{id:"reason",value:d,onChange:_=>u(_.target.value),placeholder:"e.g. Not currently looking, too many emails, already moved…",rows:3,className:"resize-none"})]}),e.jsx(K,{onClick:y,disabled:a,className:"w-full h-11",variant:"default",children:a?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Unsubscribing…"]}):"Confirm Unsubscribe"}),e.jsx("p",{className:"text-[11px] text-slate-400 text-center",children:"No login required. We process your request instantly."})]})})})}function J5s(){const t=br(),s=es(),{isAdmin:r}=$s(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,d]=k.useState(null),{data:u,isLoading:p}=ft({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:L},error:O}=await G.auth.getUser();if(O)throw O;if(!L)return[];const{data:U,error:q}=await G.from("social_accounts").select("*").eq("user_id",L.id).order("created_at",{ascending:!1});if(q)throw q;return U}}),f=Et({mutationFn:async L=>{const{data:{user:O},error:U}=await G.auth.getUser();if(U)throw U;if(!O)throw new Error("Not authenticated");const{error:q}=await G.from("social_accounts").delete().eq("id",L).eq("user_id",O.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:O}=await G.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(O)throw O;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:O}=await G.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(O)throw O;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:O}=await G.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(O)throw O;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)}},N=(u==null?void 0:u.filter(L=>L.platform==="facebook"))||[],w=(u==null?void 0:u.filter(L=>L.platform==="instagram"))||[],S=(u==null?void 0:u.filter(L=>L.platform==="linkedin"))||[],C=(u==null?void 0:u.filter(L=>L.platform==="google_business"))||[],A=((u==null?void 0:u.length)||0)>0,I=async(L,O)=>{l(L),d(null);try{const{data:U,error:q}=await G.functions.invoke("meta-api-test",{body:{testType:"all",accountId:L}});if(q)throw q;d(U.results||[]),me.success(U.summary||"API tests completed")}catch(U){console.error("Meta API test error:",U),me.error("Failed to run API tests")}finally{l(null)}};return e.jsx(Ls,{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(Ye,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(qr,{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(Ra,{className:"h-4 w-4"}),"Back to Social Swag"]}),!r&&e.jsx(Ie,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:e.jsxs(Be,{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(rn,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(Ye,{variant:"secondary",className:"mb-3 bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Social Connections Coming Soon!"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"We're putting the finishing touches on this feature. Soon you'll be able to connect your social accounts and post directly from Social Swag with one click."})]})}),r&&e.jsxs(e.Fragment,{children:[A&&e.jsx(Ie,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs(Be,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(si,{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(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-500/10 p-3",children:e.jsx(du,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-lg",children:"Facebook"}),e.jsx(mr,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(Be,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(to,{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(vn,{className:"h-10 w-10",children:[e.jsx(Ca,{src:L.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(du,{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(Ye,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Disconnect Facebook?"}),e.jsx(vl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{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:N.length>0?"outline":"default",children:[n?e.jsx(to,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{className:"h-4 w-4"}),N.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-gradient-to-br from-purple-500/10 via-pink-500/10 to-orange-500/10 p-3",children:e.jsx(hu,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-lg",children:"Instagram"}),e.jsx(mr,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(Be,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(to,{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(vn,{className:"h-10 w-10",children:[e.jsx(Ca,{src:L.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(hu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",L.platform_username||"Instagram Account"]}),e.jsx(Ye,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Disconnect Instagram?"}),e.jsx(vl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{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:w.length>0?"outline":"default",children:[n?e.jsx(to,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{className:"h-4 w-4"}),w.length>0?"Connect Another Account":"Connect Instagram"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Instagram Business accounts must be connected to a Facebook Page"})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-600/10 p-3",children:e.jsx(fp,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-lg",children:"LinkedIn"}),e.jsx(mr,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(Be,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(to,{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(vn,{className:"h-10 w-10",children:[e.jsx(Ca,{src:L.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(fp,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.platform_username||"LinkedIn Account"}),e.jsx(Ye,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Disconnect LinkedIn?"}),e.jsx(vl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{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:S.length>0?"outline":"default",children:[n?e.jsx(to,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{className:"h-4 w-4"}),S.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(Ie,{className:`relative overflow-hidden ${r?"":"opacity-75"}`,children:[!r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(Ye,{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(Ye,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-red-500/10 p-3",children:e.jsx(La,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-lg",children:"Google Business"}),e.jsx(mr,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(Be,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(to,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C.length>0?e.jsx("div",{className:"space-y-3",children:C.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(vn,{className:"h-10 w-10",children:[e.jsx(Ca,{src:L.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(La,{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(Ye,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Ll,{children:[e.jsx(ym,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Disconnect Google Business?"}),e.jsx(vl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:r?"No Google Business account connected yet":"Google Business Profile integration is coming soon!"}),e.jsxs(K,{onClick:r?b:void 0,disabled:!r||n,className:"w-full gap-2",variant:C.length>0?"outline":"default",children:[n?e.jsx(to,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{className:"h-4 w-4"}),C.length>0?"Reconnect Google Business":"Connect Google Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Post updates directly to your Google Business Profile"})]})]})]}),r&&(N.length>0||w.length>0)&&e.jsxs(Ie,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-amber-500/10 p-3",children:e.jsx(Ab,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(mr,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs(Be,{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:[N.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(du,{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(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ab,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${L.id}`)),w.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(hu,{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(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ab,{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,O)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[L.status==="success"?e.jsx(Hn,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):L.status==="pending"?e.jsx(ps,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(Ql,{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})]})]},O))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Note: Facebook posts are auto-deleted. Instagram posts will remain and should be manually deleted. Allow up to 24 hours for Meta to register the API calls."})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"How it works"})}),e.jsx(Be,{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 eMs(){const[t]=Sc(),s=br(),[r,n]=k.useState("loading"),[a,o]=k.useState("Processing your connection...");return k.useEffect(()=>{(async()=>{var f;const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||d));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(Ie,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(ps,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(si,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Ql,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ft,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(mr,{children:a})]}),e.jsx(Be,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function tMs(){const[t]=Sc(),s=br(),[r,n]=k.useState("loading"),[a,o]=k.useState("Connecting your Google Business Profile...");return k.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||d));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(Ie,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(ps,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(si,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Ql,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ft,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(mr,{children:a})]}),e.jsx(Be,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function sMs(){const[t]=Sc(),s=br(),[r,n]=k.useState("loading"),[a,o]=k.useState("Connecting your LinkedIn account...");return k.useEffect(()=>{(async()=>{var f;const i=t.get("code"),d=t.get("state"),u=t.get("error"),p=t.get("error_description");if(u){console.error("LinkedIn OAuth error:",u,p),n("error"),o(p||"Failed to connect LinkedIn account"),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:d,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(Ie,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 rounded-full bg-blue-600/10 p-4 w-fit",children:[r==="loading"&&e.jsx(ps,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(si,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(Ql,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(Ft,{className:"flex items-center justify-center gap-2",children:[e.jsx(fp,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(mr,{children:a})]}),e.jsx(Be,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function rMs(){const t=br(),[s,r]=k.useState(null),{data:n,isLoading:a}=oct(s||void 0,!0),{data:o,isLoading:l}=s3e(!0),{cartItems:i}=she(),d=i.reduce((p,f)=>p+f.quantity,0),u=p=>{t(`/marketplace/${p.id}`)};return a||l?e.jsx(Ls,{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(Ss,{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(Ss,{className:"h-72 w-full"},p))})]})}):e.jsx(Ls,{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(ip,{className:"h-4 w-4 mr-2"}),"Cart",d>0&&e.jsx(Ye,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:d})]})]}),o&&o.length>0&&e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[e.jsx(K,{variant:s===null?"default":"outline",size:"sm",onClick:()=>r(null),children:"All"}),o.map(p=>e.jsx(K,{variant:s===p.id?"default":"outline",size:"sm",onClick:()=>r(p.id),children:p.name},p.id))]}),n&&n.length>0?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(p=>{var f;return e.jsxs(Ie,{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(al,{className:"h-12 w-12 text-muted-foreground"})}),p.category&&e.jsx(Ye,{className:"absolute top-2 left-2",variant:"secondary",children:p.category.name})]}),e.jsxs(Be,{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(al,{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 Gct=k.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));Gct.displayName="Breadcrumb";const Wct=k.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:Rt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));Wct.displayName="BreadcrumbList";const uoe=k.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:Rt("inline-flex items-center gap-1.5",t),...s}));uoe.displayName="BreadcrumbItem";const a2e=k.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?Dje:"a";return e.jsx(a,{ref:n,className:Rt("transition-colors hover:text-foreground",s),...r})});a2e.displayName="BreadcrumbLink";const Kct=k.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:Rt("font-normal text-foreground",t),...s}));Kct.displayName="BreadcrumbPage";const i2e=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Rt("[&>svg]:size-3.5",s),...r,children:t??e.jsx(ja,{})});i2e.displayName="BreadcrumbSeparator";function nMs(){var J,Y;const{productId:t}=ho(),s=br(),{data:r,isLoading:n}=nCs(t||""),{addToCart:a,cartItems:o}=she(),[l,i]=k.useState(null),[d,u]=k.useState(1),[p,f]=k.useState(0),[y,_]=k.useState(null),[b,N]=k.useState(!1),[w,S]=k.useState(!1),C=(J=r==null?void 0:r.variants)==null?void 0:J.find(ce=>ce.id===l),A=((Y=r==null?void 0:r.variants)==null?void 0:Y.filter(ce=>ce.is_active))||[],I=Number((r==null?void 0:r.base_price)||0),L=C?Number(C.price_adjustment):0,O=I+L,U=Number((r==null?void 0:r.shipping_fee)||0),q=o.reduce((ce,ae)=>ce+ae.quantity,0),$=async ce=>{if(!ce.target.files||ce.target.files.length===0)return;N(!0);const ae=ce.target.files[0],ie=ae.name.split(".").pop(),le=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${ie}`;try{const{error:fe}=await G.storage.from("marketplace").upload(le,ae);if(fe)throw fe;const{data:{publicUrl:xe}}=G.storage.from("marketplace").getPublicUrl(le);_(xe),me.success("Artwork uploaded successfully")}catch(fe){me.error("Failed to upload artwork: "+fe.message)}finally{N(!1)}},V=()=>{if(r){if(A.length>0&&!l){me.error("Please select an option");return}a(r,C||void 0,d,y||void 0),S(!0),me.success("Added to cart!"),setTimeout(()=>S(!1),2e3)}},ee=()=>{r!=null&&r.images&&f(ce=>(ce+1)%r.images.length)},Z=()=>{r!=null&&r.images&&f(ce=>(ce-1+r.images.length)%r.images.length)};return n?e.jsx(Ls,{title:"Product",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsx(Ss,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ss,{className:"h-8 w-3/4"}),e.jsx(Ss,{className:"h-6 w-1/4"}),e.jsx(Ss,{className:"h-24 w-full"}),e.jsx(Ss,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Ls,{title:r.name,children:[e.jsx(Gct,{className:"mb-6",children:e.jsxs(Wct,{children:[e.jsx(uoe,{children:e.jsx(a2e,{asChild:!0,children:e.jsx(da,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(i2e,{}),e.jsx(uoe,{children:e.jsx(a2e,{asChild:!0,children:e.jsx(da,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(i2e,{}),e.jsx(uoe,{children:e.jsx(Kct,{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:Z,children:e.jsx(wl,{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:ee,children:e.jsx(ja,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(al,{className:"h-24 w-24 text-muted-foreground"})})}),r.images&&r.images.length>1&&e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:r.images.map((ce,ae)=>e.jsx("button",{onClick:()=>f(ae),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${ae===p?"border-primary":"border-transparent"}`,children:e.jsx("img",{src:ce.image_url,alt:"",className:"w-full h-full object-cover"})},ce.id))}),r.video&&e.jsx(Ie,{children:e.jsxs(Be,{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(Ye,{variant:"secondary",className:"mb-2",children:r.category.name}),e.jsx("h1",{className:"text-3xl font-bold mb-2",children:r.name}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-3xl font-bold",children:["$",O.toFixed(2)]}),U>0&&e.jsxs("span",{className:"text-muted-foreground",children:["+ $",U.toFixed(2)," shipping"]})]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})}),A.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(ge,{children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:A.map(ce=>e.jsxs(K,{variant:l===ce.id?"default":"outline",onClick:()=>i(ce.id),children:[ce.name,Number(ce.price_adjustment)!==0&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",Number(ce.price_adjustment)>0?"+":"","$",Number(ce.price_adjustment).toFixed(2),")"]})]},ce.id))})]}),r.allow_artwork_upload&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(ge,{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:$,className:"hidden",id:"artwork-upload",disabled:b}),e.jsxs("label",{htmlFor:"artwork-upload",className:"flex flex-col items-center cursor-pointer",children:[e.jsx(Da,{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(ge,{children:"Quantity"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(ce=>Math.max(1,ce-1)),children:"-"}),e.jsx(Fe,{type:"number",value:d,onChange:ce=>u(Math.max(1,parseInt(ce.target.value)||1)),className:"w-20 text-center",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(ce=>ce+1),children:"+"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(K,{size:"lg",className:"flex-1",onClick:V,disabled:w,children:w?e.jsxs(e.Fragment,{children:[e.jsx(ea,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(ip,{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(ip,{className:"h-5 w-5"}),q>0&&e.jsx(Ye,{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(Ls,{title:"Product Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(al,{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 aMs(){const t=br(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:d}=she(),[u,p]=k.useState(!1),[f,y]=k.useState(""),_=async()=>{if(s.length===0){me.error("Your cart is empty");return}p(!0);try{const{data:b,error:N}=await G.functions.invoke("marketplace-checkout",{body:{items:s.map(w=>{var S;return{product_id:w.product.id,variant_id:((S=w.variant)==null?void 0:S.id)||null,quantity:w.quantity,artwork_url:w.artworkUrl||null}}),notes:f.trim()||null}});if(N)throw N;if(b!=null&&b.url)d(),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(Ls,{title:"Shopping Cart",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(t0,{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(Ls,{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 N,w;return e.jsx(Ie,{children:e.jsx(Be,{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:((N=b.product.images.find(S=>S.is_primary))==null?void 0:N.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(t0,{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 S;return r(b.product.id,(S=b.variant)==null?void 0:S.id)},children:e.jsx(yr,{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 S;return n(b.product.id,(S=b.variant)==null?void 0:S.id,b.quantity-1)},disabled:b.quantity<=1,children:e.jsx(Xy,{className:"h-3 w-3"})}),e.jsx(Fe,{type:"number",value:b.quantity,onChange:S=>{var C;return n(b.product.id,(C=b.variant)==null?void 0:C.id,parseInt(S.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 S;return n(b.product.id,(S=b.variant)==null?void 0:S.id,b.quantity+1)},children:e.jsx(Bs,{className:"h-3 w-3"})})]})]})]})})},`${b.product.id}-${((w=b.variant)==null?void 0:w.id)||"base"}`)}),e.jsx(K,{variant:"ghost",className:"text-destructive",onClick:d,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(Ie,{className:"sticky top-4",children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Order Summary"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Subtotal (",s.reduce((b,N)=>b+N.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(jo,{}),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(jo,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(_r,{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(ps,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(ti,{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 iMs(){const t=br(),{data:s,isLoading:r}=fCs();return r?e.jsx(Ls,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(Ss,{className:"h-32 w-full"},n))})}):!s||s.length===0?e.jsx(Ls,{title:"My Orders",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(al,{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(Ls,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:s.map(n=>{var a,o,l;return e.jsx(Ie,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>t(`/marketplace/orders/${n.id}`),children:e.jsxs(Be,{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:gs(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(Ye,{className:t3e[n.status],children:oT[n.status]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex -space-x-2",children:[(a=n.items)==null?void 0:a.slice(0,3).map((i,d)=>e.jsxs("div",{className:"w-10 h-10 bg-muted rounded border-2 border-background flex items-center justify-center text-xs font-medium",style:{zIndex:3-d},children:[i.quantity,"×"]},i.id)),n.items&&n.items.length>3&&e.jsxs("div",{className:"w-10 h-10 bg-muted rounded border-2 border-background flex items-center justify-center text-xs font-medium",children:["+",n.items.length-3]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:((o=n.items)==null?void 0:o.length)===1?n.items[0].product_name:`${(l=n.items)==null?void 0:l.length} items`}),e.jsxs("p",{className:"font-semibold",children:["$",Number(n.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n.tracking_url&&e.jsxs(K,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),window.open(n.tracking_url,"_blank")},children:[e.jsx(Kr,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(ja,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const G9e=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function oMs({currentStatus:t,statusHistory:s}){const r=G9e.indexOf(t);return e.jsx("div",{className:"space-y-3",children:G9e.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(Hn,{className:"h-4 w-4"}):i?e.jsx(rn,{className:"h-4 w-4"}):e.jsx("span",{className:"text-xs",children:a+1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`font-medium ${d?"text-muted-foreground":""}`,children:oT[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[gs(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function lMs(){var S;const{orderId:t}=ho(),s=br(),{data:r,isLoading:n,refetch:a}=xCs(t||""),o=vCs(),l=_Cs(),[i,d]=k.useState(!1),[u,p]=k.useState(null),[f,y]=k.useState(""),[_,b]=k.useState(null),N=async C=>{b(C);try{await o.mutateAsync({orderId:t,itemId:C}),me.success("Proof approved!"),a()}catch{me.error("Failed to approve proof")}finally{b(null)}},w=async()=>{if(u){b(u);try{await l.mutateAsync({orderId:t,itemId:u,reason:f}),me.success("Revision requested"),d(!1),y(""),p(null),a()}catch{me.error("Failed to request revision")}finally{b(null)}}};return n?e.jsx(Ls,{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(Ss,{className:"h-64 w-full"}),e.jsx(Ss,{className:"h-48 w-full"})]}),e.jsx(Ss,{className:"h-96 w-full"})]})}):r?e.jsxs(Ls,{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(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{children:"Order Status"}),e.jsx(Ye,{className:t3e[r.status],children:oT[r.status]})]}),e.jsx(Be,{children:e.jsx(oMs,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Items"})}),e.jsx(Be,{className:"space-y-4",children:(S=r.items)==null?void 0:S.map(C=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold",children:C.product_name}),C.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.variant_name}),e.jsxs("p",{className:"text-sm",children:["Qty: ",C.quantity," × $",Number(C.unit_price).toFixed(2)]})]}),e.jsxs("p",{className:"font-semibold",children:["$",(Number(C.unit_price)*C.quantity).toFixed(2)]})]}),C.artwork_url&&e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your Artwork:"}),e.jsxs("a",{href:C.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[e.jsx(Tb,{className:"h-4 w-4"}),"View Artwork",e.jsx(Kr,{className:"h-3 w-3"})]})]}),C.proof_url&&e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Proof Ready for Review"}),e.jsxs("a",{href:C.proof_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline mb-3",children:[e.jsx(Tb,{className:"h-4 w-4"}),"View Proof",e.jsx(Kr,{className:"h-3 w-3"})]}),C.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(K,{size:"sm",onClick:()=>N(C.id),disabled:_===C.id,children:[_===C.id?e.jsx(ps,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Ou,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{p(C.id),d(!0)},disabled:_===C.id,children:[e.jsx(BL,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),C.proof_status==="approved"&&e.jsxs(Ye,{className:"bg-green-100 text-green-800",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),C.proof_status==="rejected"&&C.proof_notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx(Ye,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:C.proof_notes})]})]})]},C.id))})]}),r.shipping_name&&e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(qL,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(Be,{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(Kr,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Ie,{className:"sticky top-4",children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Order Summary"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",gs(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(jo,{}),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(jo,{}),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(jo,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-1",children:"Order Notes"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.notes})]})]})]})]})})]}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Request Changes"}),e.jsx(Rr,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(_r,{placeholder:"Describe the changes needed...",value:f,onChange:C=>y(C.target.value),rows:4}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{onClick:w,disabled:!f.trim()||_!==null,children:[_?e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):e.jsx(Ls,{title:"Order Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(al,{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 cMs(){const t=br(),[s]=Sc();return s.get("session_id"),k.useEffect(()=>{localStorage.removeItem("marketplace-cart")},[]),e.jsx(Ls,{title:"Order Confirmed",children:e.jsx("div",{className:"max-w-lg mx-auto text-center py-8",children:e.jsx(Ie,{children:e.jsxs(Be,{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(Hn,{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(al,{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(ti,{className:"h-4 w-4 ml-2"})]}),e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function dMs(){const{user:t}=$s(),[s,r]=k.useState("store"),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,d]=k.useState(!1),[u,p]=k.useState(5),[f,y]=k.useState(""),[_,b]=k.useState(!1),[N,w]=k.useState(!1),[S,C]=k.useState(""),[A,I]=k.useState(null),[L,O]=k.useState(!1),{hasSubmittedReview:U,submitReview:q,markPostedToGoogle:$}=cXe(),{data:V}=cct(),{data:ee,isLoading:Z}=lct(),{data:J,isLoading:Y}=CCs(n),{data:ce,isLoading:ae}=MCs(t==null?void 0:t.id),{data:ie=0}=ACs(t==null?void 0:t.id),le=ECs(),fe=new Set((ce==null?void 0:ce.map(Ae=>Ae.item_id))||[]),xe=async()=>{if(o)try{const Ae=await le.mutateAsync(o.id);o.item_type==="reelflow_credits"?me.success(`🎬 ${o.max_quantity} ReelFlow credits added to your balance!`):me.success(`Successfully purchased "${o.name}"!`),l(null)}catch(Ae){me.error(Ae.message||"Failed to purchase item")}},he=async()=>{if(!f.trim()){me.error("Please write a review");return}b(!0);const Ae=await q(u,f);b(!1),Ae.success?(me.success("Thank you for your review! You earned 25 points!"),C(f),w(!0),y(""),p(5)):me.error(Ae.error||"Failed to submit review")},we=()=>{navigator.clipboard.writeText(S),me.success("Review copied to clipboard!")},Ne=()=>{$(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},Ve=()=>{w(!1),d(!1),C("")};return Z||Y||ae?e.jsx(Ls,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ss,{className:"h-24 w-full"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(Ae=>e.jsx(Ss,{className:"h-64"},Ae))})]})}):e.jsxs(Ls,{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(Ie,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-primary/20",children:e.jsx(Be,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(Gn,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your Spendable Points"}),e.jsx("p",{className:"text-3xl font-bold text-primary",children:ie.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(Hi,{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(ch,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(uf,{open:L,onOpenChange:O,children:e.jsxs(Ie,{className:"border-primary/20",children:[e.jsx(hf,{asChild:!0,children:e.jsx(Lt,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Hi,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-base",children:"How to Earn Points"}),e.jsx(mr,{children:"See all the ways you can earn spendable points"})]})]}),L?e.jsx(lf,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(Fi,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(mf,{children:e.jsx(Be,{className:"pt-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[V==null?void 0:V.filter(Ae=>Ae.is_active).map(Ae=>{const ze=Ee=>{switch(Ee){case"event_attendance":return e.jsx(nn,{className:"h-5 w-5"});case"leave_review":return e.jsx(Gn,{className:"h-5 w-5"});case"add_listing":return e.jsx(Mn,{className:"h-5 w-5"});case"first_contact":return e.jsx(cr,{className:"h-5 w-5"});case"first_video":return e.jsx(hn,{className:"h-5 w-5"});case"first_community_post":return e.jsx(Si,{className:"h-5 w-5"});default:return e.jsx(Vi,{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:ze(Ae.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:Ae.action_name}),Ae.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ae.description})]}),e.jsxs(Ye,{variant:"secondary",className:"font-bold shrink-0",children:["+",Ae.points]})]},Ae.id)}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/20 flex items-center justify-center text-orange-500 shrink-0",children:e.jsx(ch,{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(Ye,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!U&&e.jsx(Ie,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx(Be,{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(Si,{className:"h-6 w-6 text-yellow-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Earn 25 Free Points!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Leave a quick review and earn 25 spendable points"})]})]}),e.jsxs(K,{onClick:()=>d(!0),className:"bg-yellow-600 hover:bg-yellow-700",children:[e.jsx(Gn,{className:"h-4 w-4 mr-2"}),"Leave Review"]})]})})}),e.jsxs(ta,{value:s,onValueChange:r,children:[e.jsxs(Qn,{children:[e.jsxs(ls,{value:"store",className:"flex items-center gap-2",children:[e.jsx(t0,{className:"h-4 w-4"}),"Store"]}),e.jsxs(ls,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(al,{className:"h-4 w-4"}),"My Rewards",ce&&ce.length>0&&e.jsx(Ye,{variant:"secondary",className:"ml-1",children:ce.length})]})]}),e.jsxs(js,{value:"store",className:"mt-6",children:[ee&&ee.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"}),ee.map(Ae=>e.jsxs(K,{variant:n===Ae.id?"default":"outline",size:"sm",onClick:()=>a(Ae.id),children:[Ae.icon&&`${Ae.icon} `,Ae.name]},Ae.id))]}),!J||J.length===0?e.jsx(Ie,{children:e.jsx(Be,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(Vi,{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:J.map(Ae=>{const ze=Ae.item_type==="reelflow_credits",Ee=!ze&&fe.has(Ae.id),ve=!ze&&Ae.max_quantity!==null&&Ae.current_quantity===0,Re=ie>=Ae.points_cost;return e.jsxs(Ie,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${Ee?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>I(Ae),children:[Ae.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Ae.preview_image_url,alt:Ae.name,className:"w-full h-full object-cover"}),Ee&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Ye,{className:"bg-green-500 text-white",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1"}),"Owned"]})}),ve&&!Ee&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(Ye,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(Vi,{className:"h-12 w-12 text-muted-foreground/50"}),Ee&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Ye,{className:"bg-green-500 text-white",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Ft,{className:"text-lg",children:Ae.name}),e.jsxs(Ye,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Ae.points_cost]})]}),Ae.category&&e.jsxs(Ye,{variant:"outline",className:"w-fit",children:[Ae.category.icon&&`${Ae.category.icon} `,Ae.category.name]})]}),e.jsxs(Be,{children:[e.jsx(mr,{className:"mb-4 line-clamp-2",children:Ae.description||"No description available"}),Ae.max_quantity!==null&&!Ee&&!ze&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Ae.current_quantity," of ",Ae.max_quantity," remaining"]}),ze&&e.jsxs("p",{className:"text-xs text-violet-600 font-medium mb-3",children:["🎬 Grants ",Ae.max_quantity," ReelFlow credits per purchase"]}),Ee?e.jsx(K,{className:"w-full",onClick:Ue=>{Ue.stopPropagation(),Ae.file_url&&j0e(Ae.file_url,Ae.name)},disabled:!Ae.file_url,children:Ae.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(K,{className:"w-full",onClick:Ue=>{Ue.stopPropagation(),l(Ae)},disabled:ve||!Re,children:ve?"Sold Out":Re?e.jsxs(e.Fragment,{children:[e.jsx(t0,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Ae.points_cost-ie} more pts`})]})]},Ae.id)})})]}),e.jsx(js,{value:"my-rewards",className:"mt-6",children:!ce||ce.length===0?e.jsx(Ie,{children:e.jsx(Be,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(al,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No rewards yet"}),e.jsx("p",{className:"text-sm",children:"Purchase items from the store to see them here!"})]})})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ce.map(Ae=>{var ze,Ee,ve,Re,Ue,ye,ct;return e.jsxs(Ie,{className:"overflow-hidden",children:[(ze=Ae.item)!=null&&ze.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:Ae.item.preview_image_url,alt:((Ee=Ae.item)==null?void 0:Ee.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(Vi,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(Lt,{className:"pb-2",children:[e.jsx(Ft,{className:"text-lg",children:((ve=Ae.item)==null?void 0:ve.name)||"Unknown Item"}),e.jsxs(mr,{className:"text-xs",children:["Purchased for ",Ae.points_spent," points • ",new Date(Ae.purchased_at).toLocaleDateString()]})]}),e.jsx(Be,{children:((Re=Ae.item)==null?void 0:Re.item_type)==="reelflow_credits"?e.jsxs(K,{className:"w-full",variant:"outline",disabled:!0,children:[e.jsx(Hn,{className:"h-4 w-4 mr-2 text-green-500"}),(Ue=Ae.item)==null?void 0:Ue.max_quantity," Credits Applied"]}):e.jsx(K,{className:"w-full",onClick:()=>{var pe,Ge;(pe=Ae.item)!=null&&pe.file_url&&j0e(Ae.item.file_url,(Ge=Ae.item)==null?void 0:Ge.name)},disabled:!((ye=Ae.item)!=null&&ye.file_url),children:((ct=Ae.item)==null?void 0:ct.item_type)==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Ae.id)})})})]})]}),e.jsx(Ll,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Confirm Purchase"}),e.jsxs(vl,{children:['Are you sure you want to purchase "',o==null?void 0:o.name,'" for ',o==null?void 0:o.points_cost," points?",(o==null?void 0:o.item_type)==="reelflow_credits"&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("br",{}),"🎬 ",e.jsxs("strong",{children:[o==null?void 0:o.max_quantity," ReelFlow credits"]})," will be added to your balance instantly."]}),e.jsx("br",{}),e.jsx("br",{}),"You currently have ",e.jsxs("strong",{children:[ie," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[ie-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:xe,disabled:le.isPending,children:le.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(fs,{open:i,onOpenChange:Ae=>{!Ae&&N?Ve():d(Ae)},children:e.jsx(ms,{children:N?e.jsxs(e.Fragment,{children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Hn,{className:"h-5 w-5 text-green-500"}),"Thank You for Your Review!"]}),e.jsx(Rr,{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:['"',S,'"']})]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:we,children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(gn,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(K,{variant:"outline",onClick:Ve,children:"Maybe Later"}),e.jsxs(K,{onClick:Ne,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Leave a Review"}),e.jsx(Rr,{children:"Share your experience with LevelUp and earn 25 spendable points!"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Rating"}),e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(Ae=>e.jsx("button",{type:"button",onClick:()=>p(Ae),className:"focus:outline-none",children:e.jsx(Gn,{className:`h-8 w-8 transition-colors ${u>=Ae?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Ae))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(_r,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:f,onChange:Ae=>y(Ae.target.value),rows:4})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:he,disabled:_,className:"bg-yellow-600 hover:bg-yellow-700",children:_?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(fs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[A==null?void 0:A.name,e.jsxs(Ye,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),A==null?void 0:A.points_cost]})]}),(A==null?void 0:A.category)&&e.jsxs(Ye,{variant:"outline",className:"w-fit",children:[A.category.icon&&`${A.category.icon} `,A.category.name]})]}),(A==null?void 0:A.preview_image_url)&&e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted rounded-lg",children:e.jsx("img",{src:A.preview_image_url,alt:A.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:(A==null?void 0:A.description)||"No description available"}),(A==null?void 0:A.item_type)==="reelflow_credits"&&e.jsxs("p",{className:"text-sm text-violet-600 font-medium",children:["🎬 Grants ",A==null?void 0:A.max_quantity," ReelFlow credits per purchase"]}),(A==null?void 0:A.item_type)!=="reelflow_credits"&&(A==null?void 0:A.max_quantity)!==null&&!fe.has((A==null?void 0:A.id)||"")&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[A==null?void 0:A.current_quantity," of ",A==null?void 0:A.max_quantity," remaining"]})]}),e.jsx(gn,{children:A&&A.item_type!=="reelflow_credits"&&fe.has(A.id)?e.jsx(K,{className:"w-full",onClick:()=>{A.file_url&&j0e(A.file_url,A.name)},disabled:!A.file_url,children:A.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Access"]})}):A&&e.jsx(K,{className:"w-full",onClick:()=>{I(null),l(A)},disabled:A.item_type!=="reelflow_credits"&&A.max_quantity!==null&&A.current_quantity===0||ie{const{user:t}=$s(),s=es(),r=ft({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=ft({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=Et({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=Et({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=Et({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=Et({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")}}),d=Et({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:d}},uMs=()=>{const t=br(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=Zct(),o=i=>i.status==="draft"?e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(Ye,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(Ye,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"Not Opened"}),l=i=>{const d=`https://presentations.relevelup.com/${i}`;navigator.clipboard.writeText(d),me.success("Link copied!")};return e.jsx(Ls,{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(Bs,{className:"h-4 w-4"}),"Create Presentation"]})]}),r?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>e.jsx(Ss,{className:"h-20 w-full rounded-lg"},i))}):s.length===0?e.jsx(Ie,{children:e.jsxs(Be,{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(Rg,{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(Bs,{className:"h-4 w-4"}),"Create Your First Presentation"]})]})}):e.jsx("div",{className:"space-y-3",children:s.map(i=>e.jsx(Ie,{className:"hover:shadow-sm transition-shadow",children:e.jsx(Be,{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(mn,{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 ",gs(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(jn,{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(Ya,{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(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(cx,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(xa,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(xa,{onClick:()=>a.mutate(i),children:[e.jsx(mn,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(xa,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(_M,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},W9e={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."}]},hMs=[{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 mMs(t){const s=W9e[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(W9e))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return hMs}function pMs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=k.useState(!1),[o,l]=k.useState("script"),[i,d]=k.useState(0),[u,p]=k.useState(0),{canRecord:f}=_it(),y=Ew(),[_,b]=k.useState(""),[N,w]=k.useState(!1),[S,C]=k.useState(!0),[A,I]=k.useState(!1),[L,O]=k.useState(null),U=mMs(t),q=()=>{l("script"),d(0),p(0),b(""),w(!1),C(!0),I(!1),O(null)},$=Y=>{!Y&&(o==="uploading"||o==="processing")||(a(Y),Y||q())},V=Y=>{O(Y),b(U[Y].text),w(!1)},ee=()=>{l("record"),C(_.trim().length>0)},Z=()=>{b(""),C(!1),l("record")},J=k.useCallback(async(Y,ce)=>{l("uploading");try{const ae=t||"Presentation Video",{videoId:ie,uploadUrl:le,libraryId:fe}=await wE(ae),{apiKey:xe}=await jE(ie),he=new XMLHttpRequest;he.upload.onprogress=Ae=>{Ae.lengthComputable&&d(Ae.loaded/Ae.total*100)},await new Promise((Ae,ze)=>{he.onload=()=>he.status>=200&&he.status<300?Ae():ze(new Error("Upload failed")),he.onerror=()=>ze(new Error("Upload failed")),he.open("PUT",le),he.setRequestHeader("AccessKey",xe),he.send(Y)}),l("processing");let we=0;const Ne=Date.now(),Ve=9e4;let Te=null;for(;we<4;){if(await new Promise(ze=>setTimeout(ze,3e3)),Date.now()-Ne>Ve){const ze=Y.size/1048576,Ee=`https://iframe.mediadelivery.net/embed/${fe}/${ie}?responsive=true`;await y.mutateAsync({bunny_video_id:ie,playback_url:Ee,file_size_mb:ze,title:ae,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(Ee),me.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Ae=await ow(ie);if(we=Ae.status,p(Ae.encodeProgress||0),we===4)Te={playbackUrl:Ae.directPlayUrl,thumbnailUrl:Ae.thumbnailUrl,previewUrl:Ae.previewUrl||null,duration:Ae.length||ce,fileSizeMb:(Ae.storageSize||Y.size)/(1024*1024)};else if(we===5||we===6)throw new Error("Video processing failed")}if(!Te)throw new Error("No video data");await y.mutateAsync({bunny_video_id:ie,contact_id:s||void 0,playback_url:Te.playbackUrl,thumbnail_url:Te.thumbnailUrl,preview_url:Te.previewUrl,duration_seconds:Te.duration,file_size_mb:Te.fileSizeMb,title:ae,status:"ready",touch_type:"presentation"}),r(Te.playbackUrl),me.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(ae){console.error("Recording upload error:",ae),me.error("Failed to process video. Please try again."),l("record")}},[t,s,r,y]);return e.jsxs(fs,{open:n,onOpenChange:$,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Record a video",children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"Record"]})}),e.jsxs(ms,{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(ks,{children:e.jsxs(bs,{children:[o==="script"&&`Prepare your script for "${t}"`,o==="record"&&`Record video for "${t}"`,o==="uploading"&&"Uploading...",o==="processing"&&"Processing...",o==="done"&&"Done!"]})}),o==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a starter script below, edit it to make it yours, or skip and speak freely."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starter Scripts"}),e.jsx("div",{className:"grid gap-2",children:U.map((Y,ce)=>e.jsxs("button",{onClick:()=>V(ce),className:Rt("text-left p-3 rounded-lg border transition-all hover:bg-accent/50",L===ce?"border-primary bg-primary/5 ring-1 ring-primary":"border-border"),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(mn,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:Y.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:Y.text})]},ce))})]}),_&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Your Script"}),!N&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>w(!0),className:"h-7 text-xs gap-1",children:[e.jsx(pa,{className:"h-3 w-3"}),"Edit"]})]}),N?e.jsx(_r,{value:_,onChange:Y=>b(Y.target.value),rows:5,placeholder:"Type your script here...",className:"text-sm"}):e.jsx("div",{className:"p-3 rounded-lg bg-muted/50 text-sm text-foreground leading-relaxed",children:_})]}),!_&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Or Write Your Own"}),e.jsx(_r,{value:_,onChange:Y=>{b(Y.target.value),O(null)},rows:4,placeholder:"Type your own script here...",className:"text-sm"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:Z,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(K,{onClick:ee,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(Qc,{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 5 minutes. Saved to your library & auto-attached."}),_.trim()&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>C(!S),className:"h-7 text-xs gap-1",children:[S?e.jsx(hp,{className:"h-3 w-3"}):e.jsx(jn,{className:"h-3 w-3"}),S?"Hide Script":"Show Script"]})]}),e.jsx(AO,{maxDurationSeconds:600,onRecordingComplete:J,onRecordingStateChange:I,onError:Y=>me.error(Y),teleprompterContent:_.trim()?e.jsx(Flt,{text:_,isVisible:S,onToggleVisibility:()=>C(!S),isRecording:A,startCountdown:!1}):void 0}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>l("script"),className:"text-xs text-muted-foreground",children:"← Back to script"})]}):o==="uploading"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(ps,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(pi,{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(ps,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(pi,{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(si,{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 fMs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,d]=k.useState("idle"),[u,p]=k.useState(0),f=k.useRef(null),y=Ew(),{data:_}=Ame(),b=(_==null?void 0:_.total_storage_mb)||0,w=((_==null?void 0:_.max_storage_mb)||1024)-b,S=()=>{l(null),d("idle"),p(0)},C=U=>{!U&&i!=="idle"&&i!=="done"||(a(U),U||S())},A=U=>{var V;const q=(V=U.target.files)==null?void 0:V[0];if(!q)return;if(!q.type.startsWith("video/")){me.error("Please select a video file");return}const $=q.size/(1024*1024);if($>500){me.error("Video file must be less than 500MB");return}if($>w){me.error(`Not enough storage. You have ${w.toFixed(1)} MB remaining.`);return}l(q)},I=k.useCallback(async()=>{if(o){d("creating"),p(0);try{const U=t||o.name,{data:q,error:$}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:U,isAgentVideo:!0}});if($)throw new Error($.message);const{videoId:V,libraryId:ee}=q;d("uploading");const{data:Z,error:J}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:V,isAgentVideo:!0}});if(J)throw new Error(J.message);await new Promise((ae,ie)=>{const le=new XMLHttpRequest;le.upload.addEventListener("progress",fe=>{fe.lengthComputable&&p(Math.round(fe.loaded/fe.total*100))}),le.addEventListener("load",()=>le.status>=200&&le.status<300?ae():ie(new Error(`Upload failed (${le.status})`))),le.addEventListener("error",()=>ie(new Error("Upload failed"))),le.open("PUT",Z.uploadUrl),le.setRequestHeader("AccessKey",Z.apiKey),le.send(o)}),d("processing");const Y=o.size/(1024*1024),ce=`https://iframe.mediadelivery.net/embed/${ee}/${V}`;await y.mutateAsync({bunny_video_id:V,playback_url:ce,file_size_mb:Y,title:U,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(ce),d("done"),me.success("Video uploaded & attached to section!"),setTimeout(()=>a(!1),1200)}catch(U){console.error("Upload error:",U),me.error(U instanceof Error?U.message:"Failed to upload video"),d("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""}},O=i!=="idle"&&i!=="done";return e.jsxs(fs,{open:n,onOpenChange:C,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx(Da,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsx(ks,{children:e.jsxs(bs,{children:['Upload Video for "',t,'"']})}),e.jsxs("div",{className:"space-y-4 py-2",children:[o?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(hn,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(o.size/(1024*1024)).toFixed(1)," MB"]})]}),!O&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(Sr,{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 U;return(U=f.current)==null?void 0:U.click()},children:[e.jsx(Da,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),e.jsx("input",{ref:f,type:"file",accept:"video/*",className:"hidden",onChange:A,disabled:O}),O&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ps,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:L()})]}),e.jsx(pi,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),disabled:O,children:"Cancel"}),e.jsx(K,{onClick:I,disabled:!o||O,children:O?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Da,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const K9e=[{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"}],Z9e=()=>{const t=br(),{id:s}=ho(),{user:r}=$s(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=Zct(),{isGmailConnected:d,gmailEmail:u}=bp(),[p,f]=k.useState(!1),[y,_]=k.useState("client"),[b,N]=k.useState(!1),[w,S]=k.useState(""),[C,A]=k.useState([]),[I,L]=k.useState(!1),[O,U]=k.useState(null),[q,$]=k.useState(!1),[V,ee]=k.useState(""),[Z,J]=k.useState(""),[Y,ce]=k.useState(""),[ae,ie]=k.useState("buyer"),[le,fe]=k.useState(""),[xe,he]=k.useState(null),[we,Ne]=k.useState(""),[Ve,Te]=k.useState([]),[Ae,ze]=k.useState("schedule_call"),[Ee,ve]=k.useState("Schedule a Call"),[Re,Ue]=k.useState(""),[ye,ct]=k.useState(""),[pe,Ge]=k.useState(null),[tt,st]=k.useState(s||null),[Ce,et]=k.useState(null),[Ct,Ot]=k.useState(!1),ut=async(Bt,Xs)=>{if(!r)return;const Nr=5*1024*1024;if(Bt.size>Nr){me.error("Image must be under 5MB");return}if(!Bt.type.startsWith("image/")){me.error("Please upload an image file");return}Ge(Xs);try{const Vs=Bt.name.split(".").pop()||"jpg",ar=`${r.id}/${Date.now()}.${Vs}`,{error:Or}=await G.storage.from("listing-photos").upload(ar,Bt);if(Or)throw Or;const{data:{publicUrl:Rn}}=G.storage.from("listing-photos").getPublicUrl(ar);gt(Xs,{image_url:Rn}),me.success("Image uploaded")}catch{me.error("Failed to upload image")}finally{Ge(null)}};k.useEffect(()=>{s&&Oe(s)},[s]);const Oe=async Bt=>{const{data:Xs,error:Nr}=await G.from("smart_presentations").select("*").eq("id",Bt).single();if(Nr||!Xs)return;const Vs=Xs;if(N(!0),Ne(Vs.title),ee(Vs.client_name||""),fe(Vs.property_address||""),Te(Vs.sections||[]),ze(Vs.cta_type||"schedule_call"),ve(Vs.cta_label||"Schedule a Call"),Ue(Vs.cta_url||""),ct(Vs.heading||""),et(Vs.share_token),Ot(Vs.status==="published"),st(Vs.id),_("builder"),Vs.contact_id){const{data:ar}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",Vs.contact_id).maybeSingle();ar&&(U(ar),J(ar.email||""),ce(ar.phone||""))}};k.useEffect(()=>{if(!r||w.length<1){A([]);return}const Bt=setTimeout(async()=>{L(!0);const{data:Xs}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone, lead_source").eq("owner_user_id",r.id).or(`first_name.ilike.%${w}%,last_name.ilike.%${w}%,email.ilike.%${w}%`).limit(10);A(Xs||[]),L(!1)},300);return()=>clearTimeout(Bt)},[w,r]);const Xe=Bt=>{U(Bt),ee(`${Bt.first_name} ${Bt.last_name||""}`.trim()),J(Bt.email||""),ce(Bt.phone||""),$(!1)},at=async()=>{if(!V.trim()){me.error("Client name is required");return}const Bt=V.trim().split(" "),Xs=Bt[0],Nr=Bt.slice(1).join(" ")||null,{data:Vs,error:ar}=await G.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:Xs,last_name:Nr,email:Z||null,phone:Y||null,lead_source:"Smart Presentation"}).select().single();if(ar){me.error("Failed to create client");return}U(Vs),me.success("Client created & saved to Agent OS"),_("template")},Ke=Bt=>{he(Bt);const Xs=(Bt.sections||[]).map(Nr=>({...Nr,is_visible:!0,video_url:"",text:""}));if(Te(Xs),Ne(Bt.name+(V?` for ${V}`:"")),Bt.cta_config){const Nr=Bt.cta_config;ze(Nr.type||"schedule_call"),ve(Nr.label||"Schedule a Call")}_("builder")},He=()=>{Te([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),Ne(V?`Presentation for ${V}`:"New Presentation"),_("builder")},gt=(Bt,Xs)=>{Te(Nr=>Nr.map((Vs,ar)=>ar===Bt?{...Vs,...Xs}:Vs))},Mt=Bt=>{gt(Bt,{is_visible:!Ve[Bt].is_visible})},Wt=()=>{Te(Bt=>[...Bt,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},xs=Bt=>{Te(Xs=>Xs.filter((Nr,Vs)=>Vs!==Bt))},Cs=async()=>{if(!we.trim()){me.error("Title is required");return}try{if(tt){const Bt=await l.mutateAsync({id:tt,title:we,sections:Ve,client_name:V,property_address:le||null,cta_type:Ae,cta_label:Ee,cta_url:Re||null,heading:ye||null});me.success("Saved")}else{const Bt=await o.mutateAsync({title:we,contact_id:(O==null?void 0:O.id)||void 0,client_name:V,property_address:le||void 0,template_id:(xe==null?void 0:xe.id)||void 0,sections:Ve,cta_type:Ae,cta_label:Ee,cta_url:Re||void 0,heading:ye||void 0});st(Bt.id),et(Bt.share_token),me.success("Presentation created!")}}catch(Bt){console.error("Failed to save presentation:",Bt);const Xs=(Bt==null?void 0:Bt.message)||(Bt==null?void 0:Bt.toString())||"Unknown error";me.error(`Failed to save: ${Xs}`)}},Us=async()=>{try{await Cs();const Bt=tt;if(Bt){const Xs=await i.mutateAsync(Bt);et(Xs.share_token),Ot(!0),_("share")}}catch(Bt){console.error("Failed to publish presentation:",Bt),me.error(`Failed to publish: ${(Bt==null?void 0:Bt.message)||"Unknown error"}`)}},Ar=Ce?`https://presentations.relevelup.com/${Ce}`:"";return e.jsx(Ls,{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(Ra,{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((Bt,Xs)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Rt("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",y===Bt?"bg-primary text-primary-foreground":Xs<["client","template","builder","share"].indexOf(y)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:Xs<["client","template","builder","share"].indexOf(y)?e.jsx(ea,{className:"h-4 w-4"}):Xs+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:Bt}),Xs<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},Bt))}),y==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{U(null),ee(""),J(""),ce(""),$(!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(Nn,{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(ti,{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(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(tn,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs(Be,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(tn,{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:w,onChange:Bt=>S(Bt.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[I&&e.jsx(Ss,{className:"h-12 w-full"}),C.map(Bt=>e.jsxs("button",{onClick:()=>Xe(Bt),className:Rt("w-full text-left p-3 rounded-lg border transition-colors",(O==null?void 0:O.id)===Bt.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[Bt.first_name," ",Bt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Bt.email||Bt.phone||"No contact info"})]},Bt.id)),!w&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),w&&C.length===0&&!I&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),O&&e.jsxs(K,{onClick:()=>_("template"),className:"w-full gap-2",children:["Continue with ",O.first_name,e.jsx(ti,{className:"h-4 w-4"})]})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(il,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),e.jsxs(Be,{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(ge,{className:"text-xs",children:"Name *"}),e.jsx(Fe,{value:V,onChange:Bt=>{ee(Bt.target.value),$(!0),U(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Email"}),e.jsx(Fe,{value:Z,onChange:Bt=>J(Bt.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Phone"}),e.jsx(Fe,{value:Y,onChange:Bt=>ce(Bt.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Client Type"}),e.jsxs(zs,{value:ae,onValueChange:ie,children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"buyer",children:"Buyer"}),e.jsx(yt,{value:"seller",children:"Seller"}),e.jsx(yt,{value:"recruit",children:"Recruit"}),e.jsx(yt,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Property Address"}),e.jsx(Fe,{value:le,onChange:Bt=>fe(Bt.target.value),placeholder:"Optional"})]})]}),q&&V&&e.jsxs(K,{onClick:at,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(ti,{className:"h-4 w-4"})]})]})]})]})]}),y==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(ta,{defaultValue:"system",children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"mine",children:"My Core Templates"}),e.jsx(ls,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(ls,{value:"blank",children:"+ Start Blank"})]}),e.jsx(js,{value:"mine",className:"mt-4",children:a?e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2].map(Bt=>e.jsx(Ss,{className:"h-32"},Bt))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(Bt=>!Bt.is_system).length===0?e.jsx("p",{className:"text-muted-foreground col-span-2 text-center py-8",children:"You haven't saved any templates yet. Create a presentation and save it as a template!"}):n.filter(Bt=>!Bt.is_system).map(Bt=>e.jsx(Y9e,{template:Bt,onSelect:Ke},Bt.id))})}),e.jsx(js,{value:"system",className:"mt-4",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(Bt=>Bt.is_system).map(Bt=>e.jsx(Y9e,{template:Bt,onSelect:Ke},Bt.id))})}),e.jsx(js,{value:"blank",className:"mt-4",children:e.jsx(Ie,{children:e.jsxs(Be,{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:He,children:"Start from Scratch"})]})})})]}),e.jsxs(K,{variant:"outline",onClick:()=>_("client"),className:"gap-2",children:[e.jsx(Ra,{className:"h-4 w-4"}),"Back"]})]}),y==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Presentation Title"}),e.jsx(Fe,{value:we,onChange:Bt=>Ne(Bt.target.value)})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Page Heading"}),e.jsx(Fe,{value:ye,onChange:Bt=>ct(Bt.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(ge,{children:"Client Name"}),e.jsx(Fe,{value:V,onChange:Bt=>ee(Bt.target.value)})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Property Address"}),e.jsx(Fe,{value:le,onChange:Bt=>fe(Bt.target.value),placeholder:"Optional"})]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sections"}),e.jsx(K,{variant:"outline",size:"sm",onClick:Wt,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:Ve.map((Bt,Xs)=>e.jsx(Ie,{className:Rt(!Bt.is_visible&&"opacity-50"),children:e.jsx(Be,{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(uu,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:Bt.icon})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Fe,{value:Bt.title,onChange:Nr=>gt(Xs,{title:Nr.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:()=>Mt(Xs),children:Bt.is_visible?e.jsx(jn,{className:"h-4 w-4"}):e.jsx(hp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>xs(Xs),className:"text-destructive hover:text-destructive",children:e.jsx(yr,{className:"h-4 w-4"})})]})]}),e.jsx(Fe,{value:Bt.description||"",onChange:Nr=>gt(Xs,{description:Nr.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(ge,{className:"text-xs",children:"Video URL"}),e.jsx(Fe,{value:Bt.video_url||"",onChange:Nr=>gt(Xs,{video_url:Nr.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(pMs,{sectionTitle:Bt.title,contactId:O==null?void 0:O.id,onVideoReady:Nr=>gt(Xs,{video_url:Nr})}),e.jsx(fMs,{sectionTitle:Bt.title,contactId:O==null?void 0:O.id,onVideoReady:Nr=>gt(Xs,{video_url:Nr})}),e.jsx(QCe,{userId:r==null?void 0:r.id,onSelect:Nr=>gt(Xs,{video_url:Nr})})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),Bt.image_url?e.jsxs("div",{className:"relative mt-1 rounded-lg overflow-hidden border border-border bg-muted/30 group",children:[e.jsx("img",{src:Bt.image_url,alt:"",className:"w-full max-h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>gt(Xs,{image_url:""}),children:e.jsx(Sr,{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===Xs?e.jsx(ps,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(Xv,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:pe===Xs?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:pe===Xs,onChange:Nr=>{var ar;const Vs=(ar=Nr.target.files)==null?void 0:ar[0];Vs&&ut(Vs,Xs),Nr.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Text (optional)"}),e.jsx(Yg,{content:Bt.text||"",onChange:Nr=>gt(Xs,{text:Nr}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},Xs))})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Call to Action"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"CTA Type"}),e.jsxs(zs,{value:Ae,onValueChange:Bt=>{ze(Bt);const Xs=K9e.find(Nr=>Nr.value===Bt);Xs&&ve(Xs.label)},children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:K9e.map(Bt=>e.jsx(yt,{value:Bt.value,children:Bt.label},Bt.value))})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Button Label"}),e.jsx(Fe,{value:Ee,onChange:Bt=>ve(Bt.target.value)})]}),e.jsxs("div",{children:[e.jsxs(ge,{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:Re,onChange:Bt=>Ue(Bt.target.value),placeholder:"https://calendly.com/..."}),!Re&&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(Ra,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(K,{variant:"outline",onClick:Cs,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(K,{onClick:Us,disabled:i.isPending,className:"gap-2",children:[e.jsx(Nn,{className:"h-4 w-4"}),Ct?"Update & Reshare":"Publish & Share"]})]})]})]}),y==="share"&&Ce&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ie,{children:e.jsxs(Be,{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(ea,{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:Ar,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(K,{onClick:()=>{navigator.clipboard.writeText(Ar),me.success("Link copied!")},children:e.jsx(Ya,{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 Bt=`Hi ${V||""}! I put together something for you — check it out: ${Ar}`;navigator.clipboard.writeText(Bt),me.success("Message copied!")},children:[e.jsx(Si,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{d?f(!0):window.open(`mailto:${Z||""}?subject=${encodeURIComponent(we)}&body=${encodeURIComponent(`Hi ${(O==null?void 0:O.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${Ar} Looking forward to connecting!`)}`)},children:[e.jsx(tr,{className:"h-4 w-4"}),"Send Email"]})]}),d&&e.jsx(E1,{open:p,onOpenChange:f,contact:O?{id:O.id,first_name:O.first_name,last_name:O.last_name,email:Z||O.email||""}:Z?{id:"",first_name:(V==null?void 0:V.split(" ")[0])||"",last_name:(V==null?void 0:V.split(" ").slice(1).join(" "))||"",email:Z}:void 0,defaultSubject:we,defaultBody:`Hi ${(O==null?void 0:O.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${Ar} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(K,{variant:"outline",onClick:()=>_("builder"),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(K,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},Y9e=({template:t,onSelect:s})=>e.jsx(Ie,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(Be,{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(Ye,{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"})]})}),xMs=()=>{var N;const{shareToken:t}=ho(),[s,r]=k.useState(null),[n,a]=k.useState(!0),[o,l]=k.useState(0),[i,d]=k.useState(!1);k.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),k.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:w,error:S}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(S||!w){d(!0),a(!1);return}const{data:C}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let A;if(C!=null&&C.brokerage_id){const{data:L}=await G.from("brokerages").select("name").eq("id",C.brokerage_id).single();A=(L==null?void 0:L.name)||void 0}let I=null;if(w.contact_id){const{data:L}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();I=L}r({...w,owner_name:C==null?void 0:C.name,owner_email:C==null?void 0:C.email,owner_phone:C==null?void 0:C.phone,owner_avatar:C==null?void 0:C.avatar_url,owner_title:(C==null?void 0:C.title)||void 0,brokerage_name:A,contact_name:I?[I.first_name,I.last_name].filter(Boolean).join(" "):void 0,contact_email:(I==null?void 0:I.email)||void 0,contact_phone:(I==null?void 0:I.phone)||void 0}),a(!1);try{await G.rpc("log_presentation_view",{p_presentation_id:w.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await G.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(Ss,{className:"h-12 w-3/4 mx-auto"}),e.jsx(Ss,{className:"h-64 w-full"}),e.jsx(Ss,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const f=s.sections.filter(w=>w.is_visible!==!1),y=f[o],_=w=>{const S=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(S)return`https://www.youtube.com/embed/${S[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const I=w.replace("/play/","/embed/"),L=I.includes("?")?"&":"?";return`${I}${L}responsive=true`}if(w.includes("iframe.mediadelivery.net")){if(w.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const L=w.includes("?")?"&":"?";return`${w}${L}responsive=true`}return""}const C=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(C)return`https://www.loom.com/embed/${C[1]}`;const A=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return A?`https://iframe.mediadelivery.net/embed/${A[1]}/${A[2]}?responsive=true`:w},b=!!((N=s.cta_url)!=null&&N.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((w,S)=>e.jsx("button",{onClick:()=>l(S),className:Rt("w-full text-left p-4 rounded-xl border transition-all",o===S?"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(S+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})]})]})},S))})]}),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(Kr,{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(RWe,{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 gMs({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=uSt(t),o=fSt(),l=xSt(),i=gSt(),d=ySt(),[u,p]=k.useState(""),[f,y]=k.useState("rating"),_=async S=>{r(S),S&&(!n||n.length===0)&&await d.mutateAsync(t)},b=async()=>{if(!u.trim())return;const S=(n==null?void 0:n.reduce((C,A)=>Math.max(C,A.sort_order),0))??0;await o.mutateAsync({open_house_id:t,question_type:f,question_text:u.trim(),sort_order:S+1}),p("")},N=async S=>{await l.mutateAsync({id:S.id,open_house_id:t,is_active:!S.is_active})},w=async S=>{await i.mutateAsync({id:S.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(ge,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Mb,{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(Lr,{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(ps,{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(S=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-muted/20",children:[e.jsx(uu,{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:S.question_text}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:S.question_type.replace("_"," ")})]}),e.jsx(Lr,{checked:S.is_active,onCheckedChange:()=>N(S),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>w(S),children:e.jsx(yr,{className:"h-3.5 w-3.5"})})]},S.id))}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ge,{className:"text-xs text-muted-foreground",children:"Add Question"}),e.jsx(Fe,{value:u,onChange:S=>p(S.target.value),placeholder:"e.g. How did you hear about this listing?",className:"mt-1 h-9 text-sm",onKeyDown:S=>S.key==="Enter"&&b()})]}),e.jsxs(zs,{value:f,onValueChange:y,children:[e.jsx(Os,{className:"w-28 h-9 text-xs",children:e.jsx(qs,{})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"rating",children:"Rating"}),e.jsx(yt,{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(Bs,{className:"h-3.5 w-3.5"})})]})]})})]})}function yMs({open:t,onOpenChange:s,openHouse:r}){const n=FWe(),{user:a}=$s(),o=k.useRef(null),l=k.useRef(null),[i,d]=k.useState(r.auto_forward_to_card??!1),[u,p]=k.useState(r.disclosure_pdf_url??""),[f,y]=k.useState(r.enable_survey??!1),[_,b]=k.useState(r.ask_visitor_intent??!0),[N,w]=k.useState(r.photo_url??""),[S,C]=k.useState(!1),[A,I]=k.useState(!1),[L,O]=k.useState(!1),U=async Z=>{var le;const J=(le=Z.target.files)==null?void 0:le[0];if(!J||!a)return;if(J.size>10*1024*1024){cn({title:"Image must be under 10MB",variant:"destructive"});return}if(!J.type.startsWith("image/")){cn({title:"Please upload an image file",variant:"destructive"});return}I(!0);const Y=J.name.split(".").pop()||"jpg",ce=`${a.id}/${r.id}-${Date.now()}.${Y}`,{error:ae}=await G.storage.from("open-house-photos").upload(ce,J,{upsert:!0});if(ae){cn({title:"Upload failed",description:ae.message,variant:"destructive"}),I(!1);return}const{data:ie}=G.storage.from("open-house-photos").getPublicUrl(ce);w(ie.publicUrl),I(!1),cn({title:"Photo updated!"})},q=()=>{w(""),l.current&&(l.current.value="")},$=async Z=>{var ie;const J=(ie=Z.target.files)==null?void 0:ie[0];if(!J||!a)return;if(J.size>20*1024*1024){cn({title:"File must be under 20MB",variant:"destructive"});return}if(J.type!=="application/pdf"){cn({title:"Only PDF files are accepted",variant:"destructive"});return}C(!0);const Y=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:ce}=await G.storage.from("open-house-photos").upload(Y,J,{upsert:!0});if(ce){cn({title:"Upload failed",description:ce.message,variant:"destructive"}),C(!1);return}const{data:ae}=G.storage.from("open-house-photos").getPublicUrl(Y);p(ae.publicUrl),C(!1),cn({title:"PDF uploaded!"})},V=()=>{p(""),o.current&&(o.current.value="")},ee=async()=>{O(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:i,disclosure_pdf_url:u||null,enable_survey:f,ask_visitor_intent:_,photo_url:N||null}),cn({title:"Settings saved!"}),s(!1)}catch{cn({title:"Failed to save",variant:"destructive"})}finally{O(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Guest Book Settings"}),e.jsx(Rr,{className:"truncate",children:r.property_address})]}),e.jsxs("div",{className:"space-y-6 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"text-sm font-medium",children:"Property Photo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown on the sign-in screen and printable QR sheet"}),e.jsx("input",{ref:l,type:"file",accept:"image/*",onChange:U,className:"hidden"}),N?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("img",{src:N,alt:"Property",className:"w-full h-40 object-cover"}),e.jsxs("div",{className:"absolute top-2 right-2 flex gap-2",children:[e.jsxs(K,{variant:"secondary",size:"sm",className:"h-8",onClick:()=>{var Z;return(Z=l.current)==null?void 0:Z.click()},disabled:A,children:[A?e.jsx(ps,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Da,{className:"h-3.5 w-3.5 mr-1"}),A?"":"Replace"]}),e.jsx(K,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:q,children:e.jsx(Sr,{className:"h-4 w-4"})})]})]}):e.jsx("button",{type:"button",onClick:()=>{var Z;return(Z=l.current)==null?void 0:Z.click()},disabled:A,className:"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:A?e.jsx(ps,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Uo,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload property photo (max 10MB)"})]})})]}),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(ge,{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(Lr,{checked:i,onCheckedChange:d})]})}),!i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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:$,className:"hidden"}),u?e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:[e.jsx(mn,{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:V,children:e.jsx(Sr,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var Z;return(Z=o.current)==null?void 0:Z.click()},disabled:S,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:S?e.jsx(ps,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Da,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),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(ge,{className:"text-sm font-medium",children:'Ask "What brings you here?"'}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show the buying / selling / browsing question after sign-in. Turn off to let visitors check in without picking an option."})]}),e.jsx(Lr,{checked:_,onCheckedChange:b})]})}),e.jsx(gMs,{openHouseId:r.id,enableSurvey:f,onToggleSurvey:y}),e.jsx(K,{onClick:ee,disabled:L,className:"w-full",children:L?"Saving...":"Save Settings"})]})]})})}const Yct={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function vMs({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:Yct[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 _Ms({openHouseId:t}){const{data:s,isLoading:r}=pSt(t),{data:n}=OWe(t),a=k.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"),d=o.filter(f=>f.question_type!=="rating"),u=[...new Set(l.map(f=>f.visitor_id))],p=u.length;return p===0?e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Mb,{className:"h-4 w-4"}),"Survey Results"]})}),e.jsx(Be,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No survey responses yet."})})]}):e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Mb,{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(Be,{children:e.jsxs(ta,{defaultValue:"summary",children:[e.jsxs(Qn,{className:"mb-4",children:[e.jsxs(ls,{value:"summary",className:"text-xs gap-1",children:[e.jsx(so,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(ls,{value:"individual",className:"text-xs gap-1",children:[e.jsx(Ei,{className:"h-3.5 w-3.5"})," Per Visitor"]})]}),e.jsxs(js,{value:"summary",className:"space-y-6",children:[i.map(f=>e.jsx(vMs,{question:f,responses:l},f.id)),d.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(js,{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 N=o.find(w=>w.id===b.question_id);return N?e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:N.question_text}),e.jsx("span",{className:"font-medium",children:b.rating_value!=null?Yct[b.rating_value]||b.rating_value:b.text_value})]},b.id):null})})]},f)})})]})})]})}const o2e="guestbook.relevelup.com";function bMs(){const{data:t,isLoading:s}=oSt(),r=lSt(),n=FWe(),a=cSt(),[o,l]=k.useState(!1),[i,d]=k.useState(null),{user:u}=$s(),p=_a(),[f,y]=k.useState(null),[_,b]=k.useState(null),[N,w]=k.useState(!1),S=k.useRef(null),[C,A]=k.useState({property_address:"",city:"",state:"",zip:"",event_date:gs(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 $=(V=q.target.files)==null?void 0:V[0];if($){if($.size>5*1024*1024){cn({title:"Photo must be under 5MB",variant:"destructive"});return}y($),b(URL.createObjectURL($))}},L=()=>{y(null),b(null),S.current&&(S.current.value="")},O=async()=>{if(!C.property_address){cn({title:C.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let q;if(f&&u){w(!0);const $=f.name.split(".").pop(),V=`${p}/${Date.now()}.${$}`,{error:ee}=await G.storage.from("open-house-photos").upload(V,f,{upsert:!0});if(ee){cn({title:"Photo upload failed",description:ee.message,variant:"destructive"}),w(!1);return}const{data:Z}=G.storage.from("open-house-photos").getPublicUrl(V);q=Z.publicUrl,w(!1)}await r.mutateAsync({...C,photo_url:q}),l(!1),A({property_address:"",city:"",state:"",zip:"",event_date:gs(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),L()},U=q=>{navigator.clipboard.writeText(`https://${o2e}/${q}`),cn({title:"Link copied!"})};return e.jsxs(Ls,{title:"Guest Book",children:[e.jsx(Nc,{children:e.jsx("title",{children:"Guest Book | LevelUp"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold font-serif text-foreground",children:"Guest Book"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"The modern open house sign-in experience"})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"New Open House"]})}),e.jsxs(ms,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Create Open House"}),e.jsx(Rr,{children:"Set up a new open house sign-in page"})]}),e.jsxs("div",{className:"space-y-4 pt-2 overflow-y-auto flex-1 pr-1",children:[e.jsx("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:e.jsxs("div",{className:"flex gap-1 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>A(q=>({...q,event_type:"property"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${C.event_type==="property"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Single Property"}),e.jsx("button",{type:"button",onClick:()=>A(q=>({...q,event_type:"community"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${C.event_type==="community"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Community Event"})]})}),e.jsxs("div",{children:[e.jsx(ge,{children:C.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(Fe,{value:C.property_address,onChange:q=>A($=>({...$,property_address:q.target.value})),placeholder:C.event_type==="community"?"Spring Festival at Riverside Estates":"123 Main Street"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"City"}),e.jsx(Fe,{value:C.city,onChange:q=>A($=>({...$,city:q.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"State"}),e.jsx(Fe,{value:C.state,onChange:q=>A($=>({...$,state:q.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"ZIP"}),e.jsx(Fe,{value:C.zip,onChange:q=>A($=>({...$,zip:q.target.value})),placeholder:"78701"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Date"}),e.jsx(Fe,{type:"date",value:C.event_date,onChange:q=>A($=>({...$,event_date:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Start Time"}),e.jsx(Fe,{type:"time",value:C.start_time,onChange:q=>A($=>({...$,start_time:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"End Time"}),e.jsx(Fe,{type:"time",value:C.end_time,onChange:q=>A($=>({...$,end_time:q.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Welcome Message"}),e.jsx(_r,{value:C.agent_greeting,onChange:q=>A($=>({...$,agent_greeting:q.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(ge,{children:C.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:S,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(Sr,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var q;return(q=S.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(Xv,{className:"h-6 w-6"}),e.jsxs("span",{className:"text-sm",children:["Add a ",C.event_type==="community"?"cover":"property"," photo"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Max 5MB"})]})]}),e.jsx(K,{onClick:O,disabled:r.isPending||N,className:"w-full",children:N?"Uploading photo...":r.isPending?"Creating...":C.event_type==="community"?"Create Community Event":"Create Open House"})]})]})]})]}),s?e.jsx("div",{className:"grid gap-4",children:[1,2].map(q=>e.jsx(Ie,{className:"animate-pulse",children:e.jsxs(Lt,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-48"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 mt-2"})]})},q))}):t!=null&&t.length?e.jsx("div",{className:"space-y-4",children:t.map(q=>e.jsx(wMs,{openHouse:q,isExpanded:i===q.id,onToggle:()=>d(i===q.id?null:q.id),onCopyLink:()=>U(q.slug||""),onToggleActive:()=>n.mutate({id:q.id,is_active:!q.is_active}),onDelete:()=>a.mutate(q.id)},q.id))}):e.jsx(Ie,{className:"border-dashed",children:e.jsxs(Be,{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(Qy,{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(Bs,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function wMs({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=OWe(s?t.id:void 0),{data:i}=ft({queryKey:["agent-profile-flyer",t.agent_id],queryFn:async()=>{const{data:L,error:O}=await G.from("profiles").select("name, avatar_url, phone, title, brokerages:brokerage_id(name)").eq("id",t.agent_id).single();if(O)throw O;const U=L.brokerages;return{...L,brokerage_name:(U==null?void 0:U.name)||null}},enabled:!!t.agent_id}),[d,u]=k.useState(!1),[p,f]=k.useState(!1),[y,_]=k.useState(!1),b=k.useRef(null),N=`https://${o2e}/${t.slug}`,w=L=>{if(!L)return"";const[O,U]=L.split(":"),q=parseInt(O),$=q>=12?"PM":"AM";return`${q>12?q-12:q||12}:${U} ${$}`},S=()=>{if(!(l!=null&&l.length))return;const L=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],O=l.map(ee=>[ee.first_name,ee.last_name||"",ee.email||"",ee.phone||"",ee.visitor_intent||"",ee.wants_market_updates?"Yes":"No",(ee.message||"").replace(/"/g,'""'),gs(new Date(ee.created_at),"MM/dd/yyyy h:mm a")]),U=[L,...O].map(ee=>ee.map(Z=>`"${Z}"`).join(",")).join(` `),q=new Blob([U],{type:"text/csv"}),$=URL.createObjectURL(q),V=document.createElement("a");V.href=$,V.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,V.click(),URL.revokeObjectURL($)},C=k.useCallback(()=>{if(!b.current)return;const L=b.current.querySelector("svg");if(!L)return;const O=new XMLSerializer().serializeToString(L),U=document.createElement("canvas");U.width=1024,U.height=1024;const q=U.getContext("2d"),$=new Image;$.onload=()=>{q==null||q.drawImage($,0,0,1024,1024);const V=document.createElement("a");V.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,V.href=U.toDataURL("image/png"),V.click()},$.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O)))},[t.property_address]),A=k.useCallback(()=>{var ye;if(!b.current)return;const L=b.current.querySelector("svg");if(!L)return;const O=new XMLSerializer().serializeToString(L),U="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O))),q=gs(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),$=t.start_time?`${w(t.start_time)}${t.end_time?" – "+w(t.end_time):""}`:"",V=[t.city,t.state].filter(Boolean).join(", "),ee=t.agent_greeting||"Welcome! Please sign in below.",Z=!!t.photo_url,J=!!i,Y=Z||J,ce=Z&&J,ae=ce?"0.35in 0.75in 0.3in":"0.55in 0.75in 0.45in",ie=ce?"28px":"34px",le=ce?"0.2in 0.75in":Y?"0.3in 0.75in":"0.4in 0.75in",fe=Y?"0.15in":"0.3in",xe=Y?"0.15in":"0.3in",he=ce?"14px 36px":"22px 44px",we=ce?"20px":"24px",Ne=Y?"0.2in":"0.35in",Ve=ce?"1.8in":"2.4in",Te=Y?"0.15in":"0.3in",Ae=ce?"140px":Y?"160px":"200px",ze=ce?"16px":"24px",Ee=ce?"10px 20px":"16px 28px",ve=ce?"44px":"56px",Re="0.15in",Ue=window.open("","_blank");Ue&&(Ue.document.write(` Open House – ${t.property_address}
${t.event_type==="community"?"Community Event":"Open House"}
${t.property_address}
${V?`
${V}${t.zip?" "+t.zip:""}
`:""}
Date
${q}
${$?`
Time
${$}
`:""}
${ee}
${i?`
${i.avatar_url?`${i.name}`:`
${((ye=i.name)==null?void 0:ye.charAt(0))||"A"}
`}
Hosted By
${i.name}
${i.title?`
${i.title}
`:""} ${i.brokerage_name?`
${i.brokerage_name}
`:""} ${i.phone?`
${i.phone}
`:""}
`:""} ${t.photo_url?`Property`:""}
QR Code
Scan to Sign In
Point your phone camera at the QR code
`),Ue.document.close(),setTimeout(()=>{Ue.focus(),Ue.print()},500))},[t,N,i]),I=async()=>{_(!0);try{const{error:L}=await G.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(L)throw L;cn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(L){cn({title:"Failed to send",description:L.message,variant:"destructive"})}finally{_(!1)}};return e.jsxs(Ie,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx(Lt,{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(Ft,{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(Ye,{variant:t.is_active?"default":"secondary",className:"shrink-0 text-[11px]",children:t.is_active?"Active":"Inactive"}),t.agent_name&&e.jsxs(Ye,{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(Ei,{className:"h-3 w-3"}),t.agent_name]}),t.event_type==="community"&&e.jsxs(Ye,{variant:"outline",className:"shrink-0 gap-1 text-[11px]",children:[e.jsx(ma,{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(lf,{className:"h-4 w-4"}):e.jsx(Fi,{className:"h-4 w-4"})})]}),e.jsxs(mr,{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(La,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),gs(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(rn,{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(cr,{className:"h-3 w-3"}),t.visitor_count," signed in"]}),t.qr_scan_count>0&&e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Qy,{className:"h-3 w-3"}),t.qr_scan_count," scan",t.qr_scan_count===1?"":"s"]})]}),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(e1,{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(Ya,{className:"h-3.5 w-3.5"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>u(!0),title:"QR Code",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(Qy,{className:"h-3.5 w-3.5"}),"QR"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>f(!0),title:"Settings",className:"shrink-0 h-8 text-xs",children:e.jsx(So,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>window.open(N,"_blank"),title:"Preview",className:"shrink-0 h-8 text-xs",children:e.jsx(Kr,{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(hp,{className:"h-3.5 w-3.5"}):e.jsx(jn,{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(yr,{className:"h-3.5 w-3.5"})})]})]})}),s&&e.jsxs(Be,{className:"pt-0",children:[e.jsx(jo,{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://",o2e,"/",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:S,className:"h-7 text-xs gap-1",children:[e.jsx(Xa,{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(L=>e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsxs("td",{className:"p-2 font-medium",children:[L.first_name,L.last_name?` ${L.last_name}`:""]}),e.jsxs("td",{className:"p-2 text-muted-foreground hidden sm:table-cell",children:[L.email&&e.jsx("div",{className:"truncate max-w-[180px]",children:L.email}),L.phone&&e.jsx("div",{className:"text-xs",children:L.phone})]}),e.jsx("td",{className:"p-2 hidden md:table-cell",children:L.visitor_intent?e.jsx(Ye,{variant:"outline",className:"text-xs capitalize",children:L.visitor_intent}):L.partial_signin?e.jsx(Ye,{variant:"outline",className:"text-xs text-amber-600 border-amber-300 dark:text-amber-400 dark:border-amber-700",children:"Didn't finish"}):null}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:gs(new Date(L.created_at),"h:mm a")})]},L.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(_Ms,{openHouseId:t.id})})]}),e.jsx(fs,{open:d,onOpenChange:u,children:e.jsxs(ms,{className:"sm:max-w-sm",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"QR Code"}),e.jsx(Rr,{className:"truncate",children:t.property_address})]}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx("div",{ref:b,className:"bg-white p-4 rounded-xl",children:e.jsx(EO,{value:N,size:240,level:"H"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:N}),e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:C,children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:A,children:[e.jsx(EL,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(K,{variant:"default",className:"w-full",onClick:I,disabled:y,children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),y?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(yMs,{open:p,onOpenChange:f,openHouse:t})]})}function jMs(){const{slug:t}=ho();return t?e.jsx(cYe,{slug:t}):e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Found"}),e.jsx("p",{className:"text-slate-500",children:"No portal slug was provided."})]})})}function Xct({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=$s(),l=Ew(),i=k.useRef(null),d=k.useRef(null),[u,p]=k.useState(!1),[f,y]=k.useState(!1),[_,b]=k.useState(0),N=async S=>{if(o){p(!0);try{const C=S.name.split(".").pop()||"jpg",A=`${o.id}/card-${Date.now()}.${C}`,{error:I}=await G.storage.from("listing-photos").upload(A,S);if(I)throw I;const{data:{publicUrl:L}}=G.storage.from("listing-photos").getPublicUrl(A);r(L),me.success("Photo uploaded")}catch(C){me.error(C.message||"Failed to upload photo")}finally{p(!1)}}},w=async S=>{if(o){if(S.size>500*1024*1024){me.error("Video must be under 500MB");return}y(!0),b(0);try{const{videoId:C,libraryId:A}=await wE(`Card Video - ${Date.now()}`),{uploadUrl:I,apiKey:L}=await jE(C);await new Promise((q,$)=>{const V=new XMLHttpRequest;V.upload.addEventListener("progress",ee=>{ee.lengthComputable&&b(Math.round(ee.loaded/ee.total*100))}),V.addEventListener("load",()=>{V.status>=200&&V.status<300?q():$(new Error("Upload failed"))}),V.addEventListener("error",()=>$(new Error("Upload failed"))),V.open("PUT",I),V.setRequestHeader("AccessKey",L),V.send(S)});const O=`https://iframe.mediadelivery.net/embed/${A}/${C}`;n(O);const U=parseFloat((S.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:C,playback_url:`https://iframe.mediadelivery.net/play/${A}/${C}`,file_size_mb:U,title:"Card Video",status:"processing",touch_type:"video",contact_id:a||void 0}),me.success("Video uploaded & added to your library")}catch(C){me.error(C.message||"Failed to upload video")}finally{y(!1),b(0)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ge,{children:"Media (optional)"}),e.jsxs(ta,{defaultValue:"photo",className:"w-full",children:[e.jsxs(Qn,{className:"grid w-full grid-cols-2",children:[e.jsxs(ls,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(Uo,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(ls,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"Video"]})]}),e.jsxs(js,{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(Sr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var S;return(S=i.current)==null?void 0:S.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(ps,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(bx,{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:S=>{var A;const C=(A=S.target.files)==null?void 0:A[0];C&&N(C),S.target.value=""}})]}),e.jsxs(js,{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(Sr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var S;return(S=d.current)==null?void 0:S.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(ps,{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(Da,{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(JCe,{contactId:a,onVideoReady:S=>n(S)})}),e.jsx("input",{ref:d,type:"file",accept:"video/*",className:"hidden",onChange:S=>{var A;const C=(A=S.target.files)==null?void 0:A[0];C&&w(C),S.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 NMs=[{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 kMs({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:NMs.map((s,r)=>e.jsxs(ur.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:r*.04,duration:.25},onClick:()=>t(s.type),className:`group relative flex flex-col items-start gap-1 p-3.5 rounded-xl border bg-gradient-to-br ${s.gradient} hover:shadow-md hover:scale-[1.02] active:scale-[0.98] transition-all text-left`,children:[e.jsx("span",{className:"text-2xl",children:s.emoji}),e.jsx("span",{className:"text-sm font-semibold text-foreground",children:s.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground leading-tight",children:s.description})]},s.type))})}const RE={home_anniversary:{title:["Happy Home","Anniversary"],icon:"🏡",emojis:["🏡","✨","🎉","❤️","🎊","🏠"],defaultMessage:"Wishing you many more wonderful years of memories in your beautiful home. Thank you for letting me be part of your journey."},just_listed:{title:["Just","Listed!"],icon:"🏠",emojis:["🏠","📋","🔑","⭐","🎯","✨"],defaultMessage:"Exciting news — this beautiful property just hit the market! Contact me for a private showing."},just_sold:{title:["Just","Sold!"],icon:"🎉",emojis:["🎉","🏡","🔑","🥂","🎊","💰"],defaultMessage:"Another successful closing! Congratulations to the new homeowners. It was a pleasure making this happen."},congratulations:{title:["Congratulations!",""],icon:"🏆",emojis:["🎉","🥳","🏆","⭐","🎊","✨"],defaultMessage:"What an incredible milestone! I'm so happy for you. Wishing you all the best in this exciting new chapter."},birthday:{title:["Happy","Birthday!"],icon:"🎂",emojis:["🎂","🎈","🎁","🥳","🎉","🧁"],defaultMessage:"Wishing you the happiest of birthdays! May this year bring you joy, laughter, and everything you've been dreaming of."},holiday:{title:["Happy","Holidays!"],icon:"🎄",emojis:["🎄","❄️","🎁","⭐","🕯️","🎅"],defaultMessage:"Wishing you and your family a season filled with warmth, joy, and cherished moments. Happy Holidays!"},thank_you:{title:["Thank","You!"],icon:"💐",emojis:["💐","🙏","❤️","⭐","✨","🤝"],defaultMessage:"Thank you so much for your trust and confidence. It truly means the world to me. I'm always here for you!"},thinking_of_you:{title:["Thinking","Of You"],icon:"💭",emojis:["💭","❤️","🌸","☀️","🦋","💫"],defaultMessage:"Just wanted to reach out and let you know I'm thinking of you. I hope you're doing well — don't hesitate to reach out anytime!"}};function X9e({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=$s(),d=es(),[u,p]=k.useState(!1),[f,y]=k.useState("type"),[_,b]=k.useState(""),[N,w]=k.useState(null),[S,C]=k.useState(!1),[A,I]=k.useState("home_anniversary"),[L,O]=k.useState(""),[U,q]=k.useState(""),[$,V]=k.useState(""),[ee,Z]=k.useState(""),[J,Y]=k.useState("elegant"),[ce,ae]=k.useState(null),[ie,le]=k.useState(null),fe=k.useState(!1);!fe[0]&&t&&s&&(fe[1](!0),p(!0),I(s),r&&w(r),n&&O(n),a&&q(a),o&&V(o),y(n?"details":"contact"));const{data:xe}=ft({queryKey:["contacts-for-card",i==null?void 0:i.id,_],queryFn:async()=>{let Re=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);_&&(Re=Re.or(`first_name.ilike.%${_}%,last_name.ilike.%${_}%`));const{data:Ue,error:ye}=await Re;if(ye)throw ye;return Ue},enabled:!!(i!=null&&i.id)&&u}),{data:he}=ft({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:Re,error:Ue}=await G.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(Ue)throw Ue;return Re},enabled:!!(i!=null&&i.id)}),we=Re=>{w(Re.id),O(`${Re.first_name}${Re.last_name?" "+Re.last_name:""}`),q([Re.address,Re.city,Re.state].filter(Boolean).join(", ")),V(Re.home_anniversary||""),y("details")},Ne=Re=>{I(Re),y("contact")},Ve=async()=>{var Re;if(!(!i||!he)){C(!0);try{const Ue={owner_user_id:i.id,contact_id:N,card_type:A,template:J,recipient_name:L,property_address:U||null,home_anniversary_date:$||null,custom_message:ee||null,property_photo_url:ce||null,video_url:ie||null,agent_name:he.name||"Agent",agent_photo_url:he.avatar_url,agent_phone:he.phone,agent_email:he.email,agent_brokerage:((Re=he.brokerage)==null?void 0:Re.name)||null},{error:ye}=await G.from("sendable_cards").insert(Ue);if(ye)throw ye;me.success("Card created! Copy the link to share it."),d.invalidateQueries({queryKey:["sendable-cards"]}),Te()}catch(Ue){me.error(Ue.message||"Failed to create card")}finally{C(!1)}}},Te=()=>{p(!1),y("type"),I("home_anniversary"),b(""),w(null),O(""),q(""),V(""),Z(""),Y("elegant"),ae(null),le(null)},Ae={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"},ze=RE[A],Ee=A==="home_anniversary",ve=["home_anniversary","just_listed","just_sold"].includes(A);return e.jsxs(fs,{open:u,onOpenChange:Re=>{Re?p(!0):(Te(),l==null||l(!1))},children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Create Card"]})}),e.jsxs(ms,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:f==="type"?"What type of card?":f==="contact"?`${Ae[A]} — Choose a Contact`:`${Ae[A]} — Customize`})}),f==="type"&&e.jsx(kMs,{onSelect:Ne}),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(Ra,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(tn,{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:Re=>b(Re.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[xe==null?void 0:xe.map(Re=>e.jsxs("button",{onClick:()=>we(Re),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(Ei,{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:[Re.first_name," ",Re.last_name]}),Re.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(Mn,{className:"h-3 w-3"}),Re.address]})]}),Re.home_anniversary&&A==="home_anniversary"&&e.jsx("span",{className:"text-[10px] text-emerald-600 bg-emerald-500/10 px-2 py-0.5 rounded-full shrink-0",children:"Anniversary set"})]},Re.id)),(xe==null?void 0:xe.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No contacts found"})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{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(Ra,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Recipient Name"}),e.jsx(Fe,{value:L,onChange:Re=>O(Re.target.value),placeholder:"John & Jane Smith"})]}),ve&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Property Address"}),e.jsx(Fe,{value:U,onChange:Re=>q(Re.target.value),placeholder:"123 Main St, Austin, TX"})]}),Ee&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Home Anniversary Date"}),e.jsx(Fe,{type:"date",value:$,onChange:Re=>V(Re.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Personal Message (optional)"}),e.jsx(_r,{value:ee,onChange:Re=>Z(Re.target.value),placeholder:ze.defaultMessage,rows:3})]}),e.jsx(Xct,{photoUrl:ce,videoUrl:ie,onPhotoChange:ae,onVideoChange:le,contactId:N}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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:Re,label:Ue,gradient:ye})=>e.jsxs("button",{onClick:()=>Y(Re),className:`p-2 rounded-lg border-2 transition-all text-center ${J===Re?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-10 rounded-md mb-1.5 ${ye}`}),e.jsx("span",{className:"text-[10px] font-medium",children:Ue})]},Re))})]}),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:Ve,disabled:!L||S,className:"flex-1 gap-2",children:S?"Creating...":"Create Card"})]})]})]})]})}const SMs={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 CMs({card:t}){const{user:s}=$s(),{isGmailConnected:r}=bp(),n=es(),[a,o]=k.useState(!1),[l,i]=k.useState("");k.useEffect(()=>{a&&t.contact_id&&!l&&G.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:N})=>{N!=null&&N.email&&i(N.email)})},[a,t.contact_id]);const d={home_anniversary:`🏡 Happy Home Anniversary, ${t.recipient_name}!`,just_listed:`🏠 Just Listed — Check This Out, ${t.recipient_name}!`,just_sold:`🎉 Just Sold! Congrats, ${t.recipient_name}!`,congratulations:`🏆 Congratulations, ${t.recipient_name}!`,birthday:`🎂 Happy Birthday, ${t.recipient_name}!`,holiday:`🎄 Happy Holidays, ${t.recipient_name}!`,thank_you:`💐 Thank You, ${t.recipient_name}!`,thinking_of_you:`💭 Thinking of You, ${t.recipient_name}!`},[u,p]=k.useState(d[t.card_type]||`A Special Card for ${t.recipient_name}!`),[f,y]=k.useState(""),_=`https://cardstudio.relevelup.com/c/${t.share_token}`,b=Et({mutationFn:async()=>{var A;if(!l)throw new Error("Recipient email is required");const N=`
${f?`

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


`:""}

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

${t.property_address?`

${t.property_address}

`:""}
`,{data:w}=await G.auth.getSession(),S=(A=w==null?void 0:w.session)==null?void 0:A.access_token,C=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${S}`},body:JSON.stringify({to:l,subject:u,body:N,contactId:t.contact_id||void 0})});if(!C.ok){const I=await C.json();throw new Error(I.error||"Failed to send")}return C.json()},onSuccess:async()=>{await G.from("sendable_cards").update({sent_at:new Date().toISOString(),sent_via:"gmail"}).eq("id",t.id),n.invalidateQueries({queryKey:["sendable-cards"]}),me.success(`Card sent to ${l}!`),o(!1)},onError:N=>{me.error(N.message||"Failed to send email")}});return r?e.jsxs(fs,{open:a,onOpenChange:o,children:[e.jsx(ui,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Nn,{className:"h-3 w-3"})})}),e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Send Card via Gmail"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"To"}),e.jsx(Fe,{type:"email",value:l,onChange:N=>i(N.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Subject"}),e.jsx(Fe,{value:u,onChange:N=>p(N.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Personal Note (optional)"}),e.jsx(_r,{value:f,onChange:N=>y(N.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(ps,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Nn,{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(Nn,{className:"h-3 w-3"})})}function MMs({card:t}){const s=es(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(t.recipient_name),[d,u]=k.useState(t.property_address||""),[p,f]=k.useState(t.home_anniversary_date||""),[y,_]=k.useState(t.custom_message||""),[b,N]=k.useState(t.template),[w,S]=k.useState(t.property_photo_url),[C,A]=k.useState(t.video_url||null),I=O=>{O&&(i(t.recipient_name),u(t.property_address||""),f(t.home_anniversary_date||""),_(t.custom_message||""),N(t.template),S(t.property_photo_url),A(t.video_url||null)),n(O)},L=async()=>{if(!l.trim()){me.error("Recipient name is required");return}o(!0);try{const{error:O}=await G.from("sendable_cards").update({recipient_name:l.trim(),property_address:d.trim()||null,home_anniversary_date:p||null,custom_message:y.trim()||null,template:b,property_photo_url:w||null,video_url:C||null}).eq("id",t.id);if(O)throw O;s.invalidateQueries({queryKey:["sendable-cards"]}),me.success("Card updated"),n(!1)}catch(O){me.error(O.message||"Failed to update card")}finally{o(!1)}};return e.jsxs(fs,{open:r,onOpenChange:I,children:[e.jsx(ui,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(pa,{className:"h-3 w-3"})})}),e.jsxs(ms,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Edit Card"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Recipient Name"}),e.jsx(Fe,{value:l,onChange:O=>i(O.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Property Address"}),e.jsx(Fe,{value:d,onChange:O=>u(O.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Home Anniversary Date"}),e.jsx(Fe,{type:"date",value:p,onChange:O=>f(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Personal Message (optional)"}),e.jsx(_r,{value:y,onChange:O=>_(O.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(Xct,{photoUrl:w,videoUrl:C,onPhotoChange:S,onVideoChange:A,contactId:t.contact_id}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(O=>e.jsxs("button",{onClick:()=>N(O),className:`p-3 rounded-lg border-2 transition-all text-center ${b===O?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-12 rounded-md mb-2 ${O==="elegant"?"bg-gradient-to-br from-slate-100 to-slate-200 dark:from-slate-800 dark:to-slate-700":O==="bold"?"bg-gradient-to-br from-violet-500 to-fuchsia-500":"bg-gradient-to-br from-amber-200 to-orange-300"}`}),e.jsx("span",{className:"text-xs font-medium capitalize",children:O})]},O))})]}),e.jsx(K,{onClick:L,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function TMs(){const{user:t}=$s(),s=es(),[r,n]=k.useState(""),[a,o]=Sc(),l=a.get("cardType"),i=a.get("contactId"),d=a.get("name"),u=a.get("address"),p=a.get("date"),f=!!l,{data:y,isLoading:_}=ft({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:A,error:I}=await G.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(I)throw I;return A},enabled:!!(t!=null&&t.id)}),b=Et({mutationFn:async A=>{const{error:I}=await G.from("sendable_cards").delete().eq("id",A);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),me.success("Card deleted")}}),N=A=>{const I=`https://cardstudio.relevelup.com/c/${A}`;navigator.clipboard.writeText(I),me.success("Share link copied!")},w=y==null?void 0:y.filter(A=>{var I;return!r||A.recipient_name.toLowerCase().includes(r.toLowerCase())||((I=A.property_address)==null?void 0:I.toLowerCase().includes(r.toLowerCase()))}),S={elegant:"Elegant",bold:"Bold",warm:"Warm"},C={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};return e.jsx(Ls,{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(X9e,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(tn,{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:A=>n(A.target.value),className:"pl-9"})]}),_?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(A=>e.jsx(Ie,{className:"animate-pulse",children:e.jsxs(Be,{className:"p-4",children:[e.jsx("div",{className:"h-40 bg-muted rounded-lg mb-3"}),e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]})},A))}):w!=null&&w.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w.map(A=>e.jsxs(Ie,{className:"group overflow-hidden hover:shadow-lg transition-shadow",children:[e.jsxs("div",{className:`aspect-[16/10] flex items-center justify-center relative overflow-hidden ${A.template==="elegant"?"bg-gradient-to-br from-slate-50 via-slate-100 to-slate-200 dark:from-slate-900 dark:via-slate-800 dark:to-slate-700":A.template==="bold"?"bg-gradient-to-br from-violet-600 via-fuchsia-500 to-pink-500":"bg-gradient-to-br from-amber-100 via-orange-200 to-rose-200 dark:from-amber-900 dark:via-orange-800 dark:to-rose-800"}`,children:[A.template==="elegant"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"absolute top-0 left-0 w-full h-full opacity-10",children:[e.jsx("div",{className:"absolute top-3 left-3 w-16 h-16 border-t-2 border-l-2 border-primary/40 rounded-tl-lg"}),e.jsx("div",{className:"absolute bottom-3 right-3 w-16 h-16 border-b-2 border-r-2 border-primary/40 rounded-br-lg"})]}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-32 h-32 rounded-full border border-primary/10"})]}),A.template==="bold"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute -top-8 -right-8 w-32 h-32 rounded-full bg-white/10 blur-sm"}),e.jsx("div",{className:"absolute -bottom-6 -left-6 w-24 h-24 rounded-full bg-white/10 blur-sm"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(255,255,255,0.15)_0%,transparent_70%)]"})]}),A.template==="warm"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute -top-4 -left-4 w-28 h-28 rounded-full bg-orange-400/15 blur-md"}),e.jsx("div",{className:"absolute -bottom-6 -right-6 w-32 h-32 rounded-full bg-rose-400/15 blur-md"})]}),e.jsxs("div",{className:"text-center px-4 relative z-10",children:[e.jsx("div",{className:"text-3xl mb-1.5 opacity-80",children:A.card_type==="home_anniversary"?"🏡":A.card_type==="birthday"?"🎂":A.card_type==="just_sold"?"🎉":A.card_type==="just_listed"?"🏠":A.card_type==="thank_you"?"💐":A.card_type==="congratulations"?"🏆":A.card_type==="holiday"?"🎄":A.card_type==="thinking_of_you"?"💭":"✉️"}),e.jsx("p",{className:`text-[10px] uppercase tracking-[0.2em] mb-1 ${A.template==="bold"?"text-white/70":"text-muted-foreground"}`,children:C[A.card_type]||A.card_type}),e.jsx("p",{className:`font-semibold text-base ${A.template==="bold"?"text-white":"text-foreground"}`,children:A.recipient_name}),A.property_address&&e.jsx("p",{className:`text-xs mt-1 ${A.template==="bold"?"text-white/60":"text-muted-foreground"}`,children:A.property_address})]}),e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(Ye,{variant:A.template==="bold"?"outline":"secondary",className:`text-[10px] ${A.template==="bold"?"border-white/30 text-white/80":""}`,children:S[A.template]||A.template})})]}),e.jsxs(Be,{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(jn,{className:"h-3 w-3"}),A.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:jl(new Date(A.created_at),{addSuffix:!0})})]}),A.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",gs(new Date(A.sent_at),"MMM d, yyyy")," via ",A.sent_via]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>N(A.share_token),children:[e.jsx(Ya,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(MMs,{card:A}),e.jsx(CMs,{card:A}),e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${A.share_token}`,"_blank"),children:e.jsx(Kr,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>b.mutate(A.id),children:e.jsx(yr,{className:"h-3 w-3"})})]})]})]},A.id))}):e.jsx(Ie,{className:"border-dashed",children:e.jsxs(Be,{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(tr,{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(X9e,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]})})]})})}function w6({delay:t,x:s,y:r,size:n}){return e.jsx(ur.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 AMs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=RE[s];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-blue-50/30 to-white dark:from-slate-950 dark:to-slate-900 flex items-center justify-center p-4 overflow-hidden relative",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx(ur.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(ur.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(w6,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(w6,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(w6,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(w6,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(w6,{delay:1.5,x:"70%",y:"15%",size:5})]}),e.jsxs(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-slate-200 dark:ring-slate-700 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-full bg-gradient-to-br from-slate-200 to-blue-100 dark:from-slate-700 dark:to-slate-600 flex items-center justify-center shadow-md",children:e.jsx("span",{className:"text-sm font-semibold text-slate-600 dark:text-slate-300",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:l}),p&&e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4",children:[d&&e.jsxs(ur.a,{href:`tel:${d}`,className:"flex items-center gap-1.5 px-4 py-2 rounded-full bg-slate-100 dark:bg-slate-800 text-xs font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors shadow-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(ur.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(tr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(ur.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 S0e({delay:t,x:s,y:r,color:n,size:a}){return e.jsx(ur.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 j6({delay:t,x:s,y:r}){return e.jsx(ur.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 Q9e={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 EMs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=RE[s],b=Q9e[s]||Q9e.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(S0e,{delay:0,x:"10%",y:"10%",color:b.orbs[0],size:200}),e.jsx(S0e,{delay:1,x:"70%",y:"60%",color:b.orbs[1],size:180}),e.jsx(S0e,{delay:2,x:"50%",y:"20%",color:b.orbs[2],size:150}),e.jsx(j6,{delay:0,x:"20%",y:"25%"}),e.jsx(j6,{delay:.8,x:"75%",y:"15%"}),e.jsx(j6,{delay:1.6,x:"85%",y:"65%"}),e.jsx(j6,{delay:2.4,x:"10%",y:"75%"}),e.jsx(j6,{delay:.4,x:"45%",y:"85%"}),e.jsxs(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(Mn,{className:"h-3.5 w-3.5"}),n]})]}),f&&e.jsx(ur.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(ur.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(ur.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(ur.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(ur.img,{src:i,alt:l,className:"h-12 w-12 rounded-xl object-cover ring-2 ring-violet-500/40 shadow-lg",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-xl bg-gradient-to-br from-violet-500 to-fuchsia-500 flex items-center justify-center shadow-lg",children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-bold text-white",children:l}),p&&e.jsx("p",{className:"text-xs text-violet-300/60",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-5",children:[d&&e.jsxs(ur.a,{href:`tel:${d}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r from-violet-500/30 to-fuchsia-500/30 text-xs font-semibold text-white hover:from-violet-500/50 hover:to-fuchsia-500/50 transition-all border border-white/15 shadow-lg",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," Call Me"]}),u&&e.jsxs(ur.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(tr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(ur.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 PMs({emoji:t,delay:s,x:r,duration:n}){return e.jsx(ur.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 J9e={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 IMs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=RE[s],b=J9e[s]||J9e.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((N,w)=>e.jsx(PMs,{emoji:N,delay:w*1.2,x:`${15+w*14}%`,duration:5+w%3},w)),e.jsx(ur.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(ur.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(ur.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(ur.div,{className:`h-28 bg-gradient-to-r ${b.header} relative overflow-hidden`,children:[e.jsx(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(La,{className:"h-3 w-3"}),n]})]}),f&&e.jsx(ur.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(ur.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(ur.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(ur.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(ur.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-amber-200 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${b.header} flex items-center justify-center shadow-md`,children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:`text-sm font-bold ${b.accent}`,children:l}),p&&e.jsx("p",{className:`text-xs ${b.text} opacity-60`,children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[d&&e.jsxs(ur.a,{href:`tel:${d}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(ur.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(tr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(ur.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 I9({delay:t,x:s,y:r,size:n,color:a}){return e.jsx(ur.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 C0e({delay:t,x:s,y:r,size:n}){return e.jsx(ur.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 eBe={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 LMs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=RE[s],b=eBe[s]||eBe.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(I9,{delay:0,x:"5%",y:"10%",size:300,color:b.mesh[0]}),e.jsx(I9,{delay:2,x:"60%",y:"50%",size:250,color:b.mesh[1]}),e.jsx(I9,{delay:4,x:"30%",y:"70%",size:200,color:b.mesh[2]}),e.jsx(I9,{delay:1,x:"80%",y:"15%",size:180,color:b.mesh[0]}),e.jsx(C0e,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(C0e,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(C0e,{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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(ur.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(La,{className:"h-3 w-3"})," ",n]})]}),e.jsx(ur.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(ur.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(ur.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(ur.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(ur.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(ur.img,{src:i,alt:l,className:"h-12 w-12 rounded-2xl object-cover ring-1 ring-white/10",whileHover:{scale:1.08}}):e.jsx("div",{className:"h-12 w-12 rounded-2xl bg-white/[0.08] border border-white/[0.1] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-semibold text-white/60",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-white/80",children:l}),p&&e.jsx("p",{className:"text-xs text-white/30",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[d&&e.jsxs(ur.a,{href:`tel:${d}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/70 hover:bg-white/[0.12] transition-colors backdrop-blur-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(ur.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(tr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(ur.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 M0e({delay:t,x:s,angle:r,color:n}){return e.jsx(ur.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 L9({delay:t,x:s}){return e.jsx(ur.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 tBe={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 DMs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=RE[s],b=tBe[s]||tBe.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(M0e,{delay:0,x:"20%",angle:15,color:b.stripe}),e.jsx(M0e,{delay:2,x:"75%",angle:-12,color:b.stripe}),e.jsx(M0e,{delay:4,x:"50%",angle:5,color:b.stripe}),e.jsx(L9,{delay:0,x:"30%"}),e.jsx(L9,{delay:1.5,x:"60%"}),e.jsx(L9,{delay:3,x:"45%"}),e.jsx(L9,{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(ur.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0},animate:{opacity:1},transition:{duration:1.2},children:[e.jsx(ur.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(ur.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(ur.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(ur.div,{className:"mb-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:.7},children:[e.jsx(ur.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(ur.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(ur.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(ur.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(La,{className:"h-3 w-3"})," ",n]})]}),e.jsxs(ur.div,{className:"flex items-center justify-center gap-3 my-8",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2},children:[e.jsx(ur.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(ur.span,{className:"text-white/10 text-xs",animate:{rotate:[0,360]},transition:{duration:20,repeat:1/0,ease:"linear"},children:"✦"}),e.jsx(ur.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(ur.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(ur.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(ur.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(ur.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(ur.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-white/10 shadow-xl",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${b.accent} flex items-center justify-center shadow-xl`,children:e.jsx("span",{className:"text-sm font-bold text-slate-900",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium text-white/70",children:l}),p&&e.jsx("p",{className:"text-[11px] text-white/25",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[d&&e.jsxs(ur.a,{href:`tel:${d}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.accent} text-xs font-semibold text-slate-900 shadow-lg`,whileHover:{scale:1.05,boxShadow:"0 10px 40px rgba(255,255,255,0.15)"},whileTap:{scale:.95},children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(ur.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(tr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})}),e.jsx(ur.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 Qct(){const{shareToken:t}=ho(),{data:s,isLoading:r,error:n}=ft({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(k.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()-pl(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(EMs,{...o});case"warm":return e.jsx(IMs,{...o});case"glass":return e.jsx(LMs,{...o});case"cinematic":return e.jsx(DMs,{...o});case"elegant":default:return e.jsx(AMs,{...o})}}function RMs(){const t=_a();return ft({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 OMs(){const t=_a(),s=es();return Et({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 FMs(){const t=br(),{isGmailConnected:s,gmailEmail:r}=bp(),{data:n,isLoading:a}=RMs(),o=OMs(),[l,i]=k.useState(!1),[d,u]=k.useState(!0),[p,f]=k.useState(!1);k.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(fs,{open:p,onOpenChange:f,children:[e.jsx(ui,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(So,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(So,{className:"h-5 w-5 text-primary"}),"Smart Drip Settings"]}),e.jsx(Rr,{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(tr,{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(Ye,{variant:"outline",className:"gap-1 text-emerald-600 border-emerald-200 bg-emerald-500/10 text-[10px]",children:[e.jsx(Hn,{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(Kr,{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(jo,{}),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(AL,{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(Lr,{checked:l,onCheckedChange:y,disabled:a||o.isPending})]}),e.jsx(jo,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-full ${d?"bg-primary/10":"bg-muted"}`,children:e.jsx(Ry,{className:`h-4 w-4 ${d?"text-primary":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Append Email Signature"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d?"Your signature from Profile settings will be added":"Drip emails will send without a signature"})]})]}),e.jsx(Lr,{checked:d,onCheckedChange:_,disabled:a||o.isPending})]}),d&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>{f(!1),t("/profile")},children:[e.jsx(Ry,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function zMs(){const t=_a();return ft({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 BMs(){const t=_a();return ft({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 $Ms(){const t=_a(),s=es();return Et({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 qMs(){const t=es();return Et({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 UMs(){const t=es();return Et({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 VMs(){const t=_a(),s=es();return Et({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 HMs=[{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 GMs({open:t,onOpenChange:s,campaignId:r,campaignName:n}){const{data:a,isLoading:o}=Pws(r||void 0),l=Lws(),i=xit(),d=async(f,y)=>{try{await l.mutateAsync({id:f,status:y}),me.success(`Enrollment ${y}`)}catch{me.error("Failed to update")}},u=async f=>{if(r)try{const y=await i.mutateAsync({campaignId:r,contactIds:[f]});y.enrolled>0?me.success("Contact re-enrolled — first email queued"):y.skipped>0?me.message("Already active in this campaign"):me.error("Could not re-enroll")}catch{me.error("Failed to re-enroll")}},p=f=>{const y={active:"bg-emerald-500/10 text-emerald-600 border-emerald-200",paused:"bg-amber-500/10 text-amber-600 border-amber-200",completed:"bg-blue-500/10 text-blue-600 border-blue-200",exited:"bg-muted text-muted-foreground"};return e.jsx(Ye,{variant:"outline",className:`text-[10px] capitalize ${y[f]||""}`,children:f})};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"max-w-2xl max-h-[85vh] flex flex-col p-0 overflow-hidden",children:[e.jsxs("div",{className:"p-5 border-b shrink-0",children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4 text-primary"}),"Enrollments — ",n||"Campaign"]}),e.jsx(Rr,{className:"text-xs mt-1",children:"Manage every contact currently in this campaign. Pause to take over, or exit to remove."})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx("div",{className:"p-5",children:o?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(f=>e.jsx(Ss,{className:"h-14"},f))}):!a||a.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(cr,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-sm font-medium mb-1",children:"No contacts enrolled yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Head to your contacts page and bulk-enroll to start nurturing."})]}):e.jsx("div",{className:"space-y-2",children:a.map(f=>{var y,_,b,N;return e.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-lg bg-card",children:[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 text-sm truncate",children:[(y=f.contact)==null?void 0:y.first_name," ",(_=f.contact)==null?void 0:_.last_name]}),p(f.status)]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground mt-0.5",children:[((b=f.contact)==null?void 0:b.email)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(tr,{className:"h-2.5 w-2.5"})," ",f.contact.email]}),e.jsxs("span",{children:["Step ",f.current_step]}),f.next_send_at&&f.status==="active"&&e.jsxs("span",{children:["Next: ",gs(new Date(f.next_send_at),"MMM d, h:mma")]}),f.exit_reason&&e.jsxs("span",{children:["Exit: ",f.exit_reason]})]})]}),f.status==="active"&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>d(f.id,"paused"),title:"Pause",children:e.jsx(uh,{className:"h-3.5 w-3.5"})}),f.status==="paused"&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>d(f.id,"active"),title:"Resume",children:e.jsx(Co,{className:"h-3.5 w-3.5"})}),(f.status==="active"||f.status==="paused")&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>d(f.id,"exited"),title:"Exit",children:e.jsx(Sr,{className:"h-3.5 w-3.5 text-destructive"})}),(f.status==="exited"||f.status==="completed")&&((N=f.contact)==null?void 0:N.id)&&e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-[11px] gap-1",onClick:()=>u(f.contact.id),disabled:i.isPending,children:[e.jsx(e0,{className:"h-3 w-3"}),"Re-enroll"]})]},f.id)})})})})]})})}function WMs(){var C;const{data:t,isLoading:s}=XSe(),r=Mws(),n=Cws(),a=pit(),[o,l]=k.useState(null),[i,d]=k.useState(!1),[u,p]=k.useState(null),[f,y]=k.useState(null),_=(t||[]).filter(A=>!A.is_starter),b=(t||[]).filter(A=>A.is_starter),N=async A=>{try{await r.mutateAsync(A),me.success("Campaign added to your library — customize and activate it!"),l(null)}catch(I){me.error(I.message||"Failed to copy campaign")}},w=async A=>{try{await a.mutateAsync({id:A.id,is_active:!A.is_active}),me.success(A.is_active?"Campaign paused":"Campaign activated")}catch{me.error("Failed to update")}},S=async A=>{if(confirm("Delete this campaign? Active enrollments will be removed."))try{await n.mutateAsync(A),me.success("Campaign deleted")}catch{me.error("Failed to delete")}};return s?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(A=>e.jsx(Ss,{className:"h-44 rounded-xl"},A))}):e.jsxs("div",{className:"space-y-8",children:[e.jsx("div",{className:"rounded-xl border bg-gradient-to-br from-primary/5 via-background to-background p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(nS,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm mb-1",children:"How Smart Drips work"}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3 mt-2",children:[e.jsxs("div",{className:"flex gap-2 text-xs",children:[e.jsx(Oh,{className:"h-3.5 w-3.5 text-amber-500 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:"Stage Drips (automatic)"}),e.jsx("p",{className:"text-muted-foreground",children:"Trigger when a contact moves to a deal stage (Listing, Under Contract, etc)."})]})]}),e.jsxs("div",{className:"flex gap-2 text-xs",children:[e.jsx(Nn,{className:"h-3.5 w-3.5 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:"Campaigns (manual / bulk)"}),e.jsx("p",{className:"text-muted-foreground",children:"You enroll contacts yourself — from this page or the Contacts list."})]})]})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-2.5 italic",children:["Tip: A campaign must be ",e.jsx("strong",{children:"Active"})," before its emails will send to enrolled contacts."]})]})]})}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4 text-primary"}),"My Campaigns"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Custom drip campaigns you've created or copied"})]}),e.jsxs(K,{size:"sm",onClick:()=>{p(null),d(!0)},children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1.5"})," New Campaign"]})]}),_.length===0?e.jsxs("div",{className:"text-center py-10 border border-dashed rounded-xl bg-muted/20",children:[e.jsx(qr,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold mb-1",children:"No custom campaigns yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Build one from scratch or clone a starter from the library below."}),e.jsxs(K,{size:"sm",onClick:()=>{p(null),d(!0)},children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1.5"})," Create your first campaign"]})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:_.map(A=>e.jsx(KMs,{campaign:A,onPreview:()=>l(A.id),onToggleActive:()=>w(A),onDelete:()=>S(A.id),onEdit:()=>{p(A.id),d(!0)},onViewEnrollments:()=>y(A.id)},A.id))})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(qr,{className:"h-4 w-4 text-amber-500"}),"Starter Library"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Premium, ready-to-go campaigns crafted for real estate. One-click copy."})]}),e.jsxs(Ye,{variant:"outline",className:"text-[10px]",children:[b.length," templates"]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:b.map(A=>e.jsx(ZMs,{campaign:A,onPreview:()=>l(A.id)},A.id))})]}),e.jsx(YMs,{campaignId:o,open:!!o,onOpenChange:A=>!A&&l(null),onClone:N,isCloning:r.isPending,onEdit:A=>{l(null),p(A),d(!0)}}),e.jsx(git,{open:i,onOpenChange:d,campaignId:u}),e.jsx(GMs,{open:!!f,onOpenChange:A=>!A&&y(null),campaignId:f,campaignName:(C=_.find(A=>A.id===f))==null?void 0:C.name})]})}function KMs({campaign:t,onPreview:s,onToggleActive:r,onDelete:n,onEdit:a,onViewEnrollments:o}){const i=Iws(t.id).data??0,d=!t.is_active&&i>0;return e.jsxs("div",{className:"group rounded-xl border bg-card overflow-hidden hover:shadow-lg transition-shadow",children:[e.jsxs("div",{className:`h-20 bg-gradient-to-br ${t.cover_color} relative flex items-center justify-center`,children:[e.jsx("span",{className:"text-4xl drop-shadow-sm",children:t.icon}),t.is_active&&e.jsx(Ye,{className:"absolute top-2 right-2 bg-emerald-500 hover:bg-emerald-500 text-white text-[10px]",children:"Active"})]}),e.jsxs("div",{className:"p-3.5",children:[e.jsx("h3",{className:"font-semibold text-sm truncate",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1 min-h-[2rem]",children:t.description||"No description"}),e.jsx(Ye,{variant:"outline",className:"text-[9px] mt-2",children:Mme[t.category]}),d&&e.jsxs("button",{onClick:r,className:"mt-2 w-full flex items-start gap-1.5 p-2 rounded-md bg-amber-500/10 border border-amber-500/30 text-left hover:bg-amber-500/15 transition-colors",children:[e.jsx(Qc,{className:"h-3 w-3 text-amber-600 dark:text-amber-400 shrink-0 mt-0.5"}),e.jsxs("span",{className:"text-[10px] leading-tight text-amber-700 dark:text-amber-300",children:[e.jsxs("strong",{children:[i," contact",i===1?"":"s"," enrolled"]})," but not sending — tap to activate"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5 mt-3",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:a,children:[e.jsx(pa,{className:"h-3 w-3 mr-1"})," Edit"]}),e.jsx(K,{size:"sm",variant:t.is_active?"secondary":"default",className:"h-7 text-xs",onClick:r,children:t.is_active?"Pause":"Activate"})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2 text-[10px]",children:[e.jsx("button",{onClick:o,className:"text-primary hover:underline",children:"View enrollments"}),e.jsx("button",{onClick:s,className:"text-muted-foreground hover:underline",children:"Preview"}),e.jsx("button",{onClick:n,className:"text-muted-foreground hover:text-destructive",children:"Delete"})]})]})]})}function ZMs({campaign:t,onPreview:s}){return e.jsxs("button",{onClick:s,className:"group rounded-xl border bg-card overflow-hidden hover:shadow-xl hover:scale-[1.02] transition-all text-left",children:[e.jsxs("div",{className:`h-24 bg-gradient-to-br ${t.cover_color} relative flex items-center justify-center`,children:[e.jsx("span",{className:"text-5xl drop-shadow-sm",children:t.icon}),e.jsxs(Ye,{className:"absolute top-2 right-2 bg-white/90 text-foreground hover:bg-white text-[10px]",children:[e.jsx(qr,{className:"h-2.5 w-2.5 mr-0.5"})," Starter"]})]}),e.jsxs("div",{className:"p-3.5",children:[e.jsx("h3",{className:"font-semibold text-sm",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1 min-h-[2rem]",children:t.description}),e.jsx(Ye,{variant:"outline",className:"text-[9px] mt-2",children:Mme[t.category]})]})]})}function YMs({campaignId:t,open:s,onOpenChange:r,onClone:n,isCloning:a,onEdit:o}){const{data:l}=XSe(),{data:i}=fit(t||void 0),[d,u]=k.useState(new Set),p=l==null?void 0:l.find(_=>_.id===t);if(!p)return null;const f=_=>{u(b=>{const N=new Set(b);return N.has(_)?N.delete(_):N.add(_),N})},y=(_,b)=>{if(_.delay_type==="calendar_anchor"){const w=_.anchor_field==="birthday"?"birthday":"home anniversary",S=_.anchor_offset_days||0;return S===0?`On their ${w}`:S<0?`${Math.abs(S)} days before ${w}`:`${S} days after ${w}`}if(b===0&&_.delay_days===0&&_.delay_hours===0)return"Sends immediately";const N=[];return _.delay_days&&N.push(`${_.delay_days}d`),_.delay_hours&&N.push(`${_.delay_hours}h`),b===0?`After ${N.join(" ")}`:`+${N.join(" ")}`};return e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(ms,{className:"max-w-2xl max-h-[85vh] flex flex-col p-0 overflow-hidden",children:[e.jsx("div",{className:`bg-gradient-to-br ${p.cover_color} p-6 text-white shrink-0`,children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("span",{className:"text-5xl drop-shadow-sm",children:p.icon}),e.jsxs("div",{className:"flex-1",children:[e.jsx(bs,{className:"text-xl font-bold text-white",children:p.name}),e.jsx(Rr,{className:"text-white/90 mt-1",children:p.description}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx(Ye,{className:"bg-white/20 text-white border-white/20 hover:bg-white/20",children:Mme[p.category]}),e.jsxs(Ye,{className:"bg-white/20 text-white border-white/20 hover:bg-white/20",children:[(i==null?void 0:i.length)||0," step",(i==null?void 0:i.length)!==1?"s":""]})]})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsxs("div",{className:"p-6 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"The sequence"}),p.is_starter?e.jsx("span",{className:"text-[10px] text-muted-foreground italic",children:"Copy to your library to edit"}):e.jsx("span",{className:"text-[10px] text-muted-foreground italic",children:"Tap a step to expand · Edit to customize"})]}),i==null?void 0:i.map((_,b)=>{const N=d.has(_.id);return e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"shrink-0 flex flex-col items-center",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 text-primary flex items-center justify-center text-xs font-semibold",children:b+1}),bf(_.id),className:"flex-1 pb-4 text-left",children:e.jsxs("div",{className:"border rounded-lg p-3 bg-muted/20 hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 text-xs text-muted-foreground",children:[_.delay_type==="calendar_anchor"?e.jsx(nn,{className:"h-3 w-3"}):e.jsx(rn,{className:"h-3 w-3"}),e.jsx("span",{children:y(_,b)}),e.jsx("span",{children:"·"}),e.jsx(tr,{className:"h-3 w-3"}),e.jsx("span",{className:"capitalize",children:_.channel})]}),e.jsx("p",{className:"font-medium text-sm",children:_.subject}),N?e.jsx("p",{className:"text-xs text-muted-foreground mt-2 whitespace-pre-line",children:_.body}):e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1 whitespace-pre-line",children:_.body}),_.body&&_.body.length>160&&e.jsx("span",{className:"text-[10px] text-primary mt-1.5 inline-block",children:N?"Show less":"Show full email"})]})})]},_.id)})]})}),e.jsxs(gn,{className:"border-t p-4 shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),children:"Close"}),!p.is_starter&&o&&e.jsxs(K,{variant:"secondary",onClick:()=>o(p.id),children:[e.jsx(pa,{className:"h-3.5 w-3.5 mr-1.5"})," Edit Campaign"]}),p.is_starter&&e.jsxs(K,{onClick:()=>n(p.id),disabled:a,children:[a?e.jsx(ps,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):e.jsx(Ya,{className:"h-3.5 w-3.5 mr-1.5"}),"Copy to my campaigns"]})]})]})})}function XMs(){const t=_a(),s=br(),{isGmailConnected:r,gmailEmail:n,isLoading:a}=bp(),{data:o,isLoading:l}=zMs(),{data:i,isLoading:d}=BMs(),u=$Ms(),p=qMs(),f=UMs(),y=VMs(),[_,b]=k.useState(null),[N,w]=k.useState(null),S=(o==null?void 0:o.filter($=>!$.is_starter&&$.owner_user_id===t))||[],C=(o==null?void 0:o.filter($=>$.is_starter))||[],A=$=>S.filter(V=>V.stage_id===$),I=async $=>{try{await p.mutateAsync({id:$.id,is_enabled:!$.is_enabled}),me.success($.is_enabled?"Drip disabled":"Drip enabled")}catch{me.error("Failed to update")}},L=async $=>{try{const V=i==null?void 0:i.find(ee=>ee.id===$);await u.mutateAsync({stage_id:$,title:`${(V==null?void 0:V.name)||"Stage"} follow-up`,subject:"",body:"",channel:"email",delay_type:"instant",delay_minutes:0}),b($),me.success("Drip template created")}catch{me.error("Failed to create template")}},O=async $=>{try{await f.mutateAsync($),me.success("Template deleted")}catch{me.error("Failed to delete")}},U=async $=>{if(!i||i.length===0){me.error("No pipeline stages found");return}const V=i[0].id;try{await y.mutateAsync({templateId:$,stageId:V}),me.success("Template copied to your drips!")}catch{me.error("Failed to copy template")}},q=l||d;return e.jsx(Ls,{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(Fh,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(Ye,{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(FMs,{})]}),e.jsxs("div",{className:"bg-primary/5 border border-primary/15 rounded-xl p-4 mb-4 flex items-start gap-3",children:[e.jsx(nS,{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."]})]})]}),!a&&(r?e.jsxs("div",{className:"bg-emerald-500/5 border border-emerald-500/20 rounded-xl p-4 mb-6 flex items-start gap-3",children:[e.jsx(tr,{className:"h-4 w-4 text-emerald-600 mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-sm flex-1",children:[e.jsxs("p",{className:"font-medium text-foreground mb-0.5",children:["Sending from your Gmail",n?` (${n})`:""]}),e.jsx("p",{className:"text-muted-foreground",children:"Drips will send directly from your connected Gmail for the most personal feel and best deliverability."})]})]}):e.jsxs("div",{className:"bg-amber-500/5 border border-amber-500/20 rounded-xl p-4 mb-6 flex items-start gap-3",children:[e.jsx(nS,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-sm flex-1",children:[e.jsx("p",{className:"font-medium text-foreground mb-0.5",children:"Drips will send from our shared sender"}),e.jsxs("p",{className:"text-muted-foreground mb-2",children:["You haven't connected Gmail, so drips will send from ",e.jsx("strong",{children:"send.relevelup.com"})," with your name on the From line and your email as Reply-To. Connect Gmail to send directly from your own inbox for better deliverability and a more personal touch."]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>s("/mission-control/integrations"),children:[e.jsx(tr,{className:"h-3 w-3 mr-1.5"}),"Connect Gmail"]})]})]})),e.jsxs(ta,{defaultValue:"my-drips",children:[e.jsxs(Qn,{className:"grid grid-cols-3 w-full max-w-lg mb-6",children:[e.jsx(ls,{value:"my-drips",children:"Stage Drips"}),e.jsxs(ls,{value:"campaigns",children:["Campaigns",e.jsx(Ye,{variant:"outline",className:"ml-1.5 text-[9px] bg-amber-500/10 text-amber-600 border-amber-200 px-1 py-0",children:"New"})]}),e.jsxs(ls,{value:"starters",children:["Stage Starters",C.length>0&&e.jsx(Ye,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:C.length})]})]}),e.jsx(js,{value:"campaigns",children:e.jsx(WMs,{})}),e.jsx(js,{value:"my-drips",children:q?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map($=>e.jsx(Ss,{className:"h-16 w-full rounded-xl"},$))}):!i||i.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(Fh,{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:[i.filter($=>!$.is_won_stage&&!$.is_lost_stage).map($=>{const V=A($.id),ee=_===$.id,Z=V.some(J=>J.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>b(ee?null:$.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:$.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:$.name}),V.length>0&&e.jsxs(Ye,{variant:"outline",className:`text-[10px] ${Z?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[V.length," drip",V.length!==1?"s":"",Z&&" · Active"]}),ee?e.jsx(Fi,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ja,{className:"h-4 w-4 text-muted-foreground"})]}),ee&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:V.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:()=>L($.id),disabled:u.isPending,children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1.5"}),"Create Drip"]})]}):e.jsxs(e.Fragment,{children:[V.map(J=>e.jsx(sBe,{template:J,isEditing:N===J.id,onToggleEdit:()=>w(N===J.id?null:J.id),onToggleEnabled:()=>I(J),onUpdate:Y=>p.mutateAsync({id:J.id,...Y}),onDelete:()=>O(J.id),userId:t||""},J.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>L($.id),children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},$.id)}),i.filter($=>$.is_won_stage||$.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"}),i.filter($=>$.is_won_stage||$.is_lost_stage).map($=>{const V=A($.id),ee=_===$.id,Z=V.some(J=>J.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden mb-2",children:[e.jsxs("button",{onClick:()=>b(ee?null:$.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:$.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:$.name}),V.length>0&&e.jsxs(Ye,{variant:"outline",className:`text-[10px] ${Z?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[V.length," drip",V.length!==1?"s":"",Z&&" · Active"]}),ee?e.jsx(Fi,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ja,{className:"h-4 w-4 text-muted-foreground"})]}),ee&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:V.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:()=>L($.id),disabled:u.isPending,children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1.5"})," Create Drip"]})]}):e.jsxs(e.Fragment,{children:[V.map(J=>e.jsx(sBe,{template:J,isEditing:N===J.id,onToggleEdit:()=>w(N===J.id?null:J.id),onToggleEnabled:()=>I(J),onUpdate:Y=>p.mutateAsync({id:J.id,...Y}),onDelete:()=>O(J.id),userId:t||""},J.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>L($.id),children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},$.id)})]})]})}),e.jsx(js,{value:"starters",children:C.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(qr,{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:C.map($=>e.jsx(QMs,{template:$,onCopy:()=>U($.id),isCopying:y.isPending},$.id))})})]})]})})}function sBe({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,d]=k.useState(t.title),[u,p]=k.useState(t.subject),[f,y]=k.useState(t.body),[_,b]=k.useState(t.video_url||""),[N,w]=k.useState(t.channel),[S,C]=k.useState(t.delay_type),[A,I]=k.useState(t.delay_minutes),[L,O]=k.useState(!1),U=async()=>{O(!0);try{await a({title:i,subject:u,body:f,video_url:_||null,channel:N,delay_type:S,delay_minutes:A}),me.success("Drip saved"),r()}catch{me.error("Failed to save")}finally{O(!1)}},q=$=>{y(V=>V+$)};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(Si,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(tr,{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(hn,{className:"h-3 w-3 text-primary"})]})]}),e.jsx(Lr,{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(ge,{className:"text-xs font-medium",children:"Title (internal)"}),e.jsx(Fe,{value:i,onChange:$=>d($.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(ge,{className:"text-xs font-medium",children:"Channel"}),e.jsx("div",{className:"flex gap-1 mt-1",children:["email","sms"].map($=>e.jsxs("button",{onClick:()=>w($),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 ${N===$?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[$==="sms"?e.jsx(Si,{className:"h-3 w-3"}):e.jsx(tr,{className:"h-3 w-3"}),$==="sms"?"SMS":"Email"]},$))})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ge,{className:"text-xs font-medium",children:"Timing"}),e.jsxs("div",{className:"flex gap-1 mt-1",children:[e.jsx("button",{onClick:()=>C("instant"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${S==="instant"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:"Instant"}),e.jsxs("button",{onClick:()=>C("scheduled"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${S==="scheduled"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[e.jsx(rn,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),S==="scheduled"&&e.jsxs("div",{children:[e.jsx(ge,{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:A>=60?Math.round(A/60):A,onChange:$=>{const V=parseInt($.target.value)||0;I(A>=60?V*60:V)},className:"h-8 w-20 text-sm"}),e.jsx("div",{className:"flex gap-1",children:[{label:"Minutes",mins:A<60?A:30},{label:"Hours",mins:A>=60?A:60},{label:"Days",mins:A>=1440?A:1440}].map($=>e.jsx("button",{className:`px-2 py-1 rounded text-xs border transition-colors ${$.label==="Minutes"&&A<60||$.label==="Hours"&&A>=60&&A<1440||$.label==="Days"&&A>=1440?"bg-primary/10 text-primary border-primary/30":"text-muted-foreground border-input"}`,onClick:()=>{$.label==="Minutes"?I(30):$.label==="Hours"?I(60):I(1440)},children:$.label},$.label))})]})]}),N==="email"&&e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs font-medium",children:"Subject Line"}),e.jsx(Fe,{value:u,onChange:$=>p($.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(ge,{className:"text-xs font-medium",children:N==="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:$=>{$.target.value&&q($.target.value),$.target.value=""},children:[e.jsx("option",{value:"",children:"Merge variable..."}),HMs.map($=>e.jsx("option",{value:$.key,children:$.label},$.key))]})]})]}),e.jsx("textarea",{value:f,onChange:$=>y($.target.value),placeholder:N==="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(ge,{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(hn,{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(JCe,{onVideoReady:$=>b($)}),e.jsx(QCe,{userId:l,onSelect:$=>b($),triggerSize:"sm",triggerClassName:"gap-1.5 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const $=prompt("Paste a YouTube or Loom URL:");$&&b($)},children:[e.jsx(go,{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(yr,{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:U,disabled:L,children:L?"Saving...":"Save Drip"})]})]})]})]})}function QMs({template:t,onCopy:s,isCopying:r}){const[n,a]=k.useState(!1),o=t.body.replace(/<[^>]+>/g,""),l=t.deal_type==="buyer"?"Buyer":t.deal_type==="seller"?"Seller":null,i=t.delay_type==="instant"?"Sends instantly":t.delay_minutes>=1440?`Sends after ${Math.round(t.delay_minutes/1440)} day${Math.round(t.delay_minutes/1440)!==1?"s":""}`:t.delay_minutes>=60?`Sends after ${Math.round(t.delay_minutes/60)} hour${Math.round(t.delay_minutes/60)!==1?"s":""}`:`Sends after ${t.delay_minutes} min`;return e.jsxs("div",{className:"border rounded-xl overflow-hidden transition-all hover:shadow-sm",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-start gap-3 p-4 text-left hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:t.subject}),!n&&e.jsx("p",{className:"text-xs text-muted-foreground/70 line-clamp-1 mt-1",children:o})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 pt-0.5",children:[l&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1",children:[t.channel==="sms"?e.jsx(Si,{className:"h-3 w-3"}):e.jsx(tr,{className:"h-3 w-3"}),t.channel==="sms"?"SMS":"Email"]}),e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(rn,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(Fi,{className:"h-4 w-4 text-muted-foreground ml-1"}):e.jsx(ja,{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(rn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i})]}),e.jsxs(K,{onClick:d=>{d.stopPropagation(),s()},size:"sm",className:"w-full gap-1.5",disabled:r,children:[e.jsx(Ya,{className:"h-3.5 w-3.5"}),"Use This Template"]})]})]})}const Jct=()=>{const t=Fl();return k.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",t.pathname)},[t.pathname]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-100",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),e.jsx("p",{className:"mb-4 text-xl text-gray-600",children:"Oops! Page not found"}),e.jsx("a",{href:"/",className:"text-blue-500 underline hover:text-blue-700",children:"Return to Home"})]})})};function JMs(){return k.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(Voe,{children:[e.jsx(_s,{path:"/c/:shareToken",element:e.jsx(Qct,{})}),e.jsx(_s,{path:"*",element:e.jsx(Jct,{})})]})}const T0e={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function edt({slugOverride:t}){const s=ho(),r=t||s.slug,[n,a]=k.useState("types"),[o,l]=k.useState(null),[i,d]=k.useState(null),[u,p]=k.useState(null),[f,y]=k.useState(new Date),[_,b]=k.useState({name:"",email:"",phone:"",message:""}),[N,w]=k.useState(!1),{data:S,isLoading:C}=ft({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:Y,error:ce}=await G.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(ce)throw ce;return Y},enabled:!!r}),{data:A}=ft({queryKey:["public-booking-profile",S==null?void 0:S.user_id],queryFn:async()=>{const{data:Y,error:ce}=await G.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",S.user_id).single();if(ce)throw ce;return Y},enabled:!!(S!=null&&S.user_id)}),{data:I=[]}=ft({queryKey:["public-booking-types",S==null?void 0:S.user_id],queryFn:async()=>{const{data:Y,error:ce}=await G.from("agent_booking_types").select("id, name, description, duration_minutes, color, icon, qualification_enabled").eq("user_id",S.user_id).eq("is_active",!0).order("sort_order");if(ce)throw ce;return Y},enabled:!!(S!=null&&S.user_id)}),{data:L=[]}=ft({queryKey:["public-availability",S==null?void 0:S.user_id],queryFn:async()=>{const{data:Y,error:ce}=await G.from("agent_availability_slots").select("day_of_week, start_time, end_time").eq("user_id",S.user_id).eq("is_active",!0);if(ce)throw ce;return Y},enabled:!!(S!=null&&S.user_id)}),{data:O=[]}=ft({queryKey:["public-blocked-dates",S==null?void 0:S.user_id],queryFn:async()=>{const{data:Y,error:ce}=await G.from("agent_blocked_dates").select("blocked_date").eq("user_id",S.user_id);if(ce)throw ce;return Y.map(ae=>ae.blocked_date)},enabled:!!(S!=null&&S.user_id)}),{data:U=[]}=ft({queryKey:["public-existing-bookings",S==null?void 0:S.user_id,i],queryFn:async()=>{if(!i)return[];const Y=gs(i,"yyyy-MM-dd"),{data:ce,error:ae}=await G.from("bookings").select("start_time, end_time").eq("agent_user_id",S.user_id).eq("booking_date",Y).eq("status","confirmed");if(ae)throw ae;return ce},enabled:!!(S!=null&&S.user_id)&&!!i}),q=k.useMemo(()=>[...new Set(L.map(Y=>Y.day_of_week))],[L]),$=Y=>{const ce=Am(new Date),ae=dl(ce,(S==null?void 0:S.max_advance_days)||30),ie=dl(ce,0);return XS(Y,ie)||YS(Y,ae)||O.includes(gs(Y,"yyyy-MM-dd"))?!1:q.includes(Y.getDay())},V=k.useMemo(()=>{if(!i||!o||!S)return[];const Y=L.filter(xe=>xe.day_of_week===i.getDay()),ce=o.duration_minutes,ae=S.buffer_minutes||0,ie=[],le=new Date,fe=(S.min_notice_hours||2)*60*60*1e3;for(const xe of Y){const[he,we]=xe.start_time.split(":").map(Number),[Ne,Ve]=xe.end_time.split(":").map(Number);let Te=QL(XL(i,he),we);const Ae=QL(XL(i,Ne),Ve);for(;tM(Te,ce)<=Ae;){const ze=gs(Te,"HH:mm"),Ee=gs(tM(Te,ce),"HH:mm");Te.getTime()-le.getTime()>=fe&&(U.some(Re=>{const Ue=Re.start_time.slice(0,5),ye=Re.end_time.slice(0,5);return zeUe})||ie.push(ze)),Te=tM(Te,ce+ae)}}return ie},[i,o,L,S,U]),ee=k.useMemo(()=>{const Y=f.getFullYear(),ce=f.getMonth(),ae=new Date(Y,ce,1),ie=new Date(Y,ce+1,0),le=ae.getDay(),fe=[];for(let xe=0;xe{if(!(!o||!i||!u||!_.name||!S)){w(!0);try{const Y=gs(tM(QL(XL(new Date,parseInt(u.split(":")[0])),parseInt(u.split(":")[1])),o.duration_minutes),"HH:mm"),{error:ce}=await G.from("bookings").insert({agent_user_id:S.user_id,booking_type_id:o.id,booking_date:gs(i,"yyyy-MM-dd"),start_time:u,end_time:Y,guest_name:_.name,guest_email:_.email||null,guest_phone:_.phone||null,guest_message:_.message||null});if(ce)throw ce;G.functions.invoke("booking-notify",{body:{agentUserId:S.user_id,guestName:_.name,guestEmail:_.email||null,guestPhone:_.phone||null,guestMessage:_.message||null,bookingTypeName:o.name,bookingDate:gs(i,"yyyy-MM-dd"),startTime:u,endTime:Y,durationMinutes:o.duration_minutes,meetingLink:S.meeting_link||null}}).catch(ae=>console.error("Booking notify error:",ae)),a("confirmed")}catch(Y){me.error("Failed to book: "+Y.message)}finally{w(!1)}}},J=Y=>{const[ce,ae]=Y.split(":").map(Number),ie=ce>=12?"PM":"AM";return`${ce%12||12}:${ae.toString().padStart(2,"0")} ${ie}`};return C?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-[#406E71] border-t-transparent"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading booking page..."})]})}):S?e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8]",children:[e.jsx("div",{className:"h-1.5 bg-gradient-to-r from-[#406E71] via-[#5a9a9d] to-[#2a4c64]"}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-6 sm:py-10",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden mb-6",children:[e.jsx("div",{className:"relative bg-gradient-to-r from-[#406E71] to-[#2a4c64] px-6 pt-6 pb-12",children:e.jsxs("div",{className:"absolute inset-0 opacity-10",children:[e.jsx("div",{className:"absolute top-2 right-8 w-20 h-20 rounded-full border-2 border-white/30"}),e.jsx("div",{className:"absolute bottom-4 left-12 w-10 h-10 rounded-full border border-white/20"})]})}),e.jsx("div",{className:"relative -mt-10 px-6",children:e.jsxs("div",{className:"flex items-end gap-4",children:[A!=null&&A.avatar_url?e.jsx("img",{src:A.avatar_url,alt:(A==null?void 0:A.name)||"Agent",className:"w-20 h-20 sm:w-24 sm:h-24 rounded-2xl object-cover border-4 border-white shadow-md"}):e.jsx("div",{className:"w-20 h-20 sm:w-24 sm:h-24 rounded-2xl bg-gradient-to-br from-[#406E71] to-[#2a4c64] border-4 border-white shadow-md flex items-center justify-center",children:e.jsx(Ei,{className:"h-10 w-10 text-white"})}),e.jsxs("div",{className:"pb-1.5",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-slate-800 leading-tight",children:(A==null?void 0:A.name)||"Agent"}),(A==null?void 0:A.title)&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:A.title})]})]})}),e.jsxs("div",{className:"px-6 py-4 flex flex-wrap gap-2",children:[(A==null?void 0:A.phone)&&e.jsxs("a",{href:`tel:${A.phone}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#406E71]/8 hover:bg-[#406E71]/15 text-[#406E71] text-xs font-medium transition-colors",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:A.phone}),e.jsx("span",{className:"sm:hidden",children:"Call"})]}),(A==null?void 0:A.email)&&e.jsxs("a",{href:`mailto:${A.email}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#2a4c64]/8 hover:bg-[#2a4c64]/15 text-[#2a4c64] text-xs font-medium transition-colors",children:[e.jsx(tr,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:A.email}),e.jsx("span",{className:"sm:hidden",children:"Email"})]})]})]}),e.jsx("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden",children:e.jsxs("div",{className:"p-5 sm:p-6",children:[n==="types"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800",children:"Select a meeting type"}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Choose the type of meeting you'd like to schedule"})]}),e.jsx("div",{className:"space-y-2.5",children:I.map(Y=>e.jsx("button",{onClick:()=>{l(Y),a("date")},className:"w-full text-left group",children:e.jsx("div",{className:"relative rounded-xl border border-slate-150 p-4 transition-all duration-200 hover:shadow-md hover:border-[#406E71]/30 hover:-translate-y-0.5 active:translate-y-0",style:{borderLeftWidth:"3px",borderLeftColor:Y.color},children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("span",{className:"text-2xl shrink-0 mt-0.5",children:T0e[Y.icon]||"📅"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm text-slate-800 group-hover:text-[#406E71] transition-colors",children:Y.name}),Y.description&&e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 line-clamp-2",children:Y.description})]})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2.5 py-1 rounded-full bg-slate-100 text-slate-600 text-xs font-medium",children:[e.jsx(rn,{className:"h-3 w-3"}),Y.duration_minutes,"m"]})]})})},Y.id))})]}),n==="date"&&o&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>{a("types"),d(null),p(null)},className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Ra,{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:T0e[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(rn,{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:gs(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(wl,{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(ja,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-0.5 text-center",children:[["Su","Mo","Tu","We","Th","Fr","Sa"].map(Y=>e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-semibold py-2",children:Y},Y)),ee.map((Y,ce)=>{if(!Y)return e.jsx("div",{},`pad-${ce}`);const ae=$(Y),ie=i&&rl(Y,i),le=rl(Y,new Date);return e.jsx("button",{disabled:!ae,onClick:()=>{d(Y),p(null)},className:`h-10 w-10 mx-auto rounded-xl text-sm font-medium transition-all duration-150 ${ie?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-105":ae?"hover:bg-[#406E71]/10 text-slate-700 hover:text-[#406E71]":"text-slate-200 cursor-not-allowed"} ${le&&!ie?"ring-1 ring-[#406E71]/40":""}`,children:Y.getDate()},Y.toISOString())})]})]}),i&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xd,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:gs(i,"EEEE, MMMM d")})]}),V.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(rn,{className:"h-8 w-8 text-slate-300 mx-auto"}),e.jsx("p",{className:"text-sm text-slate-400",children:"No available times on this day"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Try selecting a different date"})]}):e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2 max-h-52 overflow-y-auto pr-1 custom-scrollbar",children:V.map(Y=>{const ce=u===Y;return e.jsx("button",{onClick:()=>p(Y),className:`px-3 py-2.5 rounded-xl text-sm font-medium transition-all duration-150 ${ce?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-[1.02]":"bg-slate-50 text-slate-700 hover:bg-[#406E71]/10 hover:text-[#406E71] border border-slate-150"}`,children:J(Y)},Y)})}),u&&e.jsx(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg",onClick:()=>a("form"),children:"Continue to Details"})]})]}),n==="form"&&o&&i&&u&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>a("date"),className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Ra,{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:T0e[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(xd,{className:"h-3.5 w-3.5 text-[#406E71]"}),gs(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(rn,{className:"h-3.5 w-3.5 text-[#406E71]"}),J(u)," · ",o.duration_minutes," min"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-semibold text-slate-700",children:"Full Name *"}),e.jsx(Fe,{value:_.name,onChange:Y=>b({..._,name:Y.target.value}),placeholder:"Jane Smith",className:"h-11 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-semibold text-slate-700",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(tr,{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:Y=>b({..._,email:Y.target.value}),placeholder:"jane@email.com",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-semibold text-slate-700",children:"Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(Tn,{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:Y=>b({..._,phone:Y.target.value}),placeholder:"(555) 123-4567",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ge,{className:"text-xs font-semibold text-slate-700",children:"Message (optional)"}),e.jsx(_r,{value:_.message,onChange:Y=>b({..._,message:Y.target.value}),placeholder:"Anything you'd like the agent to know ahead of time?",rows:3,className:"rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20 resize-none"})]})]}),e.jsx(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg disabled:opacity-60",onClick:Z,disabled:!_.name||N,children:N?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(Hn,{className:"h-10 w-10 text-white"})})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-slate-800",children:"You're booked!"}),e.jsxs("p",{className:"text-slate-500 mt-1.5",children:[o==null?void 0:o.name," with ",(A==null?void 0:A.name)||"your agent"]})]}),e.jsx("div",{className:"inline-flex items-center gap-3 px-5 py-3 rounded-xl bg-slate-50 border border-slate-100",children:e.jsxs("div",{className:"text-left text-sm",children:[e.jsx("p",{className:"font-semibold text-slate-800",children:i&&gs(i,"EEEE, MMMM d, yyyy")}),e.jsxs("p",{className:"text-slate-500",children:[u&&J(u)," · ",o==null?void 0:o.duration_minutes," min"]})]})}),e.jsx("p",{className:"text-sm text-slate-400 max-w-xs mx-auto",children:"A confirmation with meeting details will be sent to you shortly."}),((A==null?void 0:A.phone)||(A==null?void 0:A.email))&&e.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider font-semibold",children:"Contact"}),e.jsxs("div",{className:"flex gap-3",children:[(A==null?void 0:A.phone)&&e.jsxs("a",{href:`tel:${A.phone}`,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-full bg-[#406E71]/10 text-[#406E71] text-xs font-medium hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," Call"]}),(A==null?void 0:A.email)&&e.jsxs("a",{href:`mailto:${A.email}`,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-full bg-[#2a4c64]/10 text-[#2a4c64] text-xs font-medium hover:bg-[#2a4c64]/20 transition-colors",children:[e.jsx(tr,{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(xd,{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 eTs(){const s=Fl().pathname.slice(1).split("/")[0];return k.useEffect(()=>{document.body.classList.add("booking-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("booking-page"),n.forEach(clearTimeout)}},[]),s?e.jsx(edt,{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 tTs(){const s=Fl().pathname.slice(1);return k.useEffect(()=>{document.body.classList.add("connect-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("connect-page"),n.forEach(clearTimeout)}},[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-slate-100 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Connect"}),e.jsx("p",{className:"text-slate-500",children:"Stay connected with your real estate professional."}),e.jsx("p",{className:"text-slate-400 text-sm mt-2",children:"Visit a specific agent link to get started."})]})}):e.jsx(SXe,{slugOverride:s})}function tdt({slugOverride:t}){const{slug:s}=ho(),r=t||s,[n,a]=k.useState(!1),[o,l]=k.useState({}),[i,d]=k.useState(0),[u,p]=k.useState(!1),{data:f,isLoading:y}=ft({queryKey:["public-landing-page",r],queryFn:async()=>{const{data:U,error:q}=await G.from("landing_pages").select("*").eq("slug",r).eq("is_published",!0).single();if(q)throw q;return U},enabled:!!r}),{data:_=[]}=ft({queryKey:["public-landing-page-fields",f==null?void 0:f.id],queryFn:async()=>{const{data:U,error:q}=await G.from("landing_page_fields").select("*").eq("page_id",f.id).order("sort_order");if(q)throw q;return U},enabled:!!(f!=null&&f.id)});k.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=Et({mutationFn:async()=>{const U=_.find(Y=>Y.field_type==="text"&&Y.label.toLowerCase().includes("name")),q=_.find(Y=>Y.field_type==="email"),$=_.find(Y=>Y.field_type==="phone"),V=U?String(o[U.label]||""):null,ee=q?String(o[q.label]||""):null,Z=$?String(o[$.label]||""):null,{error:J}=await G.from("landing_page_submissions").insert([{page_id:f.id,answers:JSON.parse(JSON.stringify(o)),contact_name:V,contact_email:ee,contact_phone:Z,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(J)throw J;G.functions.invoke("landing-page-lead-notify",{body:{page_id:f.id,contact_name:V,contact_email:ee,contact_phone:Z,answers:o}}).catch(Y=>console.error("Landing page lead notification error:",Y))},onSuccess:()=>a(!0)}),N=U=>{U.preventDefault(),!(_.filter($=>$.is_required&&!o[$.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 w=f.primary_color||"#406E71",S=f.accent_color||"#2a4c64",C=f,A=f.page_type==="lead_magnet",I=f.page_type==="just_listed"||f.page_type==="just_sold",L=Array.isArray(C.property_photos)?C.property_photos:[],O=C.lead_magnet_file_url||C.lead_magnet_external_url;if(n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${w}, ${S})`},children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 max-w-md mx-4 text-center",children:[e.jsx(Hn,{className:"h-16 w-16 mx-auto mb-4",style:{color:w}}),e.jsx("h2",{className:"text-2xl font-bold mb-2",children:A?"Your download is ready!":"Submitted!"}),e.jsx("p",{className:"text-gray-600",children:f.success_message}),A&&O&&e.jsxs("a",{href:O,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 mt-6 px-6 py-3 rounded-lg text-white font-semibold transition-transform hover:scale-105",style:{backgroundColor:w},children:[e.jsx(Xa,{className:"h-5 w-5"}),"Download ",C.lead_magnet_file_name||"Your File"]}),f.agent_name&&e.jsxs("div",{className:"mt-6 pt-4 border-t",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Contact"}),e.jsx("p",{className:"font-semibold",children:f.agent_name}),f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(Tn,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(tr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})});if(I){const U=q=>{const $=parseFloat(q.replace(/[^0-9.]/g,""));return isNaN($)?q:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format($)};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(Sr,{className:"h-8 w-8"})}),e.jsx("button",{onClick:q=>{q.stopPropagation(),d($=>$===0?L.length-1:$-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(wl,{className:"h-6 w-6"})}),e.jsx("img",{src:L[i],alt:`Property photo ${i+1}`,className:"max-h-[90vh] max-w-[90vw] object-contain rounded-lg",onClick:q=>q.stopPropagation()}),e.jsx("button",{onClick:q=>{q.stopPropagation(),d($=>$===L.length-1?0:$+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(ja,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 text-white/70 text-sm",children:[i+1," / ",L.length]})]}),L.length>0&&e.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 pt-6",children:[e.jsx("div",{className:"absolute top-10 left-8 z-10 px-4 py-1.5 rounded-full text-white font-bold text-sm uppercase tracking-wider shadow-lg",style:{backgroundColor:C.property_status==="just_sold"?"#e74c3c":w},children:C.property_status==="just_sold"?"🎉 Just Sold":"🏡 Just Listed"}),L.length===1?e.jsxs("div",{className:"rounded-2xl overflow-hidden cursor-pointer group",onClick:()=>{d(0),p(!0)},children:[e.jsx("img",{src:L[0],alt:"Property",className:"w-full h-[50vh] object-cover group-hover:scale-105 transition-transform duration-500"}),e.jsxs("div",{className:"absolute bottom-4 right-4 bg-black/60 text-white px-3 py-1.5 rounded-lg text-sm flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(Ob,{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,$)=>e.jsx("div",{className:"cursor-pointer group relative",onClick:()=>{d($),p(!0)},children:e.jsx("img",{src:q,alt:`Property ${$+1}`,className:"w-full h-[45vh] object-cover group-hover:scale-105 transition-transform duration-500"})},$))}):e.jsxs("div",{className:"grid grid-cols-4 gap-2 rounded-2xl overflow-hidden",style:{height:"55vh"},children:[e.jsx("div",{className:"col-span-2 row-span-2 cursor-pointer group relative",onClick:()=>{d(0),p(!0)},children:e.jsx("img",{src:L[0],alt:"Property main",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),L.slice(1,5).map((q,$)=>e.jsxs("div",{className:"cursor-pointer group relative",onClick:()=>{d($+1),p(!0)},children:[e.jsx("img",{src:q,alt:`Property ${$+2}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}),$===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"]})]},$))]}),L.length>2&&e.jsxs("button",{onClick:()=>{d(0),p(!0)},className:"absolute bottom-4 right-8 bg-white shadow-lg hover:shadow-xl text-gray-800 px-4 py-2 rounded-lg text-sm font-medium flex items-center gap-2 transition-shadow",children:[e.jsx(Ob,{className:"h-4 w-4"})," View all ",L.length," photos"]})]}),L.length===0&&e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${S})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-4 py-8",children:e.jsxs("div",{className:"grid md:grid-cols-5 gap-6",children:[e.jsx("div",{className:"md:col-span-3 space-y-6",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[C.property_price&&e.jsx("p",{className:"text-3xl md:text-4xl font-bold mb-2",style:{color:w},children:U(C.property_price)}),C.property_address&&e.jsxs("p",{className:"text-gray-600 flex items-center gap-1.5 mb-5 text-lg",children:[e.jsx(La,{className:"h-5 w-5 shrink-0"})," ",C.property_address]}),e.jsxs("div",{className:"flex gap-6 mb-5 py-4 border-y border-gray-100",children:[C.property_beds&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(Ky,{className:"h-5 w-5",style:{color:w}})," ",C.property_beds]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bedrooms"})]}),C.property_baths&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(of,{className:"h-5 w-5",style:{color:w}})," ",C.property_baths]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bathrooms"})]}),C.property_sqft&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(yS,{className:"h-5 w-5",style:{color:w}})," ",Number(C.property_sqft).toLocaleString()]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Sq Ft"})]})]}),C.property_description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800 mb-2",children:"About This Property"}),e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-line",children:C.property_description})]})]})}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 sticky top-6",children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:w},children:C.property_status==="just_sold"?"Want results like this?":"Interested in this property?"}),e.jsx("p",{className:"text-gray-500 text-sm mb-4",children:"Fill out the form and I'll be in touch!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-5 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:f.agent_name}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-xs text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Tn,{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(tr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:N,className:"space-y-3",children:[_.map(q=>e.jsxs("div",{children:[e.jsxs(ge,{className:"text-xs font-medium",children:[q.label,q.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),rBe(q,o,l)]},q.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},disabled:b.isPending,children:b.isPending?"Submitting...":"Submit"}),b.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${S})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext}),A&&C.lead_magnet_file_name&&e.jsxs("div",{className:"mt-6 inline-flex items-center gap-2 bg-white/20 backdrop-blur px-4 py-2 rounded-full text-sm",children:[e.jsx(Xa,{className:"h-4 w-4"}),"Free Download: ",C.lead_magnet_file_name]})]})}),e.jsx("div",{className:"max-w-2xl mx-auto px-4 -mt-8",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[A&&e.jsx("p",{className:"text-sm text-gray-500 mb-4 text-center",children:"Fill out the form below to get your free download!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-6 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:f.agent_name}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Tn,{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(tr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[_.map(U=>e.jsxs("div",{children:[e.jsxs(ge,{className:"text-sm font-medium",children:[U.label,U.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),rBe(U,o,l)]},U.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},disabled:b.isPending,children:b.isPending?"Submitting...":A?"Get My Free Download":"Submit"}),b.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}function rBe(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(_r,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",rows:3,className:"mt-1"});case"select":return e.jsxs(zs,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(Os,{className:"mt-1",children:e.jsx(qs,{placeholder:"Select..."})}),e.jsx(Fs,{children:o.map(l=>e.jsx(yt,{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(Gi,{checked:i.includes(l),onCheckedChange:d=>{const u=d?[...i,l]:i.filter(p=>p!==l);r(p=>({...p,[t.label]:u}))}}),e.jsx("span",{className:"text-sm",children:l})]},l)})});case"toggle":return e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx(Lr,{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 sTs(){const s=Fl().pathname.slice(1).split("/")[0];return k.useEffect(()=>{document.body.classList.add("landing-page-public");const r=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("landing-page-public"),n.forEach(clearTimeout)}},[]),s?e.jsx(tdt,{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 rTs=[{type:"hero",enabled:!0},{type:"featured_listings",enabled:!0},{type:"new_listings",enabled:!1},{type:"open_houses",enabled:!1},{type:"my_listings",enabled:!1},{type:"city_pages",enabled:!1},{type:"featured_areas",enabled:!0},{type:"about",enabled:!0},{type:"testimonials",enabled:!0},{type:"cta_banner",enabled:!0}],SEs={hero:"Hero Section",featured_listings:"Featured Listings",featured_areas:"Featured Areas",about:"About Me",testimonials:"Testimonials",cta_banner:"Call To Action",new_listings:"New Listings Carousel",open_houses:"Open Houses Carousel",my_listings:"My Listings Carousel",city_pages:"City Pages Grid",property_types:"Property Types Gallery",advantages:"Advantages / Why Choose Us",lifestyle_gallery:"Lifestyle Gallery",market_pulse:"Market Pulse",concierge_services:"Concierge Services",land_use_guide:"Land Use Guide",land_valuation_cta:"Land Valuation CTA",acreage_showcase:"Acreage Showcase"},CEs={hero:"Full-screen background image with headline, subtitle, and search bar",featured_listings:"Grid of highlighted properties from the MLS",featured_areas:"Spotlight regions or neighborhoods that link to property search",about:"Agent photo, bio, and credentials section",testimonials:"Client reviews carousel with quotes",cta_banner:"Call-to-action block to drive contact and search engagement",new_listings:"Horizontal carousel of newest listings, filterable by city",open_houses:"Horizontal carousel of open house listings, filterable by city",my_listings:"Showcase the agent's own active listings in a carousel",city_pages:"Grid of your city landing pages with photos and links",property_types:"Visual gallery of property categories (Ranch, Farm, Land, etc.)",advantages:"Feature cards highlighting your expertise and unique value",lifestyle_gallery:"Cinematic photo grid showcasing luxury living — pools, views, interiors",market_pulse:"Sleek market stats dashboard with avg price, days on market, inventory",concierge_services:"White-glove services showcase — staging, design, moving coordination",land_use_guide:"Interactive land use cards — Agriculture, Hunting, Equestrian, Recreational",land_valuation_cta:`"What's Your Land Worth?" — bold call-to-action for landowners`,acreage_showcase:"Large visual cards emphasizing lot size with aerial imagery"},nBe={basic:["hero","featured_listings","new_listings","open_houses","my_listings","city_pages","featured_areas","about","testimonials","cta_banner"],luxury:["hero","featured_listings","new_listings","open_houses","my_listings","city_pages","featured_areas","about","testimonials","cta_banner","lifestyle_gallery","market_pulse","concierge_services"],"land-ranch":["hero","featured_listings","new_listings","open_houses","my_listings","city_pages","featured_areas","about","testimonials","cta_banner","property_types","advantages","land_use_guide","land_valuation_cta","acreage_showcase"]};function MEs(t){return nBe[t]||nBe.basic}function nTs(t){const s=t.theme_config||{};return{themeTier:t.theme_tier||"basic",brandColor:t.brand_color||"#0f172a",accentColor:t.accent_color||"#3b82f6",fontFamily:t.font_family||"Inter",heroImageUrl:t.hero_image_url||null,homepageModules:Array.isArray(t.homepage_modules)&&t.homepage_modules.length?t.homepage_modules:rTs,testimonials:Array.isArray(t.testimonials)?t.testimonials:[],featuredListingIds:t.featured_listing_ids||[],searchCities:Array.isArray(s.searchCities)?s.searchCities:[],searchZipCodes:Array.isArray(s.searchZipCodes)?s.searchZipCodes:[],searchCounties:Array.isArray(s.searchCounties)?s.searchCounties:[]}}function aTs(){const s=window.location.hostname.match(/^([^.]+)\.thelocalmove\.com$/i);return s?s[1]:null}function iTs(){const t=aTs(),{data:s,isLoading:r,error:n}=ft({queryKey:["lead-site",t],queryFn:async()=>{var p;if(!t)return null;const{data:a,error:o}=await G.from("lead_sites").select("*").eq("subdomain_slug",t).eq("is_active",!0).maybeSingle();if(o)throw o;if(!a)return null;const{data:l}=await G.from("profiles").select("id, name, avatar_url, email, phone, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url").eq("id",a.agent_id).single();let i=null;if(a.show_team_logo)if(a.team_logo_url)i=a.team_logo_url;else{const{data:f}=await G.from("team_members").select("team_id, teams(avatar_url, name)").eq("user_id",a.agent_id).limit(1).maybeSingle();f&&((p=f.teams)!=null&&p.avatar_url)&&(i=f.teams.avatar_url)}const d={id:a.id,agentId:a.agent_id,subdomainSlug:a.subdomain_slug,mlsProviderId:a.mls_provider_id,siteTitle:a.site_title,siteTagline:a.site_tagline,leadRegistrationMode:a.lead_registration_mode||"disabled",registrationTriggerCount:a.registration_trigger_count??1,themeConfig:a.theme_config||{},isActive:a.is_active,brokerageLegalName:a.brokerage_legal_name||null,brokerageLicenseNumber:a.brokerage_license_number||null,agentLicenseNumber:a.agent_license_number||null,mlsDisclaimerText:a.mls_disclaimer_text||null,mlsLogoUrl:a.mls_logo_url||null,equalHousingEnabled:a.equal_housing_enabled??!0,faviconUrl:a.favicon_url||null,ogImageUrl:a.og_image_url||null,showTeamLogo:a.show_team_logo??!1,teamLogoUrl:i,agent:l?{id:l.id,full_name:l.name||"",avatar_url:l.avatar_url,email:l.email,phone:l.phone,title:l.title,bio:l.bio,areas_served:l.areas_served||null,years_experience:l.years_experience??null,instagram_url:l.instagram_url||null,facebook_url:l.facebook_url||null,linkedin_url:l.linkedin_url||null}:void 0,testimonials:Array.isArray(a.testimonials)?a.testimonials.filter(f=>f&&typeof f=="object"&&f.text).map(f=>({name:String(f.name||"Client"),text:String(f.text),rating:typeof f.rating=="number"?f.rating:5,location:f.location?String(f.location):void 0})):[],seoMetaTitle:a.seo_meta_title||null,seoMetaDescription:a.seo_meta_description||null},u=nTs(a);return{siteConfig:d,themeConfig:u}},enabled:!!t,staleTime:5*60*1e3,gcTime:30*60*1e3,refetchOnWindowFocus:!1});return{siteConfig:(s==null?void 0:s.siteConfig)??null,themeConfig:(s==null?void 0:s.themeConfig)??null,isLoading:r,error:n,slug:t}}async function oTs(t,s){try{await G.functions.invoke("lead-site-notify",{body:{lead:s,lead_site_id:t}})}catch(r){console.warn("Lead notification failed:",r)}}const sdt=k.createContext(null);function npe(){const t=k.useContext(sdt);if(!t)throw new Error("useLeadSiteAuth must be used within LeadSiteAuthProvider");return t}function lTs({siteConfig:t,children:s}){const[r,n]=k.useState(null),[a,o]=k.useState(null),[l,i]=k.useState(!0);k.useEffect(()=>{const{data:{subscription:f}}=G.auth.onAuthStateChange(async(y,_)=>{const b=(_==null?void 0:_.user)??null;if(n(b),b){const{data:N}=await G.from("lead_site_consumer_profiles").select("id, name, phone").eq("user_id",b.id).eq("lead_site_id",t.id).maybeSingle();N&&o({...N,email:b.email||""})}else o(null);i(!1)});return G.auth.getSession().then(({data:{session:y}})=>{n((y==null?void 0:y.user)??null),y!=null&&y.user?G.from("lead_site_consumer_profiles").select("id, name, phone").eq("user_id",y.user.id).eq("lead_site_id",t.id).maybeSingle().then(({data:_})=>{_&&o({..._,email:y.user.email||""}),i(!1)}):i(!1)}),()=>f.unsubscribe()},[t.id]);const d=k.useCallback(async f=>{const y=f.email.toLowerCase().trim(),_=f.phone.replace(/\D/g,""),{data:b,error:N}=await G.auth.signUp({email:y,password:_,options:{data:{full_name:f.name,consumer_site_id:t.id},emailRedirectTo:window.location.origin}});if(N){if(N.message.includes("already registered")){await u(y,_);return}throw N}if(b.user){const{error:w}=await G.from("lead_site_consumer_profiles").insert({user_id:b.user.id,lead_site_id:t.id,name:f.name.trim(),phone:f.phone.trim()});w&&console.warn("Consumer profile insert error:",w);const{error:S}=await G.from("lead_site_leads").insert({lead_site_id:t.id,name:f.name.trim(),email:y,phone:f.phone.trim(),message:"Created account on website",source_page:window.location.pathname,lead_type:"website_registration",metadata:{registered:!0,has_account:!0}});S&&console.error("Lead insert error (CRM sync may not trigger):",S),oTs(t.id,{name:f.name.trim(),email:y,phone:f.phone.trim(),lead_type:"website_registration",message:"Created account on website",source_page:window.location.pathname})}},[t.id]),u=k.useCallback(async(f,y)=>{const _=y.replace(/\D/g,""),{error:b}=await G.auth.signInWithPassword({email:f.toLowerCase().trim(),password:_});if(b)throw b},[]),p=k.useCallback(async()=>{await G.auth.signOut(),n(null),o(null)},[]);return e.jsx(sdt.Provider,{value:{user:r,profile:a,isLoading:l,signUp:d,signIn:u,signOut:p},children:s})}function i3e({open:t,mode:s,siteConfig:r,onComplete:n,onSkip:a,theme:o="default",accentColor:l}){var J;const{signUp:i,signIn:d}=npe(),[u,p]=k.useState(!1),[f,y]=k.useState(""),[_,b]=k.useState(""),[N,w]=k.useState(""),[S,C]=k.useState(!1),[A,I]=k.useState(""),L=s==="required",O=o==="luxury",U=l||(O?"#c9a96e":"#2563eb"),q=((J=r.agent)==null?void 0:J.full_name)||"the agent",$={borderColor:`${U}66`,"--tw-ring-color":`${U}66`},V=async Y=>{var ae;if(Y.preventDefault(),I(""),!_.trim()||!N.trim()){I("Email and phone number are required.");return}if(!u&&!f.trim()){I("Name is required.");return}if(N.replace(/\D/g,"").length<7){I("Please enter a valid phone number.");return}C(!0);try{u?await d(_,N):await i({name:f,email:_,phone:N}),n()}catch(ie){(ae=ie==null?void 0:ie.message)!=null&&ae.includes("Invalid login")?I("Invalid email or phone number. Please try again."):I((ie==null?void 0:ie.message)||"Something went wrong. Please try again.")}finally{C(!1)}},ee=O?"w-full px-3 py-2.5 border rounded-lg text-sm focus:outline-none focus:ring-2":"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",Z=O?$:void 0;return e.jsx(fs,{open:t,onOpenChange:L?void 0:Y=>{Y||a()},children:e.jsxs(ms,{className:`sm:max-w-md ${O?"border-white/10 bg-[#f7f1e7] text-[#201915]":""}`,onPointerDownOutside:L?Y=>Y.preventDefault():void 0,onEscapeKeyDown:L?Y=>Y.preventDefault():void 0,children:[e.jsxs(ks,{children:[e.jsx(bs,{className:"text-xl",style:O?{fontFamily:"'Playfair Display', Georgia, serif"}:void 0,children:u?"Welcome Back":L?"Create a Free Account to Continue":"Save Your Search & Get Updates"}),e.jsx(Rr,{className:O?"text-[#5f5145]":void 0,children:u?"Sign in with your email and phone number.":`Create a free account to save favorites, get alerts, and connect with ${q}.`})]}),e.jsxs("form",{onSubmit:V,className:"space-y-3 mt-2",children:[!u&&e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:f,onChange:Y=>y(Y.target.value),className:ee,style:Z}),e.jsx("input",{type:"email",required:!0,placeholder:"Email address",value:_,onChange:Y=>b(Y.target.value),className:ee,style:Z}),e.jsxs("div",{children:[e.jsx("input",{type:"tel",required:!0,placeholder:"Phone number",value:N,onChange:Y=>w(Y.target.value),className:ee,style:Z}),e.jsx("p",{className:`text-xs mt-1 ${O?"text-[#8a7869]":"text-gray-400"}`,children:u?"Your phone number is your password":"Your phone number will be used as your password"})]}),A&&e.jsx("p",{className:"text-red-600 text-sm",children:A}),e.jsx("button",{type:"submit",disabled:S,className:`w-full py-2.5 font-medium rounded-lg disabled:opacity-50 transition-colors ${O?"text-black hover:opacity-90 tracking-wider uppercase text-sm":"bg-blue-600 text-white hover:bg-blue-700"}`,style:O?{backgroundColor:U}:void 0,children:S?u?"Signing in...":"Creating account...":u?"Sign In":"Create Account"}),e.jsx("button",{type:"button",onClick:()=>{p(!u),I("")},className:"w-full text-center text-sm hover:opacity-80 transition-opacity",style:{color:U},children:u?"Don't have an account? Sign up":"Already have an account? Sign in"}),!L&&!u&&e.jsx("button",{type:"button",onClick:a,className:`w-full py-2 text-sm transition-colors ${O?"text-[#7a6758] hover:text-[#201915]":"text-gray-500 hover:text-gray-700"}`,children:"Skip for now"})]}),e.jsx("p",{className:`text-xs text-center mt-1 ${O?"text-[#8a7869]":"text-gray-400"}`,children:"By registering you agree to receive property updates. You can unsubscribe anytime."})]})})}function o3e({siteConfig:t,pagePath:s}){const r=t.agent;if(!r)return null;const n=`https://${t.subdomainSlug}.thelocalmove.com`,o=(r.areas_served||"").split(/,|;|\|/).map(A=>A.trim()).filter(Boolean),l=o[0]||"",[i,d]=l.split(/,\s*/),u=(r.bio||"").match(/\b(CRS|GRI|ABR|CNE|SRES|SRS|RENE|MRP|PSA|AHWD|C2EX|CIPS|CRB|e-?PRO)\b/gi)||[],p=[...new Set(u.map(A=>A.toUpperCase()))],f=t.testimonials||[],y=f.length?{"@type":"AggregateRating",ratingValue:(f.reduce((A,I)=>A+(I.rating||5),0)/f.length).toFixed(1),reviewCount:f.length,bestRating:5,worstRating:1}:void 0,_=[r.facebook_url,r.instagram_url,r.linkedin_url].filter(Boolean),b={"@context":"https://schema.org","@type":["RealEstateAgent","LocalBusiness"],"@id":`${n}/#agent`,name:r.full_name,url:n,image:r.avatar_url||t.ogImageUrl||void 0,logo:t.ogImageUrl||r.avatar_url||void 0,email:r.email,telephone:r.phone||void 0,jobTitle:r.title||"Real Estate Agent",description:r.bio||`${r.full_name} is a trusted local real estate professional${l?` serving ${l}`:""}.`,priceRange:"$$",..._.length&&{sameAs:_},...t.brokerageLegalName&&{worksFor:{"@type":"RealEstateAgent",name:t.brokerageLegalName,...t.brokerageLicenseNumber&&{identifier:t.brokerageLicenseNumber}}},...t.agentLicenseNumber&&{identifier:t.agentLicenseNumber},...i&&{address:{"@type":"PostalAddress",addressLocality:i,...d&&{addressRegion:d},addressCountry:"US"}},...o.length&&{areaServed:o.map(A=>{const[I,L]=A.split(/,\s*/);return{"@type":"City",name:I,...L&&{containedInPlace:{"@type":"State",name:L}}}})},...y&&{aggregateRating:y},...f.length&&{review:f.slice(0,10).map(A=>({"@type":"Review",author:{"@type":"Person",name:A.name},reviewBody:A.text,reviewRating:{"@type":"Rating",ratingValue:A.rating||5,bestRating:5,worstRating:1},...A.location&&{locationCreated:{"@type":"Place",name:A.location}}}))}},N={"@context":"https://schema.org","@type":"Person","@id":`${n}/#person`,name:r.full_name,jobTitle:r.title||"Real Estate Agent",description:r.bio||void 0,image:r.avatar_url||void 0,url:n,email:r.email,telephone:r.phone||void 0,..._.length&&{sameAs:_},...r.years_experience&&{knowsAbout:["Residential Real Estate","Home Buying","Home Selling",l?`${l} Real Estate`:"Local Real Estate"].filter(Boolean)},...p.length&&{hasCredential:p.map(A=>({"@type":"EducationalOccupationalCredential",credentialCategory:"designation",name:A}))},...t.brokerageLegalName&&{worksFor:{"@type":"Organization",name:t.brokerageLegalName}}},w={"@context":"https://schema.org","@type":"WebSite","@id":`${n}/#website`,name:t.siteTitle||`${r.full_name} Real Estate`,url:n,publisher:{"@id":`${n}/#agent`},potentialAction:{"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${n}/search?q={search_term_string}`},"query-input":"required name=search_term_string"}},S=[{name:"Search Homes",description:`Browse all current MLS listings${l?` in ${l}`:""}.`,path:"/search"},{name:"Featured Areas",description:"Explore featured neighborhoods, cities, and communities.",path:"/areas"},{name:"Sold Properties",description:"See recently sold homes and local market activity.",path:"/sold"},{name:"Home Valuation",description:"Get a free, no-obligation estimate of what your home is worth.",path:"/sell"},{name:"About",description:`Learn more about ${r.full_name}${t.brokerageLegalName?` and ${t.brokerageLegalName}`:""}.`,path:"/about"},{name:"Contact",description:`Get in touch with ${r.full_name} for buying, selling, or relocation help.`,path:"/contact"}],C={"@context":"https://schema.org","@type":"ItemList","@id":`${n}/#nav`,name:"Main Navigation",itemListElement:S.map((A,I)=>({"@type":"SiteNavigationElement",position:I+1,name:A.name,description:A.description,url:`${n}${A.path}`}))};return e.jsxs(Nc,{children:[e.jsx("script",{type:"application/ld+json",children:JSON.stringify(b)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(N)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(w)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(C)})]})}function TEs({items:t,siteConfig:s}){const r=`https://${s.subdomainSlug}.thelocalmove.com`,n={"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:t.map((a,o)=>({"@type":"ListItem",position:o+1,name:a.name,item:`${r}${a.path}`}))};return e.jsx(Nc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function AEs({listing:t,siteConfig:s}){var a;const r=`https://${s.subdomainSlug}.thelocalmove.com`,n={"@context":"https://schema.org","@type":"SingleFamilyResidence",name:`${t.address}, ${t.city}, ${t.state} ${t.zip}`,url:`${r}/listing/${t.mlsNumber}`,image:((a=t.photos)==null?void 0:a[0])||void 0,numberOfRooms:t.bedrooms,numberOfBathroomsTotal:t.bathrooms,floorSize:t.sqft?{"@type":"QuantitativeValue",value:t.sqft,unitCode:"FTK"}:void 0,address:{"@type":"PostalAddress",streetAddress:t.address,addressLocality:t.city,addressRegion:t.state,postalCode:t.zip},...t.latitude&&t.longitude&&{geo:{"@type":"GeoCoordinates",latitude:t.latitude,longitude:t.longitude}},offers:{"@type":"Offer",price:t.price,priceCurrency:"USD",availability:t.status==="Active"?"https://schema.org/InStock":"https://schema.org/SoldOut"},...t.yearBuilt&&{yearBuilt:t.yearBuilt}};return e.jsx(Nc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function cTs({faqs:t}){if(!t.length)return null;const s={"@context":"https://schema.org","@type":"FAQPage",mainEntity:t.map(r=>({"@type":"Question",name:r.question,acceptedAnswer:{"@type":"Answer",text:r.answer}}))};return e.jsx(Nc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(s)})})}function EEs({title:t,description:s,publishedAt:r,imageUrl:n,slug:a,siteConfig:o}){const l=`https://${o.subdomainSlug}.thelocalmove.com`,i=o.agent,d={"@context":"https://schema.org","@type":"Article",headline:t,description:s,url:`${l}/blog/${a}`,datePublished:r,...n&&{image:n},author:i?{"@type":"Person",name:i.full_name,url:l}:void 0,publisher:{"@type":"Organization",name:o.siteTitle||(i==null?void 0:i.full_name)||"Agent",url:l}};return e.jsx(Nc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(d)})})}function l3e({siteConfig:t}){var _;const s=t.agent;if(!s)return null;const r=s.full_name,n=t.brokerageLegalName||"their brokerage",a=s.areas_served||"the local market",o=((_=a.split(/,|;|\|/)[0])==null?void 0:_.trim())||"the local area",l=s.years_experience,i=s.phone||"",d=s.email,u=t.agentLicenseNumber,p=(s.bio||"").match(/\b(CRS|GRI|ABR|CNE|SRES|SRS|RENE|MRP|PSA|AHWD|C2EX|CIPS|CRB|e-?PRO)\b/gi)||[],f=[...new Set(p.map(b=>b.toUpperCase()))],y=[{question:`Who is ${r}?`,answer:`${r} is a ${s.title||"REALTOR®"} with ${n}${l?`, with ${l}+ years of local real estate experience`:""} serving ${a}. ${s.bio?s.bio.slice(0,280):""}`.trim()},{question:`What areas does ${r} serve?`,answer:`${r} serves ${a} and surrounding communities. Whether you're buying, selling, relocating, or downsizing, ${r.split(" ")[0]} provides expert local guidance.`},{question:`How can I contact ${r}?`,answer:`You can reach ${r} by ${i?`phone at ${i}, `:""}email at ${d}, or by booking a consultation directly through this website.`},...f.length?[{question:`What real estate designations does ${r} hold?`,answer:`${r} holds the following professional designations: ${f.join(", ")}. These designations represent advanced training in specialized areas of real estate.`}]:[],...u?[{question:`Is ${r} a licensed real estate agent?`,answer:`Yes, ${r} is a fully licensed real estate professional (License #${u}) with ${n}.`}]:[],{question:`How do I search for homes for sale in ${o}?`,answer:`Use the property search on this site to view all current MLS listings in ${o}. You can filter by price, bedrooms, neighborhood, school district, and more. Save searches to receive instant email alerts when new homes match your criteria.`},{question:`What is the home buying process like in ${o}?`,answer:`${r} guides buyers through every step: getting pre-approved, searching MLS listings, touring homes, writing competitive offers, navigating inspections and appraisals, and closing on schedule. Contact ${r.split(" ")[0]} for a free buyer consultation.`},{question:`How do I find out what my home is worth in ${o}?`,answer:`Request a free, no-obligation home valuation from ${r}. ${r.split(" ")[0]} provides a comparative market analysis (CMA) using recent sold comps and current market conditions in ${o}.`}];return e.jsx(cTs,{faqs:y})}const aBe="ls_visitor_geo",dTs=1e3*60*60;function uTs(t){return t==="/"?"home":t==="/search"?"search":t==="/sell"?"sell":t==="/blog"?"blog":t.startsWith("/listing/")?"listing":t.startsWith("/homes-for-sale-in-")?"city":t==="/dashboard"?"dashboard":"other"}function hTs(t,s){switch(s){case"home":return"Home";case"search":return"Search";case"sell":return"Sell Your Home";case"blog":return"Blog";case"listing":return`Listing ${t.split("/listing/")[1]||""}`;case"city":return t.replace("/homes-for-sale-in-","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");case"dashboard":return"My Dashboard";default:return t}}async function mTs(){try{const t=localStorage.getItem(aBe);if(t){const s=JSON.parse(t);if(Date.now()-s.ts{o.current||(o.current=!0,mTs().then(l=>{a.current=l}))},[]),k.useEffect(()=>{if(!(t!=null&&t.id))return;const l=r.pathname;if(l===n.current)return;n.current=l;const i=uTs(l),d=hTs(l,i),u=localStorage.getItem(`ls_visitor_fp_${t.id}`)||null,p=a.current;G.from("lead_site_page_views").insert({lead_site_id:t.id,page_type:i,page_path:l,page_title:d,visitor_fingerprint:u,auth_user_id:s||null,visitor_city:(p==null?void 0:p.city)||null,visitor_region:(p==null?void 0:p.region)||null,visitor_country:(p==null?void 0:p.country)||null,visitor_lat:(p==null?void 0:p.lat)||null,visitor_lng:(p==null?void 0:p.lng)||null}).then(({error:f})=>{f&&console.error("[PageTracking] insert failed:",f.message)})},[r.pathname,t==null?void 0:t.id,s])}const pTs=3e4;function d3e(t,s){const r=Fl(),n=k.useRef(null),a=k.useRef(null),o=k.useRef(0),l=r.pathname,i=fTs(l),d=xTs(l,i),u=i==="listing"&&l.split("/listing/")[1]||null;k.useEffect(()=>{if(!(t!=null&&t.id)||!s)return;i==="listing"&&(o.current+=1);const p=localStorage.getItem(`ls_visitor_fp_${t.id}`)||null,f=async()=>{const{data:y,error:_}=await G.from("lead_site_active_visitors").upsert({lead_site_id:t.id,auth_user_id:s,visitor_fingerprint:p,current_page_path:l,current_page_title:d,current_mls_number:u,last_seen_at:new Date().toISOString(),listing_views_count:o.current},{onConflict:"lead_site_id,coalesce(auth_user_id::text,visitor_fingerprint,'')"}).select("id, notified_agent").single();!_&&y&&(n.current=y.id,o.current>=2&&!y.notified_agent&&G.functions.invoke("lead-site-presence-notify",{body:{visitor_id:y.id,lead_site_id:t.id}}).catch(()=>{}))};return f(),a.current&&clearInterval(a.current),a.current=setInterval(f,pTs),()=>{a.current&&clearInterval(a.current)}},[t==null?void 0:t.id,s,l]),k.useEffect(()=>{if(!(t!=null&&t.id)||!s)return;const p=()=>{n.current&&G.from("lead_site_active_visitors").delete().eq("id",n.current).then(()=>{})};return window.addEventListener("beforeunload",p),()=>window.removeEventListener("beforeunload",p)},[t==null?void 0:t.id,s])}function fTs(t){return t==="/"?"home":t==="/search"?"search":t.startsWith("/listing/")?"listing":t.startsWith("/homes-for-sale-in-")?"city":"other"}function xTs(t,s){switch(s){case"home":return"Home";case"search":return"Search";case"listing":return`Listing ${t.split("/listing/")[1]||""}`;case"city":return t.replace("/homes-for-sale-in-","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");default:return t}}function gTs({children:t,siteConfig:s}){var xe,he,we,Ne,Ve,Te,Ae,ze,Ee;const r=Fl(),n=br(),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[d,u]=k.useState(!1),[p,f]=k.useState([]),[y,_]=k.useState([]),[b,N]=k.useState(null),w=k.useRef(null),S=k.useRef(null),{user:C,profile:A,signOut:I}=npe();c3e(s,C==null?void 0:C.id),d3e(s,C==null?void 0:C.id);const L=((xe=s.agent)==null?void 0:xe.full_name)||"Agent",O=s.siteTitle||`${L} Real Estate`,U=r.pathname==="/search",q=r.pathname==="/",$=s.leadRegistrationMode!=="disabled";k.useEffect(()=>{(async()=>{const{data:Re}=await G.from("lead_site_city_pages").select("city_name, city_slug").eq("site_id",s.id).eq("is_published",!0).order("sort_order",{ascending:!0});f(Re||[])})()},[s.id]),k.useEffect(()=>{(async()=>{const{data:Re}=await G.from("lead_site_menu_items").select("*").eq("site_id",s.id).eq("is_visible",!0).order("sort_order",{ascending:!0});_(Re||[])})()},[s.id]),k.useEffect(()=>{const ve=Re=>{w.current&&!w.current.contains(Re.target)&&u(!1),S.current&&!S.current.contains(Re.target)&&N(null)};return document.addEventListener("mousedown",ve),()=>document.removeEventListener("mousedown",ve)},[]);const V=y.length>0,Z=V?[]:[{to:"/",label:"Home"},{to:"/search",label:"Search"},{to:"/sell",label:"Sell"},{to:"/blog",label:"Blog"},{to:"/community",label:"Community"},{to:"/about",label:"About"},{to:"/contact",label:"Contact"}],J=y.filter(ve=>!ve.parent_id),Y=ve=>y.filter(Re=>Re.parent_id===ve),ce=q?"bg-transparent text-white":"bg-white/95 backdrop-blur text-gray-900 border-b border-gray-100 shadow-sm",ae=s.siteTitle||`${L} - Real Estate`,ie=s.siteTagline||`Browse homes and listings with ${L}`,le=s.ogImageUrl||((he=s.agent)==null?void 0:he.avatar_url)||"",fe=`https://${s.subdomainSlug||""}.thelocalmove.com`;return e.jsxs("div",{className:`flex flex-col ${U?"h-screen overflow-hidden":"min-h-screen"} bg-white`,children:[e.jsx(o3e,{siteConfig:s,pagePath:r.pathname}),e.jsx(l3e,{siteConfig:s}),e.jsxs(Nc,{children:[e.jsx("title",{children:ae}),e.jsx("meta",{name:"description",content:ie}),e.jsx("meta",{property:"og:title",content:ae}),e.jsx("meta",{property:"og:description",content:ie}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:fe+r.pathname}),le&&e.jsx("meta",{property:"og:image",content:le}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:ae}),e.jsx("meta",{name:"twitter:description",content:ie}),le&&e.jsx("meta",{name:"twitter:image",content:le}),s.faviconUrl&&e.jsx("link",{rel:"icon",href:s.faviconUrl,type:"image/png"}),e.jsx("link",{rel:"canonical",href:`${fe}${r.pathname}`}),s.subdomainSlug==="matthogg"&&e.jsx("script",{src:"https://analytics.ahrefs.com/analytics.js","data-key":"kyFjzruyvE0yTdMokzgCBw",async:!0})]}),e.jsxs("header",{className:`${q?"absolute":"sticky"} top-0 left-0 right-0 z-50 transition-all ${ce}`,children:[e.jsx("div",{className:"max-w-7xl mx-auto px-6 lg:px-8",children:e.jsxs("div",{className:"flex items-center justify-between h-20",children:[e.jsxs(da,{to:"/",className:"flex items-center gap-3",children:[((we=s.agent)==null?void 0:we.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:L,className:"h-10 w-10 rounded-full object-cover ring-2 ring-white/20"}),e.jsx("div",{children:e.jsx("span",{className:"font-bold text-lg leading-none tracking-tight",children:O})})]}),e.jsxs("nav",{className:"hidden md:flex items-center gap-1",children:[Z.map(ve=>e.jsx(da,{to:ve.to,className:`px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname===ve.to?q?"bg-white/15 text-white":"bg-gray-100 text-gray-900":q?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:ve.label},ve.to)),V&&J.map(ve=>{if(ve.item_type==="dropdown"){const Re=Y(ve.id);return e.jsxs("div",{ref:S,className:"relative",children:[e.jsxs("button",{onClick:()=>N(b===ve.id?null:ve.id),className:`flex items-center gap-1 px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${q?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[ve.label," ",e.jsx(Fi,{className:`h-3.5 w-3.5 transition-transform ${b===ve.id?"rotate-180":""}`})]}),b===ve.id&&Re.length>0&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-52 bg-white rounded-xl shadow-xl border border-gray-100 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-150",children:Re.map(Ue=>e.jsx(D9,{item:Ue,onClick:()=>N(null),className:"w-full text-left px-4 py-2.5 text-sm text-gray-700 hover:bg-gray-50 hover:text-gray-900 transition-colors block"},Ue.id))})]},ve.id)}return e.jsx(D9,{item:ve,className:`px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${q?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`},ve.id)}),p.length>0&&e.jsxs("div",{ref:w,className:"relative",children:[e.jsxs("button",{onClick:()=>u(!d),className:`flex items-center gap-1 px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname.startsWith("/homes-for-sale-in-")?q?"bg-white/15 text-white":"bg-gray-100 text-gray-900":q?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:["Cities ",e.jsx(Fi,{className:`h-3.5 w-3.5 transition-transform ${d?"rotate-180":""}`})]}),d&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-52 bg-white rounded-xl shadow-xl border border-gray-100 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-150",children:p.map(ve=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${ve.city_slug}`),u(!1)},className:"w-full text-left px-4 py-2.5 text-sm text-gray-700 hover:bg-gray-50 hover:text-gray-900 transition-colors",children:ve.city_name},ve.city_slug))})]}),C?e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsxs(da,{to:"/account",className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${q?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[e.jsx(Za,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:"Saved"})]}),e.jsxs(da,{to:"/account",className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${q?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[e.jsx(Ei,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:((Ne=A==null?void 0:A.name)==null?void 0:Ne.split(" ")[0])||"Account"})]})]}):$?e.jsx("button",{onClick:()=>i(!0),className:`ml-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${q?"bg-white/15 text-white hover:bg-white/25":"bg-blue-600 text-white hover:bg-blue-700"}`,children:"Sign In"}):null]}),e.jsx("button",{onClick:()=>o(!a),className:`md:hidden p-2 rounded-lg ${q?"text-white hover:bg-white/10":"text-gray-600 hover:bg-gray-100"}`,children:a?e.jsx(Sr,{className:"h-5 w-5"}):e.jsx(hS,{className:"h-5 w-5"})})]})}),a&&e.jsx("div",{className:`md:hidden border-t ${q?"border-white/10 bg-black/95 backdrop-blur":"border-gray-100 bg-white"} max-h-[calc(100vh-5rem)] overflow-y-auto overscroll-contain`,children:e.jsxs("div",{className:"px-4 py-3 space-y-1 pb-8",children:[Z.map(ve=>e.jsx(da,{to:ve.to,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===ve.to?q?"bg-white/15 text-white":"bg-gray-100 text-gray-900":q?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:ve.label},ve.to)),V&&J.map(ve=>{if(ve.item_type==="dropdown"){const Re=Y(ve.id);return e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:`px-3 pt-3 pb-1 text-xs font-semibold uppercase tracking-wider ${q?"text-white/40":"text-gray-400"}`,children:ve.label}),Re.map(Ue=>e.jsx(D9,{item:Ue,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${q?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`},Ue.id))]},ve.id)}return e.jsx(D9,{item:ve,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${q?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`},ve.id)}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`px-3 pt-3 pb-1 text-xs font-semibold uppercase tracking-wider ${q?"text-white/40":"text-gray-400"}`,children:"Cities"}),p.map(ve=>e.jsx(da,{to:`/homes-for-sale-in-${ve.city_slug}`,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===`/homes-for-sale-in-${ve.city_slug}`?q?"bg-white/15 text-white":"bg-gray-100 text-gray-900":q?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:ve.city_name},ve.city_slug))]}),C?e.jsxs(e.Fragment,{children:[e.jsx(da,{to:"/account",onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${q?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:"My Account"}),e.jsx("button",{onClick:async()=>{await I(),o(!1)},className:`block w-full text-left px-3 py-2.5 rounded-lg text-sm font-medium ${q?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:"Sign Out"})]}):$?e.jsx("button",{onClick:()=>{i(!0),o(!1)},className:`block w-full text-left px-3 py-2.5 rounded-lg text-sm font-medium ${q?"text-white/70 hover:bg-white/10":"text-blue-600 hover:bg-blue-50"}`,children:"Sign In / Register"}):null]})})]}),e.jsx("main",{className:"flex-1 min-h-0 flex flex-col",children:t}),!U&&e.jsx("footer",{className:"bg-gray-950 text-gray-400",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8 py-16",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-12",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[((Ve=s.agent)==null?void 0:Ve.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:L,className:"h-16 w-16 rounded-2xl object-cover ring-2 ring-white/10"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-white text-lg tracking-tight",children:L}),e.jsx("p",{className:"text-sm text-gray-500",children:((Te=s.agent)==null?void 0:Te.title)||"Real Estate Professional"})]})]}),((Ae=s.agent)==null?void 0:Ae.phone)&&e.jsx("p",{className:"text-sm mt-3",children:e.jsxs("a",{href:`tel:${s.agent.phone}`,className:"hover:text-white transition-colors flex items-center gap-2",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," ",s.agent.phone]})}),((ze=s.agent)==null?void 0:ze.email)&&e.jsx("p",{className:"text-sm mt-1",children:e.jsxs("a",{href:`mailto:${s.agent.email}`,className:"hover:text-white transition-colors flex items-center gap-2",children:[e.jsx(tr,{className:"h-3.5 w-3.5"})," ",s.agent.email]})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-white mb-4 text-sm tracking-wider uppercase",children:"Quick Links"}),e.jsx("ul",{className:"space-y-3 text-sm",children:Z.map(ve=>e.jsx("li",{children:e.jsx(da,{to:ve.to,className:"hover:text-white transition-colors",children:ve.label})},ve.to))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-white mb-4 text-sm tracking-wider uppercase",children:"Get In Touch"}),e.jsx("p",{className:"text-sm text-gray-500 leading-relaxed mb-4",children:"Ready to find your dream home? Get in touch today for a personalized consultation."}),e.jsx(da,{to:"/contact",className:"inline-block px-5 py-2.5 bg-white text-gray-900 text-sm font-semibold rounded-lg hover:bg-gray-100 transition-colors",children:"Contact Me"})]})]}),e.jsxs("div",{className:"mt-14 pt-6 border-t border-gray-800/50",children:[s.showTeamLogo&&s.teamLogoUrl&&e.jsx("div",{className:"flex items-center justify-center mb-6",children:e.jsx("img",{src:s.teamLogoUrl,alt:"Team",className:"h-12 w-auto object-contain"})}),s.brokerageLegalName&&e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-xs text-gray-500 mb-3",children:[e.jsxs("span",{children:[L," · ",s.brokerageLegalName]}),s.agentLicenseNumber&&e.jsx("span",{children:s.agentLicenseNumber}),s.brokerageLicenseNumber&&e.jsxs("span",{children:["Brokerage #",s.brokerageLicenseNumber]})]}),s.mlsDisclaimerText&&e.jsxs("div",{className:"flex items-start justify-center gap-3 mb-4",children:[s.mlsLogoUrl&&e.jsx("img",{src:s.mlsLogoUrl,alt:"MLS",className:"h-8 w-auto flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-gray-600 leading-relaxed max-w-3xl text-center",children:s.mlsDisclaimerText})]}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-xs text-gray-600",children:[s.equalHousingEnabled&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"h-5 w-5 text-gray-500",children:e.jsx("path",{d:"M12 2L2 8v2h20V8L12 2zm0 2.5L18.5 8h-13L12 4.5zM4 12v8h4v-6h8v6h4v-8H4zm6 8v-4h4v4h-4z"})}),e.jsx("span",{children:"Equal Housing Opportunity"})]}),e.jsxs("span",{children:["© ",new Date().getFullYear()," ",L,". Powered by LevelUp."]})]})]})]})}),!U&&((Ee=s.agent)==null?void 0:Ee.avatar_url)&&e.jsx(yTs,{agent:s.agent}),l&&e.jsx(i3e,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1)})]})}function yTs({agent:t}){var a;const[s,r]=k.useState(!1),n=br();return t?e.jsx("div",{className:"fixed bottom-6 right-6 z-40",children:s?e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl border border-gray-200 w-72 overflow-hidden animate-in slide-in-from-bottom-4 fade-in duration-200",children:[e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-12 w-12 rounded-full object-cover ring-2 ring-gray-100"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-gray-900 text-sm",children:t.full_name}),e.jsx("p",{className:"text-xs text-gray-500",children:t.title||"Real Estate Professional"})]})]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"Have questions about a property or the area? I'm here to help!"}),e.jsxs("div",{className:"space-y-2",children:[t.phone&&e.jsxs("a",{href:`tel:${t.phone}`,className:"flex items-center gap-2 w-full px-3 py-2 bg-gray-50 hover:bg-gray-100 rounded-xl text-sm text-gray-700 transition-colors",children:[e.jsx(Tn,{className:"h-4 w-4 text-gray-400"}),t.phone]}),t.email&&e.jsxs("a",{href:`mailto:${t.email}`,className:"flex items-center gap-2 w-full px-3 py-2 bg-gray-50 hover:bg-gray-100 rounded-xl text-sm text-gray-700 transition-colors",children:[e.jsx(tr,{className:"h-4 w-4 text-gray-400"}),"Email Me"]}),e.jsx("button",{onClick:()=>{r(!1),n("/contact")},className:"w-full px-3 py-2.5 bg-blue-600 hover:bg-blue-700 text-white text-sm font-semibold rounded-xl transition-colors",children:"Send a Message"})]})]}),e.jsx("button",{onClick:()=>r(!1),className:"absolute top-3 right-3 p-1 text-gray-400 hover:text-gray-600 rounded-full hover:bg-gray-100",children:e.jsx(Sr,{className:"h-4 w-4"})})]}):e.jsxs("button",{onClick:()=>r(!0),className:"group flex items-center gap-3 bg-white pl-1.5 pr-5 py-1.5 rounded-full shadow-xl border border-gray-200 hover:shadow-2xl transition-all hover:scale-105",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-10 w-10 rounded-full object-cover ring-2 ring-blue-100"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-xs font-bold text-gray-900 leading-none",children:(a=t.full_name)==null?void 0:a.split(" ")[0]}),e.jsx("p",{className:"text-[10px] text-blue-600 font-medium mt-0.5",children:"Chat with me →"})]})]})}):null}function D9({item:t,className:s,onClick:r}){const n=t.target_url||"#";return t.item_type==="external"||t.open_in_new_tab?e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:s,onClick:r,children:t.label}):e.jsx(da,{to:n,className:s,onClick:r,children:t.label})}function vTs({children:t,siteConfig:s}){var fe,xe,he,we,Ne,Ve,Te;const r=Fl(),n=br(),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[d,u]=k.useState(!1),[p,f]=k.useState([]),[y,_]=k.useState(!1),b=k.useRef(null),{user:N,profile:w,signOut:S}=npe();c3e(s,N==null?void 0:N.id),d3e(s,N==null?void 0:N.id);const C=((fe=s.agent)==null?void 0:fe.full_name)||"Agent",A=s.siteTitle||`${C} Real Estate`,I=s.brokerageLegalName?`${C} | ${s.brokerageLegalName}`:C,L=Ae=>{if(!Ae)return Ae;const ze=C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ee=new RegExp(`^\\s*${ze}\\s*[|\\-–—:]\\s*`,"i");return Ae.replace(Ee,"").trim()},O=A&&A!==`${C} Real Estate`?A:null,U=O?L(O):null,q=U&&U.toLowerCase()!==C.toLowerCase()?U:null,$=r.pathname==="/search",V=r.pathname==="/",ee=s.leadRegistrationMode!=="disabled",Z="#c9a96e";k.useEffect(()=>{const Ae=()=>_(window.scrollY>80);return window.addEventListener("scroll",Ae,{passive:!0}),()=>window.removeEventListener("scroll",Ae)},[]),k.useEffect(()=>{(async()=>{const{data:ze}=await G.from("lead_site_city_pages").select("city_name, city_slug").eq("site_id",s.id).eq("is_published",!0).order("sort_order",{ascending:!0});f(ze||[])})()},[s.id]),k.useEffect(()=>{const Ae=ze=>{b.current&&!b.current.contains(ze.target)&&u(!1)};return document.addEventListener("mousedown",Ae),()=>document.removeEventListener("mousedown",Ae)},[]);const J=[{to:"/",label:"Home"},{to:"/search",label:"Search"},{to:"/sell",label:"Sell"},{to:"/blog",label:"Blog"},{to:"/community",label:"Community"},{to:"/about",label:"About"},{to:"/contact",label:"Contact"}],Y=s.siteTitle||`${C} - Real Estate`,ce=s.siteTagline||`Browse homes and listings with ${C}`,ae=s.ogImageUrl||((xe=s.agent)==null?void 0:xe.avatar_url)||"",ie=`https://${s.subdomainSlug||""}.thelocalmove.com`,le=V?y?"bg-[#0d0b0a]/95 backdrop-blur-lg border-b border-white/5":"bg-transparent":"bg-[#0d0b0a] border-b border-white/5";return e.jsxs("div",{className:`flex flex-col ${$?"h-screen overflow-hidden":"min-h-screen"} bg-[#0d0b0a]`,children:[e.jsx(o3e,{siteConfig:s,pagePath:r.pathname}),e.jsx(l3e,{siteConfig:s}),e.jsxs(Nc,{children:[e.jsx("title",{children:Y}),e.jsx("meta",{name:"description",content:ce}),e.jsx("meta",{property:"og:title",content:Y}),e.jsx("meta",{property:"og:description",content:ce}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:ie+r.pathname}),ae&&e.jsx("meta",{property:"og:image",content:ae}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:Y}),e.jsx("meta",{name:"twitter:description",content:ce}),ae&&e.jsx("meta",{name:"twitter:image",content:ae}),s.faviconUrl&&e.jsx("link",{rel:"icon",href:s.faviconUrl,type:"image/png"}),e.jsx("link",{rel:"canonical",href:`${ie}${r.pathname}`}),e.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&display=swap",rel:"stylesheet"})]}),e.jsxs("header",{className:`${V?"fixed":"sticky"} top-0 left-0 right-0 z-50 transition-all duration-500 ${le}`,children:[e.jsx("div",{className:"max-w-7xl mx-auto px-6 lg:px-8",children:e.jsxs("div",{className:"flex items-center justify-between h-20",children:[e.jsx(da,{to:"/",className:"flex items-center gap-3 min-w-0",children:e.jsxs("span",{className:"flex flex-col leading-none max-w-[320px] xl:max-w-[420px]",children:[e.jsx("span",{className:"block whitespace-normal text-white text-xl tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:I}),q&&e.jsx("span",{className:"mt-1 text-[11px] tracking-[0.18em] uppercase text-white/70",children:q})]})}),e.jsxs("nav",{className:"hidden lg:flex items-center gap-1",children:[J.map(Ae=>e.jsx(da,{to:Ae.to,className:`px-4 py-2 text-xs tracking-[0.15em] uppercase transition-colors duration-300 ${r.pathname===Ae.to?"text-white":"text-white/40 hover:text-white"}`,children:Ae.label},Ae.to)),p.length>0&&e.jsxs("div",{ref:b,className:"relative",children:[e.jsxs("button",{onClick:()=>u(!d),className:`flex items-center gap-1 px-4 py-2 text-xs tracking-[0.15em] uppercase transition-colors duration-300 ${r.pathname.startsWith("/homes-for-sale-in-")?"text-white":"text-white/40 hover:text-white"}`,children:["Cities ",e.jsx(Fi,{className:`h-3 w-3 transition-transform ${d?"rotate-180":""}`})]}),d&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-56 bg-[#1a1715] border border-white/10 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-150",children:p.map(Ae=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${Ae.city_slug}`),u(!1)},className:"w-full text-left px-5 py-2.5 text-xs tracking-wider text-white/50 hover:text-white hover:bg-white/5 uppercase transition-colors",children:Ae.city_name},Ae.city_slug))})]}),N?e.jsxs("div",{className:"flex items-center gap-1 ml-3",children:[e.jsxs(da,{to:"/account",className:"flex items-center gap-1.5 px-3 py-2 text-xs tracking-wider text-white/40 hover:text-white uppercase transition-colors",children:[e.jsx(Za,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Saved"})]}),e.jsxs(da,{to:"/account",className:"flex items-center gap-1.5 px-3 py-2 text-xs tracking-wider text-white/40 hover:text-white uppercase transition-colors",children:[e.jsx(Ei,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:((he=w==null?void 0:w.name)==null?void 0:he.split(" ")[0])||"Account"})]})]}):ee?e.jsx("button",{onClick:()=>i(!0),className:"ml-3 px-5 py-2 text-xs tracking-[0.2em] uppercase border border-white/20 text-white/60 hover:bg-white hover:text-black transition-all duration-500",children:"Sign In"}):null]}),e.jsxs("button",{onClick:()=>o(!a),className:"lg:hidden p-2 text-white/60 hover:text-white",children:[e.jsx("div",{className:"flex flex-col items-center gap-0.5",children:a?e.jsx(Sr,{className:"h-5 w-5"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-px bg-current"}),e.jsx("div",{className:"w-4 h-px bg-current mt-1.5"}),e.jsx("div",{className:"w-6 h-px bg-current mt-1.5"})]})}),e.jsx("span",{className:"text-[8px] tracking-[0.3em] uppercase mt-1 block",children:"MENU"})]})]})}),a&&e.jsx("div",{className:"lg:hidden border-t border-white/5 bg-[#0d0b0a]/98 backdrop-blur-lg",children:e.jsxs("div",{className:"px-6 py-4 space-y-1",children:[J.map(Ae=>e.jsx(da,{to:Ae.to,onClick:()=>o(!1),className:`block px-3 py-3 text-xs tracking-[0.2em] uppercase transition-colors ${r.pathname===Ae.to?"text-white":"text-white/40 hover:text-white"}`,children:Ae.label},Ae.to)),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-4 pb-2 text-[10px] tracking-[0.3em] uppercase",style:{color:Z},children:"Cities"}),p.map(Ae=>e.jsx(da,{to:`/homes-for-sale-in-${Ae.city_slug}`,onClick:()=>o(!1),className:"block px-3 py-2.5 text-xs tracking-wider text-white/40 hover:text-white uppercase transition-colors",children:Ae.city_name},Ae.city_slug))]}),N?e.jsxs(e.Fragment,{children:[e.jsx(da,{to:"/account",onClick:()=>o(!1),className:"block px-3 py-3 text-xs tracking-[0.2em] uppercase text-white/40 hover:text-white",children:"My Account"}),e.jsx("button",{onClick:async()=>{await S(),o(!1)},className:"block w-full text-left px-3 py-3 text-xs tracking-[0.2em] uppercase text-white/40 hover:text-white",children:"Sign Out"})]}):ee?e.jsx("button",{onClick:()=>{i(!0),o(!1)},className:"block w-full text-left px-3 py-3 text-xs tracking-[0.2em] uppercase text-white/40 hover:text-white",children:"Sign In / Register"}):null]})})]}),e.jsx("main",{className:"flex-1 min-h-0 flex flex-col",children:t}),!$&&e.jsx("footer",{className:"bg-[#0a0908] text-white/30 border-t border-white/5",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8 py-20",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-16",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-white text-xl tracking-tight mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:C}),e.jsx("p",{className:"text-white/20 text-xs tracking-[0.15em] uppercase mb-6",children:((we=s.agent)==null?void 0:we.title)||"Real Estate Professional"}),((Ne=s.agent)==null?void 0:Ne.phone)&&e.jsxs("a",{href:`tel:${s.agent.phone}`,className:"flex items-center gap-3 text-sm text-white/30 hover:text-white transition-colors mb-3",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," ",s.agent.phone]}),((Ve=s.agent)==null?void 0:Ve.email)&&e.jsxs("a",{href:`mailto:${s.agent.email}`,className:"flex items-center gap-3 text-sm text-white/30 hover:text-white transition-colors",children:[e.jsx(tr,{className:"h-3.5 w-3.5"})," ",s.agent.email]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs tracking-[0.3em] uppercase mb-6",style:{color:Z},children:"Quick Links"}),e.jsx("ul",{className:"space-y-3",children:J.map(Ae=>e.jsx("li",{children:e.jsx(da,{to:Ae.to,className:"text-xs tracking-wider uppercase text-white/30 hover:text-white transition-colors",children:Ae.label})},Ae.to))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs tracking-[0.3em] uppercase mb-6",style:{color:Z},children:"Get In Touch"}),e.jsx("p",{className:"text-sm text-white/20 leading-relaxed mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:"Ready to experience luxury real estate? Let's connect."}),e.jsx(da,{to:"/contact",className:"inline-block px-8 py-3 text-xs tracking-[0.3em] uppercase border border-white/15 text-white/50 hover:bg-white hover:text-black transition-all duration-500",children:"Contact Me"})]})]}),e.jsxs("div",{className:"mt-16 pt-8 border-t border-white/5",children:[s.showTeamLogo&&s.teamLogoUrl&&e.jsx("div",{className:"flex items-center justify-center mb-6",children:e.jsx("img",{src:s.teamLogoUrl,alt:"Team",className:"h-10 w-auto object-contain opacity-40"})}),s.brokerageLegalName&&e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-[10px] text-white/15 tracking-wider uppercase mb-3",children:[e.jsxs("span",{children:[C," · ",s.brokerageLegalName]}),s.agentLicenseNumber&&e.jsx("span",{children:s.agentLicenseNumber}),s.brokerageLicenseNumber&&e.jsxs("span",{children:["Brokerage #",s.brokerageLicenseNumber]})]}),s.mlsDisclaimerText&&e.jsxs("div",{className:"flex items-start justify-center gap-3 mb-4",children:[s.mlsLogoUrl&&e.jsx("img",{src:s.mlsLogoUrl,alt:"MLS",className:"h-6 w-auto flex-shrink-0 mt-0.5 opacity-30"}),e.jsx("p",{className:"text-[10px] text-white/15 leading-relaxed max-w-3xl text-center",children:s.mlsDisclaimerText})]}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-[10px] text-white/15 tracking-wider uppercase",children:[s.equalHousingEnabled&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"h-4 w-4",children:e.jsx("path",{d:"M12 2L2 8v2h20V8L12 2zm0 2.5L18.5 8h-13L12 4.5zM4 12v8h4v-6h8v6h4v-8H4zm6 8v-4h4v4h-4z"})}),e.jsx("span",{children:"Equal Housing Opportunity"})]}),e.jsxs("span",{children:["© ",new Date().getFullYear()," ",C,". Powered by LevelUp."]})]})]})]})}),!$&&((Te=s.agent)==null?void 0:Te.avatar_url)&&e.jsx(_Ts,{agent:s.agent,accentColor:Z}),l&&e.jsx(i3e,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1),theme:"luxury",accentColor:Z})]})}function _Ts({agent:t,accentColor:s}){var o;const[r,n]=k.useState(!1),a=br();return t?e.jsx("div",{className:"fixed bottom-6 right-6 z-40",children:r?e.jsxs("div",{className:"bg-[#1a1715] border border-white/10 w-72 overflow-hidden animate-in slide-in-from-bottom-4 fade-in duration-200",children:[e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-12 w-12 rounded-full object-cover ring-1 ring-white/10"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white text-sm font-medium",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:t.full_name}),e.jsx("p",{className:"text-white/30 text-[10px] tracking-[0.1em] uppercase",children:t.title||"Real Estate Professional"})]})]}),e.jsxs("div",{className:"space-y-2",children:[t.phone&&e.jsxs("a",{href:`tel:${t.phone}`,className:"flex items-center gap-2 w-full px-3 py-2.5 bg-white/5 hover:bg-white/10 text-xs text-white/50 hover:text-white transition-colors tracking-wider",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," ",t.phone]}),t.email&&e.jsxs("a",{href:`mailto:${t.email}`,className:"flex items-center gap-2 w-full px-3 py-2.5 bg-white/5 hover:bg-white/10 text-xs text-white/50 hover:text-white transition-colors tracking-wider",children:[e.jsx(tr,{className:"h-3.5 w-3.5"})," Email Me"]}),e.jsx("button",{onClick:()=>{n(!1),a("/contact")},className:"w-full px-3 py-2.5 text-xs tracking-[0.2em] uppercase text-black hover:opacity-90 transition-colors",style:{backgroundColor:s},children:"Send a Message"})]})]}),e.jsx("button",{onClick:()=>n(!1),className:"absolute top-3 right-3 p-1 text-white/20 hover:text-white/50",children:e.jsx(Sr,{className:"h-4 w-4"})})]}):e.jsxs("button",{onClick:()=>n(!0),className:"group flex items-center gap-3 bg-[#1a1715] border border-white/10 pl-1.5 pr-5 py-1.5 hover:border-white/20 transition-all",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-10 w-10 rounded-full object-cover ring-1 ring-white/10"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-[11px] text-white leading-none",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:(o=t.full_name)==null?void 0:o.split(" ")[0]}),e.jsx("p",{className:"text-[9px] tracking-[0.15em] uppercase mt-1",style:{color:s},children:"Let's connect →"})]})]})}):null}const N6="#2c1810",Ny="#b8860b";function bTs({children:t,siteConfig:s}){var q,$,V;const r=Fl();br();const[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState([]),[f,y]=k.useState(!1),_=k.useRef(null),{user:b,profile:N,signOut:w}=npe();c3e(s,b==null?void 0:b.id),d3e(s,b==null?void 0:b.id);const S=((q=s.agent)==null?void 0:q.full_name)||"Agent",C=s.siteTitle||`${S} Land & Ranch`,A=r.pathname==="/",I=s.leadRegistrationMode!=="disabled";k.useEffect(()=>{const ee=()=>y(window.scrollY>80);return window.addEventListener("scroll",ee,{passive:!0}),()=>window.removeEventListener("scroll",ee)},[]),k.useEffect(()=>{(async()=>{const{data:Z}=await G.from("lead_site_city_pages").select("city_name, city_slug").eq("site_id",s.id).eq("is_published",!0).order("sort_order");Z&&p(Z)})()},[s.id]),k.useEffect(()=>{const ee=Z=>{_.current&&!_.current.contains(Z.target)&&d(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[]);const L=[{label:"Home",path:"/"},{label:"Search Properties",path:"/search"},{label:"About",path:"/about"},{label:"Contact",path:"/contact"}],O=f||!A?"bg-white/95 backdrop-blur-md shadow-sm":"bg-transparent",U=f||!A?N6:"#ffffff";return e.jsxs("div",{className:"min-h-screen",style:{fontFamily:"'Lora', Georgia, serif"},children:[e.jsxs(Nc,{children:[e.jsx("title",{children:C}),e.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700;800&family=Lora:wght@400;500;600&display=swap",rel:"stylesheet"})]}),e.jsx(o3e,{siteConfig:s}),e.jsx(l3e,{siteConfig:s}),e.jsxs("header",{className:`fixed top-0 left-0 right-0 z-50 transition-all duration-300 ${O}`,children:[e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6",children:e.jsxs("div",{className:"flex items-center justify-between h-16 md:h-20",children:[e.jsxs(da,{to:"/",className:"flex items-center gap-2.5",children:[e.jsx(kM,{className:"w-7 h-7",style:{color:Ny}}),e.jsx("span",{className:"text-lg font-bold tracking-wide",style:{color:U,fontFamily:"'Playfair Display', Georgia, serif"},children:C})]}),e.jsxs("nav",{className:"hidden md:flex items-center gap-1",children:[L.map(ee=>e.jsx(da,{to:ee.path,className:"px-4 py-2 text-sm font-medium tracking-wide uppercase transition-colors hover:opacity-80",style:{color:r.pathname===ee.path?Ny:U},children:ee.label},ee.path)),u.length>0&&e.jsxs("div",{ref:_,className:"relative",children:[e.jsxs("button",{onClick:()=>d(!i),className:"px-4 py-2 text-sm font-medium tracking-wide uppercase flex items-center gap-1 transition-colors hover:opacity-80",style:{color:U},children:["Areas ",e.jsx(Fi,{className:`w-3.5 h-3.5 transition-transform ${i?"rotate-180":""}`})]}),i&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-56 bg-white rounded-xl shadow-xl border border-gray-100 py-2 animate-in fade-in-0 slide-in-from-top-2",children:u.map(ee=>e.jsx(da,{to:`/homes-for-sale-in-${ee.city_slug}`,className:"block px-4 py-2.5 text-sm hover:bg-gray-50 transition-colors",style:{color:N6},onClick:()=>d(!1),children:ee.city_name},ee.city_slug))})]}),b?e.jsx("div",{className:"flex items-center gap-2 ml-3",children:e.jsxs(da,{to:"/account",className:"px-4 py-2 text-sm font-medium rounded-full border-2 transition-all hover:scale-105",style:{borderColor:Ny,color:U},children:[e.jsx(Ei,{className:"w-4 h-4 inline mr-1.5"}),(N==null?void 0:N.name)||"Account"]})}):I?e.jsx("button",{onClick:()=>l(!0),className:"ml-3 px-5 py-2.5 text-sm font-semibold text-white rounded-full hover:shadow-lg transition-all hover:scale-105",style:{backgroundColor:Ny},children:"Sign In"}):null]}),e.jsx("button",{onClick:()=>a(!n),className:"md:hidden p-2",style:{color:U},children:n?e.jsx(Sr,{className:"w-6 h-6"}):e.jsx(hS,{className:"w-6 h-6"})})]})}),n&&e.jsx("div",{className:"md:hidden bg-white border-t border-gray-100 shadow-xl animate-in slide-in-from-top-2",children:e.jsxs("div",{className:"px-4 py-4 space-y-1",children:[L.map(ee=>e.jsx(da,{to:ee.path,className:"block px-4 py-3 text-base font-medium rounded-lg hover:bg-gray-50 transition-colors",style:{color:r.pathname===ee.path?Ny:N6},onClick:()=>a(!1),children:ee.label},ee.path)),u.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-4 py-2 text-xs font-semibold tracking-wider uppercase text-gray-400",children:"Areas"}),u.map(ee=>e.jsx(da,{to:`/homes-for-sale-in-${ee.city_slug}`,className:"block px-4 py-2.5 text-sm rounded-lg hover:bg-gray-50",style:{color:N6},onClick:()=>a(!1),children:ee.city_name},ee.city_slug))]}),!b&&I&&e.jsx("button",{onClick:()=>{l(!0),a(!1)},className:"w-full mt-3 px-5 py-3 text-white font-semibold rounded-full",style:{backgroundColor:Ny},children:"Sign In"})]})})]}),e.jsx("main",{children:t}),e.jsx("footer",{className:"py-16 px-4",style:{backgroundColor:N6},children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-10",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(kM,{className:"w-6 h-6",style:{color:Ny}}),e.jsx("span",{className:"text-lg font-bold text-white",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:C})]}),e.jsx("p",{className:"text-white/60 text-sm leading-relaxed",children:"Your trusted specialist in land, ranch, and rural properties. Expert guidance for every acre."})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-semibold mb-4 text-sm tracking-wider uppercase",children:"Quick Links"}),e.jsx("div",{className:"space-y-2",children:L.map(ee=>e.jsx(da,{to:ee.path,className:"block text-white/60 hover:text-white text-sm transition-colors",children:ee.label},ee.path))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-semibold mb-4 text-sm tracking-wider uppercase",children:"Contact"}),e.jsxs("div",{className:"space-y-3",children:[(($=s.agent)==null?void 0:$.phone)&&e.jsxs("a",{href:`tel:${s.agent.phone}`,className:"flex items-center gap-2 text-white/60 hover:text-white text-sm transition-colors",children:[e.jsx(Tn,{className:"w-4 h-4",style:{color:Ny}}),s.agent.phone]}),((V=s.agent)==null?void 0:V.email)&&e.jsxs("a",{href:`mailto:${s.agent.email}`,className:"flex items-center gap-2 text-white/60 hover:text-white text-sm transition-colors",children:[e.jsx(tr,{className:"w-4 h-4",style:{color:Ny}}),s.agent.email]})]})]})]}),e.jsxs("div",{className:"mt-12 pt-8 border-t border-white/10 flex items-center justify-between",children:[e.jsxs("p",{className:"text-white/40 text-xs",children:["© ",new Date().getFullYear()," ",C,". All rights reserved."]}),e.jsx("div",{className:"h-px w-16",style:{backgroundColor:Ny}})]})]})}),o&&e.jsx(i3e,{open:o,mode:s.leadRegistrationMode==="required"?"required":"optional",siteConfig:s,onSkip:()=>l(!1),onComplete:()=>l(!1)})]})}const wTs=k.lazy(()=>Ua(()=>import("./LeadSiteHome-C0VWathR.js"),__vite__mapDeps([0,1,2,3]))),jTs=k.lazy(()=>Ua(()=>import("./LeadSiteLuxuryHome-Bd5v9Pba.js"),__vite__mapDeps([4,2,3]))),NTs=k.lazy(()=>Ua(()=>import("./LeadSiteLandRanchHome-Bde4g3d5.js"),__vite__mapDeps([5,1,2,3]))),kTs=k.lazy(()=>Ua(()=>import("./LeadSiteSearch-BKCm_uay.js"),__vite__mapDeps([6,1,7,3,8]))),STs=k.lazy(()=>Ua(()=>import("./LeadSiteLuxurySearch-CCJuwrqP.js"),__vite__mapDeps([9,1,7,3,8]))),CTs=k.lazy(()=>Ua(()=>import("./LeadSiteListingDetail-C4oQriBS.js"),__vite__mapDeps([10,11,3,12]))),MTs=k.lazy(()=>Ua(()=>import("./LeadSiteLuxuryListingDetail-CiPcqG2h.js"),__vite__mapDeps([13,11,3,12]))),TTs=k.lazy(()=>Ua(()=>import("./LeadSiteAbout-DZH69eyT.js"),[])),ATs=k.lazy(()=>Ua(()=>import("./LeadSiteLuxuryAbout-CVXoAEXJ.js"),[])),ETs=k.lazy(()=>Ua(()=>import("./LeadSiteContact-DKUzoJuz.js"),[])),PTs=k.lazy(()=>Ua(()=>import("./LeadSiteLuxuryContact-D43helh5.js"),[])),ITs=k.lazy(()=>Ua(()=>import("./LeadSiteConsumerDashboard-BQZ_TCjb.js"),[])),iBe=k.lazy(()=>Ua(()=>import("./LeadSiteBlog-D_6CDm8_.js"),[])),LTs=k.lazy(()=>Ua(()=>import("./LeadSiteCommunity-DwA6n9RL.js"),[])),DTs=k.lazy(()=>Ua(()=>import("./LeadSiteSellers-D4eopjbt.js"),[])),RTs=k.lazy(()=>Ua(()=>import("./LeadSiteCityPage-BK9xXwki.js"),__vite__mapDeps([14,3,8]))),OTs=k.lazy(()=>Ua(()=>import("./LeadSiteCustomPage-DmmIdVpO.js"),[]));function FTs(){return e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-blue-600 border-t-transparent"})})}function zTs(){const{siteConfig:t,themeConfig:s,isLoading:r,error:n}=iTs();if(r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-blue-600 border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500",children:"Loading..."})]})});if(n||!t)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 p-6",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Site Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This lead site is not available or has not been set up yet."})]})});const a=(s==null?void 0:s.themeTier)==="luxury",o=(s==null?void 0:s.themeTier)==="land-ranch",l=o?bTs:a?vTs:gTs,i=o?e.jsx(NTs,{siteConfig:t,themeConfig:s??void 0}):a?e.jsx(jTs,{siteConfig:t,themeConfig:s??void 0}):e.jsx(wTs,{siteConfig:t,themeConfig:s??void 0});return e.jsx(lTs,{siteConfig:t,children:e.jsx(l,{siteConfig:t,children:e.jsx(k.Suspense,{fallback:e.jsx(FTs,{}),children:e.jsxs(Voe,{children:[e.jsx(_s,{path:"/",element:i}),e.jsx(_s,{path:"/search",element:a?e.jsx(STs,{siteConfig:t}):e.jsx(kTs,{siteConfig:t})}),e.jsx(_s,{path:"/listing/:mlsNumber",element:a?e.jsx(MTs,{siteConfig:t}):e.jsx(CTs,{siteConfig:t})}),e.jsx(_s,{path:"/about",element:a?e.jsx(ATs,{siteConfig:t}):e.jsx(TTs,{siteConfig:t})}),e.jsx(_s,{path:"/contact",element:a?e.jsx(PTs,{siteConfig:t}):e.jsx(ETs,{siteConfig:t})}),e.jsx(_s,{path:"/account",element:e.jsx(ITs,{siteConfig:t})}),e.jsx(_s,{path:"/blog",element:e.jsx(iBe,{siteConfig:t,isLuxury:a})}),e.jsx(_s,{path:"/blog/:slug",element:e.jsx(iBe,{siteConfig:t,isLuxury:a})}),e.jsx(_s,{path:"/sell",element:e.jsx(DTs,{siteConfig:t,themeConfig:s??void 0,isLuxury:a})}),e.jsx(_s,{path:"/community",element:e.jsx(LTs,{siteConfig:t,isLuxury:a})}),e.jsx(_s,{path:"/p/:pageSlug",element:e.jsx(OTs,{siteConfig:t})}),e.jsx(_s,{path:"/*",element:e.jsx(BTs,{siteConfig:t})})]})})})})}function BTs({siteConfig:t}){const r=Fl().pathname.match(/^\/homes-for-sale-in-(.+)$/);return r?e.jsx(RTs,{siteConfig:t,citySlugOverride:r[1]}):null}const $Ts=({team:t,onSelect:s})=>{const{data:r}=ft({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(Ie,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:s,children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Ft,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(mr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(Ye,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(cr,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(Be,{className:"space-y-3",children:[(r==null?void 0:r.leaderProfile)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(vn,{className:"h-6 w-6",children:[e.jsx(Ca,{src:r.leaderProfile.avatar_url||""}),e.jsx(_n,{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(km,{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(Ru,{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(Ye,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(Ye,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(Ye,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},qTs=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=$s(),l=o||(a.length>0?a[0].id:n),i=s?void 0:l||void 0,{teams:d,isLoading:u,createTeam:p,updateTeam:f,deleteTeam:y,addMember:_,removeMember:b,updateMemberRole:N}=TC(i),[w,S]=k.useState(!1),[C,A]=k.useState(null),{data:I}=ft({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:U,error:q}=await G.from("brokerages").select("id, name").order("name");if(q)throw q;return U||[]},enabled:s}),{data:L}=ft({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:U,error:q}=await G.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(q)throw q;return U||[]},enabled:!!l}),O=async U=>{const q=U.brokerage_id||l||null,$=await p.mutateAsync({name:U.name,brokerage_id:q,description:U.description});if(U.leaderId&&U.leaderId!=="none"&&await _.mutateAsync({team_id:$.id,user_id:U.leaderId,role:"team_leader"}),U.memberIds)for(const V of U.memberIds)await _.mutateAsync({team_id:$.id,user_id:V,role:"team_member"});S(!1)};return!r&&!s?e.jsx(Ls,{title:"Teams",description:"Team Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(cr,{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(Ls,{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:()=>S(!0),children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(Rtt,{open:w,onOpenChange:S,onCreateTeam:O,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(U=>e.jsx(Ie,{children:e.jsxs(Be,{className:"p-6",children:[e.jsx(Ss,{className:"h-5 w-32 mb-3"}),e.jsx(Ss,{className:"h-4 w-48 mb-4"}),e.jsx(Ss,{className:"h-8 w-full"})]})},U))}),!u&&d.length===0&&!C&&e.jsx(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(cr,{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:()=>S(!0),children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!u&&d.length>0&&!C&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:d.map(U=>e.jsx($Ts,{team:U,onSelect:()=>A(U)},U.id))}),C&&e.jsx(Dtt,{team:C,brokerageAgents:L||[],onBack:()=>A(null),onUpdate:U=>f.mutateAsync({id:C.id,...U}).then(q=>A(q)),onAddMember:(U,q)=>_.mutateAsync({team_id:C.id,user_id:U,role:q}),onRemoveMember:U=>b.mutateAsync({team_id:C.id,member_id:U}),onUpdateRole:(U,q)=>N.mutateAsync({team_id:C.id,member_id:U,role:q}),onDeleteTeam:()=>y.mutate(C.id),isUpdating:f.isPending,isAddingMember:_.isPending})]})})},UTs=()=>{const{data:t,isLoading:s}=Rx(),{useTeamMembers:r}=TC(),{data:n=[],isLoading:a}=r((t==null?void 0:t.teamId)||"");if(s)return e.jsx(Ls,{title:"My Team",description:"Your team",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ss,{className:"h-8 w-48"}),e.jsx(Ss,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Ls,{title:"My Team",description:"Your team",children:e.jsx(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(cr,{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(Ls,{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(Ye,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(km,{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(ta,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(Qn,{className:"flex-wrap",children:[e.jsx(ls,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(ls,{value:"contacts",children:[e.jsx(eS,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(ls,{value:"lead-pond",children:[e.jsx(Lg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(ls,{value:"shared-assets",children:[e.jsx(Sm,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]})]}),e.jsx(js,{value:"members",className:"space-y-2",children:a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(l=>e.jsx(Ss,{className:"h-16 w-full"},l))}):n.map(l=>{var i,d,u,p;return e.jsx(Ie,{children:e.jsxs(Be,{className:"flex items-center gap-3 p-4",children:[e.jsxs(vn,{className:"h-10 w-10",children:[e.jsx(Ca,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(_n,{children:(((d=l.profile)==null?void 0:d.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium",children:((u=l.profile)==null?void 0:u.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(p=l.profile)==null?void 0:p.email})]}),l.role==="team_leader"?e.jsxs(Ye,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(km,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(Ye,{variant:"secondary",className:"ml-auto",children:"Member"})]})},l.id)})}),o.contact_visibility!=="private"&&e.jsx(js,{value:"contacts",className:"space-y-4",children:e.jsx(k4e,{})}),o.lead_pond_enabled&&e.jsx(js,{value:"lead-pond",className:"space-y-4",children:e.jsx(S4e,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(js,{value:"shared-assets",className:"space-y-4",children:e.jsx(Ltt,{teamId:t.teamId})})]})]})})};function VTs(){const{user:t}=$s(),s=es(),r=ft({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:S}=await G.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(S)throw S;return w},enabled:!!t}),n=ft({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:S}=await G.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(S)throw S;return w},enabled:!!t}),a=ft({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:S}=await G.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(S)throw S;return w},enabled:!!t}),o=ft({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:S}=await G.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(S)throw S;return w},enabled:!!t}),l=ft({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:S}=await G.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(S)throw S;return w},enabled:!!t}),i=Et({mutationFn:async()=>{const{data:w,error:S}=await G.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(S)throw S;const C=[{name:"Listing Consultation",description:"Get a comprehensive market analysis and listing strategy for your home",duration_minutes:60,color:"#10B981",icon:"Home",sort_order:0},{name:"Buyer Consultation",description:"Discuss your home search criteria, budget, and buying process",duration_minutes:45,color:"#3B82F6",icon:"Search",sort_order:1},{name:"Home Valuation",description:"Find out what your home is worth in today's market",duration_minutes:30,color:"#F59E0B",icon:"DollarSign",sort_order:2},{name:"General Meeting",description:"Coffee chat, check-in, or quick real estate question",duration_minutes:30,color:"#8B5CF6",icon:"Coffee",sort_order:3}],{error:A}=await G.from("agent_booking_types").insert(C.map(O=>({...O,user_id:t.id})));if(A)throw A;const I=[1,2,3,4,5].map(O=>({user_id:t.id,day_of_week:O,start_time:"09:00",end_time:"17:00"})),{error:L}=await G.from("agent_availability_slots").insert(I);if(L)throw L;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),me.success("Scheduler set up successfully!")},onError:w=>me.error(w.message)}),d=Et({mutationFn:async w=>{const{error:S}=await G.from("agent_booking_settings").update(w).eq("user_id",t.id);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),me.success("Settings updated")},onError:w=>me.error(w.message)}),u=Et({mutationFn:async w=>{const S={...w,user_id:t.id};if(w.id){const{error:C}=await G.from("agent_booking_types").update(S).eq("id",w.id);if(C)throw C}else{const{error:C}=await G.from("agent_booking_types").insert(S);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type saved")},onError:w=>me.error(w.message)}),p=Et({mutationFn:async w=>{const{error:S}=await G.from("agent_booking_types").delete().eq("id",w);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type deleted")},onError:w=>me.error(w.message)}),f=Et({mutationFn:async w=>{const S={...w,user_id:t.id};if(w.id){const{error:C}=await G.from("agent_availability_slots").update(S).eq("id",w.id);if(C)throw C}else{const{error:C}=await G.from("agent_availability_slots").insert(S);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>me.error(w.message)}),y=Et({mutationFn:async w=>{const{error:S}=await G.from("agent_availability_slots").delete().eq("id",w);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>me.error(w.message)}),_=Et({mutationFn:async w=>{const{error:S}=await G.from("agent_blocked_dates").insert({...w,user_id:t.id});if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),me.success("Date blocked")},onError:w=>me.error(w.message)}),b=Et({mutationFn:async w=>{const{error:S}=await G.from("agent_blocked_dates").delete().eq("id",w);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:w=>me.error(w.message)}),N=Et({mutationFn:async({id:w,reason:S})=>{const{error:C}=await G.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:S}).eq("id",w);if(C)throw C},onSuccess:()=>{s.invalidateQueries({queryKey:["bookings"]}),me.success("Booking cancelled")},onError:w=>me.error(w.message)});return{settings:r.data,bookingTypes:n.data??[],availability:a.data??[],blockedDates:o.data??[],bookings:l.data??[],isLoading:r.isLoading,initializeSettings:i,updateSettings:d,upsertBookingType:u,deleteBookingType:p,upsertAvailability:f,deleteAvailability:y,addBlockedDate:_,removeBlockedDate:b,cancelBooking:N}}const oBe={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function HTs({types:t,onSave:s,onDelete:r}){const[n,a]=k.useState(null),[o,l]=k.useState(!1),i=()=>{a({name:"",description:"",duration_minutes:30,color:"#3B82F6",icon:"Calendar",is_active:!0,qualification_enabled:!1}),l(!0)},d=p=>{a({...p}),l(!0)},u=()=>{n!=null&&n.name&&(s(n),l(!1),a(null))};return e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Booking Types"}),e.jsx(mr,{children:"The meeting types prospects can book with you"})]}),e.jsxs(K,{onClick:i,size:"sm",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Type"]})]}),e.jsx(Be,{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:oBe[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(Ye,{variant:"secondary",className:"text-xs",children:"Inactive"}),p.qualification_enabled&&e.jsxs(Ye,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(NL,{className:"h-3 w-3"})," Qualifying"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(rn,{className:"h-3 w-3"}),p.duration_minutes," min",p.description&&e.jsxs("span",{children:["· ",p.description.slice(0,60),p.description.length>60?"...":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(p),children:e.jsx(pa,{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(yr,{className:"h-4 w-4"})})]})]},p.id))})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsxs(bs,{children:[n!=null&&n.id?"Edit":"New"," Booking Type"]})}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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(ge,{children:"Description"}),e.jsx(_r,{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(ge,{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(ge,{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(ge,{children:"Icon"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(oBe).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(ge,{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(ge,{children:"Pre-Qualification Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask qualifying questions before booking"})]}),e.jsx(Lr,{checked:n.qualification_enabled||!1,onCheckedChange:p=>a({...n,qualification_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{children:"Active"}),e.jsx(Lr,{checked:n.is_active??!0,onCheckedChange:p=>a({...n,is_active:p})})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:u,children:"Save"})]})]})})]})}const lBe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function GTs({slots:t,onSave:s,onDelete:r}){const[n,a]=k.useState(null),[o,l]=k.useState("09:00"),[i,d]=k.useState("17:00"),u=lBe.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"),d("17:00"))};return e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(rn,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(mr,{children:"Set your available hours for each day"})]}),e.jsx(Be,{className:"space-y-2",children:lBe.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 N,w;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(N=b.start_time)==null?void 0:N.slice(0,5),onBlur:S=>s({id:b.id,start_time:S.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:(w=b.end_time)==null?void 0:w.slice(0,5),onBlur:S=>s({id:b.id,end_time:S.target.value})}),e.jsx(Lr,{checked:b.is_active,onCheckedChange:S=>s({id:b.id,is_active:S})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>r(b.id),children:e.jsx(yr,{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=>d(b.target.value)}),e.jsx(K,{size:"sm",className:"h-8",onClick:p,children:"Add"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8",onClick:()=>a(null),children:"Cancel"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>a(y),children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},f)})})]})}const WTs={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 KTs({bookings:t,onCancel:s}){const r=t.filter(o=>o.status==="confirmed"&&new Date(o.booking_date)>=new Date(new Date().toDateString())),n=t.filter(o=>o.status!=="confirmed"||new Date(o.booking_date){var i,d;return e.jsxs("div",{className:"flex items-start justify-between p-4 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ei,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:o.guest_name}),e.jsx(Ye,{className:`text-xs ${WTs[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(xd,{className:"h-3.5 w-3.5"}),gs(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(rn,{className:"h-3.5 w-3.5"}),(i=o.start_time)==null?void 0:i.slice(0,5)," - ",(d=o.end_time)==null?void 0:d.slice(0,5)]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[o.guest_email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(tr,{className:"h-3 w-3"}),o.guest_email]}),o.guest_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(Ye,{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(Ql,{className:"h-4 w-4 mr-1"})," Cancel"]})]},o.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Upcoming Bookings"}),e.jsxs(mr,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(Be,{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(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Past & Cancelled"})}),e.jsx(Be,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function ZTs({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,d]=k.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),d(""))};return e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(dL,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(mr,{children:"Block specific dates (vacations, holidays, etc.)"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>a(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Block Date"]})]}),e.jsxs(Be,{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=>d(p.target.value),className:"flex-1"}),e.jsx(K,{size:"sm",onClick:u,children:"Add"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>a(!1),children:"Cancel"})]}),t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No blocked dates"}):e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(p=>e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full border bg-muted/50 text-sm",children:[e.jsx("span",{children:gs(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(Sr,{className:"h-3.5 w-3.5"})})]},p.id))})]})]})}function YTs(){const{settings:t,bookingTypes:s,availability:r,blockedDates:n,bookings:a,isLoading:o,initializeSettings:l,updateSettings:i,upsertBookingType:d,deleteBookingType:u,upsertAvailability:p,deleteAvailability:f,addBlockedDate:y,removeBlockedDate:_,cancelBooking:b}=VTs(),[N,w]=k.useState(""),[S,C]=k.useState(15);N||t!=null&&t.meeting_link;const A=t!=null&&t.slug?`https://booking.relevelup.com/${t.slug}`:null;return o?e.jsx(Ls,{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(Ls,{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(xd,{className:"h-6 w-6 text-primary"}),"LevelUp Scheduler"]}),e.jsx("p",{className:"text-muted-foreground",children:"Manage your booking types, availability, and appointments"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(A),me.success("Booking link copied!")},children:[e.jsx(Ya,{className:"h-4 w-4 mr-1"})," Copy Link"]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:A,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Kr,{className:"h-4 w-4 mr-1"})," Preview"]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{htmlFor:"scheduler-active",className:"text-sm",children:"Active"}),e.jsx(Lr,{id:"scheduler-active",checked:t.is_active,onCheckedChange:I=>i.mutate({is_active:I})})]})]})]}),e.jsxs(ta,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"types",children:"Booking Types"}),e.jsx(ls,{value:"availability",children:"Availability"}),e.jsx(ls,{value:"settings",children:"Settings"}),e.jsxs(ls,{value:"bookings",children:["Bookings",a.filter(I=>I.status==="confirmed").length>0&&e.jsx(Ye,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(I=>I.status==="confirmed").length})]})]}),e.jsx(js,{value:"types",children:e.jsx(HTs,{types:s,onSave:I=>d.mutate(I),onDelete:I=>u.mutate(I)})}),e.jsx(js,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(GTs,{slots:r,onSave:I=>p.mutate(I),onDelete:I=>f.mutate(I)}),e.jsx(ZTs,{blockedDates:n,onAdd:I=>y.mutate(I),onRemove:I=>_.mutate(I)})]})}),e.jsx(js,{value:"settings",children:e.jsxs(Ie,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(OL,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(mr,{children:"Configure your booking page defaults"})]}),e.jsxs(Be,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{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:()=>{A&&(navigator.clipboard.writeText(A),me.success("Copied!"))},children:e.jsx(Ya,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:A})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ge,{htmlFor:"meeting-link",children:[e.jsx(Do,{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(ge,{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(ge,{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(ge,{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(js,{value:"bookings",children:e.jsx(KTs,{bookings:a,onCancel:I=>b.mutate({id:I})})})]})]})}):e.jsx(Ls,{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(xd,{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(Ie,{children:e.jsxs(Be,{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(jo,{}),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(qr,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const cBe=[{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 XTs(){const{user:t}=$s(),s=_a(),{toast:r}=va(),n=br(),a=es(),[o,l]=k.useState(!1),[i,d]=k.useState(null),[u,p]=k.useState(null),[f,y]=k.useState({title:"",description:"",page_type:"lead_capture"}),{data:_=[],isLoading:b}=ft({queryKey:["landing-pages",s],queryFn:async()=>{const{data:C,error:A}=await G.from("landing_pages").select("*").eq("user_id",s).order("created_at",{ascending:!1});if(A)throw A;return C},enabled:!!s}),N=Et({mutationFn:async()=>{const C=f.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")+"-"+Date.now().toString(36),{data:A}=await G.from("profiles").select("name, phone, avatar_url, email").eq("id",s).single(),I=f.page_type==="just_listed"||f.page_type==="just_sold",{data:L,error:O}=await G.from("landing_pages").insert({user_id:s,title:f.title,description:f.description||null,page_type:f.page_type,slug:C,hero_headline:I?f.page_type==="just_listed"?"🏡 Just Listed":"🎉 Just Sold":f.page_type==="lead_magnet"?"📥 Free Download":f.title,agent_name:(A==null?void 0:A.name)||null,agent_phone:(A==null?void 0:A.phone)||null,agent_email:(A==null?void 0:A.email)||t.email||null,agent_photo_url:(A==null?void 0:A.avatar_url)||null,property_status:I?f.page_type.replace("just_",""):null}).select().single();if(O)throw O;const U=QTs(f.page_type);if(U.length>0){const{error:q}=await G.from("landing_page_fields").insert(U.map(($,V)=>({...$,page_id:L.id,sort_order:V})));if(q)throw q}return L},onSuccess:C=>{a.invalidateQueries({queryKey:["landing-pages"]}),l(!1),y({title:"",description:"",page_type:"lead_capture"}),r({title:"Landing page created!"}),n(`/mission-control/landing-pages/${C.id}`)},onError:C=>r({title:"Error",description:C.message,variant:"destructive"})}),w=Et({mutationFn:async C=>{const{error:A}=await G.from("landing_pages").delete().eq("id",C);if(A)throw A},onSuccess:()=>{a.invalidateQueries({queryKey:["landing-pages"]}),d(null),r({title:"Landing page deleted"})}}),S=C=>`https://pages.relevelup.com/${C}`;return e.jsxs(Ls,{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(Bs,{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(Ie,{children:e.jsxs(Be,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(mn,{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(Bs,{className:"h-4 w-4 mr-2"})," Create Landing Page"]})]})}):e.jsx("div",{className:"grid gap-4",children:_.map(C=>{var A;return e.jsx(Ie,{className:"hover:shadow-md transition-shadow",children:e.jsx(Be,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>n(`/mission-control/landing-pages/${C.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:C.title}),e.jsx(Ye,{variant:C.is_published?"default":"secondary",className:"text-[10px]",children:C.is_published?"Published":"Draft"}),e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:((A=cBe.find(I=>I.id===C.page_type))==null?void 0:A.label)||C.page_type})]}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:C.description}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(jn,{className:"h-3 w-3"})," ",C.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mn,{className:"h-3 w-3"})," ",C.submission_count," submissions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[C.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>p(S(C.slug)),children:e.jsx(Qy,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(S(C.slug)),r({title:"Link copied!"})},children:e.jsx(Ya,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:S(C.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(Kr,{className:"h-3.5 w-3.5"})})})]}),e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsx(K,{size:"sm",variant:"ghost",children:e.jsx(cx,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",children:[e.jsxs(xa,{onClick:()=>n(`/mission-control/landing-pages/${C.id}`),children:[e.jsx(pa,{className:"h-3.5 w-3.5 mr-2"})," Edit"]}),e.jsxs(xa,{onClick:()=>d(C.id),className:"text-destructive",children:[e.jsx(yr,{className:"h-3.5 w-3.5 mr-2"})," Delete"]})]})]})]})]})})},C.id)})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Create Landing Page"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Page Title"}),e.jsx(Fe,{value:f.title,onChange:C=>y(A=>({...A,title:C.target.value})),placeholder:"e.g. Veterans Home & Land Expo"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Description (optional)"}),e.jsx(_r,{value:f.description,onChange:C=>y(A=>({...A,description:C.target.value})),placeholder:"Brief internal description...",rows:2})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Page Template"}),e.jsxs(zs,{value:f.page_type,onValueChange:C=>y(A=>({...A,page_type:C})),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:cBe.map(C=>e.jsx(yt,{value:C.id,children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:C.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:C.description})]})},C.id))})]})]})]}),e.jsxs(gn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>N.mutate(),disabled:!f.title.trim()||N.isPending,children:N.isPending?"Creating...":"Create Page"})]})]})}),e.jsx(Ll,{open:!!i,onOpenChange:()=>d(null),children:e.jsxs(fl,{children:[e.jsxs(xl,{children:[e.jsx(yl,{children:"Delete Landing Page?"}),e.jsx(vl,{children:"This will permanently delete this page and all its submissions."})]}),e.jsxs(gl,{children:[e.jsx(_l,{children:"Cancel"}),e.jsx(nl,{onClick:()=>i&&w.mutate(i),children:"Delete"})]})]})}),e.jsx(fs,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(ms,{className:"max-w-sm",children:[e.jsx(ks,{children:e.jsx(bs,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[u&&e.jsx(EO,{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(Ya,{className:"h-3.5 w-3.5 mr-1"})," Copy URL"]})]})]})})]})}function QTs(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 JTs=[{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 eAs(){const{pageId:t}=ho(),s=br(),{user:r}=$s(),n=_a(),{toast:a}=va(),o=es(),[l,i]=k.useState(null),[d,u]=k.useState(!1),{data:p,isLoading:f}=ft({queryKey:["landing-page",t],queryFn:async()=>{const{data:ae,error:ie}=await G.from("landing_pages").select("*").eq("id",t).single();if(ie)throw ie;return ae},enabled:!!t}),{data:y=[],isLoading:_}=ft({queryKey:["landing-page-fields",t],queryFn:async()=>{const{data:ae,error:ie}=await G.from("landing_page_fields").select("*").eq("page_id",t).order("sort_order");if(ie)throw ie;return ae},enabled:!!t}),{data:b=[]}=ft({queryKey:["landing-page-submissions",t],queryFn:async()=>{const{data:ae,error:ie}=await G.from("landing_page_submissions").select("*").eq("page_id",t).order("created_at",{ascending:!1});if(ie)throw ie;return ae},enabled:!!t}),{data:N=[]}=ft({queryKey:["my-listings-for-pages",n],queryFn:async()=>{const{data:ae,error:ie}=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(ie)throw ie;return ae},enabled:!!r&&((p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold")}),[w,S]=k.useState({title:"",hero_headline:"",hero_subtext:"",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",agent_name:"",agent_phone:"",agent_email:"",agent_photo_url:null,success_message:"Thank you! We'll be in touch soon.",is_published:!1,description:"",lead_magnet_file_url:null,lead_magnet_file_name:null,lead_magnet_external_url:null,listing_id:null,property_address:"",property_price:"",property_beds:"",property_baths:"",property_sqft:"",property_description:"",property_photos:[],property_status:"just_listed"}),[C,A]=k.useState([]);k.useEffect(()=>{p&&S({title:p.title,hero_headline:p.hero_headline,hero_subtext:p.hero_subtext||"",hero_image_url:p.hero_image_url,logo_url:p.logo_url,primary_color:p.primary_color,accent_color:p.accent_color,agent_name:p.agent_name||"",agent_phone:p.agent_phone||"",agent_email:p.agent_email||"",agent_photo_url:p.agent_photo_url,success_message:p.success_message||"Thank you! We'll be in touch soon.",is_published:p.is_published,description:p.description||"",lead_magnet_file_url:p.lead_magnet_file_url||null,lead_magnet_file_name:p.lead_magnet_file_name||null,lead_magnet_external_url:p.lead_magnet_external_url||null,listing_id:p.listing_id||null,property_address:p.property_address||"",property_price:p.property_price||"",property_beds:p.property_beds||"",property_baths:p.property_baths||"",property_sqft:p.property_sqft||"",property_description:p.property_description||"",property_photos:Array.isArray(p.property_photos)?p.property_photos:[],property_status:p.property_status||"just_listed"})},[p]),k.useEffect(()=>{y.length>0&&A(y.map(ae=>({id:ae.id,field_type:ae.field_type,label:ae.label,placeholder:ae.placeholder,is_required:ae.is_required,options:typeof ae.options=="string"?ae.options:ae.options?JSON.stringify(ae.options):null,sort_order:ae.sort_order})))},[y]);const I=Et({mutationFn:async()=>{const{error:ae}=await G.from("landing_pages").update({title:w.title,hero_headline:w.hero_headline,hero_subtext:w.hero_subtext||null,hero_image_url:w.hero_image_url,logo_url:w.logo_url,primary_color:w.primary_color,accent_color:w.accent_color,agent_name:w.agent_name||null,agent_phone:w.agent_phone||null,agent_email:w.agent_email||null,agent_photo_url:w.agent_photo_url,success_message:w.success_message,is_published:w.is_published,description:w.description||null,lead_magnet_file_url:w.lead_magnet_file_url,lead_magnet_file_name:w.lead_magnet_file_name,lead_magnet_external_url:w.lead_magnet_external_url,listing_id:w.listing_id,property_address:w.property_address||null,property_price:w.property_price||null,property_beds:w.property_beds||null,property_baths:w.property_baths||null,property_sqft:w.property_sqft||null,property_description:w.property_description||null,property_photos:w.property_photos,property_status:w.property_status,updated_at:new Date().toISOString()}).eq("id",t);if(ae)throw ae;if(await G.from("landing_page_fields").delete().eq("page_id",t),C.length>0){const{error:ie}=await G.from("landing_page_fields").insert(C.map((le,fe)=>({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:fe})));if(ie)throw ie}},onSuccess:()=>{o.invalidateQueries({queryKey:["landing-page",t]}),o.invalidateQueries({queryKey:["landing-page-fields",t]}),a({title:"Page saved!"})},onError:ae=>a({title:"Error",description:ae.message,variant:"destructive"})}),L=async(ae,ie)=>{const le=ae.name.split(".").pop(),fe=`landing-pages/${r.id}/${ie}-${Date.now()}.${le}`,{error:xe}=await G.storage.from("recruit-landing").upload(fe,ae);if(xe)throw xe;const{data:{publicUrl:he}}=G.storage.from("recruit-landing").getPublicUrl(fe);return he},O=async(ae,ie)=>{var fe;const le=(fe=ae.target.files)==null?void 0:fe[0];if(le){i(ie);try{const xe=await L(le,ie);S(he=>({...he,[ie]:xe})),a({title:"Image uploaded!"})}catch(xe){a({title:"Upload failed",description:xe.message,variant:"destructive"})}finally{i(null)}}},U=async ae=>{var le;const ie=(le=ae.target.files)==null?void 0:le[0];if(ie){i("lead_magnet");try{const fe=await L(ie,"lead-magnet");S(xe=>({...xe,lead_magnet_file_url:fe,lead_magnet_file_name:ie.name})),a({title:"File uploaded!"})}catch(fe){a({title:"Upload failed",description:fe.message,variant:"destructive"})}finally{i(null)}}},q=async ae=>{const ie=ae.target.files;if(!(!ie||ie.length===0)){i("property_photos");try{const le=[];for(const fe of Array.from(ie)){const xe=await L(fe,"property-photo");le.push(xe)}S(fe=>({...fe,property_photos:[...fe.property_photos,...le]})),a({title:`${le.length} photo(s) uploaded!`})}catch(le){a({title:"Upload failed",description:le.message,variant:"destructive"})}finally{i(null)}}},$=async ae=>{const ie=N.find(fe=>fe.id===ae);if(!ie)return;const{data:le}=await G.from("listing_photos").select("photo_url").eq("listing_id",ae).order("sort_order");S(fe=>({...fe,listing_id:ae,property_address:ie.property_address||`${ie.city}, ${ie.state}`,property_price:ie.price?`$${ie.price.toLocaleString()}`:"",property_beds:ie.bedrooms?String(ie.bedrooms):"",property_baths:ie.bathrooms?String(ie.bathrooms):"",property_sqft:ie.square_footage?ie.square_footage.toLocaleString():"",property_description:ie.description||"",property_photos:(le==null?void 0:le.map(xe=>xe.photo_url))||fe.property_photos})),a({title:"Listing data imported!"})},V=()=>{A(ae=>[...ae,{field_type:"text",label:"",placeholder:"",is_required:!1,options:null,sort_order:ae.length}])},ee=(ae,ie)=>{A(le=>le.map((fe,xe)=>xe===ae?{...fe,...ie}:fe))},Z=ae=>{A(ie=>ie.filter((le,fe)=>fe!==ae))},J=p?`https://pages.relevelup.com/${p.slug}`:"",Y=(p==null?void 0:p.page_type)==="lead_magnet",ce=(p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold";return f||_?e.jsx(Ls,{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(Ls,{title:w.title||"Edit Page",children:[e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/landing-pages"),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:w.title||"Untitled Page"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(Ye,{variant:w.is_published?"default":"secondary",className:"text-[10px]",children:w.is_published?"Published":"Draft"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(jn,{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(cr,{className:"h-3 w-3"})," ",b.length," submissions"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[w.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>u(!0),children:e.jsx(Qy,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(J),a({title:"Link copied!"})},children:[e.jsx(Ya,{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:J,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Kr,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(K,{onClick:()=>I.mutate(),disabled:I.isPending,children:[e.jsx(wc,{className:"h-4 w-4 mr-2"}),I.isPending?"Saving...":"Save"]})]})]}),e.jsxs(ta,{defaultValue:"design",children:[e.jsxs(Qn,{children:[e.jsx(ls,{value:"design",children:"Design"}),Y&&e.jsx(ls,{value:"lead_magnet",children:"Lead Magnet"}),ce&&e.jsx(ls,{value:"property",children:"Property Details"}),e.jsxs(ls,{value:"fields",children:["Form Fields (",C.length,")"]}),e.jsxs(ls,{value:"submissions",children:["Submissions (",b.length,")"]}),e.jsx(ls,{value:"settings",children:"Settings"})]}),e.jsxs(js,{value:"design",className:"space-y-4 mt-4",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Page Details"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Page Title (internal)"}),e.jsx(Fe,{value:w.title,onChange:ae=>S(ie=>({...ie,title:ae.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Description (internal)"}),e.jsx(Fe,{value:w.description,onChange:ae=>S(ie=>({...ie,description:ae.target.value}))})]})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Hero Section"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Headline"}),e.jsx(Fe,{value:w.hero_headline,onChange:ae=>S(ie=>({...ie,hero_headline:ae.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Subtext"}),e.jsx(_r,{value:w.hero_subtext,onChange:ae=>S(ie=>({...ie,hero_subtext:ae.target.value})),rows:2,placeholder:"A brief description..."})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.hero_image_url&&e.jsx("img",{src:w.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(Da,{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:ae=>O(ae,"hero_image_url")})]}),w.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>S(ae=>({...ae,hero_image_url:null})),children:e.jsx(yr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Branding"})}),e.jsxs(Be,{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(ge,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.logo_url&&e.jsx("img",{src:w.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="logo_url",children:e.jsxs("span",{children:[e.jsx(Da,{className:"h-3.5 w-3.5 mr-1"}),l==="logo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ae=>O(ae,"logo_url")})]})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.agent_photo_url&&e.jsx("img",{src:w.agent_photo_url,alt:"Agent",className:"h-10 w-10 rounded-full object-cover"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="agent_photo_url",children:e.jsxs("span",{children:[e.jsx(Da,{className:"h-3.5 w-3.5 mr-1"}),l==="agent_photo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ae=>O(ae,"agent_photo_url")})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:w.primary_color,onChange:ae=>S(ie=>({...ie,primary_color:ae.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Fe,{value:w.primary_color,onChange:ae=>S(ie=>({...ie,primary_color:ae.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:w.accent_color,onChange:ae=>S(ie=>({...ie,accent_color:ae.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Fe,{value:w.accent_color,onChange:ae=>S(ie=>({...ie,accent_color:ae.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Agent Info (shown on page)"})}),e.jsx(Be,{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(ge,{children:"Name"}),e.jsx(Fe,{value:w.agent_name,onChange:ae=>S(ie=>({...ie,agent_name:ae.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Phone"}),e.jsx(Fe,{value:w.agent_phone,onChange:ae=>S(ie=>({...ie,agent_phone:ae.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Email"}),e.jsx(Fe,{value:w.agent_email,onChange:ae=>S(ie=>({...ie,agent_email:ae.target.value}))})]})]})})]})]}),Y&&e.jsx(js,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Xa,{className:"h-4 w-4"})," Giveaway File"]})}),e.jsxs(Be,{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(ge,{children:"Upload File (PDF, guide, checklist, etc.)"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.lead_magnet_file_name&&e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(Xa,{className:"h-3 w-3"})," ",w.lead_magnet_file_name]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="lead_magnet",children:e.jsxs("span",{children:[e.jsx(Da,{className:"h-3.5 w-3.5 mr-1"}),l==="lead_magnet"?"Uploading...":"Upload File"]})}),e.jsx("input",{type:"file",className:"hidden",onChange:U})]}),w.lead_magnet_file_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>S(ae=>({...ae,lead_magnet_file_url:null,lead_magnet_file_name:null})),children:e.jsx(yr,{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(ge,{className:"flex items-center gap-1",children:[e.jsx(Do,{className:"h-3.5 w-3.5"})," External URL"]}),e.jsx(Fe,{value:w.lead_magnet_external_url||"",onChange:ae=>S(ie=>({...ie,lead_magnet_external_url:ae.target.value||null})),placeholder:"https://drive.google.com/... or https://dropbox.com/...",className:"mt-1"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Link to a file on Google Drive, Dropbox, or any URL"})]})]})]})}),ce&&e.jsxs(js,{value:"property",className:"space-y-4 mt-4",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Mn,{className:"h-4 w-4"})," Import from Listing Exchange"]})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pull property details and photos directly from one of your listings, or enter them manually below."}),e.jsxs(zs,{value:w.listing_id||"",onValueChange:ae=>$(ae),children:[e.jsx(Os,{children:e.jsx(qs,{placeholder:"Select a listing to import..."})}),e.jsx(Fs,{children:N.map(ae=>{var ie;return e.jsxs(yt,{value:ae.id,children:[ae.property_address||`${ae.city}, ${ae.state}`," — $",(ie=ae.price)==null?void 0:ie.toLocaleString()]},ae.id)})})]})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Property Information"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Property Address"}),e.jsx(Fe,{value:w.property_address,onChange:ae=>S(ie=>({...ie,property_address:ae.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(ge,{children:"Price"}),e.jsx(Fe,{value:w.property_price,onChange:ae=>S(ie=>({...ie,property_price:ae.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Beds"}),e.jsx(Fe,{value:w.property_beds,onChange:ae=>S(ie=>({...ie,property_beds:ae.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Baths"}),e.jsx(Fe,{value:w.property_baths,onChange:ae=>S(ie=>({...ie,property_baths:ae.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Sq Ft"}),e.jsx(Fe,{value:w.property_sqft,onChange:ae=>S(ie=>({...ie,property_sqft:ae.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Description"}),e.jsx(_r,{value:w.property_description,onChange:ae=>S(ie=>({...ie,property_description:ae.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Property Photos"})}),e.jsxs(Be,{className:"space-y-4",children:[w.property_photos.length>0&&e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:w.property_photos.map((ae,ie)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:ae,alt:`Property ${ie+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:()=>S(le=>({...le,property_photos:le.property_photos.filter((fe,xe)=>xe!==ie)})),children:e.jsx(yr,{className:"h-3 w-3"})})]},ie))}),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(Da,{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(js,{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(Bs,{className:"h-3.5 w-3.5 mr-1"})," Add Field"]})]}),C.length===0?e.jsx(Ie,{children:e.jsx(Be,{className:"py-8 text-center text-muted-foreground",children:"No fields yet. Add fields to build your form."})}):e.jsx("div",{className:"space-y-3",children:C.map((ae,ie)=>e.jsx(Ie,{children:e.jsx(Be,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(uu,{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(ge,{className:"text-xs",children:"Field Type"}),e.jsxs(zs,{value:ae.field_type,onValueChange:le=>ee(ie,{field_type:le}),children:[e.jsx(Os,{children:e.jsx(qs,{})}),e.jsx(Fs,{children:JTs.map(le=>e.jsx(yt,{value:le.value,children:le.label},le.value))})]})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Label"}),e.jsx(Fe,{value:ae.label,onChange:le=>ee(ie,{label:le.target.value}),placeholder:"e.g. Full Name"})]}),e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Placeholder"}),e.jsx(Fe,{value:ae.placeholder||"",onChange:le=>ee(ie,{placeholder:le.target.value}),placeholder:"Optional hint text"})]})]}),(ae.field_type==="select"||ae.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(ge,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(Fe,{value:ae.options?(typeof ae.options=="string"?JSON.parse(ae.options):ae.options).join(", "):"",onChange:le=>ee(ie,{options:JSON.stringify(le.target.value.split(",").map(fe=>fe.trim()).filter(Boolean))}),placeholder:"Option 1, Option 2, Option 3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{checked:ae.is_required,onCheckedChange:le=>ee(ie,{is_required:le})}),e.jsx(ge,{className:"text-xs",children:"Required"})]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Z(ie),children:e.jsx(yr,{className:"h-3.5 w-3.5 text-destructive"})})]})})},ie))})]}),e.jsx(js,{value:"submissions",className:"mt-4",children:b.length===0?e.jsx(Ie,{children:e.jsx(Be,{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(ae=>e.jsx(Ie,{children:e.jsx(Be,{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:ae.contact_name||"Anonymous"}),ae.synced_to_crm&&e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:"Synced"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground mt-0.5",children:[ae.contact_email&&e.jsx("span",{className:"mr-3",children:ae.contact_email}),ae.contact_phone&&e.jsx("span",{children:ae.contact_phone})]}),ae.answers&&typeof ae.answers=="object"&&e.jsx("div",{className:"mt-2 text-sm space-y-1",children:Object.entries(ae.answers).map(([ie,le])=>e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-muted-foreground",children:[ie,":"]})," ",e.jsx("span",{children:String(le)})]},ie))})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(ae.created_at).toLocaleDateString()})]})})},ae.id))})}),e.jsxs(js,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Publishing"})}),e.jsxs(Be,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ge,{children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this page publicly accessible"})]}),e.jsx(Lr,{checked:w.is_published,onCheckedChange:ae=>S(ie=>({...ie,is_published:ae}))})]}),w.is_published&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Public URL:"}),e.jsx("code",{className:"text-xs ml-2 break-all",children:J})]})]})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Thank You Message"})}),e.jsx(Be,{children:e.jsx(_r,{value:w.success_message,onChange:ae=>S(ie=>({...ie,success_message:ae.target.value})),rows:2,placeholder:"Message shown after form submission"})})]})]})]})]}),e.jsx(fs,{open:d,onOpenChange:u,children:e.jsxs(ms,{className:"max-w-sm",children:[e.jsx(ks,{children:e.jsx(bs,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx(EO,{value:J,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:J})]})]})})]}):e.jsx(Ls,{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 dBe({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(aL,{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(nL,{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(Xy,{className:"h-3 w-3"}),"0%"]})}const tAs={Phone:Tn,MessageSquare:Si,Mail:tr,Gift:Vi,PenTool:Pb,Video:hn},uBe=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function sAs(){const t=br(),{contactsWithScores:s,stats:r}=lhe(),{data:n}=ZR(365),{data:a}=vke(),{data:o}=KR(),l=xke(),i=k.useMemo(()=>{if(!n)return{touchesThisMonth:0,touchesLastMonth:0,touchTrend:0};const A=new Date,I=xc(A),L=nx(A),O=xc(v4(A,1)),U=nx(v4(A,1)),q=n.filter(ee=>wg(new Date(ee.completed_at),{start:I,end:L})).length,$=n.filter(ee=>wg(new Date(ee.completed_at),{start:O,end:U})).length,V=$>0?Math.round((q-$)/$*100):q>0?100:0;return{touchesThisMonth:q,touchesLastMonth:$,touchTrend:V}},[n]),d=k.useMemo(()=>{if(!n)return 0;const A=new Date,I=xc(A),L=nx(A);return new Set(n.filter(O=>wg(new Date(O.completed_at),{start:I,end:L})).map(O=>O.contact_id)).size},[n]),u=k.useMemo(()=>{if(!a)return{closedThisMonth:0,totalGCI:0};const A=new Date,I=xc(A),L=nx(A),O=a.filter(U=>U.close_date&&wg(pl(U.close_date),{start:I,end:L}));return{closedThisMonth:O.length,totalGCI:O.reduce((U,q)=>U+(Number(q.commission_amount)||0),0)}},[a]),p=k.useMemo(()=>{if(!s.length)return{newThisMonth:0,newLastMonth:0,trend:0};const A=new Date,I=xc(A),L=xc(v4(A,1)),O=nx(v4(A,1)),U=s.filter(V=>new Date(V.created_at)>=I).length,q=s.filter(V=>wg(new Date(V.created_at),{start:L,end:O})).length,$=q>0?Math.round((U-q)/q*100):U>0?100:0;return{newThisMonth:U,newLastMonth:q,trend:$}},[s]),f=k.useMemo(()=>{if(!n||!o)return[];const A=new Date,I=xc(A),L=nx(A),O=n.filter($=>wg(new Date($.completed_at),{start:I,end:L})),U={};O.forEach($=>{const V=$.action_type_id;U[V]=(U[V]||0)+1});const q=O.length||1;return o.filter($=>U[$.id]).map($=>({id:$.id,name:$.name,icon:$.icon,count:U[$.id]||0,percent:Math.round((U[$.id]||0)/q*100)})).sort(($,V)=>V.count-$.count)},[n,o]),y=k.useMemo(()=>[...s].filter(A=>A.relationshipScore.status==="at-risk"||A.relationshipScore.status==="cooling").sort((A,I)=>{const L=A.relationshipScore.daysSinceTouch??9999;return(I.relationshipScore.daysSinceTouch??9999)-L}).slice(0,5),[s]),_=k.useMemo(()=>{if(!n)return[];const A=new Date,I=xc(A),L=nx(A),O=new Set(n.filter(U=>wg(new Date(U.completed_at),{start:I,end:L})).map(U=>U.contact_id));return s.filter(U=>U.relationshipScore.status==="warm"&&O.has(U.id)&&U.relationshipScore.touchCountLast12Months>=2).sort((U,q)=>q.relationshipScore.score-U.relationshipScore.score).slice(0,5)},[s,n]),b=k.useMemo(()=>{if(!n)return{currentStreak:0,longestStreak:0};const A=new Set(n.map(V=>{const ee=new Date(V.completed_at);return`${ee.getFullYear()}-${ee.getMonth()}-${ee.getDate()}`})),I=new Date;I.setHours(0,0,0,0);let L=0,O=new Date(I);for(;A.has(`${O.getFullYear()}-${O.getMonth()}-${O.getDate()}`);)L++,O.setDate(O.getDate()-1);let U=0,q=0;if(Array.from(A).sort().length>0){const V=n.map(ee=>{const Z=new Date(ee.completed_at);return Z.setHours(0,0,0,0),Z.getTime()}).filter((ee,Z,J)=>J.indexOf(ee)===Z).sort((ee,Z)=>ee-Z);q=1;for(let ee=1;ee[...s].sort((A,I)=>A.relationshipScore.score-I.relationshipScore.score),[s]),w=N.filter(A=>A.relationshipScore.status==="warm"),S=N.filter(A=>A.relationshipScore.status==="cooling"),C=N.filter(A=>A.relationshipScore.status==="at-risk");return e.jsx(Ls,{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:[gs(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(ch,{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(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Za,{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(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ih,{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(dBe,{value:i.touchTrend})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["vs ",i.touchesLastMonth," last month"]})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(cr,{className:"h-4 w-4"}),"Reached"]}),e.jsx("div",{className:"text-3xl font-bold",children:d}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["of ",r.total," contacts"]})]})}),e.jsx(Ie,{children:e.jsxs(Be,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Yo,{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(dBe,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Oh,{className:"h-4 w-4 text-primary"}),"Weekly Goal"]})}),e.jsxs(Be,{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(pi,{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(Hi,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(ch,{className:"h-4 w-4 text-orange-500"}),"Momentum"]})}),e.jsxs(Be,{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(Ie,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(ih,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(Be,{children:f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No touches logged this month yet."}):e.jsx("div",{className:"space-y-2.5",children:f.slice(0,5).map((A,I)=>{const L=tAs[A.icon||""]||ih;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:A.name})]}),e.jsxs("span",{className:"text-muted-foreground",children:[A.count," (",A.percent,"%)"]})]}),e.jsx(pi,{value:A.percent,className:Rt("h-1.5 bg-muted [&>div]:",uBe[I%uBe.length])})]},A.id)})})})]})]}),y.length>0&&e.jsxs(Ie,{className:"border-l-4 border-l-primary",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5 text-primary"}),"Who to Reach Out to Today"]}),e.jsxs(Ye,{variant:"secondary",children:[y.length," contacts"]})]}),e.jsx(mr,{children:"These relationships need attention the most"})]}),e.jsx(Be,{children:e.jsx("div",{className:"space-y-2",children:y.map(A=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card hover:bg-accent/50 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${A.id}`),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(C8,{score:A.relationshipScore,showScore:!0,size:"sm",showTooltip:!1}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[A.first_name," ",A.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:A.relationshipScore.daysSinceTouch===null?"Never contacted":`Last touch ${A.relationshipScore.daysSinceTouch}d ago`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`tel:${A.phone}`)},children:e.jsx(Tn,{className:"h-4 w-4"})}),A.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`mailto:${A.email}`)},children:e.jsx(tr,{className:"h-4 w-4"})}),e.jsx(ja,{className:"h-4 w-4 text-muted-foreground"})]})]},A.id))})})]}),_.length>0&&e.jsxs(Ie,{className:"border-l-4 border-l-emerald-500",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(rc,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(mr,{children:"Relationships you've successfully warmed up"})]}),e.jsx(Be,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:_.map(A=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-full bg-emerald-500/10 border border-emerald-500/20 cursor-pointer hover:bg-emerald-500/20 transition-colors",onClick:()=>t(`/mission-control/contacts/${A.id}`),children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),e.jsxs("span",{className:"text-sm font-medium",children:[A.first_name," ",A.last_name]}),e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-bold",children:A.relationshipScore.score})]},A.id))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ie,{className:"border-l-4 border-l-emerald-500",children:e.jsxs(Be,{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(pi,{value:r.total?r.warm/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-emerald-500"})]})}),e.jsx(Ie,{className:"border-l-4 border-l-amber-500",children:e.jsxs(Be,{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(pi,{value:r.total?r.cooling/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-amber-500"})]})}),e.jsx(Ie,{className:"border-l-4 border-l-red-500",children:e.jsxs(Be,{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(pi,{value:r.total?r.atRisk/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-red-500"})]})})]}),e.jsx(Ie,{children:e.jsx(Be,{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(gL,{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(ta,{defaultValue:"at-risk",children:[e.jsxs(Qn,{children:[e.jsxs(ls,{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(ls,{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(ls,{value:"warm",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),"Warm (",r.warm,")"]})]}),[{key:"at-risk",contacts:C},{key:"cooling",contacts:S},{key:"warm",contacts:w}].map(({key:A,contacts:I})=>e.jsx(js,{value:A,children:e.jsx(Ie,{children:e.jsx(Be,{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(As,{children:[e.jsx(Nt,{children:"Contact"}),e.jsx(Nt,{className:"hidden md:table-cell",children:"Last Touch"}),e.jsx(Nt,{className:"hidden md:table-cell",children:"Touches (12mo)"}),e.jsx(Nt,{children:"Score"}),e.jsx(Nt,{className:"w-10"})]})}),e.jsx(Pn,{children:I.slice(0,20).map(L=>e.jsxs(As,{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(C8,{score:L.relationshipScore,showScore:!0})}),e.jsx(dt,{children:e.jsx(ja,{className:"h-4 w-4 text-muted-foreground"})})]},L.id))})]})})})},A))]})]})})}function rAs(){const{user:t}=$s();return ft({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 nAs(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 H6=[{key:"email",label:"Missing Email",icon:tr,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:Tn,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:La,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:lh,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:Mn,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:hh,description:"Untagged — won't appear in filtered lists or plans",check:t=>!t.tags||t.tags.length===0,color:"text-slate-500"}];function q5(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 aAs({contact:t,onClose:s}){const r=pke(),[n,a]=k.useState({email:t.email||"",phone:t.phone||"",address:t.address||"",birthday:t.birthday||"",home_anniversary:t.home_anniversary||""}),o=async()=>{r.mutate({id:t.id,...n},{onSuccess:()=>s()})},l=H6.filter(i=>i.fieldKey&&i.check(t));return e.jsx(ZA,{open:!0,onOpenChange:()=>s(),children:e.jsxs(CC,{className:"sm:max-w-md overflow-y-auto",children:[e.jsxs(YA,{children:[e.jsxs(XA,{children:["Quick Edit — ",t.first_name," ",t.last_name]}),e.jsxs(pYe,{children:["Fill in missing fields to improve this contact's completeness (",q5(t),"%)"]})]}),e.jsxs("div",{className:"space-y-5 mt-6",children:[l.length>0&&e.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400 mb-1",children:"Missing Fields"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.map(i=>{const d=i.icon;return e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(d,{className:"h-3 w-3"}),i.label.replace("Missing ","")]},i.key)})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(ge,{className:"flex items-center gap-1.5",children:[e.jsx(tr,{className:"h-3.5 w-3.5"})," Email"]}),e.jsx(Fe,{type:"email",placeholder:"email@example.com",value:n.email,onChange:i=>a(d=>({...d,email:i.target.value})),className:Rt(!t.email&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ge,{className:"flex items-center gap-1.5",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," Phone"]}),e.jsx(Fe,{type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:i=>a(d=>({...d,phone:i.target.value})),className:Rt(!t.phone&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ge,{className:"flex items-center gap-1.5",children:[e.jsx(La,{className:"h-3.5 w-3.5"})," Address"]}),e.jsx(Fe,{placeholder:"123 Main St, City, ST 12345",value:n.address,onChange:i=>a(d=>({...d,address:i.target.value})),className:Rt(!t.address&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ge,{className:"flex items-center gap-1.5",children:[e.jsx(lh,{className:"h-3.5 w-3.5"})," Birthday"]}),e.jsx(Fe,{type:"date",value:n.birthday,onChange:i=>a(d=>({...d,birthday:i.target.value})),className:Rt(!t.birthday&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ge,{className:"flex items-center gap-1.5",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," Home Anniversary"]}),e.jsx(Fe,{type:"date",value:n.home_anniversary,onChange:i=>a(d=>({...d,home_anniversary:i.target.value})),className:Rt(!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(wc,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const A0e="Quick favor — can you update your info? 🙏",hBe=`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 iAs(){const t=br(),{data:s,isLoading:r}=Uh(),{data:n}=Mf(),{intakePage:a}=Sme(),{isGmailConnected:o,gmailEmail:l}=bp(),{data:i}=rAs(),[d,u]=k.useState("blocked"),[p,f]=k.useState("all"),[y,_]=k.useState(null),[b,N]=k.useState(!1),[w,S]=k.useState(!1),[C,A]=k.useState(null),[I,L]=k.useState([]),[O,U]=k.useState(""),[q,$]=k.useState(""),V=k.useMemo(()=>s?p==="all"?s:s.filter(Ee=>{var ve;return(ve=Ee.tags)==null?void 0:ve.some(Re=>Re.relationship_type_id===p)}):[],[s,p]),ee=k.useMemo(()=>V.filter(Ee=>!Ee.email&&!Ee.phone),[V]),Z=k.useMemo(()=>{if(!V.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const Ee={};Ee.blocked=ee,H6.forEach(ye=>{Ee[ye.key]=V.filter(ye.check)});const ve=V.map(q5),Re=V.length>0?Math.round(ve.reduce((ye,ct)=>ye+ct,0)/V.length):0,Ue=ve.filter(ye=>ye===100).length;return{contactsByGap:Ee,overallCompleteness:Re,fullyComplete:Ue}},[V,ee]),J=k.useMemo(()=>{if(!s||s.length===0)return null;const Ee=xc(v4(new Date,1)),ve=s.filter(ct=>new Date(ct.created_at)ct+pe,0)/ve.length),Ue=Z.overallCompleteness,ye=Ue-Re;return{oldCompleteness:Re,currentCompleteness:Ue,diff:ye,oldCount:ve.length}},[s,Z.overallCompleteness]),Y=V.length,ce=k.useCallback(()=>{var tt;const Ee=Z.contactsByGap[d];if(!(Ee!=null&&Ee.length))return;const ve=d==="blocked"?"Outreach Blocked":((tt=H6.find(st=>st.key===d))==null?void 0:tt.label)||d,Re=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],Ue=Ee.map(st=>[st.first_name,st.last_name||"",st.email||"",st.phone||"",st.address||"",st.birthday||"",st.home_anniversary||"",q5(st).toString()]),ye=[Re.join(","),...Ue.map(st=>st.map(Ce=>`"${Ce.replace(/"/g,'""')}"`).join(","))].join(` `),ct=new Blob([ye],{type:"text/csv"}),pe=URL.createObjectURL(ct),Ge=document.createElement("a");Ge.href=pe,Ge.download=`sphere-gaps-${ve.toLowerCase().replace(/\s+/g,"-")}-${gs(new Date,"yyyy-MM-dd")}.csv`,Ge.click(),URL.revokeObjectURL(pe),cn({title:`Exported ${Ee.length} contacts to CSV`})},[Z.contactsByGap,d]),ae=k.useCallback(async Ee=>{if(!a)return null;try{const{data:ve,error:Re}=await G.from("contact_intake_tokens").insert({contact_id:Ee,intake_page_id:a.id}).select("token").single();if(Re)throw Re;return ve.token}catch{return null}},[a]),ie=k.useCallback(Ee=>a?`https://contacts.relevelup.com/${a.slug}?t=${Ee}`:"",[a]),le=k.useCallback(async Ee=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const ve=await ae(Ee);ve?(await navigator.clipboard.writeText(ie(ve)),me.success("Update link copied!")):me.error("Failed to generate link")},[a,ae,ie,t]),fe=k.useCallback(async Ee=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!Ee.email){me.error("This contact has no email address");return}const ve=await ae(Ee.id);if(!ve){me.error("Failed to generate link");return}const Re=ie(ve),Ue=hBe.replace("{{update_link}}",Re).replace(/\{\{first_name\}\}/g,Ee.first_name).replace(/\{\{last_name\}\}/g,Ee.last_name||""),ye=A0e.replace(/\{\{first_name\}\}/g,Ee.first_name).replace(/\{\{last_name\}\}/g,Ee.last_name||"");if(o)A({id:Ee.id,first_name:Ee.first_name,last_name:Ee.last_name,email:Ee.email}),L([]),U(ye),$(Ue),S(!0);else{const ct=encodeURIComponent(A0e.replace("{{first_name}}",Ee.first_name)),pe=encodeURIComponent(Ue.replace(/\{\{first_name\}\}/g,Ee.first_name));window.location.href=`mailto:${Ee.email}?subject=${ct}&body=${pe}`}},[a,ae,ie,o,t]),xe=k.useCallback(async Ee=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const ve=Ee.filter(ye=>ye.email);if(!ve.length){me.error("No contacts with email addresses in this group");return}const Re=new Set((i||[]).map(ye=>ye.contact_id)),Ue=ve.filter(ye=>!Re.has(ye.id));if(Ue.length===0){me.info(`All ${ve.length} contacts with email have already been sent this update request.`);return}if(Ue.lengthet.id),intake_page_id:a.id}});if(ct)throw ct;const pe=typeof ye=="string"?JSON.parse(ye):ye,Ge=Array.isArray(pe)?pe:Array.isArray(pe==null?void 0:pe.tokens)?pe.tokens:[],tt=new Map(Ge.filter(et=>(et==null?void 0:et.contact_id)&&(et==null?void 0:et.token)).map(et=>[et.contact_id,et.token]));if(tt.size===0&&(await Promise.all(ve.map(async Ct=>({contactId:Ct.id,token:await ae(Ct.id)})))).forEach(({contactId:Ct,token:Ot})=>{Ot&&tt.set(Ct,Ot)}),tt.size===0){me.error("Failed to generate update links. Please try again.");return}const st=Ue.filter(et=>tt.has(et.id)).map(et=>({id:et.id,first_name:et.first_name,last_name:et.last_name,email:et.email,updateLink:ie(tt.get(et.id))})),Ce=hBe;A(null),L(st),U(A0e),$(Ce),S(!0),me.success(`Ready to email ${st.length} contacts`)}catch{me.error("Failed to generate links")}finally{N(!1)}},[a,o,ie,ae,t]),we=[{key:"blocked",label:"Outreach Blocked",icon:Cv,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...H6].find(Ee=>Ee.key===d),Ne=Z.contactsByGap[d]||[],Ve=Ne.filter(Ee=>Ee.email).length,Te=new Set((i||[]).map(Ee=>Ee.contact_id)),Ae=Ne.filter(Ee=>Ee.email&&Te.has(Ee.id)).length,ze=Ve-Ae;return e.jsxs(Ls,{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(Dg,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(zs,{value:p,onValueChange:f,children:[e.jsx(Os,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"Filter by tag"})}),e.jsxs(Fs,{children:[e.jsx(yt,{value:"all",children:"All Contacts"}),n==null?void 0:n.map(Ee=>e.jsx(yt,{value:Ee.id,children:Ee.name},Ee.id))]})]})]})]}),e.jsx(Ie,{children:e.jsxs(Be,{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:[Z.overallCompleteness,"%"]}),J&&J.diff!==0&&p==="all"&&e.jsxs("div",{className:Rt("flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",J.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:[J.diff>0?"↑":"↓"," ",Math.abs(J.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:[Z.fullyComplete," ",e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/ ",Y]})]})]})]}),e.jsx(pi,{value:Z.overallCompleteness,className:"h-3"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:Z.overallCompleteness>=80?"🎉 Great job! Your database is well maintained.":Z.overallCompleteness>=50?"⚡ Good start — fill in the gaps below to unlock more outreach channels.":"🔍 Your database needs attention. Start with emails and phone numbers."})]})}),ee.length>0&&e.jsx(Ie,{className:Rt("border-l-4 border-l-destructive cursor-pointer transition-all hover:shadow-md",d==="blocked"&&"ring-2 ring-primary"),onClick:()=>u("blocked"),children:e.jsx(Be,{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(Cv,{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:ee.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:H6.map(Ee=>{var ct;const ve=((ct=Z.contactsByGap[Ee.key])==null?void 0:ct.length)||0,Re=Y>0?Math.round(ve/Y*100):0,Ue=Ee.icon,ye=d===Ee.key;return e.jsx(Ie,{className:Rt("cursor-pointer transition-all hover:shadow-md",ye&&"ring-2 ring-primary"),onClick:()=>u(Ee.key),children:e.jsxs(Be,{className:"pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ue,{className:Rt("h-5 w-5",Ee.color)}),e.jsx("span",{className:"text-sm font-medium",children:Ee.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-2xl font-bold",children:ve}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Re,"% of contacts"]})]}),e.jsx(pi,{value:100-Re,className:"mt-2 h-1.5"})]})},Ee.key)})}),e.jsxs(Ie,{children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{className:"text-lg",children:[(we==null?void 0:we.label)||"Contacts"," — Contacts to Fix"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(Ye,{variant:"secondary",children:[Ne.length," contacts"]}),Ae>0&&e.jsxs(Ye,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(Hn,{className:"h-3 w-3"}),Ae," already emailed"]}),Ne.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:ce,className:"gap-1.5",children:[e.jsx(Xa,{className:"h-3.5 w-3.5"}),"Export"]}),ze>0&&a&&e.jsxs(K,{size:"sm",onClick:()=>xe(Ne),disabled:b,className:"gap-1.5",children:[b?e.jsx(ps,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Nn,{className:"h-3.5 w-3.5"}),"Email ",ze," Update Links"]})]})]})]}),e.jsx(mr,{children:we==null?void 0:we.description})]}),e.jsx(Be,{className:"p-0",children:Ne.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(Hn,{className:"h-10 w-10 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:d==="blocked"?"All contacts have at least an email or phone!":"All contacts have this field filled in!"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(As,{children:[e.jsx(Nt,{children:"Contact"}),e.jsx(Nt,{className:"hidden md:table-cell",children:"Email"}),e.jsx(Nt,{className:"hidden md:table-cell",children:"Phone"}),e.jsx(Nt,{children:"Completeness"}),e.jsx(Nt,{className:"w-28",children:"Actions"})]})}),e.jsx(Pn,{children:Ne.map(Ee=>{const ve=nAs(i,Ee.id);return e.jsxs(As,{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/${Ee.id}`),children:[Ee.first_name," ",Ee.last_name]}),!Ee.email&&!Ee.phone&&d!=="blocked"&&e.jsx(Ye,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),ve&&e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsxs(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0 gap-1 text-muted-foreground border-muted",children:[e.jsx(tr,{className:"h-2.5 w-2.5"}),jl(new Date(ve),{addSuffix:!0})]})}),e.jsxs(Il,{children:["Last bulk emailed ",gs(new Date(ve),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:Ee.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:Ee.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(pi,{value:q5(Ee),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[q5(Ee),"%"]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>_(Ee),children:e.jsx(Tv,{className:"h-3.5 w-3.5"})})}),e.jsx(Il,{children:"Quick edit"})]}),(Ee.email||Ee.phone)&&a&&e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>le(Ee.id),children:e.jsx(Ya,{className:"h-3.5 w-3.5"})})}),e.jsx(Il,{children:"Copy update link"})]}),Ee.email&&a&&e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>fe(Ee),children:e.jsx(tr,{className:"h-3.5 w-3.5"})})}),e.jsx(Il,{children:"Email update link"})]})]})})]},Ee.id)})})]})})]})]}),y&&e.jsx(aAs,{contact:y,onClose:()=>_(null)}),e.jsx(E1,{open:w,onOpenChange:S,contact:C||void 0,bulkContacts:I.length>0?I:void 0,defaultSubject:O,defaultBody:q,gmailEmail:l})]})}function oAs(){const{user:t}=$s(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=Sme(),[i,d]=k.useState(""),[u,p]=k.useState(""),[f,y]=k.useState(!1);k.useEffect(()=>{s&&p(s.welcome_message||"")},[s]),k.useEffect(()=>{if(t!=null&&t.email&&!s){const A=t.email.split("@")[0];d(A.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+$/,""))}},[t,s]);const _=s?`https://contacts.relevelup.com/${s.slug}`:"",b=()=>{navigator.clipboard.writeText(_),me.success("Link copied!")};if(r)return e.jsx(Ie,{children:e.jsx(Be,{className:"p-6 flex items-center justify-center",children:e.jsx(ps,{className:"h-5 w-5 animate-spin text-muted-foreground"})})});if(!s)return e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Do,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ft,{children:"Connect Page"}),e.jsx(mr,{children:"Create a public link to capture contact info from new leads or update existing contacts"})]})]})}),e.jsx(Be,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ge,{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:A=>d(A.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"jane-smith",className:"max-w-[200px]"})]})]}),e.jsxs(K,{onClick:()=>n.mutate(i),disabled:!i.trim()||n.isPending,children:[n.isPending?e.jsx(ps,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Connect Page"]})]})})]});const N=o.filter(A=>!A.is_processed),w=o.filter(A=>A.is_processed),S=N.length,C=(A,I)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:[A.first_name," ",A.last_name||""]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[A.email&&e.jsx("span",{children:A.email}),A.phone&&e.jsx("span",{children:A.phone})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A.real_estate_interest&&A.real_estate_interest!=="not_now"&&e.jsx(Ye,{variant:"outline",className:"text-xs",children:A.real_estate_interest==="buying"?"🏠 Buying":A.real_estate_interest==="selling"?"📋 Selling":A.real_estate_interest==="both"?"🔄 Both":A.real_estate_interest}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(rn,{className:"h-3 w-3"}),gs(new Date(A.created_at),"MMM d")]}),I&&e.jsx(Hn,{className:"h-4 w-4 text-emerald-500"})]})]},A.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Do,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ft,{children:"Connect Page"}),e.jsx(mr,{children:"Share this link to capture contact info"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{htmlFor:"active-toggle",className:"text-sm text-muted-foreground",children:"Active"}),e.jsx(Lr,{id:"active-toggle",checked:s.is_active,onCheckedChange:A=>a.mutate({is_active:A})})]})]})}),e.jsxs(Be,{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(Ya,{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(Kr,{className:"h-3.5 w-3.5"})})})]}),e.jsxs("div",{children:[e.jsx(ge,{children:"Welcome Message"}),f?e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("textarea",{value:u,onChange:A=>p(A.target.value),rows:3,className:"w-full px-3 py-2 text-sm border rounded-md bg-background"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:()=>{a.mutate({welcome_message:u}),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(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(cr,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-base",children:"New Submissions"}),S>0&&e.jsxs(mr,{children:[S," awaiting sync"]})]})]}),S>0&&e.jsxs(K,{size:"sm",onClick:async()=>{try{const{data:A,error:I}=await G.functions.invoke("process-intake-submissions",{body:{action:"process_all"}});if(I)throw I;me.success(`Synced ${A.processed} contacts to your CRM!`)}catch{me.error("Failed to sync")}},className:"gap-1.5",children:["Sync ",S," to CRM"]})]})}),e.jsx(Be,{children:l?e.jsx(ps,{className:"h-5 w-5 animate-spin text-muted-foreground"}):N.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:N.map(A=>C(A,!1))})})]}),w.length>0&&e.jsxs(Ie,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Hn,{className:"h-5 w-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-base",children:"Synced to CRM"}),e.jsxs(mr,{children:[w.length," contacts already in your database"]})]})]})}),e.jsx(Be,{children:e.jsxs("div",{className:"space-y-3",children:[w.slice(0,10).map(A=>C(A,!0)),w.length>10&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-1",children:["+ ",w.length-10," more synced contacts"]})]})})]})]})}function lAs(){return e.jsx(Ls,{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(oAs,{})]})})}const cAs={property_view:{label:"Viewed Listing",icon:jn,badgeClass:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-200 dark:border-blue-700"},new_lead:{label:"New Lead",icon:il,badgeClass:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-200 dark:border-emerald-700"},saved_listing:{label:"Saved Listing",icon:Za,badgeClass:"bg-rose-500/10 text-rose-600 dark:text-rose-400 border-rose-200 dark:border-rose-700"}},dAs={home:"🏠",search:"🔍",listing:"🏡",city:"🌆",sell:"💰",blog:"📝",dashboard:"📊",other:"📄"};function uAs({locations:t}){const s=k.useRef(null),r=k.useRef(null),[n,a]=k.useState(null);return k.useEffect(()=>{G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle().then(({data:o})=>{o!=null&&o.value&&a(o.value)})},[]),k.useEffect(()=>{if(!(!s.current||!n||r.current))return yc.accessToken=n,r.current=new yc.Map({container:s.current,style:"mapbox://styles/mapbox/light-v11",zoom:3.5,center:[-98.5795,39.8283],interactive:!0}),r.current.addControl(new yc.NavigationControl,"top-right"),()=>{var o;(o=r.current)==null||o.remove(),r.current=null}},[n]),k.useEffect(()=>{if(!r.current||!n||t.length===0)return;const o=()=>{if(t.forEach(l=>{if(!Number.isFinite(l.lat)||!Number.isFinite(l.lng))return;const i=Math.min(40,Math.max(16,12+l.visitor_count*3)),d=document.createElement("div");d.style.cssText=` width: ${i}px; height: ${i}px; border-radius: 50%; background: radial-gradient(circle, rgba(64,110,113,0.9), rgba(64,110,113,0.4)); border: 2px solid rgba(64,110,113,0.8); display: flex; align-items: center; justify-content: center; font-size: ${Math.max(9,i*.35)}px; font-weight: 700; color: white; cursor: pointer; transition: transform 0.2s; `,d.textContent=String(l.visitor_count),d.addEventListener("mouseenter",()=>{d.style.transform="scale(1.3)"}),d.addEventListener("mouseleave",()=>{d.style.transform="scale(1)"});const u=document.createElement("div");u.appendChild(d),new yc.Marker({element:u,anchor:"center"}).setLngLat([l.lng,l.lat]).setPopup(new yc.Popup({offset:15}).setHTML(`
${l.city}, ${l.region}
${l.visitor_count} visitor${l.visitor_count>1?"s":""}
`)).addTo(r.current)}),t.length>1){const l=new yc.LngLatBounds;t.forEach(i=>{Number.isFinite(i.lat)&&Number.isFinite(i.lng)&&l.extend([i.lng,i.lat])}),l.isEmpty()||r.current.fitBounds(l,{padding:60,maxZoom:10})}else t.length===1&&r.current.flyTo({center:[t[0].lng,t[0].lat],zoom:8})};r.current.loaded()?o():r.current.on("load",o)},[t,n]),n?e.jsx("div",{ref:s,className:"w-full h-full rounded-xl overflow-hidden"}):e.jsxs("div",{className:"h-full flex items-center justify-center bg-muted/30 rounded-xl text-muted-foreground text-sm",children:[e.jsx(uS,{className:"h-5 w-5 mr-2"})," Map not configured"]})}function rdt(){var L,O,U,q;const{user:t}=$s(),s=br(),{isGmailConnected:r,gmailEmail:n}=bp(),[a,o]=k.useState("all"),[l,i]=k.useState("30"),[d,u]=k.useState(""),[p,f]=k.useState(!1),[y,_]=k.useState(null),{data:b,isLoading:N}=ft({queryKey:["lead-site-activity-full",t==null?void 0:t.id,l],queryFn:async()=>{const{data:$,error:V}=await G.rpc("get_lead_site_activity_full",{_user_id:t.id,_days:parseInt(l)});if(V)throw V;const ee=$;return{...ee,visitor_locations:((ee==null?void 0:ee.visitor_locations)||[]).map(Z=>({...Z,lat:Number(Z.lat),lng:Number(Z.lng),visitor_count:Number(Z.visitor_count??Z.visit_count??0)}))}},enabled:!!t,refetchInterval:6e4}),w=k.useMemo(()=>{if(!(b!=null&&b.activities))return[];let $=b.activities;if(a!=="all"&&($=$.filter(V=>V.activity_type===a)),d){const V=d.toLowerCase();$=$.filter(ee=>{var Z,J,Y,ce,ae;return((Z=ee.visitor_name)==null?void 0:Z.toLowerCase().includes(V))||((J=ee.visitor_email)==null?void 0:J.toLowerCase().includes(V))||((Y=ee.mls_number)==null?void 0:Y.includes(V))||((ce=ee.property_address)==null?void 0:ce.toLowerCase().includes(V))||((ae=ee.lead_type)==null?void 0:ae.toLowerCase().includes(V))})}return $},[b==null?void 0:b.activities,a,d]),S=b==null?void 0:b.subdomain,C=$=>S?`https://${S}.thelocalmove.com/listing/${$}`:null,A=b==null?void 0:b.stats,I=$=>{if($.visitor_email)if(r){const V=($.visitor_name||"").split(" ");_({id:$.contact_id||"",first_name:V[0]||"",last_name:V.slice(1).join(" ")||null,email:$.visitor_email}),f(!0)}else window.location.href=`mailto:${$.visitor_email}`};return!(b!=null&&b.has_site)&&!N?e.jsx(Ls,{title:"Website Activity",description:"Monitor your website lead activity",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx(gd,{className:"h-16 w-16 text-muted-foreground/30 mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Website Connected"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"Set up your Lead Site to start capturing and tracking visitor activity."})]})}):e.jsxs(Ls,{title:"Website Activity",description:"Monitor and act on your website leads",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/mission-control"),children:e.jsx(Ra,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(gd,{className:"h-6 w-6 text-primary"}),"Website Activity"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track, respond, and convert your website visitors"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:["7","30","90"].map($=>e.jsxs(K,{variant:l===$?"default":"outline",size:"sm",onClick:()=>i($),children:[$,"d"]},$))})]}),A&&e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{label:"Page Views",value:A.total_page_views,sub:A.page_views_7d,icon:mn,color:"text-violet-600 dark:text-violet-400",bg:"bg-violet-500/10"},{label:"Listing Views",value:A.total_views,sub:A.views_7d,icon:jn,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-500/10"},{label:"New Leads",value:A.total_leads,sub:A.leads_7d,icon:il,color:"text-emerald-600 dark:text-emerald-400",bg:"bg-emerald-500/10"},{label:"Saved Listings",value:A.total_saved,sub:A.saved_7d,icon:Za,color:"text-rose-600 dark:text-rose-400",bg:"bg-rose-500/10"}].map($=>e.jsx(Ie,{children:e.jsxs(Be,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:$.label}),e.jsx("p",{className:`text-2xl font-bold ${$.color}`,children:$.value})]}),e.jsx("div",{className:`p-2.5 rounded-xl ${$.bg}`,children:e.jsx($.icon,{className:`h-5 w-5 ${$.color}`})})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1",children:[e.jsx("span",{className:`font-semibold ${$.color}`,children:$.sub})," in last 7d"]})]})},$.label))}),e.jsxs(ta,{defaultValue:"overview",className:"space-y-4",children:[e.jsxs(Qn,{children:[e.jsxs(ls,{value:"overview",className:"gap-1.5",children:[e.jsx(so,{className:"h-4 w-4"})," Overview"]}),e.jsxs(ls,{value:"leads",className:"gap-1.5",children:[e.jsx(Fh,{className:"h-4 w-4"})," Lead Inbox"]}),e.jsxs(ls,{value:"map",className:"gap-1.5",children:[e.jsx(uS,{className:"h-4 w-4"})," Visitor Map"]})]}),e.jsxs(js,{value:"overview",className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Yo,{className:"h-4 w-4 text-primary"}),"Most Viewed Listings"]})}),e.jsx(Be,{className:"pt-0",children:!(b!=null&&b.top_listings)||b.top_listings.length===0?e.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[e.jsx(Mn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/30"}),"No listing views yet"]}):e.jsx("div",{className:"space-y-1.5",children:b.top_listings.map(($,V)=>{const ee=C($.mls_number);return e.jsxs("a",{href:ee||"#",target:"_blank",rel:"noopener noreferrer",onClick:Z=>{ee||Z.preventDefault()},className:"group flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[e.jsx("span",{className:"text-sm font-bold text-muted-foreground w-5 text-right",children:V+1}),$.photo_url?e.jsx("div",{className:"h-10 w-10 rounded-lg overflow-hidden bg-muted shrink-0",children:e.jsx("img",{src:$.photo_url,alt:"",className:"w-full h-full object-cover"})}):e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Mn,{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:$.property_address||`MLS# ${$.mls_number}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:jl(new Date($.last_viewed),{addSuffix:!0})})]}),e.jsxs(Ye,{variant:"secondary",className:"shrink-0 text-xs",children:[$.view_count," view",$.view_count!==1?"s":""]}),ee&&e.jsx(Kr,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},$.mls_number)})})})]}),e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(mn,{className:"h-4 w-4 text-primary"}),"Most Visited Pages"]})}),e.jsx(Be,{className:"pt-0",children:!(b!=null&&b.top_pages)||b.top_pages.length===0?e.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[e.jsx(mn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/30"}),"No page views yet"]}):e.jsx("div",{className:"space-y-1.5",children:b.top_pages.map(($,V)=>e.jsxs("div",{className:"flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[e.jsx("span",{className:"text-sm font-bold text-muted-foreground w-5 text-right",children:V+1}),e.jsx("span",{className:"text-lg w-8 text-center",children:dAs[$.page_type]||"📄"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:$.page_title||$.page_path}),e.jsx("p",{className:"text-xs text-muted-foreground",children:$.page_path})]}),e.jsx(Ye,{variant:"secondary",className:"shrink-0 text-xs capitalize",children:$.page_type}),e.jsx(Ye,{variant:"outline",className:"shrink-0 text-xs",children:$.view_count})]},`${$.page_type}-${$.page_path}`))})})]})]}),(b==null?void 0:b.visitor_locations)&&b.visitor_locations.length>0&&e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(La,{className:"h-4 w-4 text-primary"}),"Where Visitors Are Browsing From"]})}),e.jsx(Be,{className:"pt-0",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:b.visitor_locations.slice(0,9).map($=>e.jsxs("div",{className:"flex items-center gap-2.5 p-2.5 rounded-lg bg-muted/40",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(La,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[$.city,", ",$.region]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:$.country})]}),e.jsx("span",{className:"text-sm font-bold text-primary",children:$.visitor_count})]},`${$.city}-${$.region}`))})})]})]}),e.jsxs(js,{value:"leads",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(tn,{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, address...",value:d,onChange:$=>u($.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex gap-2",children:[{key:"all",label:"All",count:((L=b==null?void 0:b.activities)==null?void 0:L.length)||0},{key:"new_lead",label:"Leads",count:((O=b==null?void 0:b.activities)==null?void 0:O.filter($=>$.activity_type==="new_lead").length)||0},{key:"property_view",label:"Views",count:((U=b==null?void 0:b.activities)==null?void 0:U.filter($=>$.activity_type==="property_view").length)||0},{key:"saved_listing",label:"Saved",count:((q=b==null?void 0:b.activities)==null?void 0:q.filter($=>$.activity_type==="saved_listing").length)||0}].map($=>e.jsxs(K,{variant:a===$.key?"default":"outline",size:"sm",onClick:()=>o($.key),className:"gap-1.5",children:[$.label,e.jsx(Ye,{variant:"secondary",className:"text-[10px] h-4 px-1 rounded-full",children:$.count})]},$.key))})]}),N?e.jsx("div",{className:"space-y-3",children:[1,2,3].map($=>e.jsx("div",{className:"h-20 rounded-xl bg-muted animate-pulse"},$))}):w.length===0?e.jsx(Ie,{children:e.jsxs(Be,{className:"p-8 text-center",children:[e.jsx(ih,{className:"h-10 w-10 text-muted-foreground/30 mx-auto mb-3"}),e.jsx("p",{className:"font-medium",children:"No activity found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d?"Try adjusting your search.":"Website engagement will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:w.map(($,V)=>{const ee=cAs[$.activity_type],Z=ee.icon,J=jl(new Date($.occurred_at),{addSuffix:!0}),Y=$.visitor_name&&$.visitor_name!=="Site Visitor";return e.jsx(Ie,{className:`transition-all hover:shadow-md ${$.activity_type==="new_lead"?"border-l-4 border-l-emerald-500":$.activity_type==="saved_listing"?"border-l-4 border-l-rose-500":"border-l-4 border-l-blue-500"}`,children:e.jsx(Be,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[$.photo_url?e.jsx("a",{href:$.mls_number&&C($.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"shrink-0 rounded-lg overflow-hidden w-12 h-12 bg-muted",children:e.jsx("img",{src:$.photo_url,alt:$.property_address||"Property",className:"w-full h-full object-cover"})}):e.jsx("div",{className:`p-2 rounded-lg shrink-0 ${$.activity_type==="new_lead"?"bg-emerald-500/10":$.activity_type==="saved_listing"?"bg-rose-500/10":"bg-blue-500/10"}`,children:e.jsx(Z,{className:`h-4 w-4 ${$.activity_type==="new_lead"?"text-emerald-500":$.activity_type==="saved_listing"?"text-rose-500":"text-blue-500"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Y?e.jsx("button",{className:"font-semibold text-sm text-primary hover:underline text-left truncate",onClick:()=>{$.contact_id&&s(`/mission-control/contacts/${$.contact_id}`)},children:$.visitor_name}):e.jsx("span",{className:"font-medium text-sm text-muted-foreground",children:$.visitor_name||"Site Visitor"}),e.jsx(Ye,{variant:"outline",className:`text-[10px] shrink-0 ${ee.badgeClass}`,children:ee.label}),$.lead_type&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] capitalize",children:$.lead_type.replace(/_/g," ")})]}),$.property_address&&$.mls_number&&e.jsxs("a",{href:C($.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-0.5 text-xs font-medium text-foreground hover:text-primary transition-colors truncate",children:[e.jsx(La,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:$.property_address}),e.jsx(Kr,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(rn,{className:"h-3 w-3"}),J]}),$.mls_number&&!$.property_address&&e.jsxs("a",{href:C($.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"hover:text-primary transition-colors",children:["MLS# ",$.mls_number]})]}),$.message&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5 line-clamp-2 italic",children:['"',$.message,'"']})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[$.visitor_email&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:r?"Compose via Gmail":"Send Email",onClick:()=>I($),children:e.jsx(tr,{className:"h-4 w-4"})}),$.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Call",onClick:()=>window.location.href=`tel:${$.visitor_phone}`,children:e.jsx(Tn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Text",onClick:()=>window.location.href=`sms:${$.visitor_phone}`,children:e.jsx(Si,{className:"h-4 w-4"})})]}),$.contact_id&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",title:"View Contact",onClick:()=>s(`/mission-control/contacts/${$.contact_id}`),children:e.jsx(ja,{className:"h-4 w-4"})})]})]})})},`${$.activity_type}-${$.occurred_at}-${V}`)})})]}),e.jsxs(js,{value:"map",className:"space-y-4",children:[e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(uS,{className:"h-4 w-4 text-primary"}),"Visitor Locations",(b==null?void 0:b.visitor_locations)&&b.visitor_locations.length>0&&e.jsxs(Ye,{variant:"secondary",className:"text-xs ml-2",children:[b.visitor_locations.reduce(($,V)=>$+V.visitor_count,0)," visitors from ",b.visitor_locations.length," cities"]})]})}),e.jsx(Be,{className:"pt-0",children:e.jsx("div",{className:"h-[450px] rounded-xl overflow-hidden border",children:e.jsx(uAs,{locations:(b==null?void 0:b.visitor_locations)||[]})})})]}),(b==null?void 0:b.visitor_locations)&&b.visitor_locations.length>0&&e.jsxs(Ie,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(Ft,{className:"text-base",children:"Location Breakdown"})}),e.jsx(Be,{className:"pt-0",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:b.visitor_locations.map($=>e.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-muted/40",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(La,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[$.city,", ",$.region]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:$.country})]}),e.jsx("span",{className:"text-sm font-bold text-primary",children:$.visitor_count})]},`${$.city}-${$.region}`))})})]})]})]})]}),r&&y&&e.jsx(E1,{open:p,onOpenChange:f,contact:y,gmailEmail:n})]})}const hAs=Object.freeze(Object.defineProperty({__proto__:null,default:rdt},Symbol.toStringTag,{value:"Module"})),mAs=k.lazy(()=>Ua(()=>import("./MobileAgentApp-CE6dJSv4.js"),[])),pAs=k.lazy(()=>Ua(()=>import("./PostcardManager-BNv4wQwN.js"),__vite__mapDeps([15,16]))),fAs=k.lazy(()=>Ua(()=>import("./HomeReelManager-Casyt9aj.js"),[])),xAs=k.lazy(()=>Ua(()=>import("./AdminCredits-Cfu9DLTX.js"),[])),gAs=k.lazy(()=>Ua(()=>import("./DirectMail-DQVNdRZL.js"),__vite__mapDeps([17,16,18]))),yAs=k.lazy(()=>Ua(()=>import("./InnerCirclePopbyMap-BwxiMcvt.js"),[])),vAs=k.lazy(()=>Ua(()=>import("./LiveVisitorFeed-Ds85Dcis.js"),[])),_As=k.lazy(()=>Ua(()=>import("./LeadSites-BU2degpU.js"),[])),mBe=k.lazy(()=>Ua(()=>import("./LeadSiteEditor-lDqA65NA.js"),__vite__mapDeps([19,20,21]))),bAs=k.lazy(()=>Ua(()=>import("./AdminLeadSiteThemes-Crc5wFHx.js"),__vite__mapDeps([22,20]))),wAs=k.lazy(()=>Ua(()=>import("./AdminMlsFeeds-9P2zUmR3.js"),[])),jAs=k.lazy(()=>Ua(()=>import("./AdminLeadSiteAnalytics-Dt1Vm2zM.js"),[])),NAs=k.lazy(()=>Ua(()=>import("./AdminWebsiteInterests-DpeEtPFc.js"),[])),kAs=k.lazy(()=>Ua(()=>import("./AdminMlsFeeTracker-Bc2TvL9e.js"),[])),SAs=k.lazy(()=>Ua(()=>import("./MLSListings-BDHs-x-Q.js"),[])),CAs=k.lazy(()=>Ua(()=>import("./MLSListingDetail-nDeNDdg1.js"),__vite__mapDeps([23,12,18]))),MAs=k.lazy(()=>Ua(()=>import("./MarketReportPage-1ERsFOcZ.js"),[]));k.lazy(()=>Ua(()=>Promise.resolve().then(()=>hAs),void 0));const TAs=k.lazy(()=>Ua(()=>import("./EmailCampaigns-DIV3PSh7.js"),[])),AAs=k.lazy(()=>Ua(()=>import("./EmailCampaignComposer-C5bvFK8b.js"),__vite__mapDeps([24,25]))),EAs=k.lazy(()=>Ua(()=>import("./EmailCampaignDetail-BSSp4FCq.js"),[])),PAs=k.lazy(()=>Ua(()=>import("./SharedCampaignTemplates-BJIh0UhF.js"),__vite__mapDeps([26,27,25]))),IAs=k.lazy(()=>Ua(()=>import("./AgentTemplates-DpAX_5GW.js"),__vite__mapDeps([28,27,25]))),pBe=k.lazy(()=>Ua(()=>import("./TheLocalMoveHome-TsZFqteb.js"),__vite__mapDeps([29,30]))),fBe=k.lazy(()=>Ua(()=>import("./TheLocalMoveGetStarted-acnGBlqC.js"),__vite__mapDeps([31,30]))),xBe=k.lazy(()=>Ua(()=>import("./TheLocalMoveCheckout-Ckm7HX4k.js"),[])),gBe=k.lazy(()=>Ua(()=>import("./TheLocalMoveCheckoutSuccess-BSExV-b3.js"),[])),LAs=k.lazy(()=>Ua(()=>import("./AdminWebsiteOrders-Bxn5ubai.js"),[])),DAs=new n1t({defaultOptions:{queries:{refetchOnWindowFocus:!1,staleTime:5*60*1e3}}}),RAs=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},OAs=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},FAs=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},zAs=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},BAs=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},$As=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},qAs=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},UAs=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},VAs=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},ndt=()=>{const t=window.location.hostname;return t==="thelocalmove.com"||t==="www.thelocalmove.com"},HAs=()=>window.location.hostname.endsWith(".thelocalmove.com")&&!ndt(),GAs=()=>e.jsx(a1t,{client:DAs,children:e.jsx(AVe,{children:e.jsxs(S1,{children:[e.jsx(vyt,{}),e.jsx(Xyt,{}),e.jsx(y_t,{children:e.jsx(c2t,{children:e.jsx(d2t,{children:e.jsxs(v2t,{children:[e.jsx(y2t,{}),e.jsx(okt,{}),e.jsx(Tkt,{}),$As()?e.jsx(JMs,{}):OAs()?e.jsx(sSt,{}):RAs()?e.jsx(N4t,{}):FAs()?e.jsx(aSt,{}):zAs()?e.jsx(WPt,{}):BAs()?e.jsx(dIt,{}):qAs()?e.jsx(eTs,{}):UAs()?e.jsx(tTs,{}):VAs()?e.jsx(sTs,{}):ndt()?e.jsxs(Voe,{children:[e.jsx(_s,{path:"/get-started",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(fBe,{})})}),e.jsx(_s,{path:"/checkout",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(xBe,{})})}),e.jsx(_s,{path:"/checkout/success",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(gBe,{})})}),e.jsx(_s,{path:"/privacy-policy",element:e.jsx(Y6e,{})}),e.jsx(_s,{path:"/terms-of-service",element:e.jsx(X6e,{})}),e.jsx(_s,{path:"*",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(pBe,{})})})]}):HAs()?e.jsx(zTs,{}):e.jsxs(Voe,{children:[e.jsx(_s,{path:"/",element:e.jsx(vIt,{})}),e.jsx(_s,{path:"/the-local-move",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(pBe,{})})}),e.jsx(_s,{path:"/get-started",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(fBe,{})})}),e.jsx(_s,{path:"/local-move/checkout",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(xBe,{})})}),e.jsx(_s,{path:"/local-move/checkout/success",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(gBe,{})})}),e.jsx(_s,{path:"/privacy-policy",element:e.jsx(Y6e,{})}),e.jsx(_s,{path:"/terms-of-service",element:e.jsx(X6e,{})}),e.jsx(_s,{path:"/data-deletion",element:e.jsx(_It,{})}),e.jsx(_s,{path:"/public/listings",element:e.jsx(TWe,{})}),e.jsx(_s,{path:"/public/listing/:slugOrId",element:e.jsx(h8t,{})}),e.jsx(_s,{path:"/card/:slug",element:e.jsx(m8t,{})}),e.jsx(_s,{path:"/join-brokerage/:slug",element:e.jsx(K5s,{})}),e.jsx(_s,{path:"/recruit-unsubscribe",element:e.jsx(Q5s,{})}),e.jsx(_s,{path:"/recruit-video/:shareToken",element:e.jsx(Y5s,{})}),e.jsx(_s,{path:"/connect/:slug",element:e.jsx(SXe,{})}),e.jsx(_s,{path:"/auth",element:e.jsx(wIt,{})}),e.jsx(_s,{path:"/subscription-success",element:e.jsx(jIt,{})}),e.jsx(_s,{path:"/subscription",element:e.jsx(rr,{children:e.jsx(yLt,{})})}),e.jsxs(_s,{path:"/share/video",element:e.jsx(a8t,{}),children:[e.jsx(_s,{path:":shareToken",element:e.jsx(bLe,{})}),e.jsx(_s,{path:":shareToken/r/:recipientToken",element:e.jsx(bLe,{})})]}),e.jsx(_s,{path:"/p/:shareToken",element:e.jsx(xMs,{})}),e.jsx(_s,{path:"/portal/:slug",element:e.jsx(jMs,{})}),e.jsx(_s,{path:"/og/video/:token",element:e.jsx(i8t,{})}),e.jsx(_s,{path:"/setup-brokerage",element:e.jsx(rr,{children:e.jsx(vLt,{})})}),e.jsx(_s,{path:"/claim-account",element:e.jsx(yLe,{})}),e.jsx(_s,{path:"/claim",element:e.jsx(yLe,{})}),e.jsx(_s,{path:"/join",element:e.jsx(_Lt,{})}),e.jsx(_s,{path:"/trial",element:e.jsx(ELt,{})}),e.jsx(_s,{path:"/trial/success",element:e.jsx(PLt,{})}),e.jsx(_s,{path:"/dashboard",element:e.jsx(rr,{children:e.jsx(ODt,{})})}),e.jsx(_s,{path:"/profile",element:e.jsx(rr,{children:e.jsx(Nqt,{})})}),e.jsx(_s,{path:"/apps",element:e.jsx(rr,{children:e.jsx(Oqt,{})})}),e.jsx(_s,{path:"/admin",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(_De,{})})}),e.jsx(_s,{path:"/admin/dashboard",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(_De,{})})}),e.jsx(_s,{path:"/admin/apps",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(PHt,{})})}),e.jsx(_s,{path:"/admin/members",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(BHt,{})})}),e.jsx(_s,{path:"/admin/invite-codes",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx($Ht,{})})}),e.jsx(_s,{path:"/admin/events",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(WHt,{})})}),e.jsx(_s,{path:"/events",element:e.jsx(rr,{children:e.jsx(Iqt,{})})}),e.jsx(_s,{path:"/events/:eventId",element:e.jsx(rr,{children:e.jsx(Dqt,{})})}),e.jsx(_s,{path:"/templates",element:e.jsx(rr,{children:e.jsx(Fqt,{})})}),e.jsx(_s,{path:"/templates/:templateId",element:e.jsx(rr,{children:e.jsx(Vqt,{})})}),e.jsx(_s,{path:"/admin/templates",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(ZHt,{})})}),e.jsx(_s,{path:"/academy",element:e.jsx(rr,{children:e.jsx(Hqt,{})})}),e.jsx(_s,{path:"/academy/:videoId",element:e.jsx(rr,{children:e.jsx(Wqt,{})})}),e.jsx(_s,{path:"/admin/academy",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(XHt,{})})}),e.jsx(_s,{path:"/toolbox",element:e.jsx(rr,{children:e.jsx(Kqt,{})})}),e.jsx(_s,{path:"/toolbox/:kitId",element:e.jsx(rr,{children:e.jsx(Zqt,{})})}),e.jsx(_s,{path:"/admin/toolbox",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(QHt,{})})}),e.jsx(_s,{path:"/social-swag",element:e.jsx(rr,{children:e.jsx(Yqt,{})})}),e.jsx(_s,{path:"/social-swag-2",element:e.jsx(rr,{children:e.jsx(eHt,{})})}),e.jsx(_s,{path:"/social-swag/:swagId",element:e.jsx(rr,{children:e.jsx(tHt,{})})}),e.jsx(_s,{path:"/social-connections",element:e.jsx(rr,{children:e.jsx(J5s,{})})}),e.jsx(_s,{path:"/social-connections/callback",element:e.jsx(rr,{children:e.jsx(eMs,{})})}),e.jsx(_s,{path:"/social-connections/linkedin-callback",element:e.jsx(rr,{children:e.jsx(sMs,{})})}),e.jsx(_s,{path:"/social-connections/google-callback",element:e.jsx(rr,{children:e.jsx(tMs,{})})}),e.jsx(_s,{path:"/admin/social-swag",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(JHt,{})})}),e.jsx(_s,{path:"/admin/social-swag-2",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(OWt,{})})}),e.jsx(_s,{path:"/community",element:e.jsx(rr,{children:e.jsx(_Ht,{})})}),e.jsx(_s,{path:"/support",element:e.jsx(rr,{children:e.jsx(bHt,{})})}),e.jsx(_s,{path:"/admin/community",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(FWt,{})})}),e.jsx(_s,{path:"/admin/support-tickets",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(A_s,{})})}),e.jsx(_s,{path:"/admin/email-templates",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(P_s,{})})}),e.jsx(_s,{path:"/admin/agent-email-templates",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(I_s,{})})}),e.jsx(_s,{path:"/admin/analytics",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(C_s,{})})}),e.jsx(_s,{path:"/admin/brokerage-resources",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(M_s,{})})}),e.jsx(_s,{path:"/admin/dashboard-management",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(T_s,{})})}),e.jsx(_s,{path:"/brokerage/dashboard",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(H_s,{})})}),e.jsx(_s,{path:"/brokerage/teams",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(qTs,{})})}),e.jsx(_s,{path:"/brokerage/recruiting",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(x3s,{})})}),e.jsx(_s,{path:"/my-team",element:e.jsx(rr,{children:e.jsx(UTs,{})})}),e.jsx(_s,{path:"/my-brokerage",element:e.jsx(rr,{children:e.jsx(X_s,{})})}),e.jsx(_s,{path:"/brokerage-content",element:e.jsx(rr,{children:e.jsx(rbs,{})})}),e.jsx(_s,{path:"/brokerage-content/:contentId",element:e.jsx(rr,{children:e.jsx(lbs,{})})}),e.jsx(_s,{path:"/brokerage-resources",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(CHt,{})})}),e.jsx(_s,{path:"/brokerage-resources/:resourceId",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(MHt,{})})}),e.jsx(_s,{path:"/newsletters",element:e.jsx(rr,{children:e.jsx(cbs,{})})}),e.jsx(_s,{path:"/newsletters/:id",element:e.jsx(rr,{children:e.jsx(ubs,{})})}),e.jsx(_s,{path:"/wishlist",element:e.jsx(rr,{children:e.jsx(pbs,{})})}),e.jsx(_s,{path:"/wishlist/:itemId",element:e.jsx(rr,{children:e.jsx(fbs,{})})}),e.jsx(_s,{path:"/admin/wishlist",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(xbs,{})})}),e.jsx(_s,{path:"/admin/levelup-brief",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(gbs,{})})}),e.jsx(_s,{path:"/admin/newsletters",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(mbs,{})})}),e.jsx(_s,{path:"/admin/additional-services",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(ybs,{})})}),e.jsx(_s,{path:"/admin/discounts",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(vbs,{})})}),e.jsx(_s,{path:"/admin/subscriptions",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(_bs,{})})}),e.jsx(_s,{path:"/admin/referrals",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(bbs,{})})}),e.jsx(_s,{path:"/admin/prospector",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(KCs,{})})}),e.jsx(_s,{path:"/admin/recruiting",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(f3s,{})})}),e.jsx(_s,{path:"/admin/beta/social-post-generator",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(g5s,{})})}),e.jsx(_s,{path:"/admin/credits",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(xAs,{})})})}),e.jsx(_s,{path:"/admin/beta/postcard-manager",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(pAs,{})})})}),e.jsx(_s,{path:"/admin/beta/homereel",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(fAs,{})})})}),e.jsx(_s,{path:"/admin/lms",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(E5s,{})})}),e.jsx(_s,{path:"/admin/lms/stats",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(R5s,{})})}),e.jsx(_s,{path:"/admin/lms/:courseId",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(P5s,{})})}),e.jsx(_s,{path:"/levelup-u",element:e.jsx(rr,{children:e.jsx(O5s,{})})}),e.jsx(_s,{path:"/levelup-u/:courseId",element:e.jsx(rr,{children:e.jsx(z5s,{})})}),e.jsx(_s,{path:"/admin/brokerage-content-activity",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(g3s,{})})}),e.jsx(_s,{path:"/admin/onboarding-checklist",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(jbs,{})})}),e.jsx(_s,{path:"/admin/marketplace",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(kCs,{})})}),e.jsx(_s,{path:"/admin/agent-points",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(ZSs,{})})}),e.jsx(_s,{path:"/admin/reward-store",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(BCs,{})})}),e.jsx(_s,{path:"/admin/integrations",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(qCs,{})})}),e.jsx(_s,{path:"/admin/integrations/callback",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(WCs,{})})}),e.jsx(_s,{path:"/admin/email-campaigns",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(TAs,{})})})}),e.jsx(_s,{path:"/admin/email-campaigns/templates",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(PAs,{})})})}),e.jsx(_s,{path:"/email-campaigns/templates",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(IAs,{})})})}),e.jsx(_s,{path:"/admin/email-campaigns/new",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(AAs,{})})})}),e.jsx(_s,{path:"/admin/email-campaigns/:id",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(EAs,{})})})}),e.jsx(_s,{path:"/reward-store",element:e.jsx(rr,{children:e.jsx(dMs,{})})}),e.jsx(_s,{path:"/additional-services",element:e.jsx(rr,{children:e.jsx(Lbs,{})})}),e.jsx(_s,{path:"/additional-services/:serviceId",element:e.jsx(rr,{children:e.jsx(Dbs,{})})}),e.jsx(_s,{path:"/ai-toolkit",element:e.jsx(rr,{children:e.jsx(Rbs,{})})}),e.jsx(_s,{path:"/mission-control",element:e.jsx(rr,{children:e.jsx(tws,{})})}),e.jsx(_s,{path:"/mission-control/contacts",element:e.jsx(rr,{children:e.jsx(t2s,{})})}),e.jsx(_s,{path:"/mission-control/contacts/:contactId",element:e.jsx(rr,{children:e.jsx(L2s,{})})}),e.jsx(_s,{path:"/mission-control/plans",element:e.jsx(rr,{children:e.jsx(D2s,{})})}),e.jsx(_s,{path:"/mission-control/popbys",element:e.jsx(rr,{children:e.jsx(q2s,{})})}),e.jsx(_s,{path:"/mission-control/popbys/map",element:e.jsx(rr,{children:e.jsx(yAs,{})})}),e.jsx(_s,{path:"/admin/notification-settings",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(VCs,{})})}),e.jsx(_s,{path:"/admin/agent-os",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(kbs,{})})}),e.jsx(_s,{path:"/mission-control/listings",element:e.jsx(rr,{children:e.jsx(hjs,{})})}),e.jsx(_s,{path:"/mission-control/listings/new",element:e.jsx(rr,{children:e.jsx(uze,{})})}),e.jsx(_s,{path:"/mission-control/listings/:listingId",element:e.jsx(rr,{children:e.jsx(Ajs,{})})}),e.jsx(_s,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(rr,{children:e.jsx(uze,{})})}),e.jsx(_s,{path:"/admin/listing-exchange",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(USs,{})})}),e.jsx(_s,{path:"/mission-control/pipeline",element:e.jsx(rr,{children:e.jsx(Y4s,{})})}),e.jsx(_s,{path:"/mission-control/tasks",element:e.jsx(rr,{children:e.jsx(iSs,{})})}),e.jsx(_s,{path:"/mission-control/my-card",element:e.jsx(rr,{children:e.jsx(SSs,{})})}),e.jsx(_s,{path:"/mission-control/integrations",element:e.jsx(rr,{children:e.jsx(RSs,{})})}),e.jsx(_s,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(rr,{children:e.jsx(OSs,{})})}),e.jsx(_s,{path:"/mission-control/integrations/canva/callback",element:e.jsx(FSs,{})}),e.jsx(_s,{path:"/mission-control/integrations/meta/callback",element:e.jsx(rr,{children:e.jsx(zSs,{})})}),e.jsx(_s,{path:"/mission-control/scorecard",element:e.jsx(rr,{children:e.jsx(sjs,{})})}),e.jsx(_s,{path:"/admin/scorecard",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx($Ss,{})})}),e.jsx(_s,{path:"/admin/scorecard/:userId",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(N9e,{})})}),e.jsx(_s,{path:"/mission-control/scorecard/:userId",element:e.jsx(rr,{children:e.jsx(N9e,{})})}),e.jsx(_s,{path:"/mission-control/relationship-scorecard",element:e.jsx(rr,{children:e.jsx(sAs,{})})}),e.jsx(_s,{path:"/mission-control/sphere-gaps",element:e.jsx(rr,{children:e.jsx(iAs,{})})}),e.jsx(_s,{path:"/mission-control/website-activity",element:e.jsx(rr,{children:e.jsx(rdt,{})})}),e.jsx(_s,{path:"/mission-control/connect-page",element:e.jsx(rr,{children:e.jsx(lAs,{})})}),e.jsx(_s,{path:"/admin/membership-reviews",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(VSs,{})})}),e.jsx(_s,{path:"/admin/weekly-digest",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(WSs,{})})}),e.jsx(_s,{path:"/mission-control/video/record",element:e.jsx(rr,{children:e.jsx(Iks,{})})}),e.jsx(_s,{path:"/mission-control/video-library",element:e.jsx(rr,{children:e.jsx(Kks,{})})}),e.jsx(_s,{path:"/marketplace",element:e.jsx(rr,{children:e.jsx(rMs,{})})}),e.jsx(_s,{path:"/marketplace/:productId",element:e.jsx(rr,{children:e.jsx(nMs,{})})}),e.jsx(_s,{path:"/marketplace/cart",element:e.jsx(rr,{children:e.jsx(aMs,{})})}),e.jsx(_s,{path:"/marketplace/orders",element:e.jsx(rr,{children:e.jsx(iMs,{})})}),e.jsx(_s,{path:"/marketplace/orders/:orderId",element:e.jsx(rr,{children:e.jsx(lMs,{})})}),e.jsx(_s,{path:"/marketplace/success",element:e.jsx(rr,{children:e.jsx(cMs,{})})}),e.jsx(_s,{path:"/admin/agent-cards",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(YSs,{})})}),e.jsx(_s,{path:"/admin/presentation-analytics",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(HCs,{})})}),e.jsx(_s,{path:"/admin/guest-book-analytics",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(GCs,{})})}),e.jsx(_s,{path:"/mission-control/smart-drips",element:e.jsx(rr,{children:e.jsx(XMs,{})})}),e.jsx(_s,{path:"/mission-control/direct-mail",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(gAs,{})})})}),e.jsx(_s,{path:"/mission-control/presentations",element:e.jsx(rr,{children:e.jsx(uMs,{})})}),e.jsx(_s,{path:"/mission-control/presentations/new",element:e.jsx(rr,{children:e.jsx(Z9e,{})})}),e.jsx(_s,{path:"/mission-control/presentations/:id",element:e.jsx(rr,{children:e.jsx(Z9e,{})})}),e.jsx(_s,{path:"/mission-control/guest-book",element:e.jsx(rr,{children:e.jsx(bMs,{})})}),e.jsx(_s,{path:"/mission-control/guest-book/live/:id",element:e.jsx(rr,{children:e.jsx(vAs,{})})}),e.jsx(_s,{path:"/guestbook/:slug",element:e.jsx(cKe,{})}),e.jsx(_s,{path:"/mission-control/card-studio",element:e.jsx(rr,{children:e.jsx(TMs,{})})}),e.jsx(_s,{path:"/mission-control/scheduler",element:e.jsx(rr,{children:e.jsx(YTs,{})})}),e.jsx(_s,{path:"/c/:shareToken",element:e.jsx(Qct,{})}),e.jsx(_s,{path:"/book/:slug",element:e.jsx(edt,{})}),e.jsx(_s,{path:"/page/:slug",element:e.jsx(tdt,{})}),e.jsx(_s,{path:"/mission-control/landing-pages",element:e.jsx(rr,{children:e.jsx(XTs,{})})}),e.jsx(_s,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(rr,{children:e.jsx(eAs,{})})}),e.jsx(_s,{path:"/my-website/:siteId/edit",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(mBe,{})})})}),e.jsx(_s,{path:"/my-website/mls-listings",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(SAs,{})})})}),e.jsx(_s,{path:"/my-website/mls-listings/:mlsId",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(CAs,{})})})}),e.jsx(_s,{path:"/my-website/market-report",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(MAs,{})})})}),e.jsx(_s,{path:"/admin/lead-sites",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(_As,{})})})}),e.jsx(_s,{path:"/admin/lead-sites/themes",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(bAs,{})})})}),e.jsx(_s,{path:"/admin/lead-sites/:siteId/edit",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(mBe,{})})})}),e.jsx(_s,{path:"/admin/mls-feeds",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(wAs,{})})})}),e.jsx(_s,{path:"/admin/lead-site-analytics",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(jAs,{})})})}),e.jsx(_s,{path:"/admin/website-interests",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(NAs,{})})})}),e.jsx(_s,{path:"/admin/website-orders",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(LAs,{})})})}),e.jsx(_s,{path:"/admin/mls-fee-tracker",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(kAs,{})})})}),e.jsx(_s,{path:"/m/*",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(mAs,{})})}),e.jsx(_s,{path:"*",element:e.jsx(Jct,{})})]}),")"]})})})})]})})}),Hp=window.location.hostname,WAs=Hp.includes("lovable.app")||Hp.includes("lovableproject.com"),KAs=(()=>{try{return window.self!==window.top}catch{return!0}})(),ZAs=Hp.startsWith("cards.")||Hp.startsWith("cardstudio.")||Hp.startsWith("listings.")||Hp.startsWith("presentations.")||Hp.startsWith("guestbook.")||Hp.startsWith("clients.")||Hp.startsWith("booking.")||Hp.startsWith("contacts.")||Hp.startsWith("pages.")||Hp.endsWith(".thelocalmove.com")&&!Hp.startsWith("dashboard.");var TBe;WAs||KAs||ZAs?((TBe=navigator.serviceWorker)==null||TBe.getRegistrations().then(t=>{t.forEach(s=>s.unregister())}),"caches"in window&&caches.keys().then(t=>t.forEach(s=>caches.delete(s)))):"serviceWorker"in navigator&&Ua(async()=>{const{registerSW:t}=await import("./virtual_pwa-register-DYGVYMiW.js");return{registerSW:t}},[]).then(({registerSW:t})=>{t({onNeedRefresh(){},onOfflineReady(){}})});qqe(document.getElementById("root")).render(e.jsx(GAs,{}));export{ho as $,Bs as A,Ra as B,so as C,Lh as D,jn as E,pa as F,La as G,Mn as H,FY as I,nn as J,VEe as K,Za as L,Si as M,Qxe as N,c_t as O,Tn as P,Tme as Q,Bws as R,So as S,hh as T,cr as U,yit as V,Uws as W,Sr as X,QSe as Y,ea as Z,Ua as _,br as a,wc as a$,bp as a0,Et as a1,gd as a2,Nn as a3,E1 as a4,Yo as a5,bS as a6,ps as a7,Ky as a8,of as a9,En as aA,As as aB,Nt as aC,Pn as aD,dt as aE,Ye as aF,Lr as aG,fs as aH,ms as aI,ks as aJ,bs as aK,ge as aL,Fe as aM,zs as aN,Os as aO,qs as aP,Fs as aQ,yt as aR,gn as aS,hEs as aT,gs as aU,Vi as aV,_r as aW,Uo as aX,Cae as aY,W4 as aZ,ma as a_,wL as aa,vd as ab,WU as ac,hX as ad,ch as ae,Bv as af,Lg as ag,wl as ah,Kr as ai,Nm as aj,IM as ak,Voe as al,_s as am,Ie as an,Lt as ao,Ft as ap,_c as aq,mr as ar,Be as as,ta as at,Qn as au,ls as av,al as aw,js as ax,K as ay,An as az,$s as b,S1 as b$,Ya as b0,yr as b1,Ls as b2,lS as b3,ui as b4,Da as b5,qr as b6,Ab as b7,TJ as b8,uh as b9,lO as bA,z4e as bB,oC as bC,uu as bD,Jl as bE,ec as bF,Gv as bG,Il as bH,bse as bI,yo as bJ,vo as bK,uo as bL,di as bM,hL as bN,Hn as bO,co as bP,jJ as bQ,gJ as bR,oL as bS,qu as bT,EV as bU,mn as bV,AM as bW,GL as bX,jx as bY,Rr as bZ,Gj as b_,Co as ba,tie as bb,Eg as bc,Ev as bd,pi as be,Xa as bf,cS as bg,to as bh,Ld as bi,hn as bj,s0 as bk,pS as bl,Xy as bm,hLt as bn,vn as bo,Ca as bp,_n as bq,E4e as br,xce as bs,ure as bt,R4e as bu,P4e as bv,F4e as bw,wEs as bx,qV as by,L4e as bz,Rt as c,hS as c$,qL as c0,Qc as c1,EL as c2,Gi as c3,cn as c4,Ept as c5,ro as c6,ht as c7,dws as c8,cws as c9,rS as cA,lJ as cB,km as cC,wZ as cD,Ru as cE,cu as cF,Ih as cG,O4e as cH,Mv as cI,jEs as cJ,MEs as cK,LWt as cL,Db as cM,bx as cN,Gn as cO,Kv as cP,dh as cQ,SEs as cR,CEs as cS,hp as cT,hd as cU,Ud as cV,Vd as cW,jd as cX,lje as cY,xa as cZ,OL as c_,hws as ca,yc as cb,PM as cc,CL as cd,si as ce,mEs as cf,OWe as cg,pEs as ch,fEs as ci,xEs as cj,e1 as ck,qNe as cl,Do as cm,ur as cn,Rb as co,ZA as cp,CC as cq,YA as cr,XA as cs,Kre as ct,Rl as cu,wx as cv,AL as cw,nte as cx,Zre as cy,uS as cz,Sc as d,lL as d$,rTs as d0,il as d1,mp as d2,mL as d3,_x as d4,td as d5,WSe as d6,_a as d7,Vws as d8,Iie as d9,X4 as dA,Zke as dB,Xke as dC,UBt as dD,Yat as dE,c4e as dF,o4e as dG,l4e as dH,Y4 as dI,aS as dJ,MM as dK,TM as dL,Rh as dM,Yy as dN,G4 as dO,K4 as dP,go as dQ,NS as dR,gS as dS,Wke as dT,va as dU,Nc as dV,eS as dW,Oh as dX,_j as dY,Mb as dZ,oS as d_,QCe as da,Qy as db,jo as dc,du as dd,kae as de,EO as df,ti as dg,Sm as dh,Q4 as di,fS as dj,ff as dk,sT as dl,Kat as dm,S0 as dn,mO as dp,Jm as dq,Wat as dr,pC as ds,fC as dt,v1 as du,sh as dv,iL as dw,yS as dx,Tv as dy,bne as dz,ft as e,MW as e0,ute as e1,Fh as e2,yd as e3,sN as e4,Lb as e5,Jy as e6,xS as e7,VPt as e8,kM as e9,x1t as ea,npe as eb,uq as ec,i3e as ed,oTs as ee,AEs as ef,TEs as eg,cW as eh,qne as ei,hie as ej,wM as ek,rc as el,EEs as em,o3e as en,RM as eo,cTs as ep,da as eq,tn as f,QA as g,Ybs as h,ja as i,e as j,tr as k,es as l,rLt as m,jl as n,Ei as o,rn as p,nhe as q,k as r,G as s,Mf as t,Fl as u,eE as v,ap as w,lf as x,Fi as y,me as z};